aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-block37
-rw-r--r--Documentation/DocBook/kernel-hacking.tmpl4
-rw-r--r--Documentation/arm/memory.txt2
-rw-r--r--Documentation/filesystems/9p.txt3
-rw-r--r--Documentation/filesystems/afs.txt26
-rw-r--r--Documentation/filesystems/proc.txt15
-rw-r--r--Documentation/ioctl/ioctl-number.txt1
-rw-r--r--Documentation/kernel-parameters.txt4
-rw-r--r--Documentation/laptops/thinkpad-acpi.txt127
-rw-r--r--Documentation/lockdep-design.txt6
-rw-r--r--Documentation/video4linux/CARDLIST.em28xx2
-rw-r--r--Documentation/video4linux/CARDLIST.saa71344
-rw-r--r--MAINTAINERS21
-rw-r--r--Makefile2
-rw-r--r--REPORTING-BUGS5
-rw-r--r--arch/arm/boot/compressed/misc.c1
-rw-r--r--arch/arm/common/clkdev.c1
-rw-r--r--arch/arm/configs/jornada720_defconfig329
-rw-r--r--arch/arm/configs/kirkwood_defconfig2
-rw-r--r--arch/arm/configs/mx27_defconfig270
-rw-r--r--arch/arm/configs/mx3_defconfig151
-rw-r--r--arch/arm/configs/omap3_evm_defconfig2
-rw-r--r--arch/arm/configs/rx51_defconfig7
-rw-r--r--arch/arm/include/asm/atomic.h2
-rw-r--r--arch/arm/include/asm/memory.h17
-rw-r--r--arch/arm/include/asm/page.h4
-rw-r--r--arch/arm/include/asm/setup.h3
-rw-r--r--arch/arm/kernel/entry-common.S2
-rw-r--r--arch/arm/kernel/signal.c4
-rw-r--r--arch/arm/mach-davinci/board-dm355-evm.c1
-rw-r--r--arch/arm/mach-davinci/board-dm355-leopard.c1
-rw-r--r--arch/arm/mach-davinci/board-dm644x-evm.c1
-rw-r--r--arch/arm/mach-davinci/board-dm646x-evm.c1
-rw-r--r--arch/arm/mach-davinci/board-sffsdr.c1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ts72xx.h3
-rw-r--r--arch/arm/mach-ep93xx/ts72xx.c18
-rw-r--r--arch/arm/mach-ixp4xx/include/mach/io.h2
-rw-r--r--arch/arm/mach-kirkwood/ts219-setup.c9
-rw-r--r--arch/arm/mach-ks8695/include/mach/hardware.h5
-rw-r--r--arch/arm/mach-ks8695/include/mach/timex.h5
-rw-r--r--arch/arm/mach-ks8695/pci.c3
-rw-r--r--arch/arm/mach-mx3/mx31moboard-devboard.c2
-rw-r--r--arch/arm/mach-mx3/mx31moboard-marxbot.c2
-rw-r--r--arch/arm/mach-mx3/mx31moboard.c2
-rw-r--r--arch/arm/mach-mx3/pcm037_eet.c9
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-3430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-4430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-apollon.c2
-rw-r--r--arch/arm/mach-omap2/board-generic.c2
-rw-r--r--arch/arm/mach-omap2/board-h4.c2
-rw-r--r--arch/arm/mach-omap2/board-ldp.c2
-rw-r--r--arch/arm/mach-omap2/board-omap3beagle.c7
-rw-r--r--arch/arm/mach-omap2/board-omap3evm.c7
-rw-r--r--arch/arm/mach-omap2/board-omap3pandora.c8
-rw-r--r--arch/arm/mach-omap2/board-overo.c10
-rw-r--r--arch/arm/mach-omap2/board-rx51-peripherals.c5
-rw-r--r--arch/arm/mach-omap2/board-rx51.c6
-rw-r--r--arch/arm/mach-omap2/board-zoom2.c2
-rw-r--r--arch/arm/mach-omap2/clock.c156
-rw-r--r--arch/arm/mach-omap2/clock.h6
-rw-r--r--arch/arm/mach-omap2/clock24xx.c37
-rw-r--r--arch/arm/mach-omap2/clock24xx.h4
-rw-r--r--arch/arm/mach-omap2/clock34xx.c155
-rw-r--r--arch/arm/mach-omap2/clock34xx.h85
-rw-r--r--arch/arm/mach-omap2/io.c5
-rw-r--r--arch/arm/mach-omap2/mmc-twl4030.c6
-rw-r--r--arch/arm/mach-omap2/mux.c6
-rw-r--r--arch/arm/mach-omap2/prcm.c43
-rw-r--r--arch/arm/mach-omap2/sdrc.c68
-rw-r--r--arch/arm/mach-omap2/sram34xx.S143
-rw-r--r--arch/arm/mach-omap2/usb-musb.c21
-rw-r--r--arch/arm/mach-pxa/em-x270.c4
-rw-r--r--arch/arm/mach-pxa/palmld.c4
-rw-r--r--arch/arm/mach-pxa/palmt5.c4
-rw-r--r--arch/arm/mach-pxa/palmtx.c4
-rw-r--r--arch/arm/mach-pxa/sharpsl_pm.c4
-rw-r--r--arch/arm/mach-pxa/treo680.c2
-rw-r--r--arch/arm/mach-pxa/zylonite_pxa300.c2
-rw-r--r--arch/arm/mach-pxa/zylonite_pxa320.c2
-rw-r--r--arch/arm/mach-u300/core.c2
-rw-r--r--arch/arm/mm/flush.c9
-rw-r--r--arch/arm/mm/highmem.c8
-rw-r--r--arch/arm/mm/init.c150
-rw-r--r--arch/arm/mm/mmu.c9
-rw-r--r--arch/arm/plat-omap/dma.c4
-rw-r--r--arch/arm/plat-omap/gpio.c121
-rw-r--r--arch/arm/plat-omap/include/mach/clock.h2
-rw-r--r--arch/arm/plat-omap/include/mach/cpu.h5
-rw-r--r--arch/arm/plat-omap/include/mach/io.h3
-rw-r--r--arch/arm/plat-omap/include/mach/mux.h4
-rw-r--r--arch/arm/plat-omap/include/mach/prcm.h1
-rw-r--r--arch/arm/plat-omap/include/mach/sdrc.h11
-rw-r--r--arch/arm/plat-omap/include/mach/sram.h23
-rw-r--r--arch/arm/plat-omap/sram.c34
-rw-r--r--arch/arm/plat-orion/include/plat/gpio.h2
-rw-r--r--arch/arm/plat-s3c/pwm.c4
-rw-r--r--arch/arm/plat-s3c24xx/clock-dclk.c2
-rw-r--r--arch/arm/plat-s3c64xx/pm.c2
-rw-r--r--arch/avr32/boards/favr-32/setup.c4
-rw-r--r--arch/avr32/lib/memcpy.S16
-rw-r--r--arch/ia64/Makefile5
-rw-r--r--arch/ia64/include/asm/bitops.h2
-rw-r--r--arch/ia64/include/asm/pgtable.h1
-rw-r--r--arch/ia64/kernel/ia64_ksyms.c4
-rw-r--r--arch/ia64/kernel/iosapic.c4
-rw-r--r--arch/ia64/kernel/pci-dma.c5
-rw-r--r--arch/ia64/kernel/topology.c6
-rw-r--r--arch/ia64/kvm/mmio.c6
-rw-r--r--arch/ia64/kvm/vcpu.c6
-rw-r--r--arch/ia64/kvm/vcpu.h13
-rw-r--r--arch/m68k/amiga/config.c6
-rw-r--r--arch/m68k/include/asm/motorola_pgalloc.h10
-rw-r--r--arch/m68k/include/asm/pgtable_mm.h3
-rw-r--r--arch/m68k/include/asm/unistd.h4
-rw-r--r--arch/m68k/kernel/entry.S2
-rw-r--r--arch/m68knommu/kernel/syscalltable.S2
-rw-r--r--arch/microblaze/configs/mmu_defconfig70
-rw-r--r--arch/microblaze/configs/nommu_defconfig91
-rw-r--r--arch/microblaze/include/asm/hardirq.h2
-rw-r--r--arch/microblaze/kernel/intc.c2
-rw-r--r--arch/microblaze/kernel/irq.c9
-rw-r--r--arch/microblaze/kernel/syscall_table.S2
-rw-r--r--arch/microblaze/kernel/timer.c2
-rw-r--r--arch/microblaze/mm/init.c6
-rw-r--r--arch/mips/alchemy/mtx-1/platform.c14
-rw-r--r--arch/mips/ar7/Makefile1
-rw-r--r--arch/mips/ar7/clock.c13
-rw-r--r--arch/mips/ar7/memory.c2
-rw-r--r--arch/mips/ar7/platform.c10
-rw-r--r--arch/mips/ar7/prom.c2
-rw-r--r--arch/mips/ar7/setup.c1
-rw-r--r--arch/mips/cavium-octeon/smp.c4
-rw-r--r--arch/mips/dec/ecc-berr.c2
-rw-r--r--arch/mips/dec/int-handler.S2
-rw-r--r--arch/mips/dec/ioasic-irq.c2
-rw-r--r--arch/mips/dec/kn01-berr.c2
-rw-r--r--arch/mips/dec/kn02-irq.c2
-rw-r--r--arch/mips/dec/kn02xa-berr.c2
-rw-r--r--arch/mips/dec/prom/call_o32.S2
-rw-r--r--arch/mips/dec/prom/console.c2
-rw-r--r--arch/mips/dec/time.c2
-rw-r--r--arch/mips/emma/common/Makefile3
-rw-r--r--arch/mips/emma/common/prom.c3
-rw-r--r--arch/mips/emma/markeins/Makefile3
-rw-r--r--arch/mips/emma/markeins/irq.c3
-rw-r--r--arch/mips/emma/markeins/led.c3
-rw-r--r--arch/mips/emma/markeins/platform.c3
-rw-r--r--arch/mips/emma/markeins/setup.c3
-rw-r--r--arch/mips/fw/lib/call_o32.S2
-rw-r--r--arch/mips/include/asm/emma/emma2rh.h3
-rw-r--r--arch/mips/include/asm/emma/markeins.h3
-rw-r--r--arch/mips/include/asm/gic.h2
-rw-r--r--arch/mips/include/asm/page.h2
-rw-r--r--arch/mips/include/asm/pmc-sierra/msp71xx/war.h2
-rw-r--r--arch/mips/include/asm/processor.h5
-rw-r--r--arch/mips/include/asm/unistd.h15
-rw-r--r--arch/mips/jazz/jazzdma.c2
-rw-r--r--arch/mips/kernel/head.S3
-rw-r--r--arch/mips/kernel/irq_txx9.c2
-rw-r--r--arch/mips/kernel/module.c12
-rw-r--r--arch/mips/kernel/proc.c2
-rw-r--r--arch/mips/kernel/process.c4
-rw-r--r--arch/mips/kernel/scall32-o32.S1
-rw-r--r--arch/mips/kernel/scall64-64.S1
-rw-r--r--arch/mips/kernel/scall64-n32.S1
-rw-r--r--arch/mips/kernel/scall64-o32.S1
-rw-r--r--arch/mips/kernel/smtc.c13
-rw-r--r--arch/mips/kernel/stacktrace.c2
-rw-r--r--arch/mips/kernel/vpe.c49
-rw-r--r--arch/mips/mipssim/sim_time.c12
-rw-r--r--arch/mips/mm/c-octeon.c4
-rw-r--r--arch/mips/mm/extable.c6
-rw-r--r--arch/mips/mm/fault.c1
-rw-r--r--arch/mips/mti-malta/malta-int.c2
-rw-r--r--arch/mips/nxp/pnx8550/common/time.c2
-rw-r--r--arch/mips/pci/fixup-emma2rh.c3
-rw-r--r--arch/mips/pci/fixup-sb1250.c2
-rw-r--r--arch/mips/pci/ops-emma2rh.c3
-rw-r--r--arch/mips/pci/pci-emma2rh.c3
-rw-r--r--arch/mips/pci/pci-tx4927.c2
-rw-r--r--arch/mips/pci/pci-tx4938.c2
-rw-r--r--arch/mips/pci/pci-tx4939.c2
-rw-r--r--arch/mips/pci/pcie-octeon.c31
-rw-r--r--arch/mips/pmc-sierra/msp71xx/gpio.c2
-rw-r--r--arch/mips/pmc-sierra/msp71xx/gpio_extended.c2
-rw-r--r--arch/mips/pmc-sierra/msp71xx/msp_irq_slp.c12
-rw-r--r--arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c2
-rw-r--r--arch/mips/sibyte/swarm/swarm-i2c.c2
-rw-r--r--arch/mips/txx9/generic/mem_tx4927.c2
-rw-r--r--arch/mips/txx9/generic/setup.c2
-rw-r--r--arch/mips/txx9/rbtx4939/setup.c2
-rw-r--r--arch/mn10300/include/asm/pci.h1
-rw-r--r--arch/parisc/kernel/entry.S2
-rw-r--r--arch/parisc/kernel/module.c50
-rw-r--r--arch/parisc/kernel/traps.c2
-rw-r--r--arch/powerpc/configs/ps3_defconfig211
-rw-r--r--arch/powerpc/include/asm/kvm_host.h2
-rw-r--r--arch/powerpc/kernel/dma.c6
-rw-r--r--arch/powerpc/kernel/mpc7450-pmu.c3
-rw-r--r--arch/powerpc/kernel/perf_counter.c8
-rw-r--r--arch/powerpc/kernel/power4-pmu.c3
-rw-r--r--arch/powerpc/kernel/power5+-pmu.c5
-rw-r--r--arch/powerpc/kernel/power5-pmu.c3
-rw-r--r--arch/powerpc/kernel/power6-pmu.c3
-rw-r--r--arch/powerpc/kernel/power7-pmu.c3
-rw-r--r--arch/powerpc/kernel/ppc970-pmu.c5
-rw-r--r--arch/powerpc/platforms/ps3/time.c4
-rw-r--r--arch/s390/kernel/early.c3
-rw-r--r--arch/s390/kernel/setup.c25
-rw-r--r--arch/s390/kvm/interrupt.c2
-rw-r--r--arch/s390/kvm/sigp.c7
-rw-r--r--arch/sh/boards/board-ap325rxa.c2
-rw-r--r--arch/sh/boards/mach-migor/setup.c2
-rw-r--r--arch/sh/boards/mach-se/7724/setup.c9
-rw-r--r--arch/sh/kernel/cpu/sh2/setup-sh7619.c2
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-mxg.c2
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-sh7201.c2
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-sh7203.c2
-rw-r--r--arch/sh/kernel/cpu/sh2a/setup-sh7206.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7705.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh770x.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7710.c2
-rw-r--r--arch/sh/kernel/cpu/sh3/setup-sh7720.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh4-202.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7750.c2
-rw-r--r--arch/sh/kernel/cpu/sh4/setup-sh7760.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7343.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7366.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7722.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7723.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7724.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7763.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7770.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7780.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7785.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-sh7786.c2
-rw-r--r--arch/sh/kernel/cpu/sh4a/setup-shx3.c2
-rw-r--r--arch/sh/kernel/cpu/sh5/setup-sh5.c2
-rw-r--r--arch/sh/kernel/cpu/shmobile/sleep.S70
-rw-r--r--arch/sparc/configs/sparc32_defconfig74
-rw-r--r--arch/sparc/configs/sparc64_defconfig59
-rw-r--r--arch/sparc/include/asm/pgtable_64.h12
-rw-r--r--arch/sparc/kernel/ktlb.S42
-rw-r--r--arch/sparc/kernel/smp_64.c4
-rw-r--r--arch/sparc/kernel/sun4d_smp.c22
-rw-r--r--arch/sparc/kernel/sun4m_smp.c26
-rw-r--r--arch/sparc/kernel/sys32.S4
-rw-r--r--arch/sparc/kernel/systbls_64.S4
-rw-r--r--arch/sparc/mm/fault_32.c7
-rw-r--r--arch/sparc/mm/fault_64.c7
-rw-r--r--arch/sparc/mm/init_64.c43
-rw-r--r--arch/sparc/mm/init_64.h7
-rw-r--r--arch/x86/Kconfig2
-rw-r--r--arch/x86/boot/compressed/Makefile2
-rw-r--r--arch/x86/include/asm/efi.h5
-rw-r--r--arch/x86/include/asm/irqflags.h8
-rw-r--r--arch/x86/include/asm/pgtable.h12
-rw-r--r--arch/x86/include/asm/uv/uv_bau.h2
-rw-r--r--arch/x86/include/asm/uv/uv_hub.h9
-rw-r--r--arch/x86/kernel/apic/io_apic.c3
-rw-r--r--arch/x86/kernel/apic/ipi.c3
-rw-r--r--arch/x86/kernel/apic/probe_64.c10
-rw-r--r--arch/x86/kernel/apic/x2apic_cluster.c10
-rw-r--r--arch/x86/kernel/apic/x2apic_phys.c10
-rw-r--r--arch/x86/kernel/apic/x2apic_uv_x.c42
-rw-r--r--arch/x86/kernel/apm_32.c2
-rw-r--r--arch/x86/kernel/cpu/Makefile4
-rw-r--r--arch/x86/kernel/cpu/amd.c7
-rw-r--r--arch/x86/kernel/cpu/common.c48
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c19
-rw-r--r--arch/x86/kernel/cpu/mcheck/therm_throt.c23
-rw-r--r--arch/x86/kernel/cpu/perf_counter.c40
-rw-r--r--arch/x86/kernel/efi.c4
-rw-r--r--arch/x86/kernel/efi_64.c6
-rw-r--r--arch/x86/kernel/head_32.S6
-rw-r--r--arch/x86/kernel/process.c6
-rw-r--r--arch/x86/kernel/reboot.c42
-rw-r--r--arch/x86/kernel/setup_percpu.c14
-rw-r--r--arch/x86/kernel/tlb_uv.c1
-rw-r--r--arch/x86/kernel/tsc.c29
-rw-r--r--arch/x86/kernel/vmi_32.c2
-rw-r--r--arch/x86/kernel/vmlinux.lds.S142
-rw-r--r--arch/x86/kvm/i8254.c3
-rw-r--r--arch/x86/kvm/mmu.c48
-rw-r--r--arch/x86/kvm/svm.c6
-rw-r--r--arch/x86/kvm/vmx.c6
-rw-r--r--arch/x86/kvm/x86.c44
-rw-r--r--arch/x86/lib/msr.c26
-rw-r--r--arch/x86/mm/init_64.c2
-rw-r--r--arch/x86/mm/pageattr.c39
-rw-r--r--arch/x86/mm/pat.c3
-rw-r--r--arch/x86/mm/pgtable.c1
-rw-r--r--arch/x86/mm/tlb.c21
-rw-r--r--arch/x86/xen/Makefile4
-rw-r--r--arch/x86/xen/enlighten.c24
-rw-r--r--block/Kconfig11
-rw-r--r--block/blk-settings.c77
-rw-r--r--drivers/acpi/acpi_memhotplug.c34
-rw-r--r--drivers/acpi/acpica/acobject.h1
-rw-r--r--drivers/acpi/acpica/dsopcode.c24
-rw-r--r--drivers/acpi/acpica/exfldio.c6
-rw-r--r--drivers/acpi/acpica/exstorob.c12
-rw-r--r--drivers/acpi/osl.c25
-rw-r--r--drivers/acpi/processor_core.c6
-rw-r--r--drivers/acpi/processor_idle.c6
-rw-r--r--drivers/acpi/processor_thermal.c6
-rw-r--r--drivers/acpi/processor_throttling.c30
-rw-r--r--drivers/acpi/system.c2
-rw-r--r--drivers/acpi/video.c7
-rw-r--r--drivers/ata/ahci.c79
-rw-r--r--drivers/ata/ata_piix.c14
-rw-r--r--drivers/ata/libata-core.c3
-rw-r--r--drivers/ata/pata_at91.c17
-rw-r--r--drivers/ata/pata_atiixp.c19
-rw-r--r--drivers/ata/sata_nv.c8
-rw-r--r--drivers/base/platform.c3
-rw-r--r--drivers/char/agp/parisc-agp.c2
-rw-r--r--drivers/char/pty.c2
-rw-r--r--drivers/char/tty_ldisc.c162
-rw-r--r--drivers/clocksource/sh_cmt.c28
-rw-r--r--drivers/cpufreq/cpufreq.c27
-rw-r--r--drivers/cpufreq/cpufreq_conservative.c6
-rw-r--r--drivers/edac/amd64_edac.c7
-rw-r--r--drivers/gpu/drm/drm_crtc.c42
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c6
-rw-r--r--drivers/gpu/drm/drm_edid.c72
-rw-r--r--drivers/gpu/drm/drm_irq.c2
-rw-r--r--drivers/gpu/drm/drm_modes.c2
-rw-r--r--drivers/gpu/drm/drm_sysfs.c51
-rw-r--r--drivers/gpu/drm/i915/i915_dma.c15
-rw-r--r--drivers/gpu/drm/i915/i915_drv.h11
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c90
-rw-r--r--drivers/gpu/drm/i915/i915_gem_debugfs.c2
-rw-r--r--drivers/gpu/drm/i915/i915_irq.c239
-rw-r--r--drivers/gpu/drm/i915/i915_reg.h45
-rw-r--r--drivers/gpu/drm/i915/i915_suspend.c2
-rw-r--r--drivers/gpu/drm/i915/intel_bios.c91
-rw-r--r--drivers/gpu/drm/i915/intel_bios.h45
-rw-r--r--drivers/gpu/drm/i915/intel_crt.c23
-rw-r--r--drivers/gpu/drm/i915/intel_display.c822
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c230
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h23
-rw-r--r--drivers/gpu/drm/i915/intel_dvo.c6
-rw-r--r--drivers/gpu/drm/i915/intel_hdmi.c82
-rw-r--r--drivers/gpu/drm/i915/intel_lvds.c14
-rw-r--r--drivers/gpu/drm/i915/intel_sdvo.c265
-rw-r--r--drivers/gpu/drm/i915/intel_tv.c24
-rw-r--r--drivers/gpu/drm/radeon/r100.c99
-rw-r--r--drivers/gpu/drm/radeon/r300.c42
-rw-r--r--drivers/gpu/drm/radeon/r420.c13
-rw-r--r--drivers/gpu/drm/radeon/r500_reg.h16
-rw-r--r--drivers/gpu/drm/radeon/r520.c1
-rw-r--r--drivers/gpu/drm/radeon/r600_cp.c22
-rw-r--r--drivers/gpu/drm/radeon/radeon.h55
-rw-r--r--drivers/gpu/drm/radeon/radeon_asic.h26
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c48
-rw-r--r--drivers/gpu/drm/radeon/radeon_cp.c9
-rw-r--r--drivers/gpu/drm/radeon/radeon_device.c17
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.c17
-rw-r--r--drivers/gpu/drm/radeon/radeon_drv.h6
-rw-r--r--drivers/gpu/drm/radeon/radeon_fb.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_gem.c30
-rw-r--r--drivers/gpu/drm/radeon/radeon_irq_kms.c54
-rw-r--r--drivers/gpu/drm/radeon/radeon_kms.c39
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_crtc.c7
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_encoders.c1
-rw-r--r--drivers/gpu/drm/radeon/radeon_object.c21
-rw-r--r--drivers/gpu/drm/radeon/radeon_reg.h16
-rw-r--r--drivers/gpu/drm/radeon/radeon_state.c3
-rw-r--r--drivers/gpu/drm/radeon/rs600.c82
-rw-r--r--drivers/gpu/drm/radeon/rs690.c65
-rw-r--r--drivers/gpu/drm/radeon/rv515.c20
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c7
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo_util.c8
-rw-r--r--drivers/i2c/busses/i2c-omap.c14
-rw-r--r--drivers/i2c/busses/i2c-stu300.c157
-rw-r--r--drivers/input/joydev.c68
-rw-r--r--drivers/input/joystick/iforce/iforce-main.c1
-rw-r--r--drivers/input/joystick/iforce/iforce-usb.c1
-rw-r--r--drivers/input/keyboard/matrix_keypad.c18
-rw-r--r--drivers/input/misc/wistron_btns.c16
-rw-r--r--drivers/input/serio/hp_sdc_mlc.c2
-rw-r--r--drivers/input/serio/i8042-x86ia64io.h8
-rw-r--r--drivers/input/tablet/wacom_sys.c43
-rw-r--r--drivers/input/touchscreen/ucb1400_ts.c17
-rw-r--r--drivers/isdn/mISDN/l1oip_core.c2
-rw-r--r--drivers/leds/ledtrig-gpio.c24
-rw-r--r--drivers/macintosh/via-maciisi.c2
-rw-r--r--drivers/md/dm-log-userspace-transfer.c2
-rw-r--r--drivers/md/linear.c2
-rw-r--r--drivers/md/md.c177
-rw-r--r--drivers/md/md.h12
-rw-r--r--drivers/md/multipath.c5
-rw-r--r--drivers/md/raid0.c1
-rw-r--r--drivers/md/raid1.c7
-rw-r--r--drivers/md/raid10.c4
-rw-r--r--drivers/md/raid5.c85
-rw-r--r--drivers/media/common/tuners/qt1010.c12
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.c4
-rw-r--r--drivers/media/common/tuners/tuner-xc2028.h1
-rw-r--r--drivers/media/dvb/dvb-usb/af9015.c2
-rw-r--r--drivers/media/dvb/frontends/cx22700.c2
-rw-r--r--drivers/media/dvb/frontends/cx22702.c2
-rw-r--r--drivers/media/dvb/frontends/cx24110.c2
-rw-r--r--drivers/media/dvb/frontends/dvb_dummy_fe.c6
-rw-r--r--drivers/media/dvb/frontends/l64781.c2
-rw-r--r--drivers/media/dvb/frontends/lgs8gl5.c2
-rw-r--r--drivers/media/dvb/frontends/mt312.c2
-rw-r--r--drivers/media/dvb/frontends/nxt6000.c2
-rw-r--r--drivers/media/dvb/frontends/or51132.c2
-rw-r--r--drivers/media/dvb/frontends/or51211.c2
-rw-r--r--drivers/media/dvb/frontends/s5h1409.c2
-rw-r--r--drivers/media/dvb/frontends/s5h1411.c2
-rw-r--r--drivers/media/dvb/frontends/si21xx.c2
-rw-r--r--drivers/media/dvb/frontends/sp8870.c2
-rw-r--r--drivers/media/dvb/frontends/sp887x.c2
-rw-r--r--drivers/media/dvb/frontends/stv0288.c2
-rw-r--r--drivers/media/dvb/frontends/stv0297.c2
-rw-r--r--drivers/media/dvb/frontends/stv0299.c2
-rw-r--r--drivers/media/dvb/frontends/tda10021.c2
-rw-r--r--drivers/media/dvb/frontends/tda10048.c2
-rw-r--r--drivers/media/dvb/frontends/tda1004x.c4
-rw-r--r--drivers/media/dvb/frontends/tda10086.c2
-rw-r--r--drivers/media/dvb/frontends/tda8083.c2
-rw-r--r--drivers/media/dvb/frontends/ves1820.c2
-rw-r--r--drivers/media/dvb/frontends/ves1x93.c2
-rw-r--r--drivers/media/dvb/frontends/zl10353.c12
-rw-r--r--drivers/media/dvb/siano/Kconfig40
-rw-r--r--drivers/media/dvb/siano/Makefile9
-rw-r--r--drivers/media/dvb/siano/sms-cards.c102
-rw-r--r--drivers/media/dvb/siano/smscoreapi.c2
-rw-r--r--drivers/media/dvb/siano/smsdvb.c44
-rw-r--r--drivers/media/dvb/siano/smssdio.c54
-rw-r--r--drivers/media/video/Kconfig2
-rw-r--r--drivers/media/video/bw-qcam.c2
-rw-r--r--drivers/media/video/cx18/cx18-controls.c3
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c2
-rw-r--r--drivers/media/video/cx88/cx88-cards.c8
-rw-r--r--drivers/media/video/cx88/cx88-dvb.c1
-rw-r--r--drivers/media/video/cx88/cx88-mpeg.c4
-rw-r--r--drivers/media/video/em28xx/em28xx-cards.c219
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c8
-rw-r--r--drivers/media/video/em28xx/em28xx-dvb.c2
-rw-r--r--drivers/media/video/em28xx/em28xx-reg.h3
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c77
-rw-r--r--drivers/media/video/em28xx/em28xx.h4
-rw-r--r--drivers/media/video/gspca/Kconfig2
-rw-r--r--drivers/media/video/hdpvr/hdpvr-video.c2
-rw-r--r--drivers/media/video/ivtv/ivtv-controls.c3
-rw-r--r--drivers/media/video/mt9v011.c156
-rw-r--r--drivers/media/video/mt9v011.h3
-rw-r--r--drivers/media/video/mx1_camera.c6
-rw-r--r--drivers/media/video/mx3_camera.c19
-rw-r--r--drivers/media/video/pxa_camera.c8
-rw-r--r--drivers/media/video/saa7134/saa7134-cards.c30
-rw-r--r--drivers/media/video/saa7134/saa7134-dvb.c4
-rw-r--r--drivers/media/video/saa7134/saa7134.h4
-rw-r--r--drivers/media/video/sh_mobile_ceu_camera.c5
-rw-r--r--drivers/media/video/stk-webcam.c4
-rw-r--r--drivers/media/video/uvc/uvc_driver.c24
-rw-r--r--drivers/media/video/uvc/uvc_status.c4
-rw-r--r--drivers/media/video/v4l2-ioctl.c15
-rw-r--r--drivers/media/video/zr364xx.c2
-rw-r--r--drivers/mfd/twl4030-irq.c55
-rw-r--r--drivers/mmc/host/sdhci-of.c2
-rw-r--r--drivers/mtd/maps/Kconfig7
-rw-r--r--drivers/mtd/maps/Makefile1
-rw-r--r--drivers/mtd/maps/sbc8240.c250
-rw-r--r--drivers/mtd/mtd_blkdevs.c6
-rw-r--r--drivers/mtd/mtdblock.c16
-rw-r--r--drivers/mtd/mtdcore.c7
-rw-r--r--drivers/mtd/nand/orion_nand.c2
-rw-r--r--drivers/mtd/onenand/omap2.c3
-rw-r--r--drivers/mtd/ubi/eba.c1
-rw-r--r--drivers/mtd/ubi/scan.c13
-rw-r--r--drivers/net/3c515.c4
-rw-r--r--drivers/net/3c59x.c14
-rw-r--r--drivers/net/8139cp.c5
-rw-r--r--drivers/net/Kconfig4
-rw-r--r--drivers/net/arm/w90p910_ether.c4
-rw-r--r--drivers/net/atl1c/atl1c_ethtool.c8
-rw-r--r--drivers/net/atlx/atl1.c8
-rw-r--r--drivers/net/b44.c5
-rw-r--r--drivers/net/bnx2.c17
-rw-r--r--drivers/net/bnx2.h1
-rw-r--r--drivers/net/can/dev.c7
-rw-r--r--drivers/net/cnic.c143
-rw-r--r--drivers/net/cnic.h1
-rw-r--r--drivers/net/cnic_if.h1
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/e1000e/ich8lan.c94
-rw-r--r--drivers/net/e1000e/netdev.c22
-rw-r--r--drivers/net/eexpress.c6
-rw-r--r--drivers/net/ehea/ehea.h2
-rw-r--r--drivers/net/ehea/ehea_main.c3
-rw-r--r--drivers/net/fec.c9
-rw-r--r--drivers/net/fec_mpc52xx.c5
-rw-r--r--drivers/net/gianfar.c12
-rw-r--r--drivers/net/gianfar_ethtool.c10
-rw-r--r--drivers/net/ibm_newemac/core.c2
-rw-r--r--drivers/net/igbvf/vf.c4
-rw-r--r--drivers/net/irda/au1k_ir.c4
-rw-r--r--drivers/net/irda/pxaficp_ir.c4
-rw-r--r--drivers/net/irda/sa1100_ir.c4
-rw-r--r--drivers/net/irda/w83977af_ir.c2
-rw-r--r--drivers/net/ixgbe/ixgbe.h4
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c67
-rw-r--r--drivers/net/ixgbe/ixgbe_ethtool.c38
-rw-r--r--drivers/net/ixgbe/ixgbe_fcoe.c2
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c115
-rw-r--r--drivers/net/ixgbe/ixgbe_type.h8
-rw-r--r--drivers/net/ixp2000/ixpdev.c5
-rw-r--r--drivers/net/macb.c7
-rw-r--r--drivers/net/mlx4/en_rx.c5
-rw-r--r--drivers/net/mlx4/en_tx.c6
-rw-r--r--drivers/net/netxen/netxen_nic.h2
-rw-r--r--drivers/net/netxen/netxen_nic_init.c7
-rw-r--r--drivers/net/netxen/netxen_nic_main.c142
-rw-r--r--drivers/net/pcnet32.c32
-rw-r--r--drivers/net/ppp_generic.c34
-rw-r--r--drivers/net/pppoe.c1
-rw-r--r--drivers/net/pppol2tp.c1
-rw-r--r--drivers/net/s6gmac.c2
-rw-r--r--drivers/net/sky2.c14
-rw-r--r--drivers/net/sky2.h1
-rw-r--r--drivers/net/smc91x.c40
-rw-r--r--drivers/net/tulip/de4x5.c6
-rw-r--r--drivers/net/tulip/tulip_core.c5
-rw-r--r--drivers/net/tun.c50
-rw-r--r--drivers/net/ucc_geth.c5
-rw-r--r--drivers/net/usb/pegasus.h2
-rw-r--r--drivers/net/via-rhine.c5
-rw-r--r--drivers/net/via-velocity.c2
-rw-r--r--drivers/net/virtio_net.c61
-rw-r--r--drivers/net/wireless/airo.c13
-rw-r--r--drivers/net/wireless/ath/ar9170/main.c5
-rw-r--r--drivers/net/wireless/ath/ar9170/usb.c6
-rw-r--r--drivers/net/wireless/ath/ath9k/eeprom.c4
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.h2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-debugfs.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h6
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl3945-base.c7
-rw-r--r--drivers/net/wireless/iwmc3200wifi/commands.c1
-rw-r--r--drivers/net/wireless/iwmc3200wifi/netdev.c6
-rw-r--r--drivers/net/wireless/libertas/11d.c2
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h4
-rw-r--r--drivers/net/wireless/libertas/scan.c3
-rw-r--r--drivers/net/wireless/mwl8k.c31
-rw-r--r--drivers/net/wireless/orinoco/hw.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00.h6
-rw-r--r--drivers/net/wireless/rtl818x/rtl8187_dev.c14
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c2
-rw-r--r--drivers/net/yellowfin.c28
-rw-r--r--drivers/net/zorro8390.c3
-rw-r--r--drivers/parisc/ccio-dma.c1
-rw-r--r--drivers/parisc/dino.c2
-rw-r--r--drivers/parisc/eisa_eeprom.c2
-rw-r--r--drivers/parisc/hppb.c9
-rw-r--r--drivers/parisc/lba_pci.c2
-rw-r--r--drivers/parisc/pdc_stable.c2
-rw-r--r--drivers/pci/hotplug/sgi_hotplug.c7
-rw-r--r--drivers/pci/intel-iommu.c25
-rw-r--r--drivers/pci/pci-driver.c2
-rw-r--r--drivers/pci/pci.c2
-rw-r--r--drivers/pci/setup-res.c4
-rw-r--r--drivers/platform/x86/Kconfig25
-rw-r--r--drivers/platform/x86/eeepc-laptop.c9
-rw-r--r--drivers/platform/x86/hp-wmi.c12
-rw-r--r--drivers/platform/x86/thinkpad_acpi.c390
-rw-r--r--drivers/platform/x86/toshiba_acpi.c1
-rw-r--r--drivers/platform/x86/wmi.c8
-rw-r--r--drivers/pps/pps.c2
-rw-r--r--drivers/s390/block/dasd.c2
-rw-r--r--drivers/s390/cio/device.c4
-rw-r--r--drivers/s390/scsi/zfcp_erp.c68
-rw-r--r--drivers/s390/scsi/zfcp_fc.c8
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c56
-rw-r--r--drivers/s390/scsi/zfcp_scsi.c25
-rw-r--r--drivers/s390/scsi/zfcp_sysfs.c7
-rw-r--r--drivers/sbus/char/bbc_envctrl.c11
-rw-r--r--drivers/scsi/libfc/fc_exch.c23
-rw-r--r--drivers/scsi/libiscsi.c4
-rw-r--r--drivers/scsi/libsas/sas_expander.c147
-rw-r--r--drivers/scsi/libsas/sas_port.c19
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.c98
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_base.h6
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_config.c91
-rw-r--r--drivers/scsi/mpt2sas/mpt2sas_scsih.c124
-rw-r--r--drivers/scsi/qla4xxx/ql4_dbg.c15
-rw-r--r--drivers/scsi/qla4xxx/ql4_def.h9
-rw-r--r--drivers/scsi/qla4xxx/ql4_fw.h7
-rw-r--r--drivers/scsi/qla4xxx/ql4_iocb.c133
-rw-r--r--drivers/scsi/qla4xxx/ql4_isr.c145
-rw-r--r--drivers/scsi/qla4xxx/ql4_mbx.c10
-rw-r--r--drivers/scsi/qla4xxx/ql4_os.c40
-rw-r--r--drivers/scsi/qla4xxx/ql4_version.h2
-rw-r--r--drivers/scsi/scsi_transport_iscsi.c4
-rw-r--r--drivers/scsi/sd.c20
-rw-r--r--drivers/serial/Kconfig2
-rw-r--r--drivers/serial/s3c2400.c8
-rw-r--r--drivers/serial/s3c2410.c8
-rw-r--r--drivers/serial/s3c2412.c8
-rw-r--r--drivers/serial/s3c2440.c8
-rw-r--r--drivers/serial/s3c24a0.c8
-rw-r--r--drivers/serial/s3c6400.c8
-rw-r--r--drivers/serial/serial_ks8695.c8
-rw-r--r--drivers/spi/spi_s3c24xx.c23
-rw-r--r--drivers/staging/b3dfg/Kconfig1
-rw-r--r--drivers/staging/heci/Kconfig1
-rw-r--r--drivers/staging/rspiusb/rspiusb.c2
-rw-r--r--drivers/staging/rt2860/rt_linux.h13
-rw-r--r--drivers/staging/rt2870/2870_main_dev.c67
-rw-r--r--drivers/staging/rt2870/common/2870_rtmp_init.c33
-rw-r--r--drivers/staging/rt2870/common/rtusb_io.c3
-rw-r--r--drivers/staging/rt2870/rt2870.h9
-rw-r--r--drivers/staging/rtl8192su/ieee80211.h2
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211.h2
-rw-r--r--drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c3
-rw-r--r--drivers/staging/rtl8192su/r8192U_core.c2
-rw-r--r--drivers/thermal/thermal_sys.c9
-rw-r--r--drivers/usb/class/cdc-acm.c10
-rw-r--r--drivers/usb/class/cdc-acm.h2
-rw-r--r--drivers/usb/core/devio.c10
-rw-r--r--drivers/usb/host/ehci-hcd.c3
-rw-r--r--drivers/usb/host/ehci-q.c15
-rw-r--r--drivers/usb/host/ehci-sched.c1
-rw-r--r--drivers/usb/musb/Kconfig1
-rw-r--r--drivers/usb/serial/ftdi_sio.c3
-rw-r--r--drivers/usb/serial/ftdi_sio.h14
-rw-r--r--drivers/usb/serial/pl2303.c1
-rw-r--r--drivers/usb/serial/pl2303.h4
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/video/console/fbcon.c6
-rw-r--r--drivers/video/console/fbcon_rotate.h2
-rw-r--r--drivers/video/console/sticore.c9
-rw-r--r--drivers/video/mx3fb.c86
-rw-r--r--drivers/video/sh_mobile_lcdcfb.c5
-rw-r--r--drivers/video/via/hw.c4
-rw-r--r--drivers/video/via/lcd.c15
-rw-r--r--drivers/video/via/viafbdev.c101
-rw-r--r--drivers/video/via/viafbdev.h3
-rw-r--r--drivers/video/xen-fbfront.c8
-rw-r--r--drivers/w1/masters/omap_hdq.c1
-rw-r--r--drivers/watchdog/ar7_wdt.c2
-rw-r--r--drivers/watchdog/coh901327_wdt.c11
-rw-r--r--drivers/watchdog/ks8695_wdt.c4
-rw-r--r--fs/9p/v9fs.c21
-rw-r--r--fs/9p/v9fs.h1
-rw-r--r--fs/9p/vfs_inode.c126
-rw-r--r--fs/9p/vfs_super.c39
-rw-r--r--fs/afs/file.c18
-rw-r--r--fs/autofs4/expire.c2
-rw-r--r--fs/binfmt_flat.c17
-rw-r--r--fs/btrfs/extent-tree.c21
-rw-r--r--fs/btrfs/free-space-cache.c73
-rw-r--r--fs/btrfs/inode.c24
-rw-r--r--fs/btrfs/relocation.c9
-rw-r--r--fs/btrfs/zlib.c6
-rw-r--r--fs/buffer.c7
-rw-r--r--fs/cifs/CHANGES7
-rw-r--r--fs/cifs/README25
-rw-r--r--fs/cifs/cifs_dfs_ref.c12
-rw-r--r--fs/cifs/cifs_unicode.c2
-rw-r--r--fs/cifs/cifsfs.c4
-rw-r--r--fs/cifs/connect.c55
-rw-r--r--fs/compat_ioctl.c1
-rw-r--r--fs/exec.c4
-rw-r--r--fs/ext3/Kconfig32
-rw-r--r--fs/ext3/super.c40
-rw-r--r--fs/gfs2/sys.c20
-rw-r--r--fs/hugetlbfs/inode.c20
-rw-r--r--fs/inode.c40
-rw-r--r--fs/jffs2/file.c2
-rw-r--r--fs/libfs.c2
-rw-r--r--fs/namespace.c3
-rw-r--r--fs/nfs/direct.c20
-rw-r--r--fs/nfs/nfs4state.c4
-rw-r--r--fs/nfs/read.c6
-rw-r--r--fs/nfs/write.c6
-rw-r--r--fs/nilfs2/mdt.c4
-rw-r--r--fs/nilfs2/segment.c16
-rw-r--r--fs/nilfs2/super.c2
-rw-r--r--fs/nilfs2/the_nilfs.h2
-rw-r--r--fs/notify/inotify/inotify_fsnotify.c46
-rw-r--r--fs/notify/inotify/inotify_user.c254
-rw-r--r--fs/notify/notification.c11
-rw-r--r--fs/ocfs2/alloc.c49
-rw-r--r--fs/ocfs2/aops.c69
-rw-r--r--fs/ocfs2/dcache.c35
-rw-r--r--fs/ocfs2/dcache.h3
-rw-r--r--fs/ocfs2/dlm/dlmast.c1
-rw-r--r--fs/ocfs2/dlm/dlmrecovery.c2
-rw-r--r--fs/ocfs2/dlm/dlmunlock.c4
-rw-r--r--fs/ocfs2/file.c5
-rw-r--r--fs/ocfs2/journal.c8
-rw-r--r--fs/ocfs2/journal.h19
-rw-r--r--fs/ocfs2/ocfs2.h22
-rw-r--r--fs/ocfs2/ocfs2_lockid.h1
-rw-r--r--fs/ocfs2/quota.h1
-rw-r--r--fs/ocfs2/quota_global.c144
-rw-r--r--fs/ocfs2/quota_local.c110
-rw-r--r--fs/ocfs2/stack_o2cb.c3
-rw-r--r--fs/ocfs2/super.c34
-rw-r--r--fs/ocfs2/xattr.c3
-rw-r--r--fs/proc/base.c46
-rw-r--r--fs/proc/task_mmu.c1
-rw-r--r--fs/proc/task_nommu.c1
-rw-r--r--fs/select.c1
-rw-r--r--fs/xfs/linux-2.6/xfs_buf.c2
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.c13
-rw-r--r--fs/xfs/linux-2.6/xfs_sync.h1
-rw-r--r--fs/xfs/xfs_attr.c8
-rw-r--r--fs/xfs/xfs_bmap.c2
-rw-r--r--fs/xfs/xfs_btree.c4
-rw-r--r--fs/xfs/xfs_da_btree.c6
-rw-r--r--fs/xfs/xfs_dir2.c2
-rw-r--r--fs/xfs/xfs_fsops.c20
-rw-r--r--fs/xfs/xfs_iget.c253
-rw-r--r--fs/xfs/xfs_inode.c10
-rw-r--r--fs/xfs/xfs_inode.h17
-rw-r--r--fs/xfs/xfs_log.c2
-rw-r--r--fs/xfs/xfs_vnodeops.c4
-rw-r--r--include/acpi/acpiosxf.h4
-rw-r--r--include/acpi/processor.h5
-rw-r--r--include/drm/drm_pciids.h10
-rw-r--r--include/drm/radeon_drm.h6
-rw-r--r--include/linux/bitmap.h18
-rw-r--r--include/linux/blkdev.h1
-rw-r--r--include/linux/cpumask.h20
-rw-r--r--include/linux/decompress/generic.h32
-rw-r--r--include/linux/flex_array.h12
-rw-r--r--include/linux/fs.h5
-rw-r--r--include/linux/ftrace_event.h12
-rw-r--r--include/linux/gen_stats.h5
-rw-r--r--include/linux/hugetlb.h6
-rw-r--r--include/linux/inetdevice.h2
-rw-r--r--include/linux/input/matrix_keypad.h13
-rw-r--r--include/linux/kvm_host.h1
-rw-r--r--include/linux/lmb.h2
-rw-r--r--include/linux/mm.h15
-rw-r--r--include/linux/mm_types.h2
-rw-r--r--include/linux/mtd/mtd.h2
-rw-r--r--include/linux/mtd/partitions.h2
-rw-r--r--include/linux/nfs_fs.h5
-rw-r--r--include/linux/nodemask.h28
-rw-r--r--include/linux/perf_counter.h73
-rw-r--r--include/linux/sched.h1
-rw-r--r--include/linux/security.h24
-rw-r--r--include/linux/tty_ldisc.h2
-rw-r--r--include/linux/ucb1400.h4
-rw-r--r--include/linux/wait.h9
-rw-r--r--include/net/act_api.h2
-rw-r--r--include/net/bluetooth/rfcomm.h12
-rw-r--r--include/net/cfg80211.h5
-rw-r--r--include/net/gen_stats.h10
-rw-r--r--include/net/netfilter/xt_rateest.h2
-rw-r--r--include/net/pkt_sched.h4
-rw-r--r--include/net/sch_generic.h2
-rw-r--r--include/trace/ftrace.h183
-rw-r--r--init/Kconfig11
-rw-r--r--init/main.c9
-rw-r--r--ipc/shm.c8
-rw-r--r--kernel/fork.c47
-rw-r--r--kernel/futex.c28
-rw-r--r--kernel/futex_compat.c6
-rw-r--r--kernel/irq/manage.c27
-rw-r--r--kernel/irq/numa_migrate.c4
-rw-r--r--kernel/lockdep_proc.c3
-rw-r--r--kernel/module.c10
-rw-r--r--kernel/panic.c1
-rw-r--r--kernel/perf_counter.c677
-rw-r--r--kernel/posix-cpu-timers.c7
-rw-r--r--kernel/posix-timers.c7
-rw-r--r--kernel/rtmutex.c4
-rw-r--r--kernel/sched_cpupri.c15
-rw-r--r--kernel/sched_fair.c32
-rw-r--r--kernel/signal.c25
-rw-r--r--kernel/smp.c2
-rw-r--r--kernel/sysctl.c7
-rw-r--r--kernel/time/clockevents.c16
-rw-r--r--kernel/time/tick-broadcast.c7
-rw-r--r--kernel/time/timer_list.c2
-rw-r--r--kernel/trace/blktrace.c12
-rw-r--r--kernel/trace/ftrace.c21
-rw-r--r--kernel/trace/ring_buffer.c15
-rw-r--r--kernel/trace/trace.c25
-rw-r--r--kernel/trace/trace.h4
-rw-r--r--kernel/trace/trace_event_profile.c2
-rw-r--r--kernel/trace/trace_events.c4
-rw-r--r--kernel/trace/trace_events_filter.c20
-rw-r--r--kernel/trace/trace_functions_graph.c11
-rw-r--r--kernel/trace/trace_printk.c2
-rw-r--r--kernel/wait.c5
-rw-r--r--lib/bitmap.c12
-rw-r--r--lib/decompress_bunzip2.c24
-rw-r--r--lib/decompress_inflate.c10
-rw-r--r--lib/decompress_unlzma.c23
-rw-r--r--lib/dma-debug.c28
-rw-r--r--lib/flex_array.c43
-rw-r--r--lib/lmb.c2
-rw-r--r--mm/Kconfig6
-rw-r--r--mm/mempolicy.c84
-rw-r--r--mm/mempool.c4
-rw-r--r--mm/mmap.c3
-rw-r--r--mm/nommu.c7
-rw-r--r--mm/oom_kill.c64
-rw-r--r--mm/page_alloc.c4
-rw-r--r--mm/percpu.c35
-rw-r--r--mm/rmap.c1
-rw-r--r--mm/vmscan.c9
-rw-r--r--net/9p/client.c21
-rw-r--r--net/9p/error.c2
-rw-r--r--net/9p/trans_fd.c8
-rw-r--r--net/9p/trans_rdma.c9
-rw-r--r--net/9p/trans_virtio.c11
-rw-r--r--net/appletalk/ddp.c1
-rw-r--r--net/bluetooth/rfcomm/core.c27
-rw-r--r--net/bluetooth/rfcomm/sock.c2
-rw-r--r--net/can/raw.c1
-rw-r--r--net/core/dev.c23
-rw-r--r--net/core/gen_estimator.c12
-rw-r--r--net/core/gen_stats.c11
-rw-r--r--net/core/net_namespace.c2
-rw-r--r--net/core/netpoll.c5
-rw-r--r--net/dccp/proto.c1
-rw-r--r--net/econet/af_econet.c1
-rw-r--r--net/ieee802154/af_ieee802154.c8
-rw-r--r--net/ieee802154/dgram.c14
-rw-r--r--net/ieee802154/raw.c14
-rw-r--r--net/ipv4/arp.c4
-rw-r--r--net/ipv4/ip_gre.c2
-rw-r--r--net/ipv4/ip_output.c2
-rw-r--r--net/ipv6/af_inet6.c4
-rw-r--r--net/irda/af_irda.c1
-rw-r--r--net/llc/af_llc.c1
-rw-r--r--net/mac80211/agg-tx.c8
-rw-r--r--net/mac80211/key.c28
-rw-r--r--net/mac80211/mlme.c2
-rw-r--r--net/mac80211/pm.c24
-rw-r--r--net/mac80211/rx.c12
-rw-r--r--net/netfilter/xt_RATEEST.c2
-rw-r--r--net/netfilter/xt_quota.c2
-rw-r--r--net/netlabel/netlabel_kapi.c2
-rw-r--r--net/netrom/af_netrom.c1
-rw-r--r--net/netrom/nr_route.c21
-rw-r--r--net/phonet/pn_dev.c2
-rw-r--r--net/rose/af_rose.c1
-rw-r--r--net/sched/sch_api.c10
-rw-r--r--net/sched/sch_atm.c2
-rw-r--r--net/sched/sch_cbq.c27
-rw-r--r--net/sched/sch_drr.c2
-rw-r--r--net/sched/sch_hfsc.c2
-rw-r--r--net/sched/sch_htb.c2
-rw-r--r--net/sctp/protocol.c1
-rw-r--r--net/socket.c2
-rw-r--r--net/sunrpc/clnt.c1
-rw-r--r--net/wireless/reg.c9
-rw-r--r--net/wireless/reg.h3
-rw-r--r--net/wireless/scan.c4
-rw-r--r--net/xfrm/xfrm_hash.h2
-rwxr-xr-xscripts/recordmcount.pl12
-rw-r--r--security/Kconfig16
-rw-r--r--security/Makefile2
-rw-r--r--security/capability.c9
-rw-r--r--security/commoncap.c30
-rw-r--r--security/integrity/ima/ima_crypto.c6
-rw-r--r--security/integrity/ima/ima_main.c4
-rw-r--r--security/min_addr.c49
-rw-r--r--security/selinux/hooks.c17
-rw-r--r--sound/core/pcm_lib.c39
-rw-r--r--sound/pci/ali5451/ali5451.c18
-rw-r--r--sound/pci/hda/hda_codec.c2
-rw-r--r--sound/pci/hda/hda_codec.h2
-rw-r--r--sound/pci/hda/hda_intel.c103
-rw-r--r--sound/pci/hda/patch_analog.c6
-rw-r--r--sound/pci/hda/patch_realtek.c73
-rw-r--r--sound/pci/hda/patch_sigmatel.c15
-rw-r--r--sound/pci/hda/patch_via.c1
-rw-r--r--sound/pci/vx222/vx222_ops.c4
-rw-r--r--sound/soc/fsl/efika-audio-fabric.c2
-rw-r--r--sound/soc/fsl/pcm030-audio-fabric.c2
-rw-r--r--tools/perf/Documentation/Makefile2
-rw-r--r--tools/perf/Documentation/examples.txt225
-rw-r--r--tools/perf/Documentation/perf-record.txt60
-rw-r--r--tools/perf/Documentation/perf-stat.txt2
-rw-r--r--tools/perf/Documentation/perf-top.txt112
-rw-r--r--tools/perf/Makefile40
-rw-r--r--tools/perf/builtin-annotate.c14
-rw-r--r--tools/perf/builtin-list.c3
-rw-r--r--tools/perf/builtin-record.c108
-rw-r--r--tools/perf/builtin-report.c146
-rw-r--r--tools/perf/builtin-stat.c2
-rw-r--r--tools/perf/builtin-top.c553
-rw-r--r--tools/perf/util/callchain.c32
-rw-r--r--tools/perf/util/callchain.h8
-rw-r--r--tools/perf/util/header.c5
-rw-r--r--tools/perf/util/parse-events.c36
-rw-r--r--tools/perf/util/parse-events.h1
-rw-r--r--tools/perf/util/quote.c2
-rw-r--r--tools/perf/util/symbol.c133
-rw-r--r--tools/perf/util/symbol.h26
-rw-r--r--virt/kvm/ioapic.c10
-rw-r--r--virt/kvm/irq_comm.c4
908 files changed, 12536 insertions, 7059 deletions
diff --git a/Documentation/ABI/testing/sysfs-block b/Documentation/ABI/testing/sysfs-block
index cbbd3e069945..5f3bedaf8e35 100644
--- a/Documentation/ABI/testing/sysfs-block
+++ b/Documentation/ABI/testing/sysfs-block
@@ -94,28 +94,37 @@ What: /sys/block/<disk>/queue/physical_block_size
94Date: May 2009 94Date: May 2009
95Contact: Martin K. Petersen <martin.petersen@oracle.com> 95Contact: Martin K. Petersen <martin.petersen@oracle.com>
96Description: 96Description:
97 This is the smallest unit the storage device can write 97 This is the smallest unit a physical storage device can
98 without resorting to read-modify-write operation. It is 98 write atomically. It is usually the same as the logical
99 usually the same as the logical block size but may be 99 block size but may be bigger. One example is SATA
100 bigger. One example is SATA drives with 4KB sectors 100 drives with 4KB sectors that expose a 512-byte logical
101 that expose a 512-byte logical block size to the 101 block size to the operating system. For stacked block
102 operating system. 102 devices the physical_block_size variable contains the
103 maximum physical_block_size of the component devices.
103 104
104What: /sys/block/<disk>/queue/minimum_io_size 105What: /sys/block/<disk>/queue/minimum_io_size
105Date: April 2009 106Date: April 2009
106Contact: Martin K. Petersen <martin.petersen@oracle.com> 107Contact: Martin K. Petersen <martin.petersen@oracle.com>
107Description: 108Description:
108 Storage devices may report a preferred minimum I/O size, 109 Storage devices may report a granularity or preferred
109 which is the smallest request the device can perform 110 minimum I/O size which is the smallest request the
110 without incurring a read-modify-write penalty. For disk 111 device can perform without incurring a performance
111 drives this is often the physical block size. For RAID 112 penalty. For disk drives this is often the physical
112 arrays it is often the stripe chunk size. 113 block size. For RAID arrays it is often the stripe
114 chunk size. A properly aligned multiple of
115 minimum_io_size is the preferred request size for
116 workloads where a high number of I/O operations is
117 desired.
113 118
114What: /sys/block/<disk>/queue/optimal_io_size 119What: /sys/block/<disk>/queue/optimal_io_size
115Date: April 2009 120Date: April 2009
116Contact: Martin K. Petersen <martin.petersen@oracle.com> 121Contact: Martin K. Petersen <martin.petersen@oracle.com>
117Description: 122Description:
118 Storage devices may report an optimal I/O size, which is 123 Storage devices may report an optimal I/O size, which is
119 the device's preferred unit of receiving I/O. This is 124 the device's preferred unit for sustained I/O. This is
120 rarely reported for disk drives. For RAID devices it is 125 rarely reported for disk drives. For RAID arrays it is
121 usually the stripe width or the internal block size. 126 usually the stripe width or the internal track size. A
127 properly aligned multiple of optimal_io_size is the
128 preferred request size for workloads where sustained
129 throughput is desired. If no optimal I/O size is
130 reported this file contains 0.
diff --git a/Documentation/DocBook/kernel-hacking.tmpl b/Documentation/DocBook/kernel-hacking.tmpl
index a50d6cd58573..992e67e6be7f 100644
--- a/Documentation/DocBook/kernel-hacking.tmpl
+++ b/Documentation/DocBook/kernel-hacking.tmpl
@@ -449,8 +449,8 @@ printk(KERN_INFO "i = %u\n", i);
449 </para> 449 </para>
450 450
451 <programlisting> 451 <programlisting>
452__u32 ipaddress; 452__be32 ipaddress;
453printk(KERN_INFO "my ip: %d.%d.%d.%d\n", NIPQUAD(ipaddress)); 453printk(KERN_INFO "my ip: %pI4\n", &amp;ipaddress);
454 </programlisting> 454 </programlisting>
455 455
456 <para> 456 <para>
diff --git a/Documentation/arm/memory.txt b/Documentation/arm/memory.txt
index 43cb1004d35f..9d58c7c5eddd 100644
--- a/Documentation/arm/memory.txt
+++ b/Documentation/arm/memory.txt
@@ -21,6 +21,8 @@ ffff8000 ffffffff copy_user_page / clear_user_page use.
21 For SA11xx and Xscale, this is used to 21 For SA11xx and Xscale, this is used to
22 setup a minicache mapping. 22 setup a minicache mapping.
23 23
24ffff4000 ffffffff cache aliasing on ARMv6 and later CPUs.
25
24ffff1000 ffff7fff Reserved. 26ffff1000 ffff7fff Reserved.
25 Platforms must not use this address range. 27 Platforms must not use this address range.
26 28
diff --git a/Documentation/filesystems/9p.txt b/Documentation/filesystems/9p.txt
index bf8080640eba..6208f55c44c3 100644
--- a/Documentation/filesystems/9p.txt
+++ b/Documentation/filesystems/9p.txt
@@ -123,6 +123,9 @@ available from the same CVS repository.
123There are user and developer mailing lists available through the v9fs project 123There are user and developer mailing lists available through the v9fs project
124on sourceforge (http://sourceforge.net/projects/v9fs). 124on sourceforge (http://sourceforge.net/projects/v9fs).
125 125
126A stand-alone version of the module (which should build for any 2.6 kernel)
127is available via (http://github.com/ericvh/9p-sac/tree/master)
128
126News and other information is maintained on SWiK (http://swik.net/v9fs). 129News and other information is maintained on SWiK (http://swik.net/v9fs).
127 130
128Bug reports may be issued through the kernel.org bugzilla 131Bug reports may be issued through the kernel.org bugzilla
diff --git a/Documentation/filesystems/afs.txt b/Documentation/filesystems/afs.txt
index 12ad6c7f4e50..ffef91c4e0d6 100644
--- a/Documentation/filesystems/afs.txt
+++ b/Documentation/filesystems/afs.txt
@@ -23,15 +23,13 @@ it does support include:
23 23
24 (*) Security (currently only AFS kaserver and KerberosIV tickets). 24 (*) Security (currently only AFS kaserver and KerberosIV tickets).
25 25
26 (*) File reading. 26 (*) File reading and writing.
27 27
28 (*) Automounting. 28 (*) Automounting.
29 29
30It does not yet support the following AFS features: 30 (*) Local caching (via fscache).
31
32 (*) Write support.
33 31
34 (*) Local caching. 32It does not yet support the following AFS features:
35 33
36 (*) pioctl() system call. 34 (*) pioctl() system call.
37 35
@@ -56,7 +54,7 @@ They permit the debugging messages to be turned on dynamically by manipulating
56the masks in the following files: 54the masks in the following files:
57 55
58 /sys/module/af_rxrpc/parameters/debug 56 /sys/module/af_rxrpc/parameters/debug
59 /sys/module/afs/parameters/debug 57 /sys/module/kafs/parameters/debug
60 58
61 59
62===== 60=====
@@ -66,9 +64,9 @@ USAGE
66When inserting the driver modules the root cell must be specified along with a 64When inserting the driver modules the root cell must be specified along with a
67list of volume location server IP addresses: 65list of volume location server IP addresses:
68 66
69 insmod af_rxrpc.o 67 modprobe af_rxrpc
70 insmod rxkad.o 68 modprobe rxkad
71 insmod kafs.o rootcell=cambridge.redhat.com:172.16.18.73:172.16.18.91 69 modprobe kafs rootcell=cambridge.redhat.com:172.16.18.73:172.16.18.91
72 70
73The first module is the AF_RXRPC network protocol driver. This provides the 71The first module is the AF_RXRPC network protocol driver. This provides the
74RxRPC remote operation protocol and may also be accessed from userspace. See: 72RxRPC remote operation protocol and may also be accessed from userspace. See:
@@ -81,7 +79,7 @@ is the actual filesystem driver for the AFS filesystem.
81Once the module has been loaded, more modules can be added by the following 79Once the module has been loaded, more modules can be added by the following
82procedure: 80procedure:
83 81
84 echo add grand.central.org 18.7.14.88:128.2.191.224 >/proc/fs/afs/cells 82 echo add grand.central.org 18.9.48.14:128.2.203.61:130.237.48.87 >/proc/fs/afs/cells
85 83
86Where the parameters to the "add" command are the name of a cell and a list of 84Where the parameters to the "add" command are the name of a cell and a list of
87volume location servers within that cell, with the latter separated by colons. 85volume location servers within that cell, with the latter separated by colons.
@@ -101,7 +99,7 @@ The name of the volume can be suffixes with ".backup" or ".readonly" to
101specify connection to only volumes of those types. 99specify connection to only volumes of those types.
102 100
103The name of the cell is optional, and if not given during a mount, then the 101The name of the cell is optional, and if not given during a mount, then the
104named volume will be looked up in the cell specified during insmod. 102named volume will be looked up in the cell specified during modprobe.
105 103
106Additional cells can be added through /proc (see later section). 104Additional cells can be added through /proc (see later section).
107 105
@@ -163,14 +161,14 @@ THE CELL DATABASE
163 161
164The filesystem maintains an internal database of all the cells it knows and the 162The filesystem maintains an internal database of all the cells it knows and the
165IP addresses of the volume location servers for those cells. The cell to which 163IP addresses of the volume location servers for those cells. The cell to which
166the system belongs is added to the database when insmod is performed by the 164the system belongs is added to the database when modprobe is performed by the
167"rootcell=" argument or, if compiled in, using a "kafs.rootcell=" argument on 165"rootcell=" argument or, if compiled in, using a "kafs.rootcell=" argument on
168the kernel command line. 166the kernel command line.
169 167
170Further cells can be added by commands similar to the following: 168Further cells can be added by commands similar to the following:
171 169
172 echo add CELLNAME VLADDR[:VLADDR][:VLADDR]... >/proc/fs/afs/cells 170 echo add CELLNAME VLADDR[:VLADDR][:VLADDR]... >/proc/fs/afs/cells
173 echo add grand.central.org 18.7.14.88:128.2.191.224 >/proc/fs/afs/cells 171 echo add grand.central.org 18.9.48.14:128.2.203.61:130.237.48.87 >/proc/fs/afs/cells
174 172
175No other cell database operations are available at this time. 173No other cell database operations are available at this time.
176 174
@@ -233,7 +231,7 @@ insmod /tmp/kafs.o rootcell=cambridge.redhat.com:172.16.18.91
233mount -t afs \%root.afs. /afs 231mount -t afs \%root.afs. /afs
234mount -t afs \%cambridge.redhat.com:root.cell. /afs/cambridge.redhat.com/ 232mount -t afs \%cambridge.redhat.com:root.cell. /afs/cambridge.redhat.com/
235 233
236echo add grand.central.org 18.7.14.88:128.2.191.224 > /proc/fs/afs/cells 234echo add grand.central.org 18.9.48.14:128.2.203.61:130.237.48.87 > /proc/fs/afs/cells
237mount -t afs "#grand.central.org:root.cell." /afs/grand.central.org/ 235mount -t afs "#grand.central.org:root.cell." /afs/grand.central.org/
238mount -t afs "#grand.central.org:root.archive." /afs/grand.central.org/archive 236mount -t afs "#grand.central.org:root.archive." /afs/grand.central.org/archive
239mount -t afs "#grand.central.org:root.contrib." /afs/grand.central.org/contrib 237mount -t afs "#grand.central.org:root.contrib." /afs/grand.central.org/contrib
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt
index fad18f9456e4..ffead13f9443 100644
--- a/Documentation/filesystems/proc.txt
+++ b/Documentation/filesystems/proc.txt
@@ -1167,13 +1167,11 @@ CHAPTER 3: PER-PROCESS PARAMETERS
11673.1 /proc/<pid>/oom_adj - Adjust the oom-killer score 11673.1 /proc/<pid>/oom_adj - Adjust the oom-killer score
1168------------------------------------------------------ 1168------------------------------------------------------
1169 1169
1170This file can be used to adjust the score used to select which processes should 1170This file can be used to adjust the score used to select which processes
1171be killed in an out-of-memory situation. The oom_adj value is a characteristic 1171should be killed in an out-of-memory situation. Giving it a high score will
1172of the task's mm, so all threads that share an mm with pid will have the same 1172increase the likelihood of this process being killed by the oom-killer. Valid
1173oom_adj value. A high value will increase the likelihood of this process being 1173values are in the range -16 to +15, plus the special value -17, which disables
1174killed by the oom-killer. Valid values are in the range -16 to +15 as 1174oom-killing altogether for this process.
1175explained below and a special value of -17, which disables oom-killing
1176altogether for threads sharing pid's mm.
1177 1175
1178The process to be killed in an out-of-memory situation is selected among all others 1176The process to be killed in an out-of-memory situation is selected among all others
1179based on its badness score. This value equals the original memory size of the process 1177based on its badness score. This value equals the original memory size of the process
@@ -1187,9 +1185,6 @@ the parent's score if they do not share the same memory. Thus forking servers
1187are the prime candidates to be killed. Having only one 'hungry' child will make 1185are the prime candidates to be killed. Having only one 'hungry' child will make
1188parent less preferable than the child. 1186parent less preferable than the child.
1189 1187
1190/proc/<pid>/oom_adj cannot be changed for kthreads since they are immune from
1191oom-killing already.
1192
1193/proc/<pid>/oom_score shows process' current badness score. 1188/proc/<pid>/oom_score shows process' current badness score.
1194 1189
1195The following heuristics are then applied: 1190The following heuristics are then applied:
diff --git a/Documentation/ioctl/ioctl-number.txt b/Documentation/ioctl/ioctl-number.txt
index 7bb0d934b6d8..dbea4f95fc85 100644
--- a/Documentation/ioctl/ioctl-number.txt
+++ b/Documentation/ioctl/ioctl-number.txt
@@ -139,6 +139,7 @@ Code Seq# Include File Comments
139'm' all linux/synclink.h conflict! 139'm' all linux/synclink.h conflict!
140'm' 00-1F net/irda/irmod.h conflict! 140'm' 00-1F net/irda/irmod.h conflict!
141'n' 00-7F linux/ncp_fs.h 141'n' 00-7F linux/ncp_fs.h
142'n' 80-8F linux/nilfs2_fs.h NILFS2
142'n' E0-FF video/matrox.h matroxfb 143'n' E0-FF video/matrox.h matroxfb
143'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2 144'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2
144'o' 00-03 include/mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps) 145'o' 00-03 include/mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps)
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index dd1a6d4bb747..7936b801fe6a 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1115,6 +1115,10 @@ and is between 256 and 4096 characters. It is defined in the file
1115 libata.dma=4 Compact Flash DMA only 1115 libata.dma=4 Compact Flash DMA only
1116 Combinations also work, so libata.dma=3 enables DMA 1116 Combinations also work, so libata.dma=3 enables DMA
1117 for disks and CDROMs, but not CFs. 1117 for disks and CDROMs, but not CFs.
1118
1119 libata.ignore_hpa= [LIBATA] Ignore HPA limit
1120 libata.ignore_hpa=0 keep BIOS limits (default)
1121 libata.ignore_hpa=1 ignore limits, using full disk
1118 1122
1119 libata.noacpi [LIBATA] Disables use of ACPI in libata suspend/resume 1123 libata.noacpi [LIBATA] Disables use of ACPI in libata suspend/resume
1120 when set. 1124 when set.
diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index f2296ecedb89..e2ddcdeb61b6 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -36,8 +36,6 @@ detailed description):
36 - Bluetooth enable and disable 36 - Bluetooth enable and disable
37 - video output switching, expansion control 37 - video output switching, expansion control
38 - ThinkLight on and off 38 - ThinkLight on and off
39 - limited docking and undocking
40 - UltraBay eject
41 - CMOS/UCMS control 39 - CMOS/UCMS control
42 - LED control 40 - LED control
43 - ACPI sounds 41 - ACPI sounds
@@ -729,131 +727,6 @@ cannot be read or if it is unknown, thinkpad-acpi will report it as "off".
729It is impossible to know if the status returned through sysfs is valid. 727It is impossible to know if the status returned through sysfs is valid.
730 728
731 729
732Docking / undocking -- /proc/acpi/ibm/dock
733------------------------------------------
734
735Docking and undocking (e.g. with the X4 UltraBase) requires some
736actions to be taken by the operating system to safely make or break
737the electrical connections with the dock.
738
739The docking feature of this driver generates the following ACPI events:
740
741 ibm/dock GDCK 00000003 00000001 -- eject request
742 ibm/dock GDCK 00000003 00000002 -- undocked
743 ibm/dock GDCK 00000000 00000003 -- docked
744
745NOTE: These events will only be generated if the laptop was docked
746when originally booted. This is due to the current lack of support for
747hot plugging of devices in the Linux ACPI framework. If the laptop was
748booted while not in the dock, the following message is shown in the
749logs:
750
751 Mar 17 01:42:34 aero kernel: thinkpad_acpi: dock device not present
752
753In this case, no dock-related events are generated but the dock and
754undock commands described below still work. They can be executed
755manually or triggered by Fn key combinations (see the example acpid
756configuration files included in the driver tarball package available
757on the web site).
758
759When the eject request button on the dock is pressed, the first event
760above is generated. The handler for this event should issue the
761following command:
762
763 echo undock > /proc/acpi/ibm/dock
764
765After the LED on the dock goes off, it is safe to eject the laptop.
766Note: if you pressed this key by mistake, go ahead and eject the
767laptop, then dock it back in. Otherwise, the dock may not function as
768expected.
769
770When the laptop is docked, the third event above is generated. The
771handler for this event should issue the following command to fully
772enable the dock:
773
774 echo dock > /proc/acpi/ibm/dock
775
776The contents of the /proc/acpi/ibm/dock file shows the current status
777of the dock, as provided by the ACPI framework.
778
779The docking support in this driver does not take care of enabling or
780disabling any other devices you may have attached to the dock. For
781example, a CD drive plugged into the UltraBase needs to be disabled or
782enabled separately. See the provided example acpid configuration files
783for how this can be accomplished.
784
785There is no support yet for PCI devices that may be attached to a
786docking station, e.g. in the ThinkPad Dock II. The driver currently
787does not recognize, enable or disable such devices. This means that
788the only docking stations currently supported are the X-series
789UltraBase docks and "dumb" port replicators like the Mini Dock (the
790latter don't need any ACPI support, actually).
791
792
793UltraBay eject -- /proc/acpi/ibm/bay
794------------------------------------
795
796Inserting or ejecting an UltraBay device requires some actions to be
797taken by the operating system to safely make or break the electrical
798connections with the device.
799
800This feature generates the following ACPI events:
801
802 ibm/bay MSTR 00000003 00000000 -- eject request
803 ibm/bay MSTR 00000001 00000000 -- eject lever inserted
804
805NOTE: These events will only be generated if the UltraBay was present
806when the laptop was originally booted (on the X series, the UltraBay
807is in the dock, so it may not be present if the laptop was undocked).
808This is due to the current lack of support for hot plugging of devices
809in the Linux ACPI framework. If the laptop was booted without the
810UltraBay, the following message is shown in the logs:
811
812 Mar 17 01:42:34 aero kernel: thinkpad_acpi: bay device not present
813
814In this case, no bay-related events are generated but the eject
815command described below still works. It can be executed manually or
816triggered by a hot key combination.
817
818Sliding the eject lever generates the first event shown above. The
819handler for this event should take whatever actions are necessary to
820shut down the device in the UltraBay (e.g. call idectl), then issue
821the following command:
822
823 echo eject > /proc/acpi/ibm/bay
824
825After the LED on the UltraBay goes off, it is safe to pull out the
826device.
827
828When the eject lever is inserted, the second event above is
829generated. The handler for this event should take whatever actions are
830necessary to enable the UltraBay device (e.g. call idectl).
831
832The contents of the /proc/acpi/ibm/bay file shows the current status
833of the UltraBay, as provided by the ACPI framework.
834
835EXPERIMENTAL warm eject support on the 600e/x, A22p and A3x (To use
836this feature, you need to supply the experimental=1 parameter when
837loading the module):
838
839These models do not have a button near the UltraBay device to request
840a hot eject but rather require the laptop to be put to sleep
841(suspend-to-ram) before the bay device is ejected or inserted).
842The sequence of steps to eject the device is as follows:
843
844 echo eject > /proc/acpi/ibm/bay
845 put the ThinkPad to sleep
846 remove the drive
847 resume from sleep
848 cat /proc/acpi/ibm/bay should show that the drive was removed
849
850On the A3x, both the UltraBay 2000 and UltraBay Plus devices are
851supported. Use "eject2" instead of "eject" for the second bay.
852
853Note: the UltraBay eject support on the 600e/x, A22p and A3x is
854EXPERIMENTAL and may not work as expected. USE WITH CAUTION!
855
856
857CMOS/UCMS control 730CMOS/UCMS control
858----------------- 731-----------------
859 732
diff --git a/Documentation/lockdep-design.txt b/Documentation/lockdep-design.txt
index e20d913d5914..abf768c681e2 100644
--- a/Documentation/lockdep-design.txt
+++ b/Documentation/lockdep-design.txt
@@ -30,9 +30,9 @@ State
30The validator tracks lock-class usage history into 4n + 1 separate state bits: 30The validator tracks lock-class usage history into 4n + 1 separate state bits:
31 31
32- 'ever held in STATE context' 32- 'ever held in STATE context'
33- 'ever head as readlock in STATE context' 33- 'ever held as readlock in STATE context'
34- 'ever head with STATE enabled' 34- 'ever held with STATE enabled'
35- 'ever head as readlock with STATE enabled' 35- 'ever held as readlock with STATE enabled'
36 36
37Where STATE can be either one of (kernel/lockdep_states.h) 37Where STATE can be either one of (kernel/lockdep_states.h)
38 - hardirq 38 - hardirq
diff --git a/Documentation/video4linux/CARDLIST.em28xx b/Documentation/video4linux/CARDLIST.em28xx
index 68c236c01846..e352d754875c 100644
--- a/Documentation/video4linux/CARDLIST.em28xx
+++ b/Documentation/video4linux/CARDLIST.em28xx
@@ -1,5 +1,5 @@
1 0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800] 1 0 -> Unknown EM2800 video grabber (em2800) [eb1a:2800]
2 1 -> Unknown EM2750/28xx video grabber (em2820/em2840) [eb1a:2820,eb1a:2821,eb1a:2860,eb1a:2861,eb1a:2870,eb1a:2881,eb1a:2883] 2 1 -> Unknown EM2750/28xx video grabber (em2820/em2840) [eb1a:2710,eb1a:2820,eb1a:2821,eb1a:2860,eb1a:2861,eb1a:2870,eb1a:2881,eb1a:2883]
3 2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036] 3 2 -> Terratec Cinergy 250 USB (em2820/em2840) [0ccd:0036]
4 3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208] 4 3 -> Pinnacle PCTV USB 2 (em2820/em2840) [2304:0208]
5 4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200,2040:4201] 5 4 -> Hauppauge WinTV USB 2 (em2820/em2840) [2040:4200,2040:4201]
diff --git a/Documentation/video4linux/CARDLIST.saa7134 b/Documentation/video4linux/CARDLIST.saa7134
index 15562427e8a9..c913e5614195 100644
--- a/Documentation/video4linux/CARDLIST.saa7134
+++ b/Documentation/video4linux/CARDLIST.saa7134
@@ -153,8 +153,8 @@
153152 -> Asus Tiger Rev:1.00 [1043:4857] 153152 -> Asus Tiger Rev:1.00 [1043:4857]
154153 -> Kworld Plus TV Analog Lite PCI [17de:7128] 154153 -> Kworld Plus TV Analog Lite PCI [17de:7128]
155154 -> Avermedia AVerTV GO 007 FM Plus [1461:f31d] 155154 -> Avermedia AVerTV GO 007 FM Plus [1461:f31d]
156155 -> Hauppauge WinTV-HVR1120 ATSC/QAM-Hybrid [0070:6706,0070:6708] 156155 -> Hauppauge WinTV-HVR1150 ATSC/QAM-Hybrid [0070:6706,0070:6708]
157156 -> Hauppauge WinTV-HVR1110r3 DVB-T/Hybrid [0070:6707,0070:6709,0070:670a] 157156 -> Hauppauge WinTV-HVR1120 DVB-T/Hybrid [0070:6707,0070:6709,0070:670a]
158157 -> Avermedia AVerTV Studio 507UA [1461:a11b] 158157 -> Avermedia AVerTV Studio 507UA [1461:a11b]
159158 -> AVerMedia Cardbus TV/Radio (E501R) [1461:b7e9] 159158 -> AVerMedia Cardbus TV/Radio (E501R) [1461:b7e9]
160159 -> Beholder BeholdTV 505 RDS [0000:505B] 160159 -> Beholder BeholdTV 505 RDS [0000:505B]
diff --git a/MAINTAINERS b/MAINTAINERS
index ed6a10349b14..0c87b44ca8da 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -936,7 +936,7 @@ F: drivers/input/misc/ati_remote2.c
936 936
937ATLX ETHERNET DRIVERS 937ATLX ETHERNET DRIVERS
938M: Jay Cliburn <jcliburn@gmail.com> 938M: Jay Cliburn <jcliburn@gmail.com>
939M: Chris Snook <csnook@redhat.com> 939M: Chris Snook <chris.snook@gmail.com>
940M: Jie Yang <jie.yang@atheros.com> 940M: Jie Yang <jie.yang@atheros.com>
941L: atl1-devel@lists.sourceforge.net 941L: atl1-devel@lists.sourceforge.net
942W: http://sourceforge.net/projects/atl1 942W: http://sourceforge.net/projects/atl1
@@ -2270,6 +2270,13 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6.git
2270S: Maintained 2270S: Maintained
2271F: drivers/media/video/gspca/pac207.c 2271F: drivers/media/video/gspca/pac207.c
2272 2272
2273GSPCA SN9C20X SUBDRIVER
2274M: Brian Johnson <brijohn@gmail.com>
2275L: linux-media@vger.kernel.org
2276T: git git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6.git
2277S: Maintained
2278F: drivers/media/video/gspca/sn9c20x.c
2279
2273GSPCA T613 SUBDRIVER 2280GSPCA T613 SUBDRIVER
2274M: Leandro Costantino <lcostantino@gmail.com> 2281M: Leandro Costantino <lcostantino@gmail.com>
2275L: linux-media@vger.kernel.org 2282L: linux-media@vger.kernel.org
@@ -3453,6 +3460,7 @@ F: drivers/mfd/
3453 3460
3454MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM 3461MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND SDIO SUBSYSTEM
3455S: Orphan 3462S: Orphan
3463L: linux-mmc@vger.kernel.org
3456F: drivers/mmc/ 3464F: drivers/mmc/
3457F: include/linux/mmc/ 3465F: include/linux/mmc/
3458 3466
@@ -3587,6 +3595,9 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
3587S: Maintained 3595S: Maintained
3588F: net/ 3596F: net/
3589F: include/net/ 3597F: include/net/
3598F: include/linux/in.h
3599F: include/linux/net.h
3600F: include/linux/netdevice.h
3590 3601
3591NETWORKING [IPv4/IPv6] 3602NETWORKING [IPv4/IPv6]
3592M: "David S. Miller" <davem@davemloft.net> 3603M: "David S. Miller" <davem@davemloft.net>
@@ -3622,6 +3633,8 @@ W: http://www.linuxfoundation.org/en/Net
3622T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git 3633T: git git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6.git
3623S: Odd Fixes 3634S: Odd Fixes
3624F: drivers/net/ 3635F: drivers/net/
3636F: include/linux/if_*
3637F: include/linux/*device.h
3625 3638
3626NETXEN (1/10) GbE SUPPORT 3639NETXEN (1/10) GbE SUPPORT
3627M: Dhananjay Phadke <dhananjay@netxen.com> 3640M: Dhananjay Phadke <dhananjay@netxen.com>
@@ -3828,7 +3841,7 @@ W: http://open-osd.org
3828T: git git://git.open-osd.org/open-osd.git 3841T: git git://git.open-osd.org/open-osd.git
3829S: Maintained 3842S: Maintained
3830F: drivers/scsi/osd/ 3843F: drivers/scsi/osd/
3831F: drivers/include/scsi/osd_* 3844F: include/scsi/osd_*
3832F: fs/exofs/ 3845F: fs/exofs/
3833 3846
3834P54 WIRELESS DRIVER 3847P54 WIRELESS DRIVER
@@ -5027,7 +5040,9 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial.git
5027S: Maintained 5040S: Maintained
5028 5041
5029TTY LAYER 5042TTY LAYER
5030S: Orphan 5043M: Greg Kroah-Hartman <gregkh@suse.de>
5044S: Maintained
5045T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/
5031F: drivers/char/tty_* 5046F: drivers/char/tty_*
5032F: drivers/serial/serial_core.c 5047F: drivers/serial/serial_core.c
5033F: include/linux/serial_core.h 5048F: include/linux/serial_core.h
diff --git a/Makefile b/Makefile
index 0d46615bffe5..25c615e57302 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1VERSION = 2 1VERSION = 2
2PATCHLEVEL = 6 2PATCHLEVEL = 6
3SUBLEVEL = 31 3SUBLEVEL = 31
4EXTRAVERSION = -rc5 4EXTRAVERSION = -rc8
5NAME = Man-Eating Seals of Antiquity 5NAME = Man-Eating Seals of Antiquity
6 6
7# *DOCUMENTATION* 7# *DOCUMENTATION*
diff --git a/REPORTING-BUGS b/REPORTING-BUGS
index ab0c56630a8c..55a6074ccbb7 100644
--- a/REPORTING-BUGS
+++ b/REPORTING-BUGS
@@ -15,7 +15,10 @@ worry too much about getting the wrong person. If you are unsure send it
15to the person responsible for the code relevant to what you were doing. 15to the person responsible for the code relevant to what you were doing.
16If it occurs repeatably try and describe how to recreate it. That is 16If it occurs repeatably try and describe how to recreate it. That is
17worth even more than the oops itself. The list of maintainers and 17worth even more than the oops itself. The list of maintainers and
18mailing lists is in the MAINTAINERS file in this directory. 18mailing lists is in the MAINTAINERS file in this directory. If you
19know the file name that causes the problem you can use the following
20command in this directory to find some of the maintainers of that file:
21 perl scripts/get_maintainer.pl -f <filename>
19 22
20 If it is a security bug, please copy the Security Contact listed 23 If it is a security bug, please copy the Security Contact listed
21in the MAINTAINERS file. They can help coordinate bugfix and disclosure. 24in the MAINTAINERS file. They can help coordinate bugfix and disclosure.
diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c
index 9e6e512f0117..17153b54613b 100644
--- a/arch/arm/boot/compressed/misc.c
+++ b/arch/arm/boot/compressed/misc.c
@@ -29,7 +29,6 @@ unsigned int __machine_arch_type;
29 29
30static void putstr(const char *ptr); 30static void putstr(const char *ptr);
31 31
32#include <linux/compiler.h>
33#include <mach/uncompress.h> 32#include <mach/uncompress.h>
34 33
35#ifdef CONFIG_DEBUG_ICEDCC 34#ifdef CONFIG_DEBUG_ICEDCC
diff --git a/arch/arm/common/clkdev.c b/arch/arm/common/clkdev.c
index f37afd9422f3..aae5bc01acc8 100644
--- a/arch/arm/common/clkdev.c
+++ b/arch/arm/common/clkdev.c
@@ -17,6 +17,7 @@
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/string.h> 18#include <linux/string.h>
19#include <linux/mutex.h> 19#include <linux/mutex.h>
20#include <linux/clk.h>
20 21
21#include <asm/clkdev.h> 22#include <asm/clkdev.h>
22#include <mach/clkdev.h> 23#include <mach/clkdev.h>
diff --git a/arch/arm/configs/jornada720_defconfig b/arch/arm/configs/jornada720_defconfig
index f3074e49f2fa..df9bfbea8612 100644
--- a/arch/arm/configs/jornada720_defconfig
+++ b/arch/arm/configs/jornada720_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.27-rc6 3# Linux kernel version: 2.6.31-rc6
4# Tue Sep 16 18:56:58 2008 4# Fri Aug 21 15:41:39 2009
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y 7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
@@ -9,7 +9,6 @@ CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y 9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y 10CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_MMU=y 11CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y 12CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y 13CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y 14CONFIG_HAVE_LATENCYTOP_SUPPORT=y
@@ -18,16 +17,14 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y 17CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y 18CONFIG_GENERIC_IRQ_PROBE=y
20CONFIG_RWSEM_GENERIC_SPINLOCK=y 19CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y 20CONFIG_GENERIC_HWEIGHT=y
24CONFIG_GENERIC_CALIBRATE_DELAY=y 21CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_ARCH_SUPPORTS_AOUT=y
26CONFIG_ZONE_DMA=y 22CONFIG_ZONE_DMA=y
27CONFIG_ARCH_MTD_XIP=y 23CONFIG_ARCH_MTD_XIP=y
28CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 24CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
29CONFIG_VECTORS_BASE=0xffff0000 25CONFIG_VECTORS_BASE=0xffff0000
30CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 26CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
27CONFIG_CONSTRUCTORS=y
31 28
32# 29#
33# General setup 30# General setup
@@ -44,10 +41,19 @@ CONFIG_SYSVIPC_SYSCTL=y
44# CONFIG_BSD_PROCESS_ACCT is not set 41# CONFIG_BSD_PROCESS_ACCT is not set
45# CONFIG_TASKSTATS is not set 42# CONFIG_TASKSTATS is not set
46# CONFIG_AUDIT is not set 43# CONFIG_AUDIT 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
47# CONFIG_IKCONFIG is not set 53# CONFIG_IKCONFIG is not set
48CONFIG_LOG_BUF_SHIFT=14 54CONFIG_LOG_BUF_SHIFT=14
49# CONFIG_CGROUPS is not set
50# CONFIG_GROUP_SCHED is not set 55# CONFIG_GROUP_SCHED is not set
56# CONFIG_CGROUPS is not set
51CONFIG_SYSFS_DEPRECATED=y 57CONFIG_SYSFS_DEPRECATED=y
52CONFIG_SYSFS_DEPRECATED_V2=y 58CONFIG_SYSFS_DEPRECATED_V2=y
53# CONFIG_RELAY is not set 59# CONFIG_RELAY is not set
@@ -56,9 +62,11 @@ CONFIG_NAMESPACES=y
56# CONFIG_IPC_NS is not set 62# CONFIG_IPC_NS is not set
57# CONFIG_USER_NS is not set 63# CONFIG_USER_NS is not set
58# CONFIG_PID_NS is not set 64# CONFIG_PID_NS is not set
65# CONFIG_NET_NS is not set
59# CONFIG_BLK_DEV_INITRD is not set 66# CONFIG_BLK_DEV_INITRD is not set
60CONFIG_CC_OPTIMIZE_FOR_SIZE=y 67CONFIG_CC_OPTIMIZE_FOR_SIZE=y
61CONFIG_SYSCTL=y 68CONFIG_SYSCTL=y
69CONFIG_ANON_INODES=y
62# CONFIG_EMBEDDED is not set 70# CONFIG_EMBEDDED is not set
63CONFIG_UID16=y 71CONFIG_UID16=y
64CONFIG_SYSCTL_SYSCALL=y 72CONFIG_SYSCTL_SYSCALL=y
@@ -69,17 +77,22 @@ CONFIG_HOTPLUG=y
69CONFIG_PRINTK=y 77CONFIG_PRINTK=y
70CONFIG_BUG=y 78CONFIG_BUG=y
71CONFIG_ELF_CORE=y 79CONFIG_ELF_CORE=y
72CONFIG_COMPAT_BRK=y
73CONFIG_BASE_FULL=y 80CONFIG_BASE_FULL=y
74CONFIG_FUTEX=y 81CONFIG_FUTEX=y
75CONFIG_ANON_INODES=y
76CONFIG_EPOLL=y 82CONFIG_EPOLL=y
77CONFIG_SIGNALFD=y 83CONFIG_SIGNALFD=y
78CONFIG_TIMERFD=y 84CONFIG_TIMERFD=y
79CONFIG_EVENTFD=y 85CONFIG_EVENTFD=y
80CONFIG_SHMEM=y 86CONFIG_SHMEM=y
87CONFIG_AIO=y
88
89#
90# Performance Counters
91#
81CONFIG_VM_EVENT_COUNTERS=y 92CONFIG_VM_EVENT_COUNTERS=y
82CONFIG_SLUB_DEBUG=y 93CONFIG_SLUB_DEBUG=y
94# CONFIG_STRIP_ASM_SYMS is not set
95CONFIG_COMPAT_BRK=y
83# CONFIG_SLAB is not set 96# CONFIG_SLAB is not set
84CONFIG_SLUB=y 97CONFIG_SLUB=y
85# CONFIG_SLOB is not set 98# CONFIG_SLOB is not set
@@ -87,30 +100,25 @@ CONFIG_SLUB=y
87# CONFIG_MARKERS is not set 100# CONFIG_MARKERS is not set
88CONFIG_HAVE_OPROFILE=y 101CONFIG_HAVE_OPROFILE=y
89# CONFIG_KPROBES is not set 102# CONFIG_KPROBES is not set
90# CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS is not set
91# CONFIG_HAVE_IOREMAP_PROT is not set
92CONFIG_HAVE_KPROBES=y 103CONFIG_HAVE_KPROBES=y
93CONFIG_HAVE_KRETPROBES=y 104CONFIG_HAVE_KRETPROBES=y
94# CONFIG_HAVE_ARCH_TRACEHOOK is not set
95# CONFIG_HAVE_DMA_ATTRS is not set
96# CONFIG_USE_GENERIC_SMP_HELPERS is not set
97CONFIG_HAVE_CLK=y 105CONFIG_HAVE_CLK=y
98CONFIG_PROC_PAGE_MONITOR=y 106
107#
108# GCOV-based kernel profiling
109#
110# CONFIG_SLOW_WORK is not set
99CONFIG_HAVE_GENERIC_DMA_COHERENT=y 111CONFIG_HAVE_GENERIC_DMA_COHERENT=y
100CONFIG_SLABINFO=y 112CONFIG_SLABINFO=y
101CONFIG_RT_MUTEXES=y 113CONFIG_RT_MUTEXES=y
102# CONFIG_TINY_SHMEM is not set
103CONFIG_BASE_SMALL=0 114CONFIG_BASE_SMALL=0
104CONFIG_MODULES=y 115CONFIG_MODULES=y
105# CONFIG_MODULE_FORCE_LOAD is not set 116# CONFIG_MODULE_FORCE_LOAD is not set
106# CONFIG_MODULE_UNLOAD is not set 117# CONFIG_MODULE_UNLOAD is not set
107# CONFIG_MODVERSIONS is not set 118# CONFIG_MODVERSIONS is not set
108# CONFIG_MODULE_SRCVERSION_ALL is not set 119# CONFIG_MODULE_SRCVERSION_ALL is not set
109CONFIG_KMOD=y
110CONFIG_BLOCK=y 120CONFIG_BLOCK=y
111# CONFIG_LBD is not set 121CONFIG_LBDAF=y
112# CONFIG_BLK_DEV_IO_TRACE is not set
113# CONFIG_LSF is not set
114# CONFIG_BLK_DEV_BSG is not set 122# CONFIG_BLK_DEV_BSG is not set
115# CONFIG_BLK_DEV_INTEGRITY is not set 123# CONFIG_BLK_DEV_INTEGRITY is not set
116 124
@@ -126,7 +134,7 @@ CONFIG_IOSCHED_CFQ=y
126CONFIG_DEFAULT_CFQ=y 134CONFIG_DEFAULT_CFQ=y
127# CONFIG_DEFAULT_NOOP is not set 135# CONFIG_DEFAULT_NOOP is not set
128CONFIG_DEFAULT_IOSCHED="cfq" 136CONFIG_DEFAULT_IOSCHED="cfq"
129CONFIG_CLASSIC_RCU=y 137CONFIG_FREEZER=y
130 138
131# 139#
132# System Type 140# System Type
@@ -136,14 +144,15 @@ CONFIG_CLASSIC_RCU=y
136# CONFIG_ARCH_REALVIEW is not set 144# CONFIG_ARCH_REALVIEW is not set
137# CONFIG_ARCH_VERSATILE is not set 145# CONFIG_ARCH_VERSATILE is not set
138# CONFIG_ARCH_AT91 is not set 146# CONFIG_ARCH_AT91 is not set
139# CONFIG_ARCH_CLPS7500 is not set
140# CONFIG_ARCH_CLPS711X is not set 147# CONFIG_ARCH_CLPS711X is not set
148# CONFIG_ARCH_GEMINI is not set
141# CONFIG_ARCH_EBSA110 is not set 149# CONFIG_ARCH_EBSA110 is not set
142# CONFIG_ARCH_EP93XX is not set 150# CONFIG_ARCH_EP93XX is not set
143# CONFIG_ARCH_FOOTBRIDGE is not set 151# CONFIG_ARCH_FOOTBRIDGE is not set
152# CONFIG_ARCH_MXC is not set
153# CONFIG_ARCH_STMP3XXX is not set
144# CONFIG_ARCH_NETX is not set 154# CONFIG_ARCH_NETX is not set
145# CONFIG_ARCH_H720X is not set 155# CONFIG_ARCH_H720X is not set
146# CONFIG_ARCH_IMX is not set
147# CONFIG_ARCH_IOP13XX is not set 156# CONFIG_ARCH_IOP13XX is not set
148# CONFIG_ARCH_IOP32X is not set 157# CONFIG_ARCH_IOP32X is not set
149# CONFIG_ARCH_IOP33X is not set 158# CONFIG_ARCH_IOP33X is not set
@@ -152,23 +161,25 @@ CONFIG_CLASSIC_RCU=y
152# CONFIG_ARCH_IXP4XX is not set 161# CONFIG_ARCH_IXP4XX is not set
153# CONFIG_ARCH_L7200 is not set 162# CONFIG_ARCH_L7200 is not set
154# CONFIG_ARCH_KIRKWOOD is not set 163# CONFIG_ARCH_KIRKWOOD is not set
155# CONFIG_ARCH_KS8695 is not set
156# CONFIG_ARCH_NS9XXX is not set
157# CONFIG_ARCH_LOKI is not set 164# CONFIG_ARCH_LOKI is not set
158# CONFIG_ARCH_MV78XX0 is not set 165# CONFIG_ARCH_MV78XX0 is not set
159# CONFIG_ARCH_MXC is not set
160# CONFIG_ARCH_ORION5X is not set 166# CONFIG_ARCH_ORION5X is not set
167# CONFIG_ARCH_MMP is not set
168# CONFIG_ARCH_KS8695 is not set
169# CONFIG_ARCH_NS9XXX is not set
170# CONFIG_ARCH_W90X900 is not set
161# CONFIG_ARCH_PNX4008 is not set 171# CONFIG_ARCH_PNX4008 is not set
162# CONFIG_ARCH_PXA is not set 172# CONFIG_ARCH_PXA is not set
173# CONFIG_ARCH_MSM is not set
163# CONFIG_ARCH_RPC is not set 174# CONFIG_ARCH_RPC is not set
164CONFIG_ARCH_SA1100=y 175CONFIG_ARCH_SA1100=y
165# CONFIG_ARCH_S3C2410 is not set 176# CONFIG_ARCH_S3C2410 is not set
177# CONFIG_ARCH_S3C64XX is not set
166# CONFIG_ARCH_SHARK is not set 178# CONFIG_ARCH_SHARK is not set
167# CONFIG_ARCH_LH7A40X is not set 179# CONFIG_ARCH_LH7A40X is not set
180# CONFIG_ARCH_U300 is not set
168# CONFIG_ARCH_DAVINCI is not set 181# CONFIG_ARCH_DAVINCI is not set
169# CONFIG_ARCH_OMAP is not set 182# CONFIG_ARCH_OMAP is not set
170# CONFIG_ARCH_MSM7X00A is not set
171CONFIG_DMABOUNCE=y
172 183
173# 184#
174# SA11x0 Implementations 185# SA11x0 Implementations
@@ -189,14 +200,6 @@ CONFIG_SA1100_JORNADA720_SSP=y
189CONFIG_SA1100_SSP=y 200CONFIG_SA1100_SSP=y
190 201
191# 202#
192# Boot options
193#
194
195#
196# Power management
197#
198
199#
200# Processor Type 203# Processor Type
201# 204#
202CONFIG_CPU_32=y 205CONFIG_CPU_32=y
@@ -215,8 +218,8 @@ CONFIG_CPU_CP15_MMU=y
215# 218#
216# CONFIG_CPU_ICACHE_DISABLE is not set 219# CONFIG_CPU_ICACHE_DISABLE is not set
217# CONFIG_CPU_DCACHE_DISABLE is not set 220# CONFIG_CPU_DCACHE_DISABLE is not set
218# CONFIG_OUTER_CACHE is not set
219CONFIG_SA1111=y 221CONFIG_SA1111=y
222CONFIG_DMABOUNCE=y
220CONFIG_FORCE_MAX_ZONEORDER=9 223CONFIG_FORCE_MAX_ZONEORDER=9
221 224
222# 225#
@@ -246,30 +249,36 @@ CONFIG_TICK_ONESHOT=y
246# CONFIG_NO_HZ is not set 249# CONFIG_NO_HZ is not set
247# CONFIG_HIGH_RES_TIMERS is not set 250# CONFIG_HIGH_RES_TIMERS is not set
248CONFIG_GENERIC_CLOCKEVENTS_BUILD=y 251CONFIG_GENERIC_CLOCKEVENTS_BUILD=y
252CONFIG_VMSPLIT_3G=y
253# CONFIG_VMSPLIT_2G is not set
254# CONFIG_VMSPLIT_1G is not set
255CONFIG_PAGE_OFFSET=0xC0000000
249# CONFIG_PREEMPT is not set 256# CONFIG_PREEMPT is not set
250CONFIG_HZ=100 257CONFIG_HZ=100
251# CONFIG_AEABI is not set 258# CONFIG_AEABI is not set
252CONFIG_ARCH_DISCONTIGMEM_ENABLE=y
253CONFIG_ARCH_SPARSEMEM_ENABLE=y 259CONFIG_ARCH_SPARSEMEM_ENABLE=y
254CONFIG_ARCH_SELECT_MEMORY_MODEL=y 260CONFIG_ARCH_SPARSEMEM_DEFAULT=y
255CONFIG_NODES_SHIFT=2 261# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
262# CONFIG_HIGHMEM is not set
256CONFIG_SELECT_MEMORY_MODEL=y 263CONFIG_SELECT_MEMORY_MODEL=y
257# CONFIG_FLATMEM_MANUAL is not set 264# CONFIG_FLATMEM_MANUAL is not set
258CONFIG_DISCONTIGMEM_MANUAL=y 265# CONFIG_DISCONTIGMEM_MANUAL is not set
259# CONFIG_SPARSEMEM_MANUAL is not set 266CONFIG_SPARSEMEM_MANUAL=y
260CONFIG_DISCONTIGMEM=y 267CONFIG_SPARSEMEM=y
261CONFIG_FLAT_NODE_MEM_MAP=y 268CONFIG_HAVE_MEMORY_PRESENT=y
262CONFIG_NEED_MULTIPLE_NODES=y 269CONFIG_SPARSEMEM_EXTREME=y
263# CONFIG_SPARSEMEM_STATIC is not set
264# CONFIG_SPARSEMEM_VMEMMAP_ENABLE is not set
265CONFIG_PAGEFLAGS_EXTENDED=y 270CONFIG_PAGEFLAGS_EXTENDED=y
266CONFIG_SPLIT_PTLOCK_CPUS=4096 271CONFIG_SPLIT_PTLOCK_CPUS=4096
267# CONFIG_RESOURCES_64BIT is not set 272# CONFIG_PHYS_ADDR_T_64BIT is not set
268CONFIG_ZONE_DMA_FLAG=1 273CONFIG_ZONE_DMA_FLAG=1
269CONFIG_BOUNCE=y 274CONFIG_BOUNCE=y
270CONFIG_VIRT_TO_BUS=y 275CONFIG_VIRT_TO_BUS=y
276CONFIG_HAVE_MLOCK=y
277CONFIG_HAVE_MLOCKED_PAGE_BIT=y
278CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
271# CONFIG_LEDS is not set 279# CONFIG_LEDS is not set
272CONFIG_ALIGNMENT_TRAP=y 280CONFIG_ALIGNMENT_TRAP=y
281# CONFIG_UACCESS_WITH_MEMCPY is not set
273 282
274# 283#
275# Boot options 284# Boot options
@@ -281,9 +290,10 @@ CONFIG_CMDLINE=""
281# CONFIG_KEXEC is not set 290# CONFIG_KEXEC is not set
282 291
283# 292#
284# CPU Frequency scaling 293# CPU Power Management
285# 294#
286# CONFIG_CPU_FREQ is not set 295# CONFIG_CPU_FREQ is not set
296# CONFIG_CPU_IDLE is not set
287 297
288# 298#
289# Floating point emulation 299# Floating point emulation
@@ -294,12 +304,14 @@ CONFIG_CMDLINE=""
294# 304#
295CONFIG_FPE_NWFPE=y 305CONFIG_FPE_NWFPE=y
296# CONFIG_FPE_NWFPE_XP is not set 306# CONFIG_FPE_NWFPE_XP is not set
297CONFIG_FPE_FASTFPE=y 307# CONFIG_FPE_FASTFPE is not set
298 308
299# 309#
300# Userspace binary formats 310# Userspace binary formats
301# 311#
302CONFIG_BINFMT_ELF=y 312CONFIG_BINFMT_ELF=y
313# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
314CONFIG_HAVE_AOUT=y
303CONFIG_BINFMT_AOUT=y 315CONFIG_BINFMT_AOUT=y
304# CONFIG_BINFMT_MISC is not set 316# CONFIG_BINFMT_MISC is not set
305# CONFIG_ARTHUR is not set 317# CONFIG_ARTHUR is not set
@@ -353,7 +365,6 @@ CONFIG_INET_TCP_DIAG=y
353CONFIG_TCP_CONG_CUBIC=y 365CONFIG_TCP_CONG_CUBIC=y
354CONFIG_DEFAULT_TCP_CONG="cubic" 366CONFIG_DEFAULT_TCP_CONG="cubic"
355# CONFIG_TCP_MD5SIG is not set 367# CONFIG_TCP_MD5SIG is not set
356# CONFIG_IP_VS is not set
357# CONFIG_IPV6 is not set 368# CONFIG_IPV6 is not set
358# CONFIG_NETWORK_SECMARK is not set 369# CONFIG_NETWORK_SECMARK is not set
359CONFIG_NETFILTER=y 370CONFIG_NETFILTER=y
@@ -367,10 +378,12 @@ CONFIG_NETFILTER_ADVANCED=y
367# CONFIG_NETFILTER_NETLINK_LOG is not set 378# CONFIG_NETFILTER_NETLINK_LOG is not set
368# CONFIG_NF_CONNTRACK is not set 379# CONFIG_NF_CONNTRACK is not set
369# CONFIG_NETFILTER_XTABLES is not set 380# CONFIG_NETFILTER_XTABLES is not set
381# CONFIG_IP_VS is not set
370 382
371# 383#
372# IP: Netfilter Configuration 384# IP: Netfilter Configuration
373# 385#
386# CONFIG_NF_DEFRAG_IPV4 is not set
374# CONFIG_IP_NF_QUEUE is not set 387# CONFIG_IP_NF_QUEUE is not set
375# CONFIG_IP_NF_IPTABLES is not set 388# CONFIG_IP_NF_IPTABLES is not set
376# CONFIG_IP_NF_ARPTABLES is not set 389# CONFIG_IP_NF_ARPTABLES is not set
@@ -379,6 +392,7 @@ CONFIG_NETFILTER_ADVANCED=y
379# CONFIG_TIPC is not set 392# CONFIG_TIPC is not set
380# CONFIG_ATM is not set 393# CONFIG_ATM is not set
381# CONFIG_BRIDGE is not set 394# CONFIG_BRIDGE is not set
395# CONFIG_NET_DSA is not set
382# CONFIG_VLAN_8021Q is not set 396# CONFIG_VLAN_8021Q is not set
383# CONFIG_DECNET is not set 397# CONFIG_DECNET is not set
384# CONFIG_LLC2 is not set 398# CONFIG_LLC2 is not set
@@ -388,7 +402,10 @@ CONFIG_NETFILTER_ADVANCED=y
388# CONFIG_LAPB is not set 402# CONFIG_LAPB is not set
389# CONFIG_ECONET is not set 403# CONFIG_ECONET is not set
390# CONFIG_WAN_ROUTER is not set 404# CONFIG_WAN_ROUTER is not set
405# CONFIG_PHONET is not set
406# CONFIG_IEEE802154 is not set
391# CONFIG_NET_SCHED is not set 407# CONFIG_NET_SCHED is not set
408# CONFIG_DCB is not set
392 409
393# 410#
394# Network testing 411# Network testing
@@ -431,14 +448,17 @@ CONFIG_IRCOMM=m
431CONFIG_SA1100_FIR=m 448CONFIG_SA1100_FIR=m
432# CONFIG_BT is not set 449# CONFIG_BT is not set
433# CONFIG_AF_RXRPC is not set 450# CONFIG_AF_RXRPC is not set
451CONFIG_WIRELESS=y
452# CONFIG_CFG80211 is not set
453# CONFIG_WIRELESS_OLD_REGULATORY is not set
454# CONFIG_WIRELESS_EXT is not set
455# CONFIG_LIB80211 is not set
434 456
435# 457#
436# Wireless 458# CFG80211 needs to be enabled for MAC80211
437# 459#
438# CONFIG_CFG80211 is not set 460CONFIG_MAC80211_DEFAULT_PS_VALUE=0
439# CONFIG_WIRELESS_EXT is not set 461# CONFIG_WIMAX is not set
440# CONFIG_MAC80211 is not set
441# CONFIG_IEEE80211 is not set
442# CONFIG_RFKILL is not set 462# CONFIG_RFKILL is not set
443# CONFIG_NET_9P is not set 463# CONFIG_NET_9P is not set
444 464
@@ -464,29 +484,34 @@ CONFIG_EXTRA_FIRMWARE=""
464# CONFIG_PNP is not set 484# CONFIG_PNP is not set
465CONFIG_BLK_DEV=y 485CONFIG_BLK_DEV=y
466# CONFIG_BLK_DEV_COW_COMMON is not set 486# CONFIG_BLK_DEV_COW_COMMON is not set
467CONFIG_BLK_DEV_LOOP=m 487CONFIG_BLK_DEV_LOOP=y
468# CONFIG_BLK_DEV_CRYPTOLOOP is not set 488# CONFIG_BLK_DEV_CRYPTOLOOP is not set
469CONFIG_BLK_DEV_NBD=m 489CONFIG_BLK_DEV_NBD=y
470# CONFIG_BLK_DEV_RAM is not set 490# CONFIG_BLK_DEV_RAM is not set
471# CONFIG_CDROM_PKTCDVD is not set 491# CONFIG_CDROM_PKTCDVD is not set
472# CONFIG_ATA_OVER_ETH is not set 492# CONFIG_ATA_OVER_ETH is not set
493# CONFIG_MG_DISK is not set
473CONFIG_MISC_DEVICES=y 494CONFIG_MISC_DEVICES=y
474# CONFIG_EEPROM_93CX6 is not set
475# CONFIG_ENCLOSURE_SERVICES is not set 495# CONFIG_ENCLOSURE_SERVICES is not set
496# CONFIG_C2PORT is not set
497
498#
499# EEPROM support
500#
501# CONFIG_EEPROM_93CX6 is not set
476CONFIG_HAVE_IDE=y 502CONFIG_HAVE_IDE=y
477CONFIG_IDE=y 503CONFIG_IDE=y
478CONFIG_BLK_DEV_IDE=y
479 504
480# 505#
481# Please see Documentation/ide/ide.txt for help/info on IDE drives 506# Please see Documentation/ide/ide.txt for help/info on IDE drives
482# 507#
483# CONFIG_BLK_DEV_IDE_SATA is not set 508# CONFIG_BLK_DEV_IDE_SATA is not set
484CONFIG_BLK_DEV_IDEDISK=y 509CONFIG_IDE_GD=y
485# CONFIG_IDEDISK_MULTI_MODE is not set 510CONFIG_IDE_GD_ATA=y
511# CONFIG_IDE_GD_ATAPI is not set
486CONFIG_BLK_DEV_IDECS=y 512CONFIG_BLK_DEV_IDECS=y
487# CONFIG_BLK_DEV_IDECD is not set 513# CONFIG_BLK_DEV_IDECD is not set
488# CONFIG_BLK_DEV_IDETAPE is not set 514# CONFIG_BLK_DEV_IDETAPE is not set
489# CONFIG_BLK_DEV_IDEFLOPPY is not set
490# CONFIG_IDE_TASK_IOCTL is not set 515# CONFIG_IDE_TASK_IOCTL is not set
491CONFIG_IDE_PROC_FS=y 516CONFIG_IDE_PROC_FS=y
492 517
@@ -513,8 +538,34 @@ CONFIG_DUMMY=y
513# CONFIG_TUN is not set 538# CONFIG_TUN is not set
514# CONFIG_VETH is not set 539# CONFIG_VETH is not set
515# CONFIG_ARCNET is not set 540# CONFIG_ARCNET is not set
516# CONFIG_NET_ETHERNET is not set 541# CONFIG_PHYLIB is not set
517CONFIG_MII=m 542CONFIG_NET_ETHERNET=y
543# CONFIG_MII is not set
544# CONFIG_AX88796 is not set
545# CONFIG_NET_VENDOR_3COM is not set
546# CONFIG_NET_VENDOR_SMC is not set
547# CONFIG_SMC91X is not set
548# CONFIG_DM9000 is not set
549# CONFIG_ETHOC is not set
550# CONFIG_SMC911X is not set
551# CONFIG_SMSC911X is not set
552# CONFIG_NET_VENDOR_RACAL is not set
553# CONFIG_DNET is not set
554# CONFIG_AT1700 is not set
555# CONFIG_DEPCA is not set
556# CONFIG_HP100 is not set
557# CONFIG_NET_ISA is not set
558# CONFIG_IBM_NEW_EMAC_ZMII is not set
559# CONFIG_IBM_NEW_EMAC_RGMII is not set
560# CONFIG_IBM_NEW_EMAC_TAH is not set
561# CONFIG_IBM_NEW_EMAC_EMAC4 is not set
562# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
563# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
564# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
565# CONFIG_NET_PCI is not set
566# CONFIG_B44 is not set
567# CONFIG_CS89x0 is not set
568# CONFIG_KS8842 is not set
518# CONFIG_NETDEV_1000 is not set 569# CONFIG_NETDEV_1000 is not set
519# CONFIG_NETDEV_10000 is not set 570# CONFIG_NETDEV_10000 is not set
520# CONFIG_TR is not set 571# CONFIG_TR is not set
@@ -523,17 +574,27 @@ CONFIG_MII=m
523# Wireless LAN 574# Wireless LAN
524# 575#
525# CONFIG_WLAN_PRE80211 is not set 576# CONFIG_WLAN_PRE80211 is not set
526# CONFIG_WLAN_80211 is not set 577CONFIG_WLAN_80211=y
527# CONFIG_IWLWIFI_LEDS is not set 578# CONFIG_PCMCIA_RAYCS is not set
579# CONFIG_LIBERTAS is not set
580# CONFIG_ATMEL is not set
581# CONFIG_AIRO_CS is not set
582# CONFIG_PCMCIA_WL3501 is not set
583# CONFIG_HOSTAP is not set
584# CONFIG_HERMES is not set
585
586#
587# Enable WiMAX (Networking options) to see the WiMAX drivers
588#
528CONFIG_NET_PCMCIA=y 589CONFIG_NET_PCMCIA=y
529CONFIG_PCMCIA_3C589=m 590# CONFIG_PCMCIA_3C589 is not set
530CONFIG_PCMCIA_3C574=m 591# CONFIG_PCMCIA_3C574 is not set
531CONFIG_PCMCIA_FMVJ18X=m 592# CONFIG_PCMCIA_FMVJ18X is not set
532CONFIG_PCMCIA_PCNET=m 593# CONFIG_PCMCIA_PCNET is not set
533CONFIG_PCMCIA_NMCLAN=m 594# CONFIG_PCMCIA_NMCLAN is not set
534CONFIG_PCMCIA_SMC91C92=m 595# CONFIG_PCMCIA_SMC91C92 is not set
535CONFIG_PCMCIA_XIRC2PS=m 596# CONFIG_PCMCIA_XIRC2PS is not set
536CONFIG_PCMCIA_AXNET=m 597# CONFIG_PCMCIA_AXNET is not set
537# CONFIG_WAN is not set 598# CONFIG_WAN is not set
538# CONFIG_PPP is not set 599# CONFIG_PPP is not set
539# CONFIG_SLIP is not set 600# CONFIG_SLIP is not set
@@ -565,20 +626,23 @@ CONFIG_INPUT_MOUSEDEV_SCREEN_Y=240
565# 626#
566CONFIG_INPUT_KEYBOARD=y 627CONFIG_INPUT_KEYBOARD=y
567# CONFIG_KEYBOARD_ATKBD is not set 628# CONFIG_KEYBOARD_ATKBD is not set
568# CONFIG_KEYBOARD_SUNKBD is not set
569# CONFIG_KEYBOARD_LKKBD is not set 629# CONFIG_KEYBOARD_LKKBD is not set
570# CONFIG_KEYBOARD_XTKBD is not set 630# CONFIG_KEYBOARD_GPIO is not set
631# CONFIG_KEYBOARD_MATRIX is not set
632CONFIG_KEYBOARD_HP7XX=y
571# CONFIG_KEYBOARD_NEWTON is not set 633# CONFIG_KEYBOARD_NEWTON is not set
572# CONFIG_KEYBOARD_STOWAWAY is not set 634# CONFIG_KEYBOARD_STOWAWAY is not set
573CONFIG_KEYBOARD_HP7XX=y 635# CONFIG_KEYBOARD_SUNKBD is not set
574# CONFIG_KEYBOARD_GPIO is not set 636# CONFIG_KEYBOARD_XTKBD is not set
575# CONFIG_INPUT_MOUSE is not set 637# CONFIG_INPUT_MOUSE is not set
576# CONFIG_INPUT_JOYSTICK is not set 638# CONFIG_INPUT_JOYSTICK is not set
577# CONFIG_INPUT_TABLET is not set 639# CONFIG_INPUT_TABLET is not set
578CONFIG_INPUT_TOUCHSCREEN=y 640CONFIG_INPUT_TOUCHSCREEN=y
641# CONFIG_TOUCHSCREEN_AD7879 is not set
579# CONFIG_TOUCHSCREEN_FUJITSU is not set 642# CONFIG_TOUCHSCREEN_FUJITSU is not set
580# CONFIG_TOUCHSCREEN_GUNZE is not set 643# CONFIG_TOUCHSCREEN_GUNZE is not set
581# CONFIG_TOUCHSCREEN_ELO is not set 644# CONFIG_TOUCHSCREEN_ELO is not set
645# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
582# CONFIG_TOUCHSCREEN_MTOUCH is not set 646# CONFIG_TOUCHSCREEN_MTOUCH is not set
583# CONFIG_TOUCHSCREEN_INEXIO is not set 647# CONFIG_TOUCHSCREEN_INEXIO is not set
584# CONFIG_TOUCHSCREEN_MK712 is not set 648# CONFIG_TOUCHSCREEN_MK712 is not set
@@ -587,8 +651,8 @@ CONFIG_TOUCHSCREEN_HP7XX=y
587# CONFIG_TOUCHSCREEN_PENMOUNT is not set 651# CONFIG_TOUCHSCREEN_PENMOUNT is not set
588# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set 652# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
589# CONFIG_TOUCHSCREEN_TOUCHWIN is not set 653# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
590# CONFIG_TOUCHSCREEN_UCB1400 is not set
591# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set 654# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
655# CONFIG_TOUCHSCREEN_W90X900 is not set
592# CONFIG_INPUT_MISC is not set 656# CONFIG_INPUT_MISC is not set
593 657
594# 658#
@@ -624,11 +688,12 @@ CONFIG_SERIAL_SA1100_CONSOLE=y
624CONFIG_SERIAL_CORE=y 688CONFIG_SERIAL_CORE=y
625CONFIG_SERIAL_CORE_CONSOLE=y 689CONFIG_SERIAL_CORE_CONSOLE=y
626CONFIG_UNIX98_PTYS=y 690CONFIG_UNIX98_PTYS=y
691# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
627CONFIG_LEGACY_PTYS=y 692CONFIG_LEGACY_PTYS=y
628CONFIG_LEGACY_PTY_COUNT=32 693CONFIG_LEGACY_PTY_COUNT=32
629# CONFIG_IPMI_HANDLER is not set 694# CONFIG_IPMI_HANDLER is not set
630CONFIG_HW_RANDOM=m 695CONFIG_HW_RANDOM=m
631# CONFIG_NVRAM is not set 696# CONFIG_HW_RANDOM_TIMERIOMEM is not set
632# CONFIG_DTLK is not set 697# CONFIG_DTLK is not set
633# CONFIG_R3964 is not set 698# CONFIG_R3964 is not set
634 699
@@ -650,6 +715,10 @@ CONFIG_GPIOLIB=y
650# CONFIG_GPIO_SYSFS is not set 715# CONFIG_GPIO_SYSFS is not set
651 716
652# 717#
718# Memory mapped GPIO expanders:
719#
720
721#
653# I2C GPIO expanders: 722# I2C GPIO expanders:
654# 723#
655 724
@@ -663,12 +732,14 @@ CONFIG_GPIOLIB=y
663# CONFIG_W1 is not set 732# CONFIG_W1 is not set
664# CONFIG_POWER_SUPPLY is not set 733# CONFIG_POWER_SUPPLY is not set
665# CONFIG_HWMON is not set 734# CONFIG_HWMON is not set
735# CONFIG_THERMAL is not set
736# CONFIG_THERMAL_HWMON is not set
666# CONFIG_WATCHDOG is not set 737# CONFIG_WATCHDOG is not set
738CONFIG_SSB_POSSIBLE=y
667 739
668# 740#
669# Sonics Silicon Backplane 741# Sonics Silicon Backplane
670# 742#
671CONFIG_SSB_POSSIBLE=y
672# CONFIG_SSB is not set 743# CONFIG_SSB is not set
673 744
674# 745#
@@ -676,6 +747,7 @@ CONFIG_SSB_POSSIBLE=y
676# 747#
677# CONFIG_MFD_CORE is not set 748# CONFIG_MFD_CORE is not set
678# CONFIG_MFD_SM501 is not set 749# CONFIG_MFD_SM501 is not set
750# CONFIG_MFD_ASIC3 is not set
679# CONFIG_HTC_EGPIO is not set 751# CONFIG_HTC_EGPIO is not set
680# CONFIG_HTC_PASIC3 is not set 752# CONFIG_HTC_PASIC3 is not set
681# CONFIG_MFD_TMIO is not set 753# CONFIG_MFD_TMIO is not set
@@ -687,22 +759,7 @@ CONFIG_SSB_POSSIBLE=y
687# Multimedia Capabilities Port drivers 759# Multimedia Capabilities Port drivers
688# 760#
689# CONFIG_MCP_SA11X0 is not set 761# CONFIG_MCP_SA11X0 is not set
690 762# CONFIG_MEDIA_SUPPORT is not set
691#
692# Multimedia devices
693#
694
695#
696# Multimedia core support
697#
698# CONFIG_VIDEO_DEV is not set
699# CONFIG_DVB_CORE is not set
700# CONFIG_VIDEO_MEDIA is not set
701
702#
703# Multimedia drivers
704#
705# CONFIG_DAB is not set
706 763
707# 764#
708# Graphics support 765# Graphics support
@@ -712,6 +769,7 @@ CONFIG_SSB_POSSIBLE=y
712CONFIG_FB=y 769CONFIG_FB=y
713# CONFIG_FIRMWARE_EDID is not set 770# CONFIG_FIRMWARE_EDID is not set
714# CONFIG_FB_DDC is not set 771# CONFIG_FB_DDC is not set
772# CONFIG_FB_BOOT_VESA_SUPPORT is not set
715CONFIG_FB_CFB_FILLRECT=y 773CONFIG_FB_CFB_FILLRECT=y
716CONFIG_FB_CFB_COPYAREA=y 774CONFIG_FB_CFB_COPYAREA=y
717CONFIG_FB_CFB_IMAGEBLIT=y 775CONFIG_FB_CFB_IMAGEBLIT=y
@@ -733,7 +791,17 @@ CONFIG_FB_CFB_IMAGEBLIT=y
733# CONFIG_FB_SA1100 is not set 791# CONFIG_FB_SA1100 is not set
734CONFIG_FB_S1D13XXX=y 792CONFIG_FB_S1D13XXX=y
735# CONFIG_FB_VIRTUAL is not set 793# CONFIG_FB_VIRTUAL is not set
736# CONFIG_BACKLIGHT_LCD_SUPPORT is not set 794# CONFIG_FB_METRONOME is not set
795# CONFIG_FB_MB862XX is not set
796# CONFIG_FB_BROADSHEET is not set
797CONFIG_BACKLIGHT_LCD_SUPPORT=y
798CONFIG_LCD_CLASS_DEVICE=y
799# CONFIG_LCD_ILI9320 is not set
800# CONFIG_LCD_PLATFORM is not set
801CONFIG_LCD_HP700=y
802CONFIG_BACKLIGHT_CLASS_DEVICE=y
803# CONFIG_BACKLIGHT_GENERIC is not set
804CONFIG_BACKLIGHT_HP700=y
737 805
738# 806#
739# Display device support 807# Display device support
@@ -757,6 +825,8 @@ CONFIG_FONT_8x16=y
757# CONFIG_HID_SUPPORT is not set 825# CONFIG_HID_SUPPORT is not set
758# CONFIG_USB_SUPPORT is not set 826# CONFIG_USB_SUPPORT is not set
759# CONFIG_MMC is not set 827# CONFIG_MMC is not set
828# CONFIG_MEMSTICK is not set
829# CONFIG_ACCESSIBILITY is not set
760# CONFIG_NEW_LEDS is not set 830# CONFIG_NEW_LEDS is not set
761CONFIG_RTC_LIB=y 831CONFIG_RTC_LIB=y
762CONFIG_RTC_CLASS=y 832CONFIG_RTC_CLASS=y
@@ -781,12 +851,15 @@ CONFIG_RTC_INTF_DEV=y
781# Platform RTC drivers 851# Platform RTC drivers
782# 852#
783# CONFIG_RTC_DRV_CMOS is not set 853# CONFIG_RTC_DRV_CMOS is not set
854# CONFIG_RTC_DRV_DS1286 is not set
784# CONFIG_RTC_DRV_DS1511 is not set 855# CONFIG_RTC_DRV_DS1511 is not set
785# CONFIG_RTC_DRV_DS1553 is not set 856# CONFIG_RTC_DRV_DS1553 is not set
786# CONFIG_RTC_DRV_DS1742 is not set 857# CONFIG_RTC_DRV_DS1742 is not set
787# CONFIG_RTC_DRV_STK17TA8 is not set 858# CONFIG_RTC_DRV_STK17TA8 is not set
788# CONFIG_RTC_DRV_M48T86 is not set 859# CONFIG_RTC_DRV_M48T86 is not set
860# CONFIG_RTC_DRV_M48T35 is not set
789# CONFIG_RTC_DRV_M48T59 is not set 861# CONFIG_RTC_DRV_M48T59 is not set
862# CONFIG_RTC_DRV_BQ4802 is not set
790# CONFIG_RTC_DRV_V3020 is not set 863# CONFIG_RTC_DRV_V3020 is not set
791 864
792# 865#
@@ -794,15 +867,10 @@ CONFIG_RTC_INTF_DEV=y
794# 867#
795CONFIG_RTC_DRV_SA1100=y 868CONFIG_RTC_DRV_SA1100=y
796# CONFIG_DMADEVICES is not set 869# CONFIG_DMADEVICES is not set
797 870# CONFIG_AUXDISPLAY is not set
798#
799# Voltage and Current regulators
800#
801# CONFIG_REGULATOR is not set 871# CONFIG_REGULATOR is not set
802# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
803# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
804# CONFIG_REGULATOR_BQ24022 is not set
805# CONFIG_UIO is not set 872# CONFIG_UIO is not set
873# CONFIG_STAGING is not set
806 874
807# 875#
808# File systems 876# File systems
@@ -811,12 +879,16 @@ CONFIG_EXT2_FS=y
811# CONFIG_EXT2_FS_XATTR is not set 879# CONFIG_EXT2_FS_XATTR is not set
812# CONFIG_EXT2_FS_XIP is not set 880# CONFIG_EXT2_FS_XIP is not set
813# CONFIG_EXT3_FS is not set 881# CONFIG_EXT3_FS is not set
814# CONFIG_EXT4DEV_FS is not set 882# CONFIG_EXT4_FS is not set
815# CONFIG_REISERFS_FS is not set 883# CONFIG_REISERFS_FS is not set
816# CONFIG_JFS_FS is not set 884# CONFIG_JFS_FS is not set
817# CONFIG_FS_POSIX_ACL is not set 885# CONFIG_FS_POSIX_ACL is not set
818# CONFIG_XFS_FS is not set 886# CONFIG_XFS_FS is not set
887# CONFIG_GFS2_FS is not set
819# CONFIG_OCFS2_FS is not set 888# CONFIG_OCFS2_FS is not set
889# CONFIG_BTRFS_FS is not set
890CONFIG_FILE_LOCKING=y
891CONFIG_FSNOTIFY=y
820CONFIG_DNOTIFY=y 892CONFIG_DNOTIFY=y
821CONFIG_INOTIFY=y 893CONFIG_INOTIFY=y
822CONFIG_INOTIFY_USER=y 894CONFIG_INOTIFY_USER=y
@@ -826,6 +898,11 @@ CONFIG_INOTIFY_USER=y
826# CONFIG_FUSE_FS is not set 898# CONFIG_FUSE_FS is not set
827 899
828# 900#
901# Caches
902#
903# CONFIG_FSCACHE is not set
904
905#
829# CD-ROM/DVD Filesystems 906# CD-ROM/DVD Filesystems
830# 907#
831# CONFIG_ISO9660_FS is not set 908# CONFIG_ISO9660_FS is not set
@@ -846,14 +923,12 @@ CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
846# 923#
847CONFIG_PROC_FS=y 924CONFIG_PROC_FS=y
848CONFIG_PROC_SYSCTL=y 925CONFIG_PROC_SYSCTL=y
926CONFIG_PROC_PAGE_MONITOR=y
849CONFIG_SYSFS=y 927CONFIG_SYSFS=y
850# CONFIG_TMPFS is not set 928# CONFIG_TMPFS is not set
851# CONFIG_HUGETLB_PAGE is not set 929# CONFIG_HUGETLB_PAGE is not set
852# CONFIG_CONFIGFS_FS is not set 930# CONFIG_CONFIGFS_FS is not set
853 931CONFIG_MISC_FILESYSTEMS=y
854#
855# Miscellaneous filesystems
856#
857# CONFIG_ADFS_FS is not set 932# CONFIG_ADFS_FS is not set
858# CONFIG_AFFS_FS is not set 933# CONFIG_AFFS_FS is not set
859# CONFIG_HFS_FS is not set 934# CONFIG_HFS_FS is not set
@@ -862,6 +937,7 @@ CONFIG_SYSFS=y
862# CONFIG_BFS_FS is not set 937# CONFIG_BFS_FS is not set
863# CONFIG_EFS_FS is not set 938# CONFIG_EFS_FS is not set
864# CONFIG_CRAMFS is not set 939# CONFIG_CRAMFS is not set
940# CONFIG_SQUASHFS is not set
865# CONFIG_VXFS_FS is not set 941# CONFIG_VXFS_FS is not set
866# CONFIG_MINIX_FS is not set 942# CONFIG_MINIX_FS is not set
867# CONFIG_OMFS_FS is not set 943# CONFIG_OMFS_FS is not set
@@ -870,6 +946,7 @@ CONFIG_SYSFS=y
870# CONFIG_ROMFS_FS is not set 946# CONFIG_ROMFS_FS is not set
871# CONFIG_SYSV_FS is not set 947# CONFIG_SYSV_FS is not set
872# CONFIG_UFS_FS is not set 948# CONFIG_UFS_FS is not set
949# CONFIG_NILFS2_FS is not set
873# CONFIG_NETWORK_FILESYSTEMS is not set 950# CONFIG_NETWORK_FILESYSTEMS is not set
874 951
875# 952#
@@ -935,12 +1012,16 @@ CONFIG_DEBUG_KERNEL=y
935CONFIG_DETECT_SOFTLOCKUP=y 1012CONFIG_DETECT_SOFTLOCKUP=y
936# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set 1013# CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC is not set
937CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0 1014CONFIG_BOOTPARAM_SOFTLOCKUP_PANIC_VALUE=0
1015CONFIG_DETECT_HUNG_TASK=y
1016# CONFIG_BOOTPARAM_HUNG_TASK_PANIC is not set
1017CONFIG_BOOTPARAM_HUNG_TASK_PANIC_VALUE=0
938CONFIG_SCHED_DEBUG=y 1018CONFIG_SCHED_DEBUG=y
939# CONFIG_SCHEDSTATS is not set 1019# CONFIG_SCHEDSTATS is not set
940# CONFIG_TIMER_STATS is not set 1020# CONFIG_TIMER_STATS is not set
941# CONFIG_DEBUG_OBJECTS is not set 1021# CONFIG_DEBUG_OBJECTS is not set
942# CONFIG_SLUB_DEBUG_ON is not set 1022# CONFIG_SLUB_DEBUG_ON is not set
943# CONFIG_SLUB_STATS is not set 1023# CONFIG_SLUB_STATS is not set
1024# CONFIG_DEBUG_KMEMLEAK is not set
944# CONFIG_DEBUG_RT_MUTEXES is not set 1025# CONFIG_DEBUG_RT_MUTEXES is not set
945# CONFIG_RT_MUTEX_TESTER is not set 1026# CONFIG_RT_MUTEX_TESTER is not set
946# CONFIG_DEBUG_SPINLOCK is not set 1027# CONFIG_DEBUG_SPINLOCK is not set
@@ -958,19 +1039,20 @@ CONFIG_DEBUG_BUGVERBOSE=y
958CONFIG_DEBUG_MEMORY_INIT=y 1039CONFIG_DEBUG_MEMORY_INIT=y
959# CONFIG_DEBUG_LIST is not set 1040# CONFIG_DEBUG_LIST is not set
960# CONFIG_DEBUG_SG is not set 1041# CONFIG_DEBUG_SG is not set
1042# CONFIG_DEBUG_NOTIFIERS is not set
961CONFIG_FRAME_POINTER=y 1043CONFIG_FRAME_POINTER=y
962# CONFIG_BOOT_PRINTK_DELAY is not set 1044# CONFIG_BOOT_PRINTK_DELAY is not set
963# CONFIG_RCU_TORTURE_TEST is not set 1045# CONFIG_RCU_TORTURE_TEST is not set
1046# CONFIG_RCU_CPU_STALL_DETECTOR is not set
964# CONFIG_BACKTRACE_SELF_TEST is not set 1047# CONFIG_BACKTRACE_SELF_TEST is not set
1048# CONFIG_DEBUG_BLOCK_EXT_DEVT is not set
965# CONFIG_FAULT_INJECTION is not set 1049# CONFIG_FAULT_INJECTION is not set
966# CONFIG_LATENCYTOP is not set 1050# CONFIG_LATENCYTOP is not set
967# CONFIG_SYSCTL_SYSCALL_CHECK is not set 1051# CONFIG_SYSCTL_SYSCALL_CHECK is not set
968CONFIG_HAVE_FTRACE=y 1052# CONFIG_PAGE_POISONING is not set
969CONFIG_HAVE_DYNAMIC_FTRACE=y 1053CONFIG_HAVE_FUNCTION_TRACER=y
1054CONFIG_TRACING_SUPPORT=y
970# CONFIG_FTRACE is not set 1055# CONFIG_FTRACE is not set
971# CONFIG_IRQSOFF_TRACER is not set
972# CONFIG_SCHED_TRACER is not set
973# CONFIG_CONTEXT_SWITCH_TRACER is not set
974# CONFIG_SAMPLES is not set 1056# CONFIG_SAMPLES is not set
975CONFIG_HAVE_ARCH_KGDB=y 1057CONFIG_HAVE_ARCH_KGDB=y
976# CONFIG_KGDB is not set 1058# CONFIG_KGDB is not set
@@ -985,13 +1067,16 @@ CONFIG_DEBUG_LL=y
985# 1067#
986# CONFIG_KEYS is not set 1068# CONFIG_KEYS is not set
987# CONFIG_SECURITY is not set 1069# CONFIG_SECURITY is not set
1070# CONFIG_SECURITYFS is not set
988# CONFIG_SECURITY_FILE_CAPABILITIES is not set 1071# CONFIG_SECURITY_FILE_CAPABILITIES is not set
989CONFIG_CRYPTO=y 1072CONFIG_CRYPTO=y
990 1073
991# 1074#
992# Crypto core or helper 1075# Crypto core or helper
993# 1076#
1077# CONFIG_CRYPTO_FIPS is not set
994# CONFIG_CRYPTO_MANAGER is not set 1078# CONFIG_CRYPTO_MANAGER is not set
1079# CONFIG_CRYPTO_MANAGER2 is not set
995# CONFIG_CRYPTO_GF128MUL is not set 1080# CONFIG_CRYPTO_GF128MUL is not set
996# CONFIG_CRYPTO_NULL is not set 1081# CONFIG_CRYPTO_NULL is not set
997# CONFIG_CRYPTO_CRYPTD is not set 1082# CONFIG_CRYPTO_CRYPTD is not set
@@ -1062,15 +1147,21 @@ CONFIG_CRYPTO=y
1062# Compression 1147# Compression
1063# 1148#
1064# CONFIG_CRYPTO_DEFLATE is not set 1149# CONFIG_CRYPTO_DEFLATE is not set
1150# CONFIG_CRYPTO_ZLIB is not set
1065# CONFIG_CRYPTO_LZO is not set 1151# CONFIG_CRYPTO_LZO is not set
1152
1153#
1154# Random Number Generation
1155#
1156# CONFIG_CRYPTO_ANSI_CPRNG is not set
1066CONFIG_CRYPTO_HW=y 1157CONFIG_CRYPTO_HW=y
1158# CONFIG_BINARY_PRINTF is not set
1067 1159
1068# 1160#
1069# Library routines 1161# Library routines
1070# 1162#
1071CONFIG_BITREVERSE=y 1163CONFIG_BITREVERSE=y
1072# CONFIG_GENERIC_FIND_FIRST_BIT is not set 1164CONFIG_GENERIC_FIND_LAST_BIT=y
1073# CONFIG_GENERIC_FIND_NEXT_BIT is not set
1074CONFIG_CRC_CCITT=m 1165CONFIG_CRC_CCITT=m
1075# CONFIG_CRC16 is not set 1166# CONFIG_CRC16 is not set
1076# CONFIG_CRC_T10DIF is not set 1167# CONFIG_CRC_T10DIF is not set
@@ -1078,7 +1169,7 @@ CONFIG_CRC_CCITT=m
1078CONFIG_CRC32=y 1169CONFIG_CRC32=y
1079# CONFIG_CRC7 is not set 1170# CONFIG_CRC7 is not set
1080# CONFIG_LIBCRC32C is not set 1171# CONFIG_LIBCRC32C is not set
1081CONFIG_PLIST=y
1082CONFIG_HAS_IOMEM=y 1172CONFIG_HAS_IOMEM=y
1083CONFIG_HAS_IOPORT=y 1173CONFIG_HAS_IOPORT=y
1084CONFIG_HAS_DMA=y 1174CONFIG_HAS_DMA=y
1175CONFIG_NLATTR=y
diff --git a/arch/arm/configs/kirkwood_defconfig b/arch/arm/configs/kirkwood_defconfig
index 0a1abb978d7e..af74cc2de8b6 100644
--- a/arch/arm/configs/kirkwood_defconfig
+++ b/arch/arm/configs/kirkwood_defconfig
@@ -629,7 +629,7 @@ CONFIG_SCSI_LOWLEVEL=y
629CONFIG_ATA=y 629CONFIG_ATA=y
630# CONFIG_ATA_NONSTANDARD is not set 630# CONFIG_ATA_NONSTANDARD is not set
631CONFIG_SATA_PMP=y 631CONFIG_SATA_PMP=y
632# CONFIG_SATA_AHCI is not set 632CONFIG_SATA_AHCI=y
633# CONFIG_SATA_SIL24 is not set 633# CONFIG_SATA_SIL24 is not set
634CONFIG_ATA_SFF=y 634CONFIG_ATA_SFF=y
635# CONFIG_SATA_SVW is not set 635# CONFIG_SATA_SVW is not set
diff --git a/arch/arm/configs/mx27_defconfig b/arch/arm/configs/mx27_defconfig
index 083516cd0d7f..75263a83741c 100644
--- a/arch/arm/configs/mx27_defconfig
+++ b/arch/arm/configs/mx27_defconfig
@@ -1,15 +1,15 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc1 3# Linux kernel version: 2.6.31-rc4
4# Wed Apr 8 10:18:06 2009 4# Fri Jul 24 16:08:06 2009
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_HAVE_PWM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y 8CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y 9CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y 10CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y 11CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_MMU=y 12CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y 13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y 14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y 15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
@@ -18,14 +18,13 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y 18CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y 19CONFIG_GENERIC_IRQ_PROBE=y
20CONFIG_RWSEM_GENERIC_SPINLOCK=y 20CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y 21CONFIG_GENERIC_HWEIGHT=y
24CONFIG_GENERIC_CALIBRATE_DELAY=y 22CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_ARCH_MTD_XIP=y 23CONFIG_ARCH_MTD_XIP=y
26CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 24CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
27CONFIG_VECTORS_BASE=0xffff0000 25CONFIG_VECTORS_BASE=0xffff0000
28CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 26CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
27CONFIG_CONSTRUCTORS=y
29 28
30# 29#
31# General setup 30# General setup
@@ -85,7 +84,12 @@ CONFIG_TIMERFD=y
85CONFIG_EVENTFD=y 84CONFIG_EVENTFD=y
86CONFIG_SHMEM=y 85CONFIG_SHMEM=y
87CONFIG_AIO=y 86CONFIG_AIO=y
87
88#
89# Performance Counters
90#
88CONFIG_VM_EVENT_COUNTERS=y 91CONFIG_VM_EVENT_COUNTERS=y
92# CONFIG_STRIP_ASM_SYMS is not set
89# CONFIG_COMPAT_BRK is not set 93# CONFIG_COMPAT_BRK is not set
90CONFIG_SLAB=y 94CONFIG_SLAB=y
91# CONFIG_SLUB is not set 95# CONFIG_SLUB is not set
@@ -99,6 +103,12 @@ CONFIG_KPROBES=y
99CONFIG_KRETPROBES=y 103CONFIG_KRETPROBES=y
100CONFIG_HAVE_KPROBES=y 104CONFIG_HAVE_KPROBES=y
101CONFIG_HAVE_KRETPROBES=y 105CONFIG_HAVE_KRETPROBES=y
106CONFIG_HAVE_CLK=y
107
108#
109# GCOV-based kernel profiling
110#
111# CONFIG_GCOV_KERNEL is not set
102# CONFIG_SLOW_WORK is not set 112# CONFIG_SLOW_WORK is not set
103CONFIG_HAVE_GENERIC_DMA_COHERENT=y 113CONFIG_HAVE_GENERIC_DMA_COHERENT=y
104CONFIG_SLABINFO=y 114CONFIG_SLABINFO=y
@@ -111,7 +121,7 @@ CONFIG_MODULE_UNLOAD=y
111# CONFIG_MODVERSIONS is not set 121# CONFIG_MODVERSIONS is not set
112# CONFIG_MODULE_SRCVERSION_ALL is not set 122# CONFIG_MODULE_SRCVERSION_ALL is not set
113CONFIG_BLOCK=y 123CONFIG_BLOCK=y
114# CONFIG_LBD is not set 124CONFIG_LBDAF=y
115# CONFIG_BLK_DEV_BSG is not set 125# CONFIG_BLK_DEV_BSG is not set
116# CONFIG_BLK_DEV_INTEGRITY is not set 126# CONFIG_BLK_DEV_INTEGRITY is not set
117 127
@@ -138,13 +148,14 @@ CONFIG_FREEZER=y
138# CONFIG_ARCH_VERSATILE is not set 148# CONFIG_ARCH_VERSATILE is not set
139# CONFIG_ARCH_AT91 is not set 149# CONFIG_ARCH_AT91 is not set
140# CONFIG_ARCH_CLPS711X is not set 150# CONFIG_ARCH_CLPS711X is not set
151# CONFIG_ARCH_GEMINI is not set
141# CONFIG_ARCH_EBSA110 is not set 152# CONFIG_ARCH_EBSA110 is not set
142# CONFIG_ARCH_EP93XX is not set 153# CONFIG_ARCH_EP93XX is not set
143# CONFIG_ARCH_GEMINI is not set
144# CONFIG_ARCH_FOOTBRIDGE is not set 154# CONFIG_ARCH_FOOTBRIDGE is not set
155CONFIG_ARCH_MXC=y
156# CONFIG_ARCH_STMP3XXX is not set
145# CONFIG_ARCH_NETX is not set 157# CONFIG_ARCH_NETX is not set
146# CONFIG_ARCH_H720X is not set 158# CONFIG_ARCH_H720X is not set
147# CONFIG_ARCH_IMX is not set
148# CONFIG_ARCH_IOP13XX is not set 159# CONFIG_ARCH_IOP13XX is not set
149# CONFIG_ARCH_IOP32X is not set 160# CONFIG_ARCH_IOP32X is not set
150# CONFIG_ARCH_IOP33X is not set 161# CONFIG_ARCH_IOP33X is not set
@@ -153,25 +164,25 @@ CONFIG_FREEZER=y
153# CONFIG_ARCH_IXP4XX is not set 164# CONFIG_ARCH_IXP4XX is not set
154# CONFIG_ARCH_L7200 is not set 165# CONFIG_ARCH_L7200 is not set
155# CONFIG_ARCH_KIRKWOOD is not set 166# CONFIG_ARCH_KIRKWOOD is not set
156# CONFIG_ARCH_KS8695 is not set
157# CONFIG_ARCH_NS9XXX is not set
158# CONFIG_ARCH_LOKI is not set 167# CONFIG_ARCH_LOKI is not set
159# CONFIG_ARCH_MV78XX0 is not set 168# CONFIG_ARCH_MV78XX0 is not set
160CONFIG_ARCH_MXC=y
161# CONFIG_ARCH_ORION5X is not set 169# CONFIG_ARCH_ORION5X is not set
170# CONFIG_ARCH_MMP is not set
171# CONFIG_ARCH_KS8695 is not set
172# CONFIG_ARCH_NS9XXX is not set
173# CONFIG_ARCH_W90X900 is not set
162# CONFIG_ARCH_PNX4008 is not set 174# CONFIG_ARCH_PNX4008 is not set
163# CONFIG_ARCH_PXA is not set 175# CONFIG_ARCH_PXA is not set
164# CONFIG_ARCH_MMP is not set 176# CONFIG_ARCH_MSM is not set
165# CONFIG_ARCH_RPC is not set 177# CONFIG_ARCH_RPC is not set
166# CONFIG_ARCH_SA1100 is not set 178# CONFIG_ARCH_SA1100 is not set
167# CONFIG_ARCH_S3C2410 is not set 179# CONFIG_ARCH_S3C2410 is not set
168# CONFIG_ARCH_S3C64XX is not set 180# CONFIG_ARCH_S3C64XX is not set
169# CONFIG_ARCH_SHARK is not set 181# CONFIG_ARCH_SHARK is not set
170# CONFIG_ARCH_LH7A40X is not set 182# CONFIG_ARCH_LH7A40X is not set
183# CONFIG_ARCH_U300 is not set
171# CONFIG_ARCH_DAVINCI is not set 184# CONFIG_ARCH_DAVINCI is not set
172# CONFIG_ARCH_OMAP is not set 185# CONFIG_ARCH_OMAP is not set
173# CONFIG_ARCH_MSM is not set
174# CONFIG_ARCH_W90X900 is not set
175 186
176# 187#
177# Freescale MXC Implementations 188# Freescale MXC Implementations
@@ -188,6 +199,8 @@ CONFIG_MACH_MX27=y
188CONFIG_MACH_MX27ADS=y 199CONFIG_MACH_MX27ADS=y
189CONFIG_MACH_PCM038=y 200CONFIG_MACH_PCM038=y
190CONFIG_MACH_PCM970_BASEBOARD=y 201CONFIG_MACH_PCM970_BASEBOARD=y
202CONFIG_MACH_MX27_3DS=y
203CONFIG_MACH_MX27LITE=y
191CONFIG_MXC_IRQ_PRIOR=y 204CONFIG_MXC_IRQ_PRIOR=y
192CONFIG_MXC_PWM=y 205CONFIG_MXC_PWM=y
193 206
@@ -213,7 +226,6 @@ CONFIG_ARM_THUMB=y
213# CONFIG_CPU_DCACHE_DISABLE is not set 226# CONFIG_CPU_DCACHE_DISABLE is not set
214# CONFIG_CPU_DCACHE_WRITETHROUGH is not set 227# CONFIG_CPU_DCACHE_WRITETHROUGH is not set
215# CONFIG_CPU_CACHE_ROUND_ROBIN is not set 228# CONFIG_CPU_CACHE_ROUND_ROBIN is not set
216# CONFIG_OUTER_CACHE is not set
217CONFIG_COMMON_CLKDEV=y 229CONFIG_COMMON_CLKDEV=y
218 230
219# 231#
@@ -238,7 +250,6 @@ CONFIG_PREEMPT=y
238CONFIG_HZ=100 250CONFIG_HZ=100
239CONFIG_AEABI=y 251CONFIG_AEABI=y
240CONFIG_OABI_COMPAT=y 252CONFIG_OABI_COMPAT=y
241CONFIG_ARCH_FLATMEM_HAS_HOLES=y
242# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set 253# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
243# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set 254# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
244# CONFIG_HIGHMEM is not set 255# CONFIG_HIGHMEM is not set
@@ -253,10 +264,11 @@ CONFIG_SPLIT_PTLOCK_CPUS=4096
253# CONFIG_PHYS_ADDR_T_64BIT is not set 264# CONFIG_PHYS_ADDR_T_64BIT is not set
254CONFIG_ZONE_DMA_FLAG=0 265CONFIG_ZONE_DMA_FLAG=0
255CONFIG_VIRT_TO_BUS=y 266CONFIG_VIRT_TO_BUS=y
256CONFIG_UNEVICTABLE_LRU=y
257CONFIG_HAVE_MLOCK=y 267CONFIG_HAVE_MLOCK=y
258CONFIG_HAVE_MLOCKED_PAGE_BIT=y 268CONFIG_HAVE_MLOCKED_PAGE_BIT=y
269CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
259CONFIG_ALIGNMENT_TRAP=y 270CONFIG_ALIGNMENT_TRAP=y
271# CONFIG_UACCESS_WITH_MEMCPY is not set
260 272
261# 273#
262# Boot options 274# Boot options
@@ -361,6 +373,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
361# CONFIG_ECONET is not set 373# CONFIG_ECONET is not set
362# CONFIG_WAN_ROUTER is not set 374# CONFIG_WAN_ROUTER is not set
363# CONFIG_PHONET is not set 375# CONFIG_PHONET is not set
376# CONFIG_IEEE802154 is not set
364# CONFIG_NET_SCHED is not set 377# CONFIG_NET_SCHED is not set
365# CONFIG_DCB is not set 378# CONFIG_DCB is not set
366 379
@@ -474,7 +487,16 @@ CONFIG_MTD_PHYSMAP=y
474# CONFIG_MTD_DOC2000 is not set 487# CONFIG_MTD_DOC2000 is not set
475# CONFIG_MTD_DOC2001 is not set 488# CONFIG_MTD_DOC2001 is not set
476# CONFIG_MTD_DOC2001PLUS is not set 489# CONFIG_MTD_DOC2001PLUS is not set
477# CONFIG_MTD_NAND is not set 490CONFIG_MTD_NAND=y
491# CONFIG_MTD_NAND_VERIFY_WRITE is not set
492# CONFIG_MTD_NAND_ECC_SMC is not set
493# CONFIG_MTD_NAND_MUSEUM_IDS is not set
494# CONFIG_MTD_NAND_GPIO is not set
495CONFIG_MTD_NAND_IDS=y
496# CONFIG_MTD_NAND_DISKONCHIP is not set
497# CONFIG_MTD_NAND_NANDSIM is not set
498# CONFIG_MTD_NAND_PLATFORM is not set
499CONFIG_MTD_NAND_MXC=y
478# CONFIG_MTD_ONENAND is not set 500# CONFIG_MTD_ONENAND is not set
479 501
480# 502#
@@ -485,7 +507,15 @@ CONFIG_MTD_PHYSMAP=y
485# 507#
486# UBI - Unsorted block images 508# UBI - Unsorted block images
487# 509#
488# CONFIG_MTD_UBI is not set 510CONFIG_MTD_UBI=y
511CONFIG_MTD_UBI_WL_THRESHOLD=4096
512CONFIG_MTD_UBI_BEB_RESERVE=1
513# CONFIG_MTD_UBI_GLUEBI is not set
514
515#
516# UBI debugging options
517#
518# CONFIG_MTD_UBI_DEBUG is not set
489# CONFIG_PARPORT is not set 519# CONFIG_PARPORT is not set
490CONFIG_BLK_DEV=y 520CONFIG_BLK_DEV=y
491# CONFIG_BLK_DEV_COW_COMMON is not set 521# CONFIG_BLK_DEV_COW_COMMON is not set
@@ -494,7 +524,21 @@ CONFIG_BLK_DEV=y
494# CONFIG_BLK_DEV_RAM is not set 524# CONFIG_BLK_DEV_RAM is not set
495# CONFIG_CDROM_PKTCDVD is not set 525# CONFIG_CDROM_PKTCDVD is not set
496# CONFIG_ATA_OVER_ETH is not set 526# CONFIG_ATA_OVER_ETH is not set
497# CONFIG_MISC_DEVICES is not set 527# CONFIG_MG_DISK is not set
528CONFIG_MISC_DEVICES=y
529# CONFIG_ICS932S401 is not set
530# CONFIG_ENCLOSURE_SERVICES is not set
531# CONFIG_ISL29003 is not set
532# CONFIG_C2PORT is not set
533
534#
535# EEPROM support
536#
537CONFIG_EEPROM_AT24=y
538# CONFIG_EEPROM_AT25 is not set
539# CONFIG_EEPROM_LEGACY is not set
540# CONFIG_EEPROM_MAX6875 is not set
541# CONFIG_EEPROM_93CX6 is not set
498CONFIG_HAVE_IDE=y 542CONFIG_HAVE_IDE=y
499# CONFIG_IDE is not set 543# CONFIG_IDE is not set
500 544
@@ -508,7 +552,6 @@ CONFIG_HAVE_IDE=y
508# CONFIG_ATA is not set 552# CONFIG_ATA is not set
509# CONFIG_MD is not set 553# CONFIG_MD is not set
510CONFIG_NETDEVICES=y 554CONFIG_NETDEVICES=y
511CONFIG_COMPAT_NET_DEV_OPS=y
512# CONFIG_DUMMY is not set 555# CONFIG_DUMMY is not set
513# CONFIG_BONDING is not set 556# CONFIG_BONDING is not set
514# CONFIG_MACVLAN is not set 557# CONFIG_MACVLAN is not set
@@ -534,6 +577,8 @@ CONFIG_NET_ETHERNET=y
534# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set 577# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
535# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 578# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
536# CONFIG_B44 is not set 579# CONFIG_B44 is not set
580# CONFIG_KS8842 is not set
581# CONFIG_KS8851 is not set
537CONFIG_FEC=y 582CONFIG_FEC=y
538# CONFIG_FEC2 is not set 583# CONFIG_FEC2 is not set
539# CONFIG_NETDEV_1000 is not set 584# CONFIG_NETDEV_1000 is not set
@@ -580,6 +625,11 @@ CONFIG_INPUT_EVDEV=y
580# CONFIG_INPUT_TABLET is not set 625# CONFIG_INPUT_TABLET is not set
581CONFIG_INPUT_TOUCHSCREEN=y 626CONFIG_INPUT_TOUCHSCREEN=y
582# CONFIG_TOUCHSCREEN_ADS7846 is not set 627# CONFIG_TOUCHSCREEN_ADS7846 is not set
628# CONFIG_TOUCHSCREEN_AD7877 is not set
629# CONFIG_TOUCHSCREEN_AD7879_I2C is not set
630# CONFIG_TOUCHSCREEN_AD7879_SPI is not set
631# CONFIG_TOUCHSCREEN_AD7879 is not set
632# CONFIG_TOUCHSCREEN_EETI is not set
583# CONFIG_TOUCHSCREEN_FUJITSU is not set 633# CONFIG_TOUCHSCREEN_FUJITSU is not set
584# CONFIG_TOUCHSCREEN_GUNZE is not set 634# CONFIG_TOUCHSCREEN_GUNZE is not set
585# CONFIG_TOUCHSCREEN_ELO is not set 635# CONFIG_TOUCHSCREEN_ELO is not set
@@ -592,6 +642,7 @@ CONFIG_INPUT_TOUCHSCREEN=y
592# CONFIG_TOUCHSCREEN_TOUCHWIN is not set 642# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
593# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set 643# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
594# CONFIG_TOUCHSCREEN_TSC2007 is not set 644# CONFIG_TOUCHSCREEN_TSC2007 is not set
645# CONFIG_TOUCHSCREEN_W90X900 is not set
595# CONFIG_INPUT_MISC is not set 646# CONFIG_INPUT_MISC is not set
596 647
597# 648#
@@ -644,6 +695,7 @@ CONFIG_I2C_HELPER_AUTO=y
644# 695#
645# I2C system bus drivers (mostly embedded / system-on-chip) 696# I2C system bus drivers (mostly embedded / system-on-chip)
646# 697#
698# CONFIG_I2C_DESIGNWARE is not set
647# CONFIG_I2C_GPIO is not set 699# CONFIG_I2C_GPIO is not set
648CONFIG_I2C_IMX=y 700CONFIG_I2C_IMX=y
649# CONFIG_I2C_OCORES is not set 701# CONFIG_I2C_OCORES is not set
@@ -668,7 +720,6 @@ CONFIG_I2C_IMX=y
668# CONFIG_SENSORS_PCF8574 is not set 720# CONFIG_SENSORS_PCF8574 is not set
669# CONFIG_PCF8575 is not set 721# CONFIG_PCF8575 is not set
670# CONFIG_SENSORS_PCA9539 is not set 722# CONFIG_SENSORS_PCA9539 is not set
671# CONFIG_SENSORS_MAX6875 is not set
672# CONFIG_SENSORS_TSL2550 is not set 723# CONFIG_SENSORS_TSL2550 is not set
673# CONFIG_I2C_DEBUG_CORE is not set 724# CONFIG_I2C_DEBUG_CORE is not set
674# CONFIG_I2C_DEBUG_ALGO is not set 725# CONFIG_I2C_DEBUG_ALGO is not set
@@ -719,6 +770,7 @@ CONFIG_W1=y
719# 770#
720# CONFIG_W1_MASTER_DS2482 is not set 771# CONFIG_W1_MASTER_DS2482 is not set
721CONFIG_W1_MASTER_MXC=y 772CONFIG_W1_MASTER_MXC=y
773# CONFIG_W1_MASTER_DS1WM is not set
722# CONFIG_W1_MASTER_GPIO is not set 774# CONFIG_W1_MASTER_GPIO is not set
723 775
724# 776#
@@ -753,54 +805,16 @@ CONFIG_SSB_POSSIBLE=y
753# CONFIG_TPS65010 is not set 805# CONFIG_TPS65010 is not set
754# CONFIG_TWL4030_CORE is not set 806# CONFIG_TWL4030_CORE is not set
755# CONFIG_MFD_TMIO is not set 807# CONFIG_MFD_TMIO is not set
808# CONFIG_MFD_T7L66XB is not set
809# CONFIG_MFD_TC6387XB is not set
756# CONFIG_MFD_TC6393XB is not set 810# CONFIG_MFD_TC6393XB is not set
757# CONFIG_PMIC_DA903X is not set 811# CONFIG_PMIC_DA903X is not set
758# CONFIG_MFD_WM8400 is not set 812# CONFIG_MFD_WM8400 is not set
759# CONFIG_MFD_WM8350_I2C is not set 813# CONFIG_MFD_WM8350_I2C is not set
760# CONFIG_MFD_PCF50633 is not set 814# CONFIG_MFD_PCF50633 is not set
761 815# CONFIG_AB3100_CORE is not set
762# 816# CONFIG_EZX_PCAP is not set
763# Multimedia devices 817# CONFIG_MEDIA_SUPPORT is not set
764#
765
766#
767# Multimedia core support
768#
769CONFIG_VIDEO_DEV=y
770CONFIG_VIDEO_V4L2_COMMON=y
771CONFIG_VIDEO_ALLOW_V4L1=y
772CONFIG_VIDEO_V4L1_COMPAT=y
773# CONFIG_DVB_CORE is not set
774CONFIG_VIDEO_MEDIA=y
775
776#
777# Multimedia drivers
778#
779# CONFIG_MEDIA_ATTACH is not set
780CONFIG_MEDIA_TUNER=y
781# CONFIG_MEDIA_TUNER_CUSTOMISE is not set
782CONFIG_MEDIA_TUNER_SIMPLE=y
783CONFIG_MEDIA_TUNER_TDA8290=y
784CONFIG_MEDIA_TUNER_TDA9887=y
785CONFIG_MEDIA_TUNER_TEA5761=y
786CONFIG_MEDIA_TUNER_TEA5767=y
787CONFIG_MEDIA_TUNER_MT20XX=y
788CONFIG_MEDIA_TUNER_XC2028=y
789CONFIG_MEDIA_TUNER_XC5000=y
790CONFIG_MEDIA_TUNER_MC44S803=y
791CONFIG_VIDEO_V4L2=y
792CONFIG_VIDEO_V4L1=y
793CONFIG_VIDEO_CAPTURE_DRIVERS=y
794# CONFIG_VIDEO_ADV_DEBUG is not set
795# CONFIG_VIDEO_FIXED_MINOR_RANGES is not set
796CONFIG_VIDEO_HELPER_CHIPS_AUTO=y
797# CONFIG_VIDEO_VIVI is not set
798# CONFIG_VIDEO_CPIA is not set
799# CONFIG_VIDEO_SAA5246A is not set
800# CONFIG_VIDEO_SAA5249 is not set
801# CONFIG_SOC_CAMERA is not set
802# CONFIG_RADIO_ADAPTERS is not set
803# CONFIG_DAB is not set
804 818
805# 819#
806# Graphics support 820# Graphics support
@@ -917,6 +931,7 @@ CONFIG_RTC_DRV_PCF8563=y
917# CONFIG_RTC_DRV_S35390A is not set 931# CONFIG_RTC_DRV_S35390A is not set
918# CONFIG_RTC_DRV_FM3130 is not set 932# CONFIG_RTC_DRV_FM3130 is not set
919# CONFIG_RTC_DRV_RX8581 is not set 933# CONFIG_RTC_DRV_RX8581 is not set
934# CONFIG_RTC_DRV_RX8025 is not set
920 935
921# 936#
922# SPI RTC drivers 937# SPI RTC drivers
@@ -962,12 +977,15 @@ CONFIG_RTC_DRV_PCF8563=y
962# CONFIG_REISERFS_FS is not set 977# CONFIG_REISERFS_FS is not set
963# CONFIG_JFS_FS is not set 978# CONFIG_JFS_FS is not set
964# CONFIG_FS_POSIX_ACL is not set 979# CONFIG_FS_POSIX_ACL is not set
965CONFIG_FILE_LOCKING=y
966# CONFIG_XFS_FS is not set 980# CONFIG_XFS_FS is not set
981# CONFIG_GFS2_FS is not set
967# CONFIG_OCFS2_FS is not set 982# CONFIG_OCFS2_FS is not set
968# CONFIG_BTRFS_FS is not set 983# CONFIG_BTRFS_FS is not set
984CONFIG_FILE_LOCKING=y
985CONFIG_FSNOTIFY=y
969# CONFIG_DNOTIFY is not set 986# CONFIG_DNOTIFY is not set
970# CONFIG_INOTIFY is not set 987# CONFIG_INOTIFY is not set
988CONFIG_INOTIFY_USER=y
971# CONFIG_QUOTA is not set 989# CONFIG_QUOTA is not set
972# CONFIG_AUTOFS_FS is not set 990# CONFIG_AUTOFS_FS is not set
973# CONFIG_AUTOFS4_FS is not set 991# CONFIG_AUTOFS4_FS is not set
@@ -1021,6 +1039,12 @@ CONFIG_JFFS2_ZLIB=y
1021# CONFIG_JFFS2_LZO is not set 1039# CONFIG_JFFS2_LZO is not set
1022CONFIG_JFFS2_RTIME=y 1040CONFIG_JFFS2_RTIME=y
1023# CONFIG_JFFS2_RUBIN is not set 1041# CONFIG_JFFS2_RUBIN is not set
1042CONFIG_UBIFS_FS=y
1043# CONFIG_UBIFS_FS_XATTR is not set
1044# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
1045CONFIG_UBIFS_FS_LZO=y
1046CONFIG_UBIFS_FS_ZLIB=y
1047# CONFIG_UBIFS_FS_DEBUG is not set
1024# CONFIG_CRAMFS is not set 1048# CONFIG_CRAMFS is not set
1025# CONFIG_SQUASHFS is not set 1049# CONFIG_SQUASHFS is not set
1026# CONFIG_VXFS_FS is not set 1050# CONFIG_VXFS_FS is not set
@@ -1119,25 +1143,11 @@ CONFIG_SYSCTL_SYSCALL_CHECK=y
1119CONFIG_NOP_TRACER=y 1143CONFIG_NOP_TRACER=y
1120CONFIG_HAVE_FUNCTION_TRACER=y 1144CONFIG_HAVE_FUNCTION_TRACER=y
1121CONFIG_RING_BUFFER=y 1145CONFIG_RING_BUFFER=y
1146CONFIG_EVENT_TRACING=y
1147CONFIG_CONTEXT_SWITCH_TRACER=y
1122CONFIG_TRACING=y 1148CONFIG_TRACING=y
1123CONFIG_TRACING_SUPPORT=y 1149CONFIG_TRACING_SUPPORT=y
1124 1150# CONFIG_FTRACE is not set
1125#
1126# Tracers
1127#
1128# CONFIG_FUNCTION_TRACER is not set
1129# CONFIG_IRQSOFF_TRACER is not set
1130# CONFIG_PREEMPT_TRACER is not set
1131# CONFIG_SCHED_TRACER is not set
1132# CONFIG_CONTEXT_SWITCH_TRACER is not set
1133# CONFIG_EVENT_TRACER is not set
1134# CONFIG_BOOT_TRACER is not set
1135# CONFIG_TRACE_BRANCH_PROFILING is not set
1136# CONFIG_STACK_TRACER is not set
1137# CONFIG_KMEMTRACE is not set
1138# CONFIG_WORKQUEUE_TRACER is not set
1139# CONFIG_BLK_DEV_IO_TRACE is not set
1140# CONFIG_FTRACE_STARTUP_TEST is not set
1141# CONFIG_DYNAMIC_DEBUG is not set 1151# CONFIG_DYNAMIC_DEBUG is not set
1142# CONFIG_SAMPLES is not set 1152# CONFIG_SAMPLES is not set
1143CONFIG_HAVE_ARCH_KGDB=y 1153CONFIG_HAVE_ARCH_KGDB=y
@@ -1151,16 +1161,104 @@ CONFIG_ARM_UNWIND=y
1151# CONFIG_SECURITY is not set 1161# CONFIG_SECURITY is not set
1152# CONFIG_SECURITYFS is not set 1162# CONFIG_SECURITYFS is not set
1153# CONFIG_SECURITY_FILE_CAPABILITIES is not set 1163# CONFIG_SECURITY_FILE_CAPABILITIES is not set
1154# CONFIG_CRYPTO is not set 1164CONFIG_CRYPTO=y
1165
1166#
1167# Crypto core or helper
1168#
1169# CONFIG_CRYPTO_FIPS is not set
1170CONFIG_CRYPTO_ALGAPI=y
1171CONFIG_CRYPTO_ALGAPI2=y
1172# CONFIG_CRYPTO_MANAGER is not set
1173# CONFIG_CRYPTO_MANAGER2 is not set
1174# CONFIG_CRYPTO_GF128MUL is not set
1175# CONFIG_CRYPTO_NULL is not set
1176# CONFIG_CRYPTO_CRYPTD is not set
1177# CONFIG_CRYPTO_AUTHENC is not set
1178# CONFIG_CRYPTO_TEST is not set
1179
1180#
1181# Authenticated Encryption with Associated Data
1182#
1183# CONFIG_CRYPTO_CCM is not set
1184# CONFIG_CRYPTO_GCM is not set
1185# CONFIG_CRYPTO_SEQIV is not set
1186
1187#
1188# Block modes
1189#
1190# CONFIG_CRYPTO_CBC is not set
1191# CONFIG_CRYPTO_CTR is not set
1192# CONFIG_CRYPTO_CTS is not set
1193# CONFIG_CRYPTO_ECB is not set
1194# CONFIG_CRYPTO_LRW is not set
1195# CONFIG_CRYPTO_PCBC is not set
1196# CONFIG_CRYPTO_XTS is not set
1197
1198#
1199# Hash modes
1200#
1201# CONFIG_CRYPTO_HMAC is not set
1202# CONFIG_CRYPTO_XCBC is not set
1203
1204#
1205# Digest
1206#
1207# CONFIG_CRYPTO_CRC32C is not set
1208# CONFIG_CRYPTO_MD4 is not set
1209# CONFIG_CRYPTO_MD5 is not set
1210# CONFIG_CRYPTO_MICHAEL_MIC is not set
1211# CONFIG_CRYPTO_RMD128 is not set
1212# CONFIG_CRYPTO_RMD160 is not set
1213# CONFIG_CRYPTO_RMD256 is not set
1214# CONFIG_CRYPTO_RMD320 is not set
1215# CONFIG_CRYPTO_SHA1 is not set
1216# CONFIG_CRYPTO_SHA256 is not set
1217# CONFIG_CRYPTO_SHA512 is not set
1218# CONFIG_CRYPTO_TGR192 is not set
1219# CONFIG_CRYPTO_WP512 is not set
1220
1221#
1222# Ciphers
1223#
1224# CONFIG_CRYPTO_AES is not set
1225# CONFIG_CRYPTO_ANUBIS is not set
1226# CONFIG_CRYPTO_ARC4 is not set
1227# CONFIG_CRYPTO_BLOWFISH is not set
1228# CONFIG_CRYPTO_CAMELLIA is not set
1229# CONFIG_CRYPTO_CAST5 is not set
1230# CONFIG_CRYPTO_CAST6 is not set
1231# CONFIG_CRYPTO_DES is not set
1232# CONFIG_CRYPTO_FCRYPT is not set
1233# CONFIG_CRYPTO_KHAZAD is not set
1234# CONFIG_CRYPTO_SALSA20 is not set
1235# CONFIG_CRYPTO_SEED is not set
1236# CONFIG_CRYPTO_SERPENT is not set
1237# CONFIG_CRYPTO_TEA is not set
1238# CONFIG_CRYPTO_TWOFISH is not set
1239
1240#
1241# Compression
1242#
1243CONFIG_CRYPTO_DEFLATE=y
1244# CONFIG_CRYPTO_ZLIB is not set
1245CONFIG_CRYPTO_LZO=y
1246
1247#
1248# Random Number Generation
1249#
1250# CONFIG_CRYPTO_ANSI_CPRNG is not set
1251CONFIG_CRYPTO_HW=y
1155CONFIG_BINARY_PRINTF=y 1252CONFIG_BINARY_PRINTF=y
1156 1253
1157# 1254#
1158# Library routines 1255# Library routines
1159# 1256#
1160CONFIG_BITREVERSE=y 1257CONFIG_BITREVERSE=y
1258CONFIG_RATIONAL=y
1161CONFIG_GENERIC_FIND_LAST_BIT=y 1259CONFIG_GENERIC_FIND_LAST_BIT=y
1162# CONFIG_CRC_CCITT is not set 1260# CONFIG_CRC_CCITT is not set
1163# CONFIG_CRC16 is not set 1261CONFIG_CRC16=y
1164# CONFIG_CRC_T10DIF is not set 1262# CONFIG_CRC_T10DIF is not set
1165# CONFIG_CRC_ITU_T is not set 1263# CONFIG_CRC_ITU_T is not set
1166CONFIG_CRC32=y 1264CONFIG_CRC32=y
@@ -1168,6 +1266,8 @@ CONFIG_CRC32=y
1168# CONFIG_LIBCRC32C is not set 1266# CONFIG_LIBCRC32C is not set
1169CONFIG_ZLIB_INFLATE=y 1267CONFIG_ZLIB_INFLATE=y
1170CONFIG_ZLIB_DEFLATE=y 1268CONFIG_ZLIB_DEFLATE=y
1269CONFIG_LZO_COMPRESS=y
1270CONFIG_LZO_DECOMPRESS=y
1171CONFIG_HAS_IOMEM=y 1271CONFIG_HAS_IOMEM=y
1172CONFIG_HAS_IOPORT=y 1272CONFIG_HAS_IOPORT=y
1173CONFIG_HAS_DMA=y 1273CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/mx3_defconfig b/arch/arm/configs/mx3_defconfig
index 20ada526f6de..a4f9a2a8149c 100644
--- a/arch/arm/configs/mx3_defconfig
+++ b/arch/arm/configs/mx3_defconfig
@@ -1,15 +1,15 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc1 3# Linux kernel version: 2.6.31-rc4
4# Wed Apr 8 11:06:37 2009 4# Tue Jul 28 14:11:34 2009
5# 5#
6CONFIG_ARM=y 6CONFIG_ARM=y
7CONFIG_HAVE_PWM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y 8CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y 9CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y 10CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_CLOCKEVENTS=y 11CONFIG_GENERIC_CLOCKEVENTS=y
11CONFIG_MMU=y 12CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y 13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y 14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_HAVE_LATENCYTOP_SUPPORT=y 15CONFIG_HAVE_LATENCYTOP_SUPPORT=y
@@ -18,14 +18,13 @@ CONFIG_TRACE_IRQFLAGS_SUPPORT=y
18CONFIG_HARDIRQS_SW_RESEND=y 18CONFIG_HARDIRQS_SW_RESEND=y
19CONFIG_GENERIC_IRQ_PROBE=y 19CONFIG_GENERIC_IRQ_PROBE=y
20CONFIG_RWSEM_GENERIC_SPINLOCK=y 20CONFIG_RWSEM_GENERIC_SPINLOCK=y
21# CONFIG_ARCH_HAS_ILOG2_U32 is not set
22# CONFIG_ARCH_HAS_ILOG2_U64 is not set
23CONFIG_GENERIC_HWEIGHT=y 21CONFIG_GENERIC_HWEIGHT=y
24CONFIG_GENERIC_CALIBRATE_DELAY=y 22CONFIG_GENERIC_CALIBRATE_DELAY=y
25CONFIG_ARCH_MTD_XIP=y 23CONFIG_ARCH_MTD_XIP=y
26CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 24CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
27CONFIG_VECTORS_BASE=0xffff0000 25CONFIG_VECTORS_BASE=0xffff0000
28CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 26CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
27CONFIG_CONSTRUCTORS=y
29 28
30# 29#
31# General setup 30# General setup
@@ -86,7 +85,12 @@ CONFIG_TIMERFD=y
86CONFIG_EVENTFD=y 85CONFIG_EVENTFD=y
87CONFIG_SHMEM=y 86CONFIG_SHMEM=y
88CONFIG_AIO=y 87CONFIG_AIO=y
88
89#
90# Performance Counters
91#
89CONFIG_VM_EVENT_COUNTERS=y 92CONFIG_VM_EVENT_COUNTERS=y
93# CONFIG_STRIP_ASM_SYMS is not set
90CONFIG_COMPAT_BRK=y 94CONFIG_COMPAT_BRK=y
91CONFIG_SLAB=y 95CONFIG_SLAB=y
92# CONFIG_SLUB is not set 96# CONFIG_SLUB is not set
@@ -97,6 +101,11 @@ CONFIG_HAVE_OPROFILE=y
97# CONFIG_KPROBES is not set 101# CONFIG_KPROBES is not set
98CONFIG_HAVE_KPROBES=y 102CONFIG_HAVE_KPROBES=y
99CONFIG_HAVE_KRETPROBES=y 103CONFIG_HAVE_KRETPROBES=y
104CONFIG_HAVE_CLK=y
105
106#
107# GCOV-based kernel profiling
108#
100# CONFIG_SLOW_WORK is not set 109# CONFIG_SLOW_WORK is not set
101CONFIG_HAVE_GENERIC_DMA_COHERENT=y 110CONFIG_HAVE_GENERIC_DMA_COHERENT=y
102CONFIG_SLABINFO=y 111CONFIG_SLABINFO=y
@@ -109,7 +118,7 @@ CONFIG_MODULE_FORCE_UNLOAD=y
109CONFIG_MODVERSIONS=y 118CONFIG_MODVERSIONS=y
110# CONFIG_MODULE_SRCVERSION_ALL is not set 119# CONFIG_MODULE_SRCVERSION_ALL is not set
111CONFIG_BLOCK=y 120CONFIG_BLOCK=y
112# CONFIG_LBD is not set 121CONFIG_LBDAF=y
113# CONFIG_BLK_DEV_BSG is not set 122# CONFIG_BLK_DEV_BSG is not set
114# CONFIG_BLK_DEV_INTEGRITY is not set 123# CONFIG_BLK_DEV_INTEGRITY is not set
115 124
@@ -136,13 +145,14 @@ CONFIG_FREEZER=y
136# CONFIG_ARCH_VERSATILE is not set 145# CONFIG_ARCH_VERSATILE is not set
137# CONFIG_ARCH_AT91 is not set 146# CONFIG_ARCH_AT91 is not set
138# CONFIG_ARCH_CLPS711X is not set 147# CONFIG_ARCH_CLPS711X is not set
148# CONFIG_ARCH_GEMINI is not set
139# CONFIG_ARCH_EBSA110 is not set 149# CONFIG_ARCH_EBSA110 is not set
140# CONFIG_ARCH_EP93XX is not set 150# CONFIG_ARCH_EP93XX is not set
141# CONFIG_ARCH_GEMINI is not set
142# CONFIG_ARCH_FOOTBRIDGE is not set 151# CONFIG_ARCH_FOOTBRIDGE is not set
152CONFIG_ARCH_MXC=y
153# CONFIG_ARCH_STMP3XXX is not set
143# CONFIG_ARCH_NETX is not set 154# CONFIG_ARCH_NETX is not set
144# CONFIG_ARCH_H720X is not set 155# CONFIG_ARCH_H720X is not set
145# CONFIG_ARCH_IMX is not set
146# CONFIG_ARCH_IOP13XX is not set 156# CONFIG_ARCH_IOP13XX is not set
147# CONFIG_ARCH_IOP32X is not set 157# CONFIG_ARCH_IOP32X is not set
148# CONFIG_ARCH_IOP33X is not set 158# CONFIG_ARCH_IOP33X is not set
@@ -151,25 +161,25 @@ CONFIG_FREEZER=y
151# CONFIG_ARCH_IXP4XX is not set 161# CONFIG_ARCH_IXP4XX is not set
152# CONFIG_ARCH_L7200 is not set 162# CONFIG_ARCH_L7200 is not set
153# CONFIG_ARCH_KIRKWOOD is not set 163# CONFIG_ARCH_KIRKWOOD is not set
154# CONFIG_ARCH_KS8695 is not set
155# CONFIG_ARCH_NS9XXX is not set
156# CONFIG_ARCH_LOKI is not set 164# CONFIG_ARCH_LOKI is not set
157# CONFIG_ARCH_MV78XX0 is not set 165# CONFIG_ARCH_MV78XX0 is not set
158CONFIG_ARCH_MXC=y
159# CONFIG_ARCH_ORION5X is not set 166# CONFIG_ARCH_ORION5X is not set
167# CONFIG_ARCH_MMP is not set
168# CONFIG_ARCH_KS8695 is not set
169# CONFIG_ARCH_NS9XXX is not set
170# CONFIG_ARCH_W90X900 is not set
160# CONFIG_ARCH_PNX4008 is not set 171# CONFIG_ARCH_PNX4008 is not set
161# CONFIG_ARCH_PXA is not set 172# CONFIG_ARCH_PXA is not set
162# CONFIG_ARCH_MMP is not set 173# CONFIG_ARCH_MSM is not set
163# CONFIG_ARCH_RPC is not set 174# CONFIG_ARCH_RPC is not set
164# CONFIG_ARCH_SA1100 is not set 175# CONFIG_ARCH_SA1100 is not set
165# CONFIG_ARCH_S3C2410 is not set 176# CONFIG_ARCH_S3C2410 is not set
166# CONFIG_ARCH_S3C64XX is not set 177# CONFIG_ARCH_S3C64XX is not set
167# CONFIG_ARCH_SHARK is not set 178# CONFIG_ARCH_SHARK is not set
168# CONFIG_ARCH_LH7A40X is not set 179# CONFIG_ARCH_LH7A40X is not set
180# CONFIG_ARCH_U300 is not set
169# CONFIG_ARCH_DAVINCI is not set 181# CONFIG_ARCH_DAVINCI is not set
170# CONFIG_ARCH_OMAP is not set 182# CONFIG_ARCH_OMAP is not set
171# CONFIG_ARCH_MSM is not set
172# CONFIG_ARCH_W90X900 is not set
173 183
174# 184#
175# Freescale MXC Implementations 185# Freescale MXC Implementations
@@ -178,6 +188,7 @@ CONFIG_ARCH_MXC=y
178# CONFIG_ARCH_MX2 is not set 188# CONFIG_ARCH_MX2 is not set
179CONFIG_ARCH_MX3=y 189CONFIG_ARCH_MX3=y
180CONFIG_ARCH_MX31=y 190CONFIG_ARCH_MX31=y
191CONFIG_ARCH_MX35=y
181 192
182# 193#
183# MX3 platforms: 194# MX3 platforms:
@@ -185,12 +196,19 @@ CONFIG_ARCH_MX31=y
185CONFIG_MACH_MX31ADS=y 196CONFIG_MACH_MX31ADS=y
186CONFIG_MACH_MX31ADS_WM1133_EV1=y 197CONFIG_MACH_MX31ADS_WM1133_EV1=y
187CONFIG_MACH_PCM037=y 198CONFIG_MACH_PCM037=y
199CONFIG_MACH_PCM037_EET=y
188CONFIG_MACH_MX31LITE=y 200CONFIG_MACH_MX31LITE=y
189CONFIG_MACH_MX31_3DS=y 201CONFIG_MACH_MX31_3DS=y
190CONFIG_MACH_MX31MOBOARD=y 202CONFIG_MACH_MX31MOBOARD=y
203CONFIG_MACH_MX31LILLY=y
191CONFIG_MACH_QONG=y 204CONFIG_MACH_QONG=y
205CONFIG_MACH_PCM043=y
206CONFIG_MACH_ARMADILLO5X0=y
207CONFIG_MACH_MX35_3DS=y
192CONFIG_MXC_IRQ_PRIOR=y 208CONFIG_MXC_IRQ_PRIOR=y
193CONFIG_MXC_PWM=y 209CONFIG_MXC_PWM=y
210CONFIG_ARCH_HAS_RNGA=y
211CONFIG_ARCH_MXC_IOMUX_V3=y
194 212
195# 213#
196# Processor Type 214# Processor Type
@@ -218,6 +236,7 @@ CONFIG_ARM_THUMB=y
218# CONFIG_CPU_BPREDICT_DISABLE is not set 236# CONFIG_CPU_BPREDICT_DISABLE is not set
219CONFIG_OUTER_CACHE=y 237CONFIG_OUTER_CACHE=y
220CONFIG_CACHE_L2X0=y 238CONFIG_CACHE_L2X0=y
239# CONFIG_ARM_ERRATA_411920 is not set
221CONFIG_COMMON_CLKDEV=y 240CONFIG_COMMON_CLKDEV=y
222 241
223# 242#
@@ -242,7 +261,6 @@ CONFIG_PREEMPT=y
242CONFIG_HZ=100 261CONFIG_HZ=100
243CONFIG_AEABI=y 262CONFIG_AEABI=y
244CONFIG_OABI_COMPAT=y 263CONFIG_OABI_COMPAT=y
245CONFIG_ARCH_FLATMEM_HAS_HOLES=y
246# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set 264# CONFIG_ARCH_SPARSEMEM_DEFAULT is not set
247# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set 265# CONFIG_ARCH_SELECT_MEMORY_MODEL is not set
248# CONFIG_HIGHMEM is not set 266# CONFIG_HIGHMEM is not set
@@ -257,10 +275,11 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
257# CONFIG_PHYS_ADDR_T_64BIT is not set 275# CONFIG_PHYS_ADDR_T_64BIT is not set
258CONFIG_ZONE_DMA_FLAG=0 276CONFIG_ZONE_DMA_FLAG=0
259CONFIG_VIRT_TO_BUS=y 277CONFIG_VIRT_TO_BUS=y
260CONFIG_UNEVICTABLE_LRU=y
261CONFIG_HAVE_MLOCK=y 278CONFIG_HAVE_MLOCK=y
262CONFIG_HAVE_MLOCKED_PAGE_BIT=y 279CONFIG_HAVE_MLOCKED_PAGE_BIT=y
280CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
263CONFIG_ALIGNMENT_TRAP=y 281CONFIG_ALIGNMENT_TRAP=y
282# CONFIG_UACCESS_WITH_MEMCPY is not set
264 283
265# 284#
266# Boot options 285# Boot options
@@ -362,6 +381,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
362# CONFIG_ECONET is not set 381# CONFIG_ECONET is not set
363# CONFIG_WAN_ROUTER is not set 382# CONFIG_WAN_ROUTER is not set
364# CONFIG_PHONET is not set 383# CONFIG_PHONET is not set
384# CONFIG_IEEE802154 is not set
365# CONFIG_NET_SCHED is not set 385# CONFIG_NET_SCHED is not set
366# CONFIG_DCB is not set 386# CONFIG_DCB is not set
367 387
@@ -465,7 +485,16 @@ CONFIG_MTD_PHYSMAP=y
465# CONFIG_MTD_DOC2000 is not set 485# CONFIG_MTD_DOC2000 is not set
466# CONFIG_MTD_DOC2001 is not set 486# CONFIG_MTD_DOC2001 is not set
467# CONFIG_MTD_DOC2001PLUS is not set 487# CONFIG_MTD_DOC2001PLUS is not set
468# CONFIG_MTD_NAND is not set 488CONFIG_MTD_NAND=y
489# CONFIG_MTD_NAND_VERIFY_WRITE is not set
490# CONFIG_MTD_NAND_ECC_SMC is not set
491# CONFIG_MTD_NAND_MUSEUM_IDS is not set
492# CONFIG_MTD_NAND_GPIO is not set
493CONFIG_MTD_NAND_IDS=y
494# CONFIG_MTD_NAND_DISKONCHIP is not set
495# CONFIG_MTD_NAND_NANDSIM is not set
496# CONFIG_MTD_NAND_PLATFORM is not set
497CONFIG_MTD_NAND_MXC=y
469# CONFIG_MTD_ONENAND is not set 498# CONFIG_MTD_ONENAND is not set
470 499
471# 500#
@@ -476,10 +505,30 @@ CONFIG_MTD_PHYSMAP=y
476# 505#
477# UBI - Unsorted block images 506# UBI - Unsorted block images
478# 507#
479# CONFIG_MTD_UBI is not set 508CONFIG_MTD_UBI=y
509CONFIG_MTD_UBI_WL_THRESHOLD=4096
510CONFIG_MTD_UBI_BEB_RESERVE=1
511# CONFIG_MTD_UBI_GLUEBI is not set
512
513#
514# UBI debugging options
515#
516# CONFIG_MTD_UBI_DEBUG is not set
480# CONFIG_PARPORT is not set 517# CONFIG_PARPORT is not set
481# CONFIG_BLK_DEV is not set 518# CONFIG_BLK_DEV is not set
482# CONFIG_MISC_DEVICES is not set 519CONFIG_MISC_DEVICES=y
520# CONFIG_ICS932S401 is not set
521# CONFIG_ENCLOSURE_SERVICES is not set
522# CONFIG_ISL29003 is not set
523# CONFIG_C2PORT is not set
524
525#
526# EEPROM support
527#
528CONFIG_EEPROM_AT24=y
529# CONFIG_EEPROM_LEGACY is not set
530# CONFIG_EEPROM_MAX6875 is not set
531# CONFIG_EEPROM_93CX6 is not set
483CONFIG_HAVE_IDE=y 532CONFIG_HAVE_IDE=y
484# CONFIG_IDE is not set 533# CONFIG_IDE is not set
485 534
@@ -493,7 +542,6 @@ CONFIG_HAVE_IDE=y
493# CONFIG_ATA is not set 542# CONFIG_ATA is not set
494# CONFIG_MD is not set 543# CONFIG_MD is not set
495CONFIG_NETDEVICES=y 544CONFIG_NETDEVICES=y
496CONFIG_COMPAT_NET_DEV_OPS=y
497# CONFIG_DUMMY is not set 545# CONFIG_DUMMY is not set
498# CONFIG_BONDING is not set 546# CONFIG_BONDING is not set
499# CONFIG_MACVLAN is not set 547# CONFIG_MACVLAN is not set
@@ -528,7 +576,7 @@ CONFIG_MII=y
528# CONFIG_ETHOC is not set 576# CONFIG_ETHOC is not set
529# CONFIG_SMC911X is not set 577# CONFIG_SMC911X is not set
530CONFIG_SMSC911X=y 578CONFIG_SMSC911X=y
531# CONFIG_DNET is not set 579CONFIG_DNET=y
532# CONFIG_IBM_NEW_EMAC_ZMII is not set 580# CONFIG_IBM_NEW_EMAC_ZMII is not set
533# CONFIG_IBM_NEW_EMAC_RGMII is not set 581# CONFIG_IBM_NEW_EMAC_RGMII is not set
534# CONFIG_IBM_NEW_EMAC_TAH is not set 582# CONFIG_IBM_NEW_EMAC_TAH is not set
@@ -537,8 +585,10 @@ CONFIG_SMSC911X=y
537# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set 585# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
538# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 586# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
539# CONFIG_B44 is not set 587# CONFIG_B44 is not set
540CONFIG_CS89x0=y 588# CONFIG_CS89x0 is not set
541CONFIG_CS89x0_NONISA_IRQ=y 589# CONFIG_KS8842 is not set
590CONFIG_FEC=y
591# CONFIG_FEC2 is not set
542# CONFIG_NETDEV_1000 is not set 592# CONFIG_NETDEV_1000 is not set
543# CONFIG_NETDEV_10000 is not set 593# CONFIG_NETDEV_10000 is not set
544 594
@@ -609,6 +659,7 @@ CONFIG_I2C_HELPER_AUTO=y
609# 659#
610# I2C system bus drivers (mostly embedded / system-on-chip) 660# I2C system bus drivers (mostly embedded / system-on-chip)
611# 661#
662# CONFIG_I2C_DESIGNWARE is not set
612# CONFIG_I2C_GPIO is not set 663# CONFIG_I2C_GPIO is not set
613CONFIG_I2C_IMX=y 664CONFIG_I2C_IMX=y
614# CONFIG_I2C_OCORES is not set 665# CONFIG_I2C_OCORES is not set
@@ -633,7 +684,6 @@ CONFIG_I2C_IMX=y
633# CONFIG_SENSORS_PCF8574 is not set 684# CONFIG_SENSORS_PCF8574 is not set
634# CONFIG_PCF8575 is not set 685# CONFIG_PCF8575 is not set
635# CONFIG_SENSORS_PCA9539 is not set 686# CONFIG_SENSORS_PCA9539 is not set
636# CONFIG_SENSORS_MAX6875 is not set
637# CONFIG_SENSORS_TSL2550 is not set 687# CONFIG_SENSORS_TSL2550 is not set
638# CONFIG_I2C_DEBUG_CORE is not set 688# CONFIG_I2C_DEBUG_CORE is not set
639# CONFIG_I2C_DEBUG_ALGO is not set 689# CONFIG_I2C_DEBUG_ALGO is not set
@@ -669,6 +719,7 @@ CONFIG_W1=y
669# 719#
670# CONFIG_W1_MASTER_DS2482 is not set 720# CONFIG_W1_MASTER_DS2482 is not set
671CONFIG_W1_MASTER_MXC=y 721CONFIG_W1_MASTER_MXC=y
722# CONFIG_W1_MASTER_DS1WM is not set
672# CONFIG_W1_MASTER_GPIO is not set 723# CONFIG_W1_MASTER_GPIO is not set
673 724
674# 725#
@@ -703,6 +754,8 @@ CONFIG_SSB_POSSIBLE=y
703# CONFIG_TPS65010 is not set 754# CONFIG_TPS65010 is not set
704# CONFIG_TWL4030_CORE is not set 755# CONFIG_TWL4030_CORE is not set
705# CONFIG_MFD_TMIO is not set 756# CONFIG_MFD_TMIO is not set
757# CONFIG_MFD_T7L66XB is not set
758# CONFIG_MFD_TC6387XB is not set
706# CONFIG_MFD_TC6393XB is not set 759# CONFIG_MFD_TC6393XB is not set
707# CONFIG_PMIC_DA903X is not set 760# CONFIG_PMIC_DA903X is not set
708# CONFIG_MFD_WM8400 is not set 761# CONFIG_MFD_WM8400 is not set
@@ -711,10 +764,8 @@ CONFIG_MFD_WM8350_CONFIG_MODE_0=y
711CONFIG_MFD_WM8352_CONFIG_MODE_0=y 764CONFIG_MFD_WM8352_CONFIG_MODE_0=y
712CONFIG_MFD_WM8350_I2C=y 765CONFIG_MFD_WM8350_I2C=y
713# CONFIG_MFD_PCF50633 is not set 766# CONFIG_MFD_PCF50633 is not set
714 767# CONFIG_AB3100_CORE is not set
715# 768CONFIG_MEDIA_SUPPORT=y
716# Multimedia devices
717#
718 769
719# 770#
720# Multimedia core support 771# Multimedia core support
@@ -758,8 +809,10 @@ CONFIG_SOC_CAMERA_MT9T031=y
758CONFIG_SOC_CAMERA_MT9V022=y 809CONFIG_SOC_CAMERA_MT9V022=y
759CONFIG_SOC_CAMERA_TW9910=y 810CONFIG_SOC_CAMERA_TW9910=y
760# CONFIG_SOC_CAMERA_PLATFORM is not set 811# CONFIG_SOC_CAMERA_PLATFORM is not set
761# CONFIG_SOC_CAMERA_OV772X is not set 812CONFIG_SOC_CAMERA_OV772X=y
813CONFIG_MX3_VIDEO=y
762CONFIG_VIDEO_MX3=y 814CONFIG_VIDEO_MX3=y
815# CONFIG_VIDEO_SH_MOBILE_CEU is not set
763# CONFIG_RADIO_ADAPTERS is not set 816# CONFIG_RADIO_ADAPTERS is not set
764# CONFIG_DAB is not set 817# CONFIG_DAB is not set
765 818
@@ -847,8 +900,11 @@ CONFIG_REGULATOR=y
847# CONFIG_REGULATOR_DEBUG is not set 900# CONFIG_REGULATOR_DEBUG is not set
848# CONFIG_REGULATOR_FIXED_VOLTAGE is not set 901# CONFIG_REGULATOR_FIXED_VOLTAGE is not set
849# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set 902# CONFIG_REGULATOR_VIRTUAL_CONSUMER is not set
903# CONFIG_REGULATOR_USERSPACE_CONSUMER is not set
850# CONFIG_REGULATOR_BQ24022 is not set 904# CONFIG_REGULATOR_BQ24022 is not set
905# CONFIG_REGULATOR_MAX1586 is not set
851CONFIG_REGULATOR_WM8350=y 906CONFIG_REGULATOR_WM8350=y
907# CONFIG_REGULATOR_LP3971 is not set
852# CONFIG_UIO is not set 908# CONFIG_UIO is not set
853# CONFIG_STAGING is not set 909# CONFIG_STAGING is not set
854 910
@@ -861,10 +917,12 @@ CONFIG_REGULATOR_WM8350=y
861# CONFIG_REISERFS_FS is not set 917# CONFIG_REISERFS_FS is not set
862# CONFIG_JFS_FS is not set 918# CONFIG_JFS_FS is not set
863# CONFIG_FS_POSIX_ACL is not set 919# CONFIG_FS_POSIX_ACL is not set
864CONFIG_FILE_LOCKING=y
865# CONFIG_XFS_FS is not set 920# CONFIG_XFS_FS is not set
921# CONFIG_GFS2_FS is not set
866# CONFIG_OCFS2_FS is not set 922# CONFIG_OCFS2_FS is not set
867# CONFIG_BTRFS_FS is not set 923# CONFIG_BTRFS_FS is not set
924CONFIG_FILE_LOCKING=y
925CONFIG_FSNOTIFY=y
868# CONFIG_DNOTIFY is not set 926# CONFIG_DNOTIFY is not set
869CONFIG_INOTIFY=y 927CONFIG_INOTIFY=y
870CONFIG_INOTIFY_USER=y 928CONFIG_INOTIFY_USER=y
@@ -921,6 +979,12 @@ CONFIG_JFFS2_ZLIB=y
921# CONFIG_JFFS2_LZO is not set 979# CONFIG_JFFS2_LZO is not set
922CONFIG_JFFS2_RTIME=y 980CONFIG_JFFS2_RTIME=y
923# CONFIG_JFFS2_RUBIN is not set 981# CONFIG_JFFS2_RUBIN is not set
982CONFIG_UBIFS_FS=y
983# CONFIG_UBIFS_FS_XATTR is not set
984# CONFIG_UBIFS_FS_ADVANCED_COMPR is not set
985CONFIG_UBIFS_FS_LZO=y
986CONFIG_UBIFS_FS_ZLIB=y
987# CONFIG_UBIFS_FS_DEBUG is not set
924# CONFIG_CRAMFS is not set 988# CONFIG_CRAMFS is not set
925# CONFIG_SQUASHFS is not set 989# CONFIG_SQUASHFS is not set
926# CONFIG_VXFS_FS is not set 990# CONFIG_VXFS_FS is not set
@@ -937,6 +1001,7 @@ CONFIG_NFS_FS=y
937CONFIG_NFS_V3=y 1001CONFIG_NFS_V3=y
938# CONFIG_NFS_V3_ACL is not set 1002# CONFIG_NFS_V3_ACL is not set
939CONFIG_NFS_V4=y 1003CONFIG_NFS_V4=y
1004# CONFIG_NFS_V4_1 is not set
940CONFIG_ROOT_NFS=y 1005CONFIG_ROOT_NFS=y
941# CONFIG_NFSD is not set 1006# CONFIG_NFSD is not set
942CONFIG_LOCKD=y 1007CONFIG_LOCKD=y
@@ -979,22 +1044,7 @@ CONFIG_FRAME_WARN=1024
979CONFIG_SYSCTL_SYSCALL_CHECK=y 1044CONFIG_SYSCTL_SYSCALL_CHECK=y
980CONFIG_HAVE_FUNCTION_TRACER=y 1045CONFIG_HAVE_FUNCTION_TRACER=y
981CONFIG_TRACING_SUPPORT=y 1046CONFIG_TRACING_SUPPORT=y
982 1047# CONFIG_FTRACE is not set
983#
984# Tracers
985#
986# CONFIG_FUNCTION_TRACER is not set
987# CONFIG_IRQSOFF_TRACER is not set
988# CONFIG_PREEMPT_TRACER is not set
989# CONFIG_SCHED_TRACER is not set
990# CONFIG_CONTEXT_SWITCH_TRACER is not set
991# CONFIG_EVENT_TRACER is not set
992# CONFIG_BOOT_TRACER is not set
993# CONFIG_TRACE_BRANCH_PROFILING is not set
994# CONFIG_STACK_TRACER is not set
995# CONFIG_KMEMTRACE is not set
996# CONFIG_WORKQUEUE_TRACER is not set
997# CONFIG_BLK_DEV_IO_TRACE is not set
998# CONFIG_SAMPLES is not set 1048# CONFIG_SAMPLES is not set
999CONFIG_HAVE_ARCH_KGDB=y 1049CONFIG_HAVE_ARCH_KGDB=y
1000CONFIG_ARM_UNWIND=y 1050CONFIG_ARM_UNWIND=y
@@ -1094,9 +1144,9 @@ CONFIG_CRYPTO_DES=y
1094# 1144#
1095# Compression 1145# Compression
1096# 1146#
1097# CONFIG_CRYPTO_DEFLATE is not set 1147CONFIG_CRYPTO_DEFLATE=y
1098# CONFIG_CRYPTO_ZLIB is not set 1148# CONFIG_CRYPTO_ZLIB is not set
1099# CONFIG_CRYPTO_LZO is not set 1149CONFIG_CRYPTO_LZO=y
1100 1150
1101# 1151#
1102# Random Number Generation 1152# Random Number Generation
@@ -1109,9 +1159,10 @@ CONFIG_CRYPTO_HW=y
1109# Library routines 1159# Library routines
1110# 1160#
1111CONFIG_BITREVERSE=y 1161CONFIG_BITREVERSE=y
1162CONFIG_RATIONAL=y
1112CONFIG_GENERIC_FIND_LAST_BIT=y 1163CONFIG_GENERIC_FIND_LAST_BIT=y
1113# CONFIG_CRC_CCITT is not set 1164# CONFIG_CRC_CCITT is not set
1114# CONFIG_CRC16 is not set 1165CONFIG_CRC16=y
1115# CONFIG_CRC_T10DIF is not set 1166# CONFIG_CRC_T10DIF is not set
1116# CONFIG_CRC_ITU_T is not set 1167# CONFIG_CRC_ITU_T is not set
1117CONFIG_CRC32=y 1168CONFIG_CRC32=y
@@ -1119,6 +1170,8 @@ CONFIG_CRC32=y
1119# CONFIG_LIBCRC32C is not set 1170# CONFIG_LIBCRC32C is not set
1120CONFIG_ZLIB_INFLATE=y 1171CONFIG_ZLIB_INFLATE=y
1121CONFIG_ZLIB_DEFLATE=y 1172CONFIG_ZLIB_DEFLATE=y
1173CONFIG_LZO_COMPRESS=y
1174CONFIG_LZO_DECOMPRESS=y
1122CONFIG_HAS_IOMEM=y 1175CONFIG_HAS_IOMEM=y
1123CONFIG_HAS_IOPORT=y 1176CONFIG_HAS_IOPORT=y
1124CONFIG_HAS_DMA=y 1177CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/omap3_evm_defconfig b/arch/arm/configs/omap3_evm_defconfig
index 28be17fbc157..d5ff4776cd0a 100644
--- a/arch/arm/configs/omap3_evm_defconfig
+++ b/arch/arm/configs/omap3_evm_defconfig
@@ -1107,7 +1107,7 @@ CONFIG_USB_ZERO=m
1107CONFIG_USB_OTG_UTILS=y 1107CONFIG_USB_OTG_UTILS=y
1108# CONFIG_USB_GPIO_VBUS is not set 1108# CONFIG_USB_GPIO_VBUS is not set
1109# CONFIG_ISP1301_OMAP is not set 1109# CONFIG_ISP1301_OMAP is not set
1110CONFIG_TWL4030_USB=y 1110# CONFIG_TWL4030_USB is not set
1111# CONFIG_NOP_USB_XCEIV is not set 1111# CONFIG_NOP_USB_XCEIV is not set
1112CONFIG_MMC=y 1112CONFIG_MMC=y
1113# CONFIG_MMC_DEBUG is not set 1113# CONFIG_MMC_DEBUG is not set
diff --git a/arch/arm/configs/rx51_defconfig b/arch/arm/configs/rx51_defconfig
index eb2cb31825c0..f238df66efd4 100644
--- a/arch/arm/configs/rx51_defconfig
+++ b/arch/arm/configs/rx51_defconfig
@@ -282,7 +282,7 @@ CONFIG_ALIGNMENT_TRAP=y
282# 282#
283CONFIG_ZBOOT_ROM_TEXT=0x0 283CONFIG_ZBOOT_ROM_TEXT=0x0
284CONFIG_ZBOOT_ROM_BSS=0x0 284CONFIG_ZBOOT_ROM_BSS=0x0
285CONFIG_CMDLINE="init=/sbin/preinit ubi.mtd=rootfs root=ubi0:rootfs rootfstype=ubifs rootflags=bulk_read,no_chk_data_crc rw console=ttyMTD,log console=tty0" 285CONFIG_CMDLINE="init=/sbin/preinit ubi.mtd=rootfs root=ubi0:rootfs rootfstype=ubifs rootflags=bulk_read,no_chk_data_crc rw console=ttyMTD,log console=tty0 console=ttyS2,115200n8"
286# CONFIG_XIP_KERNEL is not set 286# CONFIG_XIP_KERNEL is not set
287# CONFIG_KEXEC is not set 287# CONFIG_KEXEC is not set
288 288
@@ -1354,7 +1354,7 @@ CONFIG_USB_OTG_UTILS=y
1354# CONFIG_USB_GPIO_VBUS is not set 1354# CONFIG_USB_GPIO_VBUS is not set
1355# CONFIG_ISP1301_OMAP is not set 1355# CONFIG_ISP1301_OMAP is not set
1356CONFIG_TWL4030_USB=y 1356CONFIG_TWL4030_USB=y
1357CONFIG_MMC=m 1357CONFIG_MMC=y
1358# CONFIG_MMC_DEBUG is not set 1358# CONFIG_MMC_DEBUG is not set
1359# CONFIG_MMC_UNSAFE_RESUME is not set 1359# CONFIG_MMC_UNSAFE_RESUME is not set
1360 1360
@@ -1449,7 +1449,8 @@ CONFIG_RTC_DRV_TWL4030=m
1449# on-CPU RTC drivers 1449# on-CPU RTC drivers
1450# 1450#
1451# CONFIG_DMADEVICES is not set 1451# CONFIG_DMADEVICES is not set
1452# CONFIG_REGULATOR is not set 1452CONFIG_REGULATOR=y
1453CONFIG_REGULATOR_TWL4030=y
1453# CONFIG_UIO is not set 1454# CONFIG_UIO is not set
1454# CONFIG_STAGING is not set 1455# CONFIG_STAGING is not set
1455 1456
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 9e07fe507029..9ed2377fe8e5 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -159,8 +159,6 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
159 159
160#else /* ARM_ARCH_6 */ 160#else /* ARM_ARCH_6 */
161 161
162#include <asm/system.h>
163
164#ifdef CONFIG_SMP 162#ifdef CONFIG_SMP
165#error SMP not supported on pre-ARMv6 CPUs 163#error SMP not supported on pre-ARMv6 CPUs
166#endif 164#endif
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 376be1a62866..cefedf062138 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -218,7 +218,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
218 * 218 *
219 * page_to_pfn(page) convert a struct page * to a PFN number 219 * page_to_pfn(page) convert a struct page * to a PFN number
220 * pfn_to_page(pfn) convert a _valid_ PFN number to struct page * 220 * pfn_to_page(pfn) convert a _valid_ PFN number to struct page *
221 * pfn_valid(pfn) indicates whether a PFN number is valid
222 * 221 *
223 * virt_to_page(k) convert a _valid_ virtual address to struct page * 222 * virt_to_page(k) convert a _valid_ virtual address to struct page *
224 * virt_addr_valid(k) indicates whether a virtual address is valid 223 * virt_addr_valid(k) indicates whether a virtual address is valid
@@ -227,10 +226,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
227 226
228#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET 227#define ARCH_PFN_OFFSET PHYS_PFN_OFFSET
229 228
230#ifndef CONFIG_SPARSEMEM
231#define pfn_valid(pfn) ((pfn) >= PHYS_PFN_OFFSET && (pfn) < (PHYS_PFN_OFFSET + max_mapnr))
232#endif
233
234#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT) 229#define virt_to_page(kaddr) pfn_to_page(__pa(kaddr) >> PAGE_SHIFT)
235#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory) 230#define virt_addr_valid(kaddr) ((unsigned long)(kaddr) >= PAGE_OFFSET && (unsigned long)(kaddr) < (unsigned long)high_memory)
236 231
@@ -247,18 +242,6 @@ static inline __deprecated void *bus_to_virt(unsigned long x)
247#define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn) 242#define arch_pfn_to_nid(pfn) PFN_TO_NID(pfn)
248#define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT) 243#define arch_local_page_offset(pfn, nid) LOCAL_MAP_NR((pfn) << PAGE_SHIFT)
249 244
250#define pfn_valid(pfn) \
251 ({ \
252 unsigned int nid = PFN_TO_NID(pfn); \
253 int valid = nid < MAX_NUMNODES; \
254 if (valid) { \
255 pg_data_t *node = NODE_DATA(nid); \
256 valid = (pfn - node->node_start_pfn) < \
257 node->node_spanned_pages; \
258 } \
259 valid; \
260 })
261
262#define virt_to_page(kaddr) \ 245#define virt_to_page(kaddr) \
263 (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr)) 246 (ADDR_TO_MAPBASE(kaddr) + LOCAL_MAP_NR(kaddr))
264 247
diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
index 9c746af1bf6e..3a32af4cce30 100644
--- a/arch/arm/include/asm/page.h
+++ b/arch/arm/include/asm/page.h
@@ -194,6 +194,10 @@ typedef unsigned long pgprot_t;
194 194
195typedef struct page *pgtable_t; 195typedef struct page *pgtable_t;
196 196
197#ifndef CONFIG_SPARSEMEM
198extern int pfn_valid(unsigned long);
199#endif
200
197#include <asm/memory.h> 201#include <asm/memory.h>
198 202
199#endif /* !__ASSEMBLY__ */ 203#endif /* !__ASSEMBLY__ */
diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index ee1304f22f94..5ccce0a9b03c 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -201,7 +201,8 @@ static struct tagtable __tagtable_##fn __tag = { tag, fn }
201struct membank { 201struct membank {
202 unsigned long start; 202 unsigned long start;
203 unsigned long size; 203 unsigned long size;
204 int node; 204 unsigned short node;
205 unsigned short highmem;
205}; 206};
206 207
207struct meminfo { 208struct meminfo {
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 3657c5328a5b..c71818bdf2cc 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -153,7 +153,7 @@ trace:
153 sub r0, r0, #MCOUNT_INSN_SIZE 153 sub r0, r0, #MCOUNT_INSN_SIZE
154 mov lr, pc 154 mov lr, pc
155 mov pc, r2 155 mov pc, r2
156 mov lr, r1 @ restore lr 156 ldr lr, [fp, #-4] @ restore lr
157 ldmia sp!, {r0-r3, pc} 157 ldmia sp!, {r0-r3, pc}
158 158
159#endif /* CONFIG_DYNAMIC_FTRACE */ 159#endif /* CONFIG_DYNAMIC_FTRACE */
diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
index e27ee1f701d5..f7194e44d5a9 100644
--- a/arch/arm/kernel/signal.c
+++ b/arch/arm/kernel/signal.c
@@ -98,7 +98,7 @@ sys_sigaction(int sig, const struct old_sigaction __user *act,
98} 98}
99 99
100#ifdef CONFIG_CRUNCH 100#ifdef CONFIG_CRUNCH
101static int preserve_crunch_context(struct crunch_sigframe *frame) 101static int preserve_crunch_context(struct crunch_sigframe __user *frame)
102{ 102{
103 char kbuf[sizeof(*frame) + 8]; 103 char kbuf[sizeof(*frame) + 8];
104 struct crunch_sigframe *kframe; 104 struct crunch_sigframe *kframe;
@@ -111,7 +111,7 @@ static int preserve_crunch_context(struct crunch_sigframe *frame)
111 return __copy_to_user(frame, kframe, sizeof(*frame)); 111 return __copy_to_user(frame, kframe, sizeof(*frame));
112} 112}
113 113
114static int restore_crunch_context(struct crunch_sigframe *frame) 114static int restore_crunch_context(struct crunch_sigframe __user *frame)
115{ 115{
116 char kbuf[sizeof(*frame) + 8]; 116 char kbuf[sizeof(*frame) + 8];
117 struct crunch_sigframe *kframe; 117 struct crunch_sigframe *kframe;
diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c
index 5ac2f565d860..d6ab64ccd496 100644
--- a/arch/arm/mach-davinci/board-dm355-evm.c
+++ b/arch/arm/mach-davinci/board-dm355-evm.c
@@ -37,7 +37,6 @@
37#include <mach/serial.h> 37#include <mach/serial.h>
38#include <mach/nand.h> 38#include <mach/nand.h>
39#include <mach/mmc.h> 39#include <mach/mmc.h>
40#include <mach/common.h>
41 40
42#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000 41#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
43#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 42#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c
index 28c9008df4f4..84ad5d161a87 100644
--- a/arch/arm/mach-davinci/board-dm355-leopard.c
+++ b/arch/arm/mach-davinci/board-dm355-leopard.c
@@ -36,7 +36,6 @@
36#include <mach/serial.h> 36#include <mach/serial.h>
37#include <mach/nand.h> 37#include <mach/nand.h>
38#include <mach/mmc.h> 38#include <mach/mmc.h>
39#include <mach/common.h>
40 39
41#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000 40#define DAVINCI_ASYNC_EMIF_CONTROL_BASE 0x01e10000
42#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 41#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000
diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c
index d9d40450bdc5..56c8cd01de9a 100644
--- a/arch/arm/mach-davinci/board-dm644x-evm.c
+++ b/arch/arm/mach-davinci/board-dm644x-evm.c
@@ -45,7 +45,6 @@
45#include <mach/nand.h> 45#include <mach/nand.h>
46#include <mach/mmc.h> 46#include <mach/mmc.h>
47#include <mach/emac.h> 47#include <mach/emac.h>
48#include <mach/common.h>
49 48
50#define DM644X_EVM_PHY_MASK (0x2) 49#define DM644X_EVM_PHY_MASK (0x2)
51#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ 50#define DM644X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c
index e17de6352624..8657e72debc1 100644
--- a/arch/arm/mach-davinci/board-dm646x-evm.c
+++ b/arch/arm/mach-davinci/board-dm646x-evm.c
@@ -47,7 +47,6 @@
47#include <mach/i2c.h> 47#include <mach/i2c.h>
48#include <mach/mmc.h> 48#include <mach/mmc.h>
49#include <mach/emac.h> 49#include <mach/emac.h>
50#include <mach/common.h>
51 50
52#define DM646X_EVM_PHY_MASK (0x2) 51#define DM646X_EVM_PHY_MASK (0x2)
53#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ 52#define DM646X_EVM_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c
index 748a8e48541e..7acdfd8ac071 100644
--- a/arch/arm/mach-davinci/board-sffsdr.c
+++ b/arch/arm/mach-davinci/board-sffsdr.c
@@ -52,7 +52,6 @@
52#include <mach/serial.h> 52#include <mach/serial.h>
53#include <mach/psc.h> 53#include <mach/psc.h>
54#include <mach/mux.h> 54#include <mach/mux.h>
55#include <mach/common.h>
56 55
57#define SFFSDR_PHY_MASK (0x2) 56#define SFFSDR_PHY_MASK (0x2)
58#define SFFSDR_MDIO_FREQUENCY (2200000) /* PHY bus frequency */ 57#define SFFSDR_MDIO_FREQUENCY (2200000) /* PHY bus frequency */
diff --git a/arch/arm/mach-ep93xx/include/mach/ts72xx.h b/arch/arm/mach-ep93xx/include/mach/ts72xx.h
index 2737666e800e..3bd934e9a7f1 100644
--- a/arch/arm/mach-ep93xx/include/mach/ts72xx.h
+++ b/arch/arm/mach-ep93xx/include/mach/ts72xx.h
@@ -41,9 +41,6 @@
41#define TS72XX_OPTIONS2_TS9420_BOOT 0x02 41#define TS72XX_OPTIONS2_TS9420_BOOT 0x02
42 42
43 43
44#define TS72XX_NOR_PHYS_BASE 0x60000000
45#define TS72XX_NOR2_PHYS_BASE 0x62000000
46
47#define TS72XX_NAND1_DATA_PHYS_BASE 0x60000000 44#define TS72XX_NAND1_DATA_PHYS_BASE 0x60000000
48#define TS72XX_NAND2_DATA_PHYS_BASE 0x70000000 45#define TS72XX_NAND2_DATA_PHYS_BASE 0x70000000
49#define TS72XX_NAND_DATA_VIRT_BASE 0xfebfc000 46#define TS72XX_NAND_DATA_VIRT_BASE 0xfebfc000
diff --git a/arch/arm/mach-ep93xx/ts72xx.c b/arch/arm/mach-ep93xx/ts72xx.c
index 5255dddd3067..259f7822ba52 100644
--- a/arch/arm/mach-ep93xx/ts72xx.c
+++ b/arch/arm/mach-ep93xx/ts72xx.c
@@ -111,13 +111,16 @@ static void __init ts72xx_map_io(void)
111 } 111 }
112} 112}
113 113
114/*************************************************************************
115 * NOR flash (TS-7200 only)
116 *************************************************************************/
114static struct physmap_flash_data ts72xx_flash_data = { 117static struct physmap_flash_data ts72xx_flash_data = {
115 .width = 1, 118 .width = 2,
116}; 119};
117 120
118static struct resource ts72xx_flash_resource = { 121static struct resource ts72xx_flash_resource = {
119 .start = TS72XX_NOR_PHYS_BASE, 122 .start = EP93XX_CS6_PHYS_BASE,
120 .end = TS72XX_NOR_PHYS_BASE + SZ_16M - 1, 123 .end = EP93XX_CS6_PHYS_BASE + SZ_16M - 1,
121 .flags = IORESOURCE_MEM, 124 .flags = IORESOURCE_MEM,
122}; 125};
123 126
@@ -131,6 +134,12 @@ static struct platform_device ts72xx_flash = {
131 .resource = &ts72xx_flash_resource, 134 .resource = &ts72xx_flash_resource,
132}; 135};
133 136
137static void __init ts72xx_register_flash(void)
138{
139 if (board_is_ts7200())
140 platform_device_register(&ts72xx_flash);
141}
142
134static unsigned char ts72xx_rtc_readbyte(unsigned long addr) 143static unsigned char ts72xx_rtc_readbyte(unsigned long addr)
135{ 144{
136 __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE); 145 __raw_writeb(addr, TS72XX_RTC_INDEX_VIRT_BASE);
@@ -164,8 +173,7 @@ static struct ep93xx_eth_data ts72xx_eth_data = {
164static void __init ts72xx_init_machine(void) 173static void __init ts72xx_init_machine(void)
165{ 174{
166 ep93xx_init_devices(); 175 ep93xx_init_devices();
167 if (board_is_ts7200()) 176 ts72xx_register_flash();
168 platform_device_register(&ts72xx_flash);
169 platform_device_register(&ts72xx_rtc_device); 177 platform_device_register(&ts72xx_rtc_device);
170 178
171 ep93xx_register_eth(&ts72xx_eth_data, 1); 179 ep93xx_register_eth(&ts72xx_eth_data, 1);
diff --git a/arch/arm/mach-ixp4xx/include/mach/io.h b/arch/arm/mach-ixp4xx/include/mach/io.h
index ce63048d45eb..8a947d42a6f1 100644
--- a/arch/arm/mach-ixp4xx/include/mach/io.h
+++ b/arch/arm/mach-ixp4xx/include/mach/io.h
@@ -17,7 +17,7 @@
17 17
18#include <mach/hardware.h> 18#include <mach/hardware.h>
19 19
20#define IO_SPACE_LIMIT 0xffff0000 20#define IO_SPACE_LIMIT 0x0000ffff
21 21
22extern int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data); 22extern int (*ixp4xx_pci_read)(u32 addr, u32 cmd, u32* data);
23extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data); 23extern int ixp4xx_pci_write(u32 addr, u32 cmd, u32 data);
diff --git a/arch/arm/mach-kirkwood/ts219-setup.c b/arch/arm/mach-kirkwood/ts219-setup.c
index 01aa213c0a6f..ec1a64f263d2 100644
--- a/arch/arm/mach-kirkwood/ts219-setup.c
+++ b/arch/arm/mach-kirkwood/ts219-setup.c
@@ -206,6 +206,15 @@ static void __init qnap_ts219_init(void)
206 206
207} 207}
208 208
209static int __init ts219_pci_init(void)
210{
211 if (machine_is_ts219())
212 kirkwood_pcie_init();
213
214 return 0;
215}
216subsys_initcall(ts219_pci_init);
217
209MACHINE_START(TS219, "QNAP TS-119/TS-219") 218MACHINE_START(TS219, "QNAP TS-119/TS-219")
210 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */ 219 /* Maintainer: Martin Michlmayr <tbm@cyrius.com> */
211 .phys_io = KIRKWOOD_REGS_PHYS_BASE, 220 .phys_io = KIRKWOOD_REGS_PHYS_BASE,
diff --git a/arch/arm/mach-ks8695/include/mach/hardware.h b/arch/arm/mach-ks8695/include/mach/hardware.h
index 1d640d075b7e..e0f911d9e021 100644
--- a/arch/arm/mach-ks8695/include/mach/hardware.h
+++ b/arch/arm/mach-ks8695/include/mach/hardware.h
@@ -17,6 +17,11 @@
17#include <asm/sizes.h> 17#include <asm/sizes.h>
18 18
19/* 19/*
20 * Clocks are derived from MCLK, which is 25Mhz
21 */
22#define KS8695_CLOCK_RATE 25000000
23
24/*
20 * Physical RAM address. 25 * Physical RAM address.
21 */ 26 */
22#define KS8695_SDRAM_PA 0x00000000 27#define KS8695_SDRAM_PA 0x00000000
diff --git a/arch/arm/mach-ks8695/include/mach/timex.h b/arch/arm/mach-ks8695/include/mach/timex.h
index 4682e350369b..10f716371bd3 100644
--- a/arch/arm/mach-ks8695/include/mach/timex.h
+++ b/arch/arm/mach-ks8695/include/mach/timex.h
@@ -14,7 +14,8 @@
14#ifndef __ASM_ARCH_TIMEX_H 14#ifndef __ASM_ARCH_TIMEX_H
15#define __ASM_ARCH_TIMEX_H 15#define __ASM_ARCH_TIMEX_H
16 16
17/* timers are derived from MCLK, which is 25MHz */ 17#include <mach/hardware.h>
18#define CLOCK_TICK_RATE 25000000 18
19#define CLOCK_TICK_RATE KS8695_CLOCK_RATE
19 20
20#endif 21#endif
diff --git a/arch/arm/mach-ks8695/pci.c b/arch/arm/mach-ks8695/pci.c
index f5ebcc0fcab9..78499667eb7b 100644
--- a/arch/arm/mach-ks8695/pci.c
+++ b/arch/arm/mach-ks8695/pci.c
@@ -245,6 +245,9 @@ static int ks8695_pci_fault(unsigned long addr, unsigned int fsr, struct pt_regs
245 245
246static void __init ks8695_pci_preinit(void) 246static void __init ks8695_pci_preinit(void)
247{ 247{
248 /* make software reset to avoid freeze if PCI bus was messed up */
249 __raw_writel(0x80000000, KS8695_PCI_VA + KS8695_PBCS);
250
248 /* stage 1 initialization, subid, subdevice = 0x0001 */ 251 /* stage 1 initialization, subid, subdevice = 0x0001 */
249 __raw_writel(0x00010001, KS8695_PCI_VA + KS8695_CRCSID); 252 __raw_writel(0x00010001, KS8695_PCI_VA + KS8695_CRCSID);
250 253
diff --git a/arch/arm/mach-mx3/mx31moboard-devboard.c b/arch/arm/mach-mx3/mx31moboard-devboard.c
index b3e8f251ac79..5592cdb8d0ad 100644
--- a/arch/arm/mach-mx3/mx31moboard-devboard.c
+++ b/arch/arm/mach-mx3/mx31moboard-devboard.c
@@ -50,7 +50,7 @@ static struct imxuart_platform_data uart_pdata = {
50 50
51static int devboard_sdhc2_get_ro(struct device *dev) 51static int devboard_sdhc2_get_ro(struct device *dev)
52{ 52{
53 return gpio_get_value(SDHC2_WP); 53 return !gpio_get_value(SDHC2_WP);
54} 54}
55 55
56static int devboard_sdhc2_init(struct device *dev, irq_handler_t detect_irq, 56static int devboard_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
diff --git a/arch/arm/mach-mx3/mx31moboard-marxbot.c b/arch/arm/mach-mx3/mx31moboard-marxbot.c
index 3e2b73051b94..2bfaffb344f0 100644
--- a/arch/arm/mach-mx3/mx31moboard-marxbot.c
+++ b/arch/arm/mach-mx3/mx31moboard-marxbot.c
@@ -56,7 +56,7 @@ static unsigned int marxbot_pins[] = {
56 56
57static int marxbot_sdhc2_get_ro(struct device *dev) 57static int marxbot_sdhc2_get_ro(struct device *dev)
58{ 58{
59 return gpio_get_value(SDHC2_WP); 59 return !gpio_get_value(SDHC2_WP);
60} 60}
61 61
62static int marxbot_sdhc2_init(struct device *dev, irq_handler_t detect_irq, 62static int marxbot_sdhc2_init(struct device *dev, irq_handler_t detect_irq,
diff --git a/arch/arm/mach-mx3/mx31moboard.c b/arch/arm/mach-mx3/mx31moboard.c
index d3c6bb26271f..9243de54041a 100644
--- a/arch/arm/mach-mx3/mx31moboard.c
+++ b/arch/arm/mach-mx3/mx31moboard.c
@@ -118,7 +118,7 @@ static struct imxi2c_platform_data moboard_i2c1_pdata = {
118 118
119static int moboard_sdhc1_get_ro(struct device *dev) 119static int moboard_sdhc1_get_ro(struct device *dev)
120{ 120{
121 return gpio_get_value(SDHC1_WP); 121 return !gpio_get_value(SDHC1_WP);
122} 122}
123 123
124static int moboard_sdhc1_init(struct device *dev, irq_handler_t detect_irq, 124static int moboard_sdhc1_init(struct device *dev, irq_handler_t detect_irq,
diff --git a/arch/arm/mach-mx3/pcm037_eet.c b/arch/arm/mach-mx3/pcm037_eet.c
index fe52fb1bb8b7..8d386000fc40 100644
--- a/arch/arm/mach-mx3/pcm037_eet.c
+++ b/arch/arm/mach-mx3/pcm037_eet.c
@@ -24,15 +24,6 @@
24#include "devices.h" 24#include "devices.h"
25 25
26static unsigned int pcm037_eet_pins[] = { 26static unsigned int pcm037_eet_pins[] = {
27 /* SPI #1 */
28 MX31_PIN_CSPI1_MISO__MISO,
29 MX31_PIN_CSPI1_MOSI__MOSI,
30 MX31_PIN_CSPI1_SCLK__SCLK,
31 MX31_PIN_CSPI1_SPI_RDY__SPI_RDY,
32 MX31_PIN_CSPI1_SS0__SS0,
33 MX31_PIN_CSPI1_SS1__SS1,
34 MX31_PIN_CSPI1_SS2__SS2,
35
36 /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */ 27 /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */
37 IOMUX_MODE(MX31_PIN_KEY_COL7, IOMUX_CONFIG_GPIO), 28 IOMUX_MODE(MX31_PIN_KEY_COL7, IOMUX_CONFIG_GPIO),
38 /* GPIO keys */ 29 /* GPIO keys */
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index 9c3fdcdf76c3..8ec2a132904d 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -141,7 +141,7 @@ static inline void board_smc91x_init(void)
141 141
142static void __init omap_2430sdp_init_irq(void) 142static void __init omap_2430sdp_init_irq(void)
143{ 143{
144 omap2_init_common_hw(NULL); 144 omap2_init_common_hw(NULL, NULL);
145 omap_init_irq(); 145 omap_init_irq();
146 omap_gpio_init(); 146 omap_gpio_init();
147} 147}
diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c
index 496a90e4ea7a..ac262cd74503 100644
--- a/arch/arm/mach-omap2/board-3430sdp.c
+++ b/arch/arm/mach-omap2/board-3430sdp.c
@@ -169,7 +169,7 @@ static struct platform_device *sdp3430_devices[] __initdata = {
169 169
170static void __init omap_3430sdp_init_irq(void) 170static void __init omap_3430sdp_init_irq(void)
171{ 171{
172 omap2_init_common_hw(hyb18m512160af6_sdrc_params); 172 omap2_init_common_hw(hyb18m512160af6_sdrc_params, NULL);
173 omap_init_irq(); 173 omap_init_irq();
174 omap_gpio_init(); 174 omap_gpio_init();
175} 175}
diff --git a/arch/arm/mach-omap2/board-4430sdp.c b/arch/arm/mach-omap2/board-4430sdp.c
index 7e1e721f0324..1b223076ceb7 100644
--- a/arch/arm/mach-omap2/board-4430sdp.c
+++ b/arch/arm/mach-omap2/board-4430sdp.c
@@ -59,7 +59,7 @@ static void __init gic_init_irq(void)
59 59
60static void __init omap_4430sdp_init_irq(void) 60static void __init omap_4430sdp_init_irq(void)
61{ 61{
62 omap2_init_common_hw(NULL); 62 omap2_init_common_hw(NULL, NULL);
63#ifdef CONFIG_OMAP_32K_TIMER 63#ifdef CONFIG_OMAP_32K_TIMER
64 omap2_gp_clockevent_set_gptimer(1); 64 omap2_gp_clockevent_set_gptimer(1);
65#endif 65#endif
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index 06dfba888b0c..dcfc20d03894 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -250,7 +250,7 @@ out:
250 250
251static void __init omap_apollon_init_irq(void) 251static void __init omap_apollon_init_irq(void)
252{ 252{
253 omap2_init_common_hw(NULL); 253 omap2_init_common_hw(NULL, NULL);
254 omap_init_irq(); 254 omap_init_irq();
255 omap_gpio_init(); 255 omap_gpio_init();
256 apollon_init_smc91x(); 256 apollon_init_smc91x();
diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c
index 3492162a65c3..fd00aa03690c 100644
--- a/arch/arm/mach-omap2/board-generic.c
+++ b/arch/arm/mach-omap2/board-generic.c
@@ -33,7 +33,7 @@
33 33
34static void __init omap_generic_init_irq(void) 34static void __init omap_generic_init_irq(void)
35{ 35{
36 omap2_init_common_hw(NULL); 36 omap2_init_common_hw(NULL, NULL);
37 omap_init_irq(); 37 omap_init_irq();
38} 38}
39 39
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index e7d017cdc438..7b1d61d5bb2c 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -270,7 +270,7 @@ static void __init h4_init_flash(void)
270 270
271static void __init omap_h4_init_irq(void) 271static void __init omap_h4_init_irq(void)
272{ 272{
273 omap2_init_common_hw(NULL); 273 omap2_init_common_hw(NULL, NULL);
274 omap_init_irq(); 274 omap_init_irq();
275 omap_gpio_init(); 275 omap_gpio_init();
276 h4_init_flash(); 276 h4_init_flash();
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index d8bc0a7dcb8d..ea383f88cb1b 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -270,7 +270,7 @@ static inline void __init ldp_init_smsc911x(void)
270 270
271static void __init omap_ldp_init_irq(void) 271static void __init omap_ldp_init_irq(void)
272{ 272{
273 omap2_init_common_hw(NULL); 273 omap2_init_common_hw(NULL, NULL);
274 omap_init_irq(); 274 omap_init_irq();
275 omap_gpio_init(); 275 omap_gpio_init();
276 ldp_init_smsc911x(); 276 ldp_init_smsc911x();
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 991ac9c38032..e00ba128cece 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -282,7 +282,8 @@ static int __init omap3_beagle_i2c_init(void)
282 282
283static void __init omap3_beagle_init_irq(void) 283static void __init omap3_beagle_init_irq(void)
284{ 284{
285 omap2_init_common_hw(mt46h32m32lf6_sdrc_params); 285 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
286 mt46h32m32lf6_sdrc_params);
286 omap_init_irq(); 287 omap_init_irq();
287#ifdef CONFIG_OMAP_32K_TIMER 288#ifdef CONFIG_OMAP_32K_TIMER
288 omap2_gp_clockevent_set_gptimer(12); 289 omap2_gp_clockevent_set_gptimer(12);
@@ -408,6 +409,10 @@ static void __init omap3_beagle_init(void)
408 409
409 usb_musb_init(); 410 usb_musb_init();
410 omap3beagle_flash_init(); 411 omap3beagle_flash_init();
412
413 /* Ensure SDRC pins are mux'd for self-refresh */
414 omap_cfg_reg(H16_34XX_SDRC_CKE0);
415 omap_cfg_reg(H17_34XX_SDRC_CKE1);
411} 416}
412 417
413static void __init omap3_beagle_map_io(void) 418static void __init omap3_beagle_map_io(void)
diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c
index d3cc145814d0..c4b144647dc5 100644
--- a/arch/arm/mach-omap2/board-omap3evm.c
+++ b/arch/arm/mach-omap2/board-omap3evm.c
@@ -25,6 +25,7 @@
25#include <linux/spi/spi.h> 25#include <linux/spi/spi.h>
26#include <linux/spi/ads7846.h> 26#include <linux/spi/ads7846.h>
27#include <linux/i2c/twl4030.h> 27#include <linux/i2c/twl4030.h>
28#include <linux/usb/otg.h>
28 29
29#include <mach/hardware.h> 30#include <mach/hardware.h>
30#include <asm/mach-types.h> 31#include <asm/mach-types.h>
@@ -279,7 +280,7 @@ struct spi_board_info omap3evm_spi_board_info[] = {
279 280
280static void __init omap3_evm_init_irq(void) 281static void __init omap3_evm_init_irq(void)
281{ 282{
282 omap2_init_common_hw(mt46h32m32lf6_sdrc_params); 283 omap2_init_common_hw(mt46h32m32lf6_sdrc_params, NULL);
283 omap_init_irq(); 284 omap_init_irq();
284 omap_gpio_init(); 285 omap_gpio_init();
285 omap3evm_init_smc911x(); 286 omap3evm_init_smc911x();
@@ -307,6 +308,10 @@ static void __init omap3_evm_init(void)
307 ARRAY_SIZE(omap3evm_spi_board_info)); 308 ARRAY_SIZE(omap3evm_spi_board_info));
308 309
309 omap_serial_init(); 310 omap_serial_init();
311#ifdef CONFIG_NOP_USB_XCEIV
312 /* OMAP3EVM uses ISP1504 phy and so register nop transceiver */
313 usb_nop_xceiv_register();
314#endif
310 usb_musb_init(); 315 usb_musb_init();
311 ads7846_dev_init(); 316 ads7846_dev_init();
312} 317}
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c b/arch/arm/mach-omap2/board-omap3pandora.c
index e32aa23ce962..864ee3d021f7 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -40,6 +40,7 @@
40#include <mach/mcspi.h> 40#include <mach/mcspi.h>
41#include <mach/usb.h> 41#include <mach/usb.h>
42#include <mach/keypad.h> 42#include <mach/keypad.h>
43#include <mach/mux.h>
43 44
44#include "sdram-micron-mt46h32m32lf-6.h" 45#include "sdram-micron-mt46h32m32lf-6.h"
45#include "mmc-twl4030.h" 46#include "mmc-twl4030.h"
@@ -310,7 +311,8 @@ static int __init omap3pandora_i2c_init(void)
310 311
311static void __init omap3pandora_init_irq(void) 312static void __init omap3pandora_init_irq(void)
312{ 313{
313 omap2_init_common_hw(mt46h32m32lf6_sdrc_params); 314 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
315 mt46h32m32lf6_sdrc_params);
314 omap_init_irq(); 316 omap_init_irq();
315 omap_gpio_init(); 317 omap_gpio_init();
316} 318}
@@ -397,6 +399,10 @@ static void __init omap3pandora_init(void)
397 omap3pandora_ads7846_init(); 399 omap3pandora_ads7846_init();
398 pandora_keys_gpio_init(); 400 pandora_keys_gpio_init();
399 usb_musb_init(); 401 usb_musb_init();
402
403 /* Ensure SDRC pins are mux'd for self-refresh */
404 omap_cfg_reg(H16_34XX_SDRC_CKE0);
405 omap_cfg_reg(H17_34XX_SDRC_CKE1);
400} 406}
401 407
402static void __init omap3pandora_map_io(void) 408static void __init omap3pandora_map_io(void)
diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c
index e26af837510b..6bce23004aa4 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -44,6 +44,7 @@
44#include <mach/gpmc.h> 44#include <mach/gpmc.h>
45#include <mach/hardware.h> 45#include <mach/hardware.h>
46#include <mach/nand.h> 46#include <mach/nand.h>
47#include <mach/mux.h>
47#include <mach/usb.h> 48#include <mach/usb.h>
48 49
49#include "sdram-micron-mt46h32m32lf-6.h" 50#include "sdram-micron-mt46h32m32lf-6.h"
@@ -147,7 +148,7 @@ static struct platform_device overo_smsc911x_device = {
147 .name = "smsc911x", 148 .name = "smsc911x",
148 .id = -1, 149 .id = -1,
149 .num_resources = ARRAY_SIZE(overo_smsc911x_resources), 150 .num_resources = ARRAY_SIZE(overo_smsc911x_resources),
150 .resource = &overo_smsc911x_resources, 151 .resource = overo_smsc911x_resources,
151 .dev = { 152 .dev = {
152 .platform_data = &overo_smsc911x_config, 153 .platform_data = &overo_smsc911x_config,
153 }, 154 },
@@ -361,7 +362,8 @@ static int __init overo_i2c_init(void)
361 362
362static void __init overo_init_irq(void) 363static void __init overo_init_irq(void)
363{ 364{
364 omap2_init_common_hw(mt46h32m32lf6_sdrc_params); 365 omap2_init_common_hw(mt46h32m32lf6_sdrc_params,
366 mt46h32m32lf6_sdrc_params);
365 omap_init_irq(); 367 omap_init_irq();
366 omap_gpio_init(); 368 omap_gpio_init();
367} 369}
@@ -396,6 +398,10 @@ static void __init overo_init(void)
396 overo_ads7846_init(); 398 overo_ads7846_init();
397 overo_init_smsc911x(); 399 overo_init_smsc911x();
398 400
401 /* Ensure SDRC pins are mux'd for self-refresh */
402 omap_cfg_reg(H16_34XX_SDRC_CKE0);
403 omap_cfg_reg(H17_34XX_SDRC_CKE1);
404
399 if ((gpio_request(OVERO_GPIO_W2W_NRESET, 405 if ((gpio_request(OVERO_GPIO_W2W_NRESET,
400 "OVERO_GPIO_W2W_NRESET") == 0) && 406 "OVERO_GPIO_W2W_NRESET") == 0) &&
401 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) { 407 (gpio_direction_output(OVERO_GPIO_W2W_NRESET, 1) == 0)) {
diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 9a0bf6744a05..56d931a425f7 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -278,6 +278,10 @@ static struct twl4030_gpio_platform_data rx51_gpio_data = {
278 .setup = rx51_twlgpio_setup, 278 .setup = rx51_twlgpio_setup,
279}; 279};
280 280
281static struct twl4030_usb_data rx51_usb_data = {
282 .usb_mode = T2_USB_MODE_ULPI,
283};
284
281static struct twl4030_platform_data rx51_twldata = { 285static struct twl4030_platform_data rx51_twldata = {
282 .irq_base = TWL4030_IRQ_BASE, 286 .irq_base = TWL4030_IRQ_BASE,
283 .irq_end = TWL4030_IRQ_END, 287 .irq_end = TWL4030_IRQ_END,
@@ -286,6 +290,7 @@ static struct twl4030_platform_data rx51_twldata = {
286 .gpio = &rx51_gpio_data, 290 .gpio = &rx51_gpio_data,
287 .keypad = &rx51_kp_data, 291 .keypad = &rx51_kp_data,
288 .madc = &rx51_madc_data, 292 .madc = &rx51_madc_data,
293 .usb = &rx51_usb_data,
289 294
290 .vaux1 = &rx51_vaux1, 295 .vaux1 = &rx51_vaux1,
291 .vaux2 = &rx51_vaux2, 296 .vaux2 = &rx51_vaux2,
diff --git a/arch/arm/mach-omap2/board-rx51.c b/arch/arm/mach-omap2/board-rx51.c
index 374ff63c3eb2..1c9e07fe8266 100644
--- a/arch/arm/mach-omap2/board-rx51.c
+++ b/arch/arm/mach-omap2/board-rx51.c
@@ -61,7 +61,7 @@ static struct omap_board_config_kernel rx51_config[] = {
61 61
62static void __init rx51_init_irq(void) 62static void __init rx51_init_irq(void)
63{ 63{
64 omap2_init_common_hw(NULL); 64 omap2_init_common_hw(NULL, NULL);
65 omap_init_irq(); 65 omap_init_irq();
66 omap_gpio_init(); 66 omap_gpio_init();
67} 67}
@@ -75,6 +75,10 @@ static void __init rx51_init(void)
75 omap_serial_init(); 75 omap_serial_init();
76 usb_musb_init(); 76 usb_musb_init();
77 rx51_peripherals_init(); 77 rx51_peripherals_init();
78
79 /* Ensure SDRC pins are mux'd for self-refresh */
80 omap_cfg_reg(H16_34XX_SDRC_CKE0);
81 omap_cfg_reg(H17_34XX_SDRC_CKE1);
78} 82}
79 83
80static void __init rx51_map_io(void) 84static void __init rx51_map_io(void)
diff --git a/arch/arm/mach-omap2/board-zoom2.c b/arch/arm/mach-omap2/board-zoom2.c
index bcc0f7632dea..427b7b8b1237 100644
--- a/arch/arm/mach-omap2/board-zoom2.c
+++ b/arch/arm/mach-omap2/board-zoom2.c
@@ -25,7 +25,7 @@
25 25
26static void __init omap_zoom2_init_irq(void) 26static void __init omap_zoom2_init_irq(void)
27{ 27{
28 omap2_init_common_hw(NULL); 28 omap2_init_common_hw(NULL, NULL);
29 omap_init_irq(); 29 omap_init_irq();
30 omap_gpio_init(); 30 omap_gpio_init();
31} 31}
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c
index b0665f161c03..456e2ad5f621 100644
--- a/arch/arm/mach-omap2/clock.c
+++ b/arch/arm/mach-omap2/clock.c
@@ -27,6 +27,7 @@
27#include <mach/clock.h> 27#include <mach/clock.h>
28#include <mach/clockdomain.h> 28#include <mach/clockdomain.h>
29#include <mach/cpu.h> 29#include <mach/cpu.h>
30#include <mach/prcm.h>
30#include <asm/div64.h> 31#include <asm/div64.h>
31 32
32#include <mach/sdrc.h> 33#include <mach/sdrc.h>
@@ -38,8 +39,6 @@
38#include "cm-regbits-24xx.h" 39#include "cm-regbits-24xx.h"
39#include "cm-regbits-34xx.h" 40#include "cm-regbits-34xx.h"
40 41
41#define MAX_CLOCK_ENABLE_WAIT 100000
42
43/* DPLL rate rounding: minimum DPLL multiplier, divider values */ 42/* DPLL rate rounding: minimum DPLL multiplier, divider values */
44#define DPLL_MIN_MULTIPLIER 1 43#define DPLL_MIN_MULTIPLIER 1
45#define DPLL_MIN_DIVIDER 1 44#define DPLL_MIN_DIVIDER 1
@@ -274,83 +273,97 @@ unsigned long omap2_fixed_divisor_recalc(struct clk *clk)
274} 273}
275 274
276/** 275/**
277 * omap2_wait_clock_ready - wait for clock to enable 276 * omap2_clk_dflt_find_companion - find companion clock to @clk
278 * @reg: physical address of clock IDLEST register 277 * @clk: struct clk * to find the companion clock of
279 * @mask: value to mask against to determine if the clock is active 278 * @other_reg: void __iomem ** to return the companion clock CM_*CLKEN va in
280 * @name: name of the clock (for printk) 279 * @other_bit: u8 ** to return the companion clock bit shift in
280 *
281 * Note: We don't need special code here for INVERT_ENABLE for the
282 * time being since INVERT_ENABLE only applies to clocks enabled by
283 * CM_CLKEN_PLL
281 * 284 *
282 * Returns 1 if the clock enabled in time, or 0 if it failed to enable 285 * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes it's
283 * in roughly MAX_CLOCK_ENABLE_WAIT microseconds. 286 * just a matter of XORing the bits.
287 *
288 * Some clocks don't have companion clocks. For example, modules with
289 * only an interface clock (such as MAILBOXES) don't have a companion
290 * clock. Right now, this code relies on the hardware exporting a bit
291 * in the correct companion register that indicates that the
292 * nonexistent 'companion clock' is active. Future patches will
293 * associate this type of code with per-module data structures to
294 * avoid this issue, and remove the casts. No return value.
284 */ 295 */
285int omap2_wait_clock_ready(void __iomem *reg, u32 mask, const char *name) 296void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
297 u8 *other_bit)
286{ 298{
287 int i = 0; 299 u32 r;
288 int ena = 0;
289 300
290 /* 301 /*
291 * 24xx uses 0 to indicate not ready, and 1 to indicate ready. 302 * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes
292 * 34xx reverses this, just to keep us on our toes 303 * it's just a matter of XORing the bits.
293 */ 304 */
294 if (cpu_mask & (RATE_IN_242X | RATE_IN_243X)) 305 r = ((__force u32)clk->enable_reg ^ (CM_FCLKEN ^ CM_ICLKEN));
295 ena = mask;
296 else if (cpu_mask & RATE_IN_343X)
297 ena = 0;
298
299 /* Wait for lock */
300 while (((__raw_readl(reg) & mask) != ena) &&
301 (i++ < MAX_CLOCK_ENABLE_WAIT)) {
302 udelay(1);
303 }
304
305 if (i <= MAX_CLOCK_ENABLE_WAIT)
306 pr_debug("Clock %s stable after %d loops\n", name, i);
307 else
308 printk(KERN_ERR "Clock %s didn't enable in %d tries\n",
309 name, MAX_CLOCK_ENABLE_WAIT);
310
311
312 return (i < MAX_CLOCK_ENABLE_WAIT) ? 1 : 0;
313};
314 306
307 *other_reg = (__force void __iomem *)r;
308 *other_bit = clk->enable_bit;
309}
315 310
316/* 311/**
317 * Note: We don't need special code here for INVERT_ENABLE 312 * omap2_clk_dflt_find_idlest - find CM_IDLEST reg va, bit shift for @clk
318 * for the time being since INVERT_ENABLE only applies to clocks enabled by 313 * @clk: struct clk * to find IDLEST info for
319 * CM_CLKEN_PLL 314 * @idlest_reg: void __iomem ** to return the CM_IDLEST va in
315 * @idlest_bit: u8 ** to return the CM_IDLEST bit shift in
316 *
317 * Return the CM_IDLEST register address and bit shift corresponding
318 * to the module that "owns" this clock. This default code assumes
319 * that the CM_IDLEST bit shift is the CM_*CLKEN bit shift, and that
320 * the IDLEST register address ID corresponds to the CM_*CLKEN
321 * register address ID (e.g., that CM_FCLKEN2 corresponds to
322 * CM_IDLEST2). This is not true for all modules. No return value.
320 */ 323 */
321static void omap2_clk_wait_ready(struct clk *clk) 324void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
325 u8 *idlest_bit)
322{ 326{
323 void __iomem *reg, *other_reg, *st_reg; 327 u32 r;
324 u32 bit;
325 328
326 /* 329 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
327 * REVISIT: This code is pretty ugly. It would be nice to generalize 330 *idlest_reg = (__force void __iomem *)r;
328 * it and pull it into struct clk itself somehow. 331 *idlest_bit = clk->enable_bit;
329 */ 332}
330 reg = clk->enable_reg;
331 333
332 /* 334/**
333 * Convert CM_ICLKEN* <-> CM_FCLKEN*. This conversion assumes 335 * omap2_module_wait_ready - wait for an OMAP module to leave IDLE
334 * it's just a matter of XORing the bits. 336 * @clk: struct clk * belonging to the module
335 */ 337 *
336 other_reg = (void __iomem *)((u32)reg ^ (CM_FCLKEN ^ CM_ICLKEN)); 338 * If the necessary clocks for the OMAP hardware IP block that
339 * corresponds to clock @clk are enabled, then wait for the module to
340 * indicate readiness (i.e., to leave IDLE). This code does not
341 * belong in the clock code and will be moved in the medium term to
342 * module-dependent code. No return value.
343 */
344static void omap2_module_wait_ready(struct clk *clk)
345{
346 void __iomem *companion_reg, *idlest_reg;
347 u8 other_bit, idlest_bit;
348
349 /* Not all modules have multiple clocks that their IDLEST depends on */
350 if (clk->ops->find_companion) {
351 clk->ops->find_companion(clk, &companion_reg, &other_bit);
352 if (!(__raw_readl(companion_reg) & (1 << other_bit)))
353 return;
354 }
337 355
338 /* Check if both functional and interface clocks 356 clk->ops->find_idlest(clk, &idlest_reg, &idlest_bit);
339 * are running. */
340 bit = 1 << clk->enable_bit;
341 if (!(__raw_readl(other_reg) & bit))
342 return;
343 st_reg = (void __iomem *)(((u32)other_reg & ~0xf0) | 0x20); /* CM_IDLEST* */
344 357
345 omap2_wait_clock_ready(st_reg, bit, clk->name); 358 omap2_cm_wait_idlest(idlest_reg, (1 << idlest_bit), clk->name);
346} 359}
347 360
348static int omap2_dflt_clk_enable(struct clk *clk) 361int omap2_dflt_clk_enable(struct clk *clk)
349{ 362{
350 u32 v; 363 u32 v;
351 364
352 if (unlikely(clk->enable_reg == NULL)) { 365 if (unlikely(clk->enable_reg == NULL)) {
353 printk(KERN_ERR "clock.c: Enable for %s without enable code\n", 366 pr_err("clock.c: Enable for %s without enable code\n",
354 clk->name); 367 clk->name);
355 return 0; /* REVISIT: -EINVAL */ 368 return 0; /* REVISIT: -EINVAL */
356 } 369 }
@@ -363,26 +376,13 @@ static int omap2_dflt_clk_enable(struct clk *clk)
363 __raw_writel(v, clk->enable_reg); 376 __raw_writel(v, clk->enable_reg);
364 v = __raw_readl(clk->enable_reg); /* OCP barrier */ 377 v = __raw_readl(clk->enable_reg); /* OCP barrier */
365 378
366 return 0; 379 if (clk->ops->find_idlest)
367} 380 omap2_module_wait_ready(clk);
368 381
369static int omap2_dflt_clk_enable_wait(struct clk *clk) 382 return 0;
370{
371 int ret;
372
373 if (!clk->enable_reg) {
374 printk(KERN_ERR "clock.c: Enable for %s without enable code\n",
375 clk->name);
376 return 0; /* REVISIT: -EINVAL */
377 }
378
379 ret = omap2_dflt_clk_enable(clk);
380 if (ret == 0)
381 omap2_clk_wait_ready(clk);
382 return ret;
383} 383}
384 384
385static void omap2_dflt_clk_disable(struct clk *clk) 385void omap2_dflt_clk_disable(struct clk *clk)
386{ 386{
387 u32 v; 387 u32 v;
388 388
@@ -406,8 +406,10 @@ static void omap2_dflt_clk_disable(struct clk *clk)
406} 406}
407 407
408const struct clkops clkops_omap2_dflt_wait = { 408const struct clkops clkops_omap2_dflt_wait = {
409 .enable = omap2_dflt_clk_enable_wait, 409 .enable = omap2_dflt_clk_enable,
410 .disable = omap2_dflt_clk_disable, 410 .disable = omap2_dflt_clk_disable,
411 .find_companion = omap2_clk_dflt_find_companion,
412 .find_idlest = omap2_clk_dflt_find_idlest,
411}; 413};
412 414
413const struct clkops clkops_omap2_dflt = { 415const struct clkops clkops_omap2_dflt = {
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h
index 2679ddfa6424..9ae7540f8af2 100644
--- a/arch/arm/mach-omap2/clock.h
+++ b/arch/arm/mach-omap2/clock.h
@@ -65,6 +65,12 @@ int omap2_clksel_set_rate(struct clk *clk, unsigned long rate);
65u32 omap2_get_dpll_rate(struct clk *clk); 65u32 omap2_get_dpll_rate(struct clk *clk);
66int omap2_wait_clock_ready(void __iomem *reg, u32 cval, const char *name); 66int omap2_wait_clock_ready(void __iomem *reg, u32 cval, const char *name);
67void omap2_clk_prepare_for_reboot(void); 67void omap2_clk_prepare_for_reboot(void);
68int omap2_dflt_clk_enable(struct clk *clk);
69void omap2_dflt_clk_disable(struct clk *clk);
70void omap2_clk_dflt_find_companion(struct clk *clk, void __iomem **other_reg,
71 u8 *other_bit);
72void omap2_clk_dflt_find_idlest(struct clk *clk, void __iomem **idlest_reg,
73 u8 *idlest_bit);
68 74
69extern const struct clkops clkops_omap2_dflt_wait; 75extern const struct clkops clkops_omap2_dflt_wait;
70extern const struct clkops clkops_omap2_dflt; 76extern const struct clkops clkops_omap2_dflt;
diff --git a/arch/arm/mach-omap2/clock24xx.c b/arch/arm/mach-omap2/clock24xx.c
index 44de0271fc2f..bc5d3ac66611 100644
--- a/arch/arm/mach-omap2/clock24xx.c
+++ b/arch/arm/mach-omap2/clock24xx.c
@@ -30,6 +30,7 @@
30 30
31#include <mach/clock.h> 31#include <mach/clock.h>
32#include <mach/sram.h> 32#include <mach/sram.h>
33#include <mach/prcm.h>
33#include <asm/div64.h> 34#include <asm/div64.h>
34#include <asm/clkdev.h> 35#include <asm/clkdev.h>
35 36
@@ -43,6 +44,18 @@
43static const struct clkops clkops_oscck; 44static const struct clkops clkops_oscck;
44static const struct clkops clkops_fixed; 45static const struct clkops clkops_fixed;
45 46
47static void omap2430_clk_i2chs_find_idlest(struct clk *clk,
48 void __iomem **idlest_reg,
49 u8 *idlest_bit);
50
51/* 2430 I2CHS has non-standard IDLEST register */
52static const struct clkops clkops_omap2430_i2chs_wait = {
53 .enable = omap2_dflt_clk_enable,
54 .disable = omap2_dflt_clk_disable,
55 .find_idlest = omap2430_clk_i2chs_find_idlest,
56 .find_companion = omap2_clk_dflt_find_companion,
57};
58
46#include "clock24xx.h" 59#include "clock24xx.h"
47 60
48struct omap_clk { 61struct omap_clk {
@@ -240,6 +253,26 @@ static void __iomem *prcm_clksrc_ctrl;
240 *-------------------------------------------------------------------------*/ 253 *-------------------------------------------------------------------------*/
241 254
242/** 255/**
256 * omap2430_clk_i2chs_find_idlest - return CM_IDLEST info for 2430 I2CHS
257 * @clk: struct clk * being enabled
258 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
259 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
260 *
261 * OMAP2430 I2CHS CM_IDLEST bits are in CM_IDLEST1_CORE, but the
262 * CM_*CLKEN bits are in CM_{I,F}CLKEN2_CORE. This custom function
263 * passes back the correct CM_IDLEST register address for I2CHS
264 * modules. No return value.
265 */
266static void omap2430_clk_i2chs_find_idlest(struct clk *clk,
267 void __iomem **idlest_reg,
268 u8 *idlest_bit)
269{
270 *idlest_reg = OMAP_CM_REGADDR(CORE_MOD, CM_IDLEST);
271 *idlest_bit = clk->enable_bit;
272}
273
274
275/**
243 * omap2xxx_clk_get_core_rate - return the CORE_CLK rate 276 * omap2xxx_clk_get_core_rate - return the CORE_CLK rate
244 * @clk: pointer to the combined dpll_ck + core_ck (currently "dpll_ck") 277 * @clk: pointer to the combined dpll_ck + core_ck (currently "dpll_ck")
245 * 278 *
@@ -325,8 +358,8 @@ static int omap2_clk_fixed_enable(struct clk *clk)
325 else if (clk == &apll54_ck) 358 else if (clk == &apll54_ck)
326 cval = OMAP24XX_ST_54M_APLL; 359 cval = OMAP24XX_ST_54M_APLL;
327 360
328 omap2_wait_clock_ready(OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), cval, 361 omap2_cm_wait_idlest(OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST), cval,
329 clk->name); 362 clk->name);
330 363
331 /* 364 /*
332 * REVISIT: Should we return an error code if omap2_wait_clock_ready() 365 * REVISIT: Should we return an error code if omap2_wait_clock_ready()
diff --git a/arch/arm/mach-omap2/clock24xx.h b/arch/arm/mach-omap2/clock24xx.h
index 458f00cdcbea..d19cf7a7d8db 100644
--- a/arch/arm/mach-omap2/clock24xx.h
+++ b/arch/arm/mach-omap2/clock24xx.h
@@ -2337,7 +2337,7 @@ static struct clk i2c2_fck = {
2337 2337
2338static struct clk i2chs2_fck = { 2338static struct clk i2chs2_fck = {
2339 .name = "i2c_fck", 2339 .name = "i2c_fck",
2340 .ops = &clkops_omap2_dflt_wait, 2340 .ops = &clkops_omap2430_i2chs_wait,
2341 .id = 2, 2341 .id = 2,
2342 .parent = &func_96m_ck, 2342 .parent = &func_96m_ck,
2343 .clkdm_name = "core_l4_clkdm", 2343 .clkdm_name = "core_l4_clkdm",
@@ -2370,7 +2370,7 @@ static struct clk i2c1_fck = {
2370 2370
2371static struct clk i2chs1_fck = { 2371static struct clk i2chs1_fck = {
2372 .name = "i2c_fck", 2372 .name = "i2c_fck",
2373 .ops = &clkops_omap2_dflt_wait, 2373 .ops = &clkops_omap2430_i2chs_wait,
2374 .id = 1, 2374 .id = 1,
2375 .parent = &func_96m_ck, 2375 .parent = &func_96m_ck,
2376 .clkdm_name = "core_l4_clkdm", 2376 .clkdm_name = "core_l4_clkdm",
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 045da923e75b..cd7819cc0c9e 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -2,7 +2,7 @@
2 * OMAP3-specific clock framework functions 2 * OMAP3-specific clock framework functions
3 * 3 *
4 * Copyright (C) 2007-2008 Texas Instruments, Inc. 4 * Copyright (C) 2007-2008 Texas Instruments, Inc.
5 * Copyright (C) 2007-2008 Nokia Corporation 5 * Copyright (C) 2007-2009 Nokia Corporation
6 * 6 *
7 * Written by Paul Walmsley 7 * Written by Paul Walmsley
8 * Testing and integration fixes by Jouni Högander 8 * Testing and integration fixes by Jouni Högander
@@ -41,6 +41,37 @@
41 41
42static const struct clkops clkops_noncore_dpll_ops; 42static const struct clkops clkops_noncore_dpll_ops;
43 43
44static void omap3430es2_clk_ssi_find_idlest(struct clk *clk,
45 void __iomem **idlest_reg,
46 u8 *idlest_bit);
47static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk,
48 void __iomem **idlest_reg,
49 u8 *idlest_bit);
50static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk,
51 void __iomem **idlest_reg,
52 u8 *idlest_bit);
53
54static const struct clkops clkops_omap3430es2_ssi_wait = {
55 .enable = omap2_dflt_clk_enable,
56 .disable = omap2_dflt_clk_disable,
57 .find_idlest = omap3430es2_clk_ssi_find_idlest,
58 .find_companion = omap2_clk_dflt_find_companion,
59};
60
61static const struct clkops clkops_omap3430es2_hsotgusb_wait = {
62 .enable = omap2_dflt_clk_enable,
63 .disable = omap2_dflt_clk_disable,
64 .find_idlest = omap3430es2_clk_hsotgusb_find_idlest,
65 .find_companion = omap2_clk_dflt_find_companion,
66};
67
68static const struct clkops clkops_omap3430es2_dss_usbhost_wait = {
69 .enable = omap2_dflt_clk_enable,
70 .disable = omap2_dflt_clk_disable,
71 .find_idlest = omap3430es2_clk_dss_usbhost_find_idlest,
72 .find_companion = omap2_clk_dflt_find_companion,
73};
74
44#include "clock34xx.h" 75#include "clock34xx.h"
45 76
46struct omap_clk { 77struct omap_clk {
@@ -157,10 +188,13 @@ static struct omap_clk omap34xx_clks[] = {
157 CLK(NULL, "fshostusb_fck", &fshostusb_fck, CK_3430ES1), 188 CLK(NULL, "fshostusb_fck", &fshostusb_fck, CK_3430ES1),
158 CLK(NULL, "core_12m_fck", &core_12m_fck, CK_343X), 189 CLK(NULL, "core_12m_fck", &core_12m_fck, CK_343X),
159 CLK("omap_hdq.0", "fck", &hdq_fck, CK_343X), 190 CLK("omap_hdq.0", "fck", &hdq_fck, CK_343X),
160 CLK(NULL, "ssi_ssr_fck", &ssi_ssr_fck, CK_343X), 191 CLK(NULL, "ssi_ssr_fck", &ssi_ssr_fck_3430es1, CK_3430ES1),
161 CLK(NULL, "ssi_sst_fck", &ssi_sst_fck, CK_343X), 192 CLK(NULL, "ssi_ssr_fck", &ssi_ssr_fck_3430es2, CK_3430ES2),
193 CLK(NULL, "ssi_sst_fck", &ssi_sst_fck_3430es1, CK_3430ES1),
194 CLK(NULL, "ssi_sst_fck", &ssi_sst_fck_3430es2, CK_3430ES2),
162 CLK(NULL, "core_l3_ick", &core_l3_ick, CK_343X), 195 CLK(NULL, "core_l3_ick", &core_l3_ick, CK_343X),
163 CLK("musb_hdrc", "ick", &hsotgusb_ick, CK_343X), 196 CLK("musb_hdrc", "ick", &hsotgusb_ick_3430es1, CK_3430ES1),
197 CLK("musb_hdrc", "ick", &hsotgusb_ick_3430es2, CK_3430ES2),
164 CLK(NULL, "sdrc_ick", &sdrc_ick, CK_343X), 198 CLK(NULL, "sdrc_ick", &sdrc_ick, CK_343X),
165 CLK(NULL, "gpmc_fck", &gpmc_fck, CK_343X), 199 CLK(NULL, "gpmc_fck", &gpmc_fck, CK_343X),
166 CLK(NULL, "security_l3_ick", &security_l3_ick, CK_343X), 200 CLK(NULL, "security_l3_ick", &security_l3_ick, CK_343X),
@@ -193,18 +227,21 @@ static struct omap_clk omap34xx_clks[] = {
193 CLK(NULL, "mailboxes_ick", &mailboxes_ick, CK_343X), 227 CLK(NULL, "mailboxes_ick", &mailboxes_ick, CK_343X),
194 CLK(NULL, "omapctrl_ick", &omapctrl_ick, CK_343X), 228 CLK(NULL, "omapctrl_ick", &omapctrl_ick, CK_343X),
195 CLK(NULL, "ssi_l4_ick", &ssi_l4_ick, CK_343X), 229 CLK(NULL, "ssi_l4_ick", &ssi_l4_ick, CK_343X),
196 CLK(NULL, "ssi_ick", &ssi_ick, CK_343X), 230 CLK(NULL, "ssi_ick", &ssi_ick_3430es1, CK_3430ES1),
231 CLK(NULL, "ssi_ick", &ssi_ick_3430es2, CK_3430ES2),
197 CLK(NULL, "usb_l4_ick", &usb_l4_ick, CK_3430ES1), 232 CLK(NULL, "usb_l4_ick", &usb_l4_ick, CK_3430ES1),
198 CLK(NULL, "security_l4_ick2", &security_l4_ick2, CK_343X), 233 CLK(NULL, "security_l4_ick2", &security_l4_ick2, CK_343X),
199 CLK(NULL, "aes1_ick", &aes1_ick, CK_343X), 234 CLK(NULL, "aes1_ick", &aes1_ick, CK_343X),
200 CLK("omap_rng", "ick", &rng_ick, CK_343X), 235 CLK("omap_rng", "ick", &rng_ick, CK_343X),
201 CLK(NULL, "sha11_ick", &sha11_ick, CK_343X), 236 CLK(NULL, "sha11_ick", &sha11_ick, CK_343X),
202 CLK(NULL, "des1_ick", &des1_ick, CK_343X), 237 CLK(NULL, "des1_ick", &des1_ick, CK_343X),
203 CLK("omapfb", "dss1_fck", &dss1_alwon_fck, CK_343X), 238 CLK("omapfb", "dss1_fck", &dss1_alwon_fck_3430es1, CK_3430ES1),
239 CLK("omapfb", "dss1_fck", &dss1_alwon_fck_3430es2, CK_3430ES2),
204 CLK("omapfb", "tv_fck", &dss_tv_fck, CK_343X), 240 CLK("omapfb", "tv_fck", &dss_tv_fck, CK_343X),
205 CLK("omapfb", "video_fck", &dss_96m_fck, CK_343X), 241 CLK("omapfb", "video_fck", &dss_96m_fck, CK_343X),
206 CLK("omapfb", "dss2_fck", &dss2_alwon_fck, CK_343X), 242 CLK("omapfb", "dss2_fck", &dss2_alwon_fck, CK_343X),
207 CLK("omapfb", "ick", &dss_ick, CK_343X), 243 CLK("omapfb", "ick", &dss_ick_3430es1, CK_3430ES1),
244 CLK("omapfb", "ick", &dss_ick_3430es2, CK_3430ES2),
208 CLK(NULL, "cam_mclk", &cam_mclk, CK_343X), 245 CLK(NULL, "cam_mclk", &cam_mclk, CK_343X),
209 CLK(NULL, "cam_ick", &cam_ick, CK_343X), 246 CLK(NULL, "cam_ick", &cam_ick, CK_343X),
210 CLK(NULL, "csi2_96m_fck", &csi2_96m_fck, CK_343X), 247 CLK(NULL, "csi2_96m_fck", &csi2_96m_fck, CK_343X),
@@ -301,6 +338,73 @@ static struct omap_clk omap34xx_clks[] = {
301#define SDRC_MPURATE_LOOPS 96 338#define SDRC_MPURATE_LOOPS 96
302 339
303/** 340/**
341 * omap3430es2_clk_ssi_find_idlest - return CM_IDLEST info for SSI
342 * @clk: struct clk * being enabled
343 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
344 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
345 *
346 * The OMAP3430ES2 SSI target CM_IDLEST bit is at a different shift
347 * from the CM_{I,F}CLKEN bit. Pass back the correct info via
348 * @idlest_reg and @idlest_bit. No return value.
349 */
350static void omap3430es2_clk_ssi_find_idlest(struct clk *clk,
351 void __iomem **idlest_reg,
352 u8 *idlest_bit)
353{
354 u32 r;
355
356 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
357 *idlest_reg = (__force void __iomem *)r;
358 *idlest_bit = OMAP3430ES2_ST_SSI_IDLE_SHIFT;
359}
360
361/**
362 * omap3430es2_clk_dss_usbhost_find_idlest - CM_IDLEST info for DSS, USBHOST
363 * @clk: struct clk * being enabled
364 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
365 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
366 *
367 * Some OMAP modules on OMAP3 ES2+ chips have both initiator and
368 * target IDLEST bits. For our purposes, we are concerned with the
369 * target IDLEST bits, which exist at a different bit position than
370 * the *CLKEN bit position for these modules (DSS and USBHOST) (The
371 * default find_idlest code assumes that they are at the same
372 * position.) No return value.
373 */
374static void omap3430es2_clk_dss_usbhost_find_idlest(struct clk *clk,
375 void __iomem **idlest_reg,
376 u8 *idlest_bit)
377{
378 u32 r;
379
380 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
381 *idlest_reg = (__force void __iomem *)r;
382 /* USBHOST_IDLE has same shift */
383 *idlest_bit = OMAP3430ES2_ST_DSS_IDLE_SHIFT;
384}
385
386/**
387 * omap3430es2_clk_hsotgusb_find_idlest - return CM_IDLEST info for HSOTGUSB
388 * @clk: struct clk * being enabled
389 * @idlest_reg: void __iomem ** to store CM_IDLEST reg address into
390 * @idlest_bit: pointer to a u8 to store the CM_IDLEST bit shift into
391 *
392 * The OMAP3430ES2 HSOTGUSB target CM_IDLEST bit is at a different
393 * shift from the CM_{I,F}CLKEN bit. Pass back the correct info via
394 * @idlest_reg and @idlest_bit. No return value.
395 */
396static void omap3430es2_clk_hsotgusb_find_idlest(struct clk *clk,
397 void __iomem **idlest_reg,
398 u8 *idlest_bit)
399{
400 u32 r;
401
402 r = (((__force u32)clk->enable_reg & ~0xf0) | 0x20);
403 *idlest_reg = (__force void __iomem *)r;
404 *idlest_bit = OMAP3430ES2_ST_HSOTGUSB_IDLE_SHIFT;
405}
406
407/**
304 * omap3_dpll_recalc - recalculate DPLL rate 408 * omap3_dpll_recalc - recalculate DPLL rate
305 * @clk: DPLL struct clk 409 * @clk: DPLL struct clk
306 * 410 *
@@ -725,7 +829,9 @@ static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate)
725 u32 unlock_dll = 0; 829 u32 unlock_dll = 0;
726 u32 c; 830 u32 c;
727 unsigned long validrate, sdrcrate, mpurate; 831 unsigned long validrate, sdrcrate, mpurate;
728 struct omap_sdrc_params *sp; 832 struct omap_sdrc_params *sdrc_cs0;
833 struct omap_sdrc_params *sdrc_cs1;
834 int ret;
729 835
730 if (!clk || !rate) 836 if (!clk || !rate)
731 return -EINVAL; 837 return -EINVAL;
@@ -743,8 +849,8 @@ static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate)
743 else 849 else
744 sdrcrate >>= ((clk->rate / rate) >> 1); 850 sdrcrate >>= ((clk->rate / rate) >> 1);
745 851
746 sp = omap2_sdrc_get_params(sdrcrate); 852 ret = omap2_sdrc_get_params(sdrcrate, &sdrc_cs0, &sdrc_cs1);
747 if (!sp) 853 if (ret)
748 return -EINVAL; 854 return -EINVAL;
749 855
750 if (sdrcrate < MIN_SDRC_DLL_LOCK_FREQ) { 856 if (sdrcrate < MIN_SDRC_DLL_LOCK_FREQ) {
@@ -765,12 +871,29 @@ static int omap3_core_dpll_m2_set_rate(struct clk *clk, unsigned long rate)
765 871
766 pr_debug("clock: changing CORE DPLL rate from %lu to %lu\n", clk->rate, 872 pr_debug("clock: changing CORE DPLL rate from %lu to %lu\n", clk->rate,
767 validrate); 873 validrate);
768 pr_debug("clock: SDRC timing params used: %08x %08x %08x\n", 874 pr_debug("clock: SDRC CS0 timing params used:"
769 sp->rfr_ctrl, sp->actim_ctrla, sp->actim_ctrlb); 875 " RFR %08x CTRLA %08x CTRLB %08x MR %08x\n",
770 876 sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla,
771 omap3_configure_core_dpll(sp->rfr_ctrl, sp->actim_ctrla, 877 sdrc_cs0->actim_ctrlb, sdrc_cs0->mr);
772 sp->actim_ctrlb, new_div, unlock_dll, c, 878 if (sdrc_cs1)
773 sp->mr, rate > clk->rate); 879 pr_debug("clock: SDRC CS1 timing params used: "
880 " RFR %08x CTRLA %08x CTRLB %08x MR %08x\n",
881 sdrc_cs1->rfr_ctrl, sdrc_cs1->actim_ctrla,
882 sdrc_cs1->actim_ctrlb, sdrc_cs1->mr);
883
884 if (sdrc_cs1)
885 omap3_configure_core_dpll(
886 new_div, unlock_dll, c, rate > clk->rate,
887 sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla,
888 sdrc_cs0->actim_ctrlb, sdrc_cs0->mr,
889 sdrc_cs1->rfr_ctrl, sdrc_cs1->actim_ctrla,
890 sdrc_cs1->actim_ctrlb, sdrc_cs1->mr);
891 else
892 omap3_configure_core_dpll(
893 new_div, unlock_dll, c, rate > clk->rate,
894 sdrc_cs0->rfr_ctrl, sdrc_cs0->actim_ctrla,
895 sdrc_cs0->actim_ctrlb, sdrc_cs0->mr,
896 0, 0, 0, 0);
774 897
775 return 0; 898 return 0;
776} 899}
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
index e433aec4efdd..57cc2725b923 100644
--- a/arch/arm/mach-omap2/clock34xx.h
+++ b/arch/arm/mach-omap2/clock34xx.h
@@ -1568,7 +1568,7 @@ static const struct clksel ssi_ssr_clksel[] = {
1568 { .parent = NULL } 1568 { .parent = NULL }
1569}; 1569};
1570 1570
1571static struct clk ssi_ssr_fck = { 1571static struct clk ssi_ssr_fck_3430es1 = {
1572 .name = "ssi_ssr_fck", 1572 .name = "ssi_ssr_fck",
1573 .ops = &clkops_omap2_dflt, 1573 .ops = &clkops_omap2_dflt,
1574 .init = &omap2_init_clksel_parent, 1574 .init = &omap2_init_clksel_parent,
@@ -1581,10 +1581,31 @@ static struct clk ssi_ssr_fck = {
1581 .recalc = &omap2_clksel_recalc, 1581 .recalc = &omap2_clksel_recalc,
1582}; 1582};
1583 1583
1584static struct clk ssi_sst_fck = { 1584static struct clk ssi_ssr_fck_3430es2 = {
1585 .name = "ssi_ssr_fck",
1586 .ops = &clkops_omap3430es2_ssi_wait,
1587 .init = &omap2_init_clksel_parent,
1588 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_FCLKEN1),
1589 .enable_bit = OMAP3430_EN_SSI_SHIFT,
1590 .clksel_reg = OMAP_CM_REGADDR(CORE_MOD, CM_CLKSEL),
1591 .clksel_mask = OMAP3430_CLKSEL_SSI_MASK,
1592 .clksel = ssi_ssr_clksel,
1593 .clkdm_name = "core_l4_clkdm",
1594 .recalc = &omap2_clksel_recalc,
1595};
1596
1597static struct clk ssi_sst_fck_3430es1 = {
1585 .name = "ssi_sst_fck", 1598 .name = "ssi_sst_fck",
1586 .ops = &clkops_null, 1599 .ops = &clkops_null,
1587 .parent = &ssi_ssr_fck, 1600 .parent = &ssi_ssr_fck_3430es1,
1601 .fixed_div = 2,
1602 .recalc = &omap2_fixed_divisor_recalc,
1603};
1604
1605static struct clk ssi_sst_fck_3430es2 = {
1606 .name = "ssi_sst_fck",
1607 .ops = &clkops_null,
1608 .parent = &ssi_ssr_fck_3430es2,
1588 .fixed_div = 2, 1609 .fixed_div = 2,
1589 .recalc = &omap2_fixed_divisor_recalc, 1610 .recalc = &omap2_fixed_divisor_recalc,
1590}; 1611};
@@ -1606,9 +1627,19 @@ static struct clk core_l3_ick = {
1606 .recalc = &followparent_recalc, 1627 .recalc = &followparent_recalc,
1607}; 1628};
1608 1629
1609static struct clk hsotgusb_ick = { 1630static struct clk hsotgusb_ick_3430es1 = {
1610 .name = "hsotgusb_ick", 1631 .name = "hsotgusb_ick",
1611 .ops = &clkops_omap2_dflt_wait, 1632 .ops = &clkops_omap2_dflt,
1633 .parent = &core_l3_ick,
1634 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1635 .enable_bit = OMAP3430_EN_HSOTGUSB_SHIFT,
1636 .clkdm_name = "core_l3_clkdm",
1637 .recalc = &followparent_recalc,
1638};
1639
1640static struct clk hsotgusb_ick_3430es2 = {
1641 .name = "hsotgusb_ick",
1642 .ops = &clkops_omap3430es2_hsotgusb_wait,
1612 .parent = &core_l3_ick, 1643 .parent = &core_l3_ick,
1613 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1), 1644 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1614 .enable_bit = OMAP3430_EN_HSOTGUSB_SHIFT, 1645 .enable_bit = OMAP3430_EN_HSOTGUSB_SHIFT,
@@ -1947,7 +1978,7 @@ static struct clk ssi_l4_ick = {
1947 .recalc = &followparent_recalc, 1978 .recalc = &followparent_recalc,
1948}; 1979};
1949 1980
1950static struct clk ssi_ick = { 1981static struct clk ssi_ick_3430es1 = {
1951 .name = "ssi_ick", 1982 .name = "ssi_ick",
1952 .ops = &clkops_omap2_dflt, 1983 .ops = &clkops_omap2_dflt,
1953 .parent = &ssi_l4_ick, 1984 .parent = &ssi_l4_ick,
@@ -1957,6 +1988,16 @@ static struct clk ssi_ick = {
1957 .recalc = &followparent_recalc, 1988 .recalc = &followparent_recalc,
1958}; 1989};
1959 1990
1991static struct clk ssi_ick_3430es2 = {
1992 .name = "ssi_ick",
1993 .ops = &clkops_omap3430es2_ssi_wait,
1994 .parent = &ssi_l4_ick,
1995 .enable_reg = OMAP_CM_REGADDR(CORE_MOD, CM_ICLKEN1),
1996 .enable_bit = OMAP3430_EN_SSI_SHIFT,
1997 .clkdm_name = "core_l4_clkdm",
1998 .recalc = &followparent_recalc,
1999};
2000
1960/* REVISIT: Technically the TRM claims that this is CORE_CLK based, 2001/* REVISIT: Technically the TRM claims that this is CORE_CLK based,
1961 * but l4_ick makes more sense to me */ 2002 * but l4_ick makes more sense to me */
1962 2003
@@ -2024,7 +2065,7 @@ static struct clk des1_ick = {
2024}; 2065};
2025 2066
2026/* DSS */ 2067/* DSS */
2027static struct clk dss1_alwon_fck = { 2068static struct clk dss1_alwon_fck_3430es1 = {
2028 .name = "dss1_alwon_fck", 2069 .name = "dss1_alwon_fck",
2029 .ops = &clkops_omap2_dflt, 2070 .ops = &clkops_omap2_dflt,
2030 .parent = &dpll4_m4x2_ck, 2071 .parent = &dpll4_m4x2_ck,
@@ -2034,6 +2075,16 @@ static struct clk dss1_alwon_fck = {
2034 .recalc = &followparent_recalc, 2075 .recalc = &followparent_recalc,
2035}; 2076};
2036 2077
2078static struct clk dss1_alwon_fck_3430es2 = {
2079 .name = "dss1_alwon_fck",
2080 .ops = &clkops_omap3430es2_dss_usbhost_wait,
2081 .parent = &dpll4_m4x2_ck,
2082 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_FCLKEN),
2083 .enable_bit = OMAP3430_EN_DSS1_SHIFT,
2084 .clkdm_name = "dss_clkdm",
2085 .recalc = &followparent_recalc,
2086};
2087
2037static struct clk dss_tv_fck = { 2088static struct clk dss_tv_fck = {
2038 .name = "dss_tv_fck", 2089 .name = "dss_tv_fck",
2039 .ops = &clkops_omap2_dflt, 2090 .ops = &clkops_omap2_dflt,
@@ -2067,7 +2118,7 @@ static struct clk dss2_alwon_fck = {
2067 .recalc = &followparent_recalc, 2118 .recalc = &followparent_recalc,
2068}; 2119};
2069 2120
2070static struct clk dss_ick = { 2121static struct clk dss_ick_3430es1 = {
2071 /* Handles both L3 and L4 clocks */ 2122 /* Handles both L3 and L4 clocks */
2072 .name = "dss_ick", 2123 .name = "dss_ick",
2073 .ops = &clkops_omap2_dflt, 2124 .ops = &clkops_omap2_dflt,
@@ -2079,6 +2130,18 @@ static struct clk dss_ick = {
2079 .recalc = &followparent_recalc, 2130 .recalc = &followparent_recalc,
2080}; 2131};
2081 2132
2133static struct clk dss_ick_3430es2 = {
2134 /* Handles both L3 and L4 clocks */
2135 .name = "dss_ick",
2136 .ops = &clkops_omap3430es2_dss_usbhost_wait,
2137 .parent = &l4_ick,
2138 .init = &omap2_init_clk_clkdm,
2139 .enable_reg = OMAP_CM_REGADDR(OMAP3430_DSS_MOD, CM_ICLKEN),
2140 .enable_bit = OMAP3430_CM_ICLKEN_DSS_EN_DSS_SHIFT,
2141 .clkdm_name = "dss_clkdm",
2142 .recalc = &followparent_recalc,
2143};
2144
2082/* CAM */ 2145/* CAM */
2083 2146
2084static struct clk cam_mclk = { 2147static struct clk cam_mclk = {
@@ -2118,7 +2181,7 @@ static struct clk csi2_96m_fck = {
2118 2181
2119static struct clk usbhost_120m_fck = { 2182static struct clk usbhost_120m_fck = {
2120 .name = "usbhost_120m_fck", 2183 .name = "usbhost_120m_fck",
2121 .ops = &clkops_omap2_dflt_wait, 2184 .ops = &clkops_omap2_dflt,
2122 .parent = &dpll5_m2_ck, 2185 .parent = &dpll5_m2_ck,
2123 .init = &omap2_init_clk_clkdm, 2186 .init = &omap2_init_clk_clkdm,
2124 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN), 2187 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN),
@@ -2129,7 +2192,7 @@ static struct clk usbhost_120m_fck = {
2129 2192
2130static struct clk usbhost_48m_fck = { 2193static struct clk usbhost_48m_fck = {
2131 .name = "usbhost_48m_fck", 2194 .name = "usbhost_48m_fck",
2132 .ops = &clkops_omap2_dflt_wait, 2195 .ops = &clkops_omap3430es2_dss_usbhost_wait,
2133 .parent = &omap_48m_fck, 2196 .parent = &omap_48m_fck,
2134 .init = &omap2_init_clk_clkdm, 2197 .init = &omap2_init_clk_clkdm,
2135 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN), 2198 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_FCLKEN),
@@ -2141,7 +2204,7 @@ static struct clk usbhost_48m_fck = {
2141static struct clk usbhost_ick = { 2204static struct clk usbhost_ick = {
2142 /* Handles both L3 and L4 clocks */ 2205 /* Handles both L3 and L4 clocks */
2143 .name = "usbhost_ick", 2206 .name = "usbhost_ick",
2144 .ops = &clkops_omap2_dflt_wait, 2207 .ops = &clkops_omap3430es2_dss_usbhost_wait,
2145 .parent = &l4_ick, 2208 .parent = &l4_ick,
2146 .init = &omap2_init_clk_clkdm, 2209 .init = &omap2_init_clk_clkdm,
2147 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_ICLKEN), 2210 .enable_reg = OMAP_CM_REGADDR(OMAP3430ES2_USBHOST_MOD, CM_ICLKEN),
diff --git a/arch/arm/mach-omap2/io.c b/arch/arm/mach-omap2/io.c
index 3a86b0f66031..e9b9bcb19b4e 100644
--- a/arch/arm/mach-omap2/io.c
+++ b/arch/arm/mach-omap2/io.c
@@ -276,14 +276,15 @@ static int __init _omap2_init_reprogram_sdrc(void)
276 return v; 276 return v;
277} 277}
278 278
279void __init omap2_init_common_hw(struct omap_sdrc_params *sp) 279void __init omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
280 struct omap_sdrc_params *sdrc_cs1)
280{ 281{
281 omap2_mux_init(); 282 omap2_mux_init();
282#ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once the clkdev is ready */ 283#ifndef CONFIG_ARCH_OMAP4 /* FIXME: Remove this once the clkdev is ready */
283 pwrdm_init(powerdomains_omap); 284 pwrdm_init(powerdomains_omap);
284 clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps); 285 clkdm_init(clockdomains_omap, clkdm_pwrdm_autodeps);
285 omap2_clk_init(); 286 omap2_clk_init();
286 omap2_sdrc_init(sp); 287 omap2_sdrc_init(sdrc_cs0, sdrc_cs1);
287 _omap2_init_reprogram_sdrc(); 288 _omap2_init_reprogram_sdrc();
288#endif 289#endif
289 gpmc_init(); 290 gpmc_init();
diff --git a/arch/arm/mach-omap2/mmc-twl4030.c b/arch/arm/mach-omap2/mmc-twl4030.c
index 1541fd4c8d0f..3c04c2f1b23f 100644
--- a/arch/arm/mach-omap2/mmc-twl4030.c
+++ b/arch/arm/mach-omap2/mmc-twl4030.c
@@ -119,6 +119,7 @@ static int twl_mmc_late_init(struct device *dev)
119 if (i != 0) 119 if (i != 0)
120 break; 120 break;
121 ret = PTR_ERR(reg); 121 ret = PTR_ERR(reg);
122 hsmmc[i].vcc = NULL;
122 goto err; 123 goto err;
123 } 124 }
124 hsmmc[i].vcc = reg; 125 hsmmc[i].vcc = reg;
@@ -165,8 +166,13 @@ done:
165static void twl_mmc_cleanup(struct device *dev) 166static void twl_mmc_cleanup(struct device *dev)
166{ 167{
167 struct omap_mmc_platform_data *mmc = dev->platform_data; 168 struct omap_mmc_platform_data *mmc = dev->platform_data;
169 int i;
168 170
169 gpio_free(mmc->slots[0].switch_pin); 171 gpio_free(mmc->slots[0].switch_pin);
172 for(i = 0; i < ARRAY_SIZE(hsmmc); i++) {
173 regulator_put(hsmmc[i].vcc);
174 regulator_put(hsmmc[i].vcc_aux);
175 }
170} 176}
171 177
172#ifdef CONFIG_PM 178#ifdef CONFIG_PM
diff --git a/arch/arm/mach-omap2/mux.c b/arch/arm/mach-omap2/mux.c
index 026c4fc883a7..43d6b92b65f2 100644
--- a/arch/arm/mach-omap2/mux.c
+++ b/arch/arm/mach-omap2/mux.c
@@ -486,6 +486,12 @@ MUX_CFG_34XX("H19_34XX_GPIO164_OUT", 0x19c,
486 OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT) 486 OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
487MUX_CFG_34XX("J25_34XX_GPIO170", 0x1c6, 487MUX_CFG_34XX("J25_34XX_GPIO170", 0x1c6,
488 OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_INPUT) 488 OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_INPUT)
489
490/* OMAP3 SDRC CKE signals to SDR/DDR ram chips */
491MUX_CFG_34XX("H16_34XX_SDRC_CKE0", 0x262,
492 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_OUTPUT)
493MUX_CFG_34XX("H17_34XX_SDRC_CKE1", 0x264,
494 OMAP34XX_MUX_MODE0 | OMAP34XX_PIN_OUTPUT)
489}; 495};
490 496
491#define OMAP34XX_PINS_SZ ARRAY_SIZE(omap34xx_pins) 497#define OMAP34XX_PINS_SZ ARRAY_SIZE(omap34xx_pins)
diff --git a/arch/arm/mach-omap2/prcm.c b/arch/arm/mach-omap2/prcm.c
index f945156d5585..ced555a4cd1a 100644
--- a/arch/arm/mach-omap2/prcm.c
+++ b/arch/arm/mach-omap2/prcm.c
@@ -17,6 +17,7 @@
17#include <linux/init.h> 17#include <linux/init.h>
18#include <linux/clk.h> 18#include <linux/clk.h>
19#include <linux/io.h> 19#include <linux/io.h>
20#include <linux/delay.h>
20 21
21#include <mach/common.h> 22#include <mach/common.h>
22#include <mach/prcm.h> 23#include <mach/prcm.h>
@@ -28,6 +29,8 @@
28static void __iomem *prm_base; 29static void __iomem *prm_base;
29static void __iomem *cm_base; 30static void __iomem *cm_base;
30 31
32#define MAX_MODULE_ENABLE_WAIT 100000
33
31u32 omap_prcm_get_reset_sources(void) 34u32 omap_prcm_get_reset_sources(void)
32{ 35{
33 /* XXX This presumably needs modification for 34XX */ 36 /* XXX This presumably needs modification for 34XX */
@@ -120,6 +123,46 @@ u32 cm_rmw_mod_reg_bits(u32 mask, u32 bits, s16 module, s16 idx)
120} 123}
121EXPORT_SYMBOL(cm_rmw_mod_reg_bits); 124EXPORT_SYMBOL(cm_rmw_mod_reg_bits);
122 125
126/**
127 * omap2_cm_wait_idlest - wait for IDLEST bit to indicate module readiness
128 * @reg: physical address of module IDLEST register
129 * @mask: value to mask against to determine if the module is active
130 * @name: name of the clock (for printk)
131 *
132 * Returns 1 if the module indicated readiness in time, or 0 if it
133 * failed to enable in roughly MAX_MODULE_ENABLE_WAIT microseconds.
134 */
135int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, const char *name)
136{
137 int i = 0;
138 int ena = 0;
139
140 /*
141 * 24xx uses 0 to indicate not ready, and 1 to indicate ready.
142 * 34xx reverses this, just to keep us on our toes
143 */
144 if (cpu_is_omap24xx())
145 ena = mask;
146 else if (cpu_is_omap34xx())
147 ena = 0;
148 else
149 BUG();
150
151 /* Wait for lock */
152 while (((__raw_readl(reg) & mask) != ena) &&
153 (i++ < MAX_MODULE_ENABLE_WAIT))
154 udelay(1);
155
156 if (i < MAX_MODULE_ENABLE_WAIT)
157 pr_debug("cm: Module associated with clock %s ready after %d "
158 "loops\n", name, i);
159 else
160 pr_err("cm: Module associated with clock %s didn't enable in "
161 "%d tries\n", name, MAX_MODULE_ENABLE_WAIT);
162
163 return (i < MAX_MODULE_ENABLE_WAIT) ? 1 : 0;
164};
165
123void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals) 166void __init omap2_set_globals_prcm(struct omap_globals *omap2_globals)
124{ 167{
125 prm_base = omap2_globals->prm; 168 prm_base = omap2_globals->prm;
diff --git a/arch/arm/mach-omap2/sdrc.c b/arch/arm/mach-omap2/sdrc.c
index 2045441e8385..9e3bd4fa7810 100644
--- a/arch/arm/mach-omap2/sdrc.c
+++ b/arch/arm/mach-omap2/sdrc.c
@@ -32,7 +32,7 @@
32#include <mach/sdrc.h> 32#include <mach/sdrc.h>
33#include "sdrc.h" 33#include "sdrc.h"
34 34
35static struct omap_sdrc_params *sdrc_init_params; 35static struct omap_sdrc_params *sdrc_init_params_cs0, *sdrc_init_params_cs1;
36 36
37void __iomem *omap2_sdrc_base; 37void __iomem *omap2_sdrc_base;
38void __iomem *omap2_sms_base; 38void __iomem *omap2_sms_base;
@@ -45,33 +45,49 @@ void __iomem *omap2_sms_base;
45/** 45/**
46 * omap2_sdrc_get_params - return SDRC register values for a given clock rate 46 * omap2_sdrc_get_params - return SDRC register values for a given clock rate
47 * @r: SDRC clock rate (in Hz) 47 * @r: SDRC clock rate (in Hz)
48 * @sdrc_cs0: chip select 0 ram timings **
49 * @sdrc_cs1: chip select 1 ram timings **
48 * 50 *
49 * Return pre-calculated values for the SDRC_ACTIM_CTRLA, 51 * Return pre-calculated values for the SDRC_ACTIM_CTRLA,
50 * SDRC_ACTIM_CTRLB, SDRC_RFR_CTRL, and SDRC_MR registers, for a given 52 * SDRC_ACTIM_CTRLB, SDRC_RFR_CTRL and SDRC_MR registers in sdrc_cs[01]
51 * SDRC clock rate 'r'. These parameters control various timing 53 * structs,for a given SDRC clock rate 'r'.
52 * delays in the SDRAM controller that are expressed in terms of the 54 * These parameters control various timing delays in the SDRAM controller
53 * number of SDRC clock cycles to wait; hence the clock rate 55 * that are expressed in terms of the number of SDRC clock cycles to
54 * dependency. Note that sdrc_init_params must be sorted rate 56 * wait; hence the clock rate dependency.
55 * descending. Also assumes that both chip-selects use the same 57 *
56 * timing parameters. Returns a struct omap_sdrc_params * upon 58 * Supports 2 different timing parameters for both chip selects.
57 * success, or NULL upon failure. 59 *
60 * Note 1: the sdrc_init_params_cs[01] must be sorted rate descending.
61 * Note 2: If sdrc_init_params_cs_1 is not NULL it must be of same size
62 * as sdrc_init_params_cs_0.
63 *
64 * Fills in the struct omap_sdrc_params * for each chip select.
65 * Returns 0 upon success or -1 upon failure.
58 */ 66 */
59struct omap_sdrc_params *omap2_sdrc_get_params(unsigned long r) 67int omap2_sdrc_get_params(unsigned long r,
68 struct omap_sdrc_params **sdrc_cs0,
69 struct omap_sdrc_params **sdrc_cs1)
60{ 70{
61 struct omap_sdrc_params *sp; 71 struct omap_sdrc_params *sp0, *sp1;
62 72
63 if (!sdrc_init_params) 73 if (!sdrc_init_params_cs0)
64 return NULL; 74 return -1;
65 75
66 sp = sdrc_init_params; 76 sp0 = sdrc_init_params_cs0;
77 sp1 = sdrc_init_params_cs1;
67 78
68 while (sp->rate && sp->rate != r) 79 while (sp0->rate && sp0->rate != r) {
69 sp++; 80 sp0++;
81 if (sdrc_init_params_cs1)
82 sp1++;
83 }
70 84
71 if (!sp->rate) 85 if (!sp0->rate)
72 return NULL; 86 return -1;
73 87
74 return sp; 88 *sdrc_cs0 = sp0;
89 *sdrc_cs1 = sp1;
90 return 0;
75} 91}
76 92
77 93
@@ -83,13 +99,15 @@ void __init omap2_set_globals_sdrc(struct omap_globals *omap2_globals)
83 99
84/** 100/**
85 * omap2_sdrc_init - initialize SMS, SDRC devices on boot 101 * omap2_sdrc_init - initialize SMS, SDRC devices on boot
86 * @sp: pointer to a null-terminated list of struct omap_sdrc_params 102 * @sdrc_cs[01]: pointers to a null-terminated list of struct omap_sdrc_params
103 * Support for 2 chip selects timings
87 * 104 *
88 * Turn on smart idle modes for SDRAM scheduler and controller. 105 * Turn on smart idle modes for SDRAM scheduler and controller.
89 * Program a known-good configuration for the SDRC to deal with buggy 106 * Program a known-good configuration for the SDRC to deal with buggy
90 * bootloaders. 107 * bootloaders.
91 */ 108 */
92void __init omap2_sdrc_init(struct omap_sdrc_params *sp) 109void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
110 struct omap_sdrc_params *sdrc_cs1)
93{ 111{
94 u32 l; 112 u32 l;
95 113
@@ -103,11 +121,15 @@ void __init omap2_sdrc_init(struct omap_sdrc_params *sp)
103 l |= (0x2 << 3); 121 l |= (0x2 << 3);
104 sdrc_write_reg(l, SDRC_SYSCONFIG); 122 sdrc_write_reg(l, SDRC_SYSCONFIG);
105 123
106 sdrc_init_params = sp; 124 sdrc_init_params_cs0 = sdrc_cs0;
125 sdrc_init_params_cs1 = sdrc_cs1;
107 126
108 /* XXX Enable SRFRONIDLEREQ here also? */ 127 /* XXX Enable SRFRONIDLEREQ here also? */
128 /*
129 * PWDENA should not be set due to 34xx erratum 1.150 - PWDENA
130 * can cause random memory corruption
131 */
109 l = (1 << SDRC_POWER_EXTCLKDIS_SHIFT) | 132 l = (1 << SDRC_POWER_EXTCLKDIS_SHIFT) |
110 (1 << SDRC_POWER_PWDENA_SHIFT) |
111 (1 << SDRC_POWER_PAGEPOLICY_SHIFT); 133 (1 << SDRC_POWER_PAGEPOLICY_SHIFT);
112 sdrc_write_reg(l, SDRC_POWER); 134 sdrc_write_reg(l, SDRC_POWER);
113} 135}
diff --git a/arch/arm/mach-omap2/sram34xx.S b/arch/arm/mach-omap2/sram34xx.S
index f41f8d96ddba..82aa4a3d160c 100644
--- a/arch/arm/mach-omap2/sram34xx.S
+++ b/arch/arm/mach-omap2/sram34xx.S
@@ -36,7 +36,7 @@
36 36
37 .text 37 .text
38 38
39/* r4 parameters */ 39/* r1 parameters */
40#define SDRC_NO_UNLOCK_DLL 0x0 40#define SDRC_NO_UNLOCK_DLL 0x0
41#define SDRC_UNLOCK_DLL 0x1 41#define SDRC_UNLOCK_DLL 0x1
42 42
@@ -58,7 +58,6 @@
58 58
59/* SDRC_POWER bit settings */ 59/* SDRC_POWER bit settings */
60#define SRFRONIDLEREQ_MASK 0x40 60#define SRFRONIDLEREQ_MASK 0x40
61#define PWDENA_MASK 0x4
62 61
63/* CM_IDLEST1_CORE bit settings */ 62/* CM_IDLEST1_CORE bit settings */
64#define ST_SDRC_MASK 0x2 63#define ST_SDRC_MASK 0x2
@@ -71,41 +70,72 @@
71 70
72/* 71/*
73 * omap3_sram_configure_core_dpll - change DPLL3 M2 divider 72 * omap3_sram_configure_core_dpll - change DPLL3 M2 divider
74 * r0 = new SDRC_RFR_CTRL register contents 73 *
75 * r1 = new SDRC_ACTIM_CTRLA register contents 74 * Params passed in registers:
76 * r2 = new SDRC_ACTIM_CTRLB register contents 75 * r0 = new M2 divider setting (only 1 and 2 supported right now)
77 * r3 = new M2 divider setting (only 1 and 2 supported right now) 76 * r1 = unlock SDRC DLL? (1 = yes, 0 = no). Only unlock DLL for
78 * r4 = unlock SDRC DLL? (1 = yes, 0 = no). Only unlock DLL for
79 * SDRC rates < 83MHz 77 * SDRC rates < 83MHz
80 * r5 = number of MPU cycles to wait for SDRC to stabilize after 78 * r2 = number of MPU cycles to wait for SDRC to stabilize after
81 * reprogramming the SDRC when switching to a slower MPU speed 79 * reprogramming the SDRC when switching to a slower MPU speed
82 * r6 = new SDRC_MR_0 register value 80 * r3 = increasing SDRC rate? (1 = yes, 0 = no)
83 * r7 = increasing SDRC rate? (1 = yes, 0 = no) 81 *
82 * Params passed via the stack. The needed params will be copied in SRAM
83 * before use by the code in SRAM (SDRAM is not accessible during SDRC
84 * reconfiguration):
85 * new SDRC_RFR_CTRL_0 register contents
86 * new SDRC_ACTIM_CTRL_A_0 register contents
87 * new SDRC_ACTIM_CTRL_B_0 register contents
88 * new SDRC_MR_0 register value
89 * new SDRC_RFR_CTRL_1 register contents
90 * new SDRC_ACTIM_CTRL_A_1 register contents
91 * new SDRC_ACTIM_CTRL_B_1 register contents
92 * new SDRC_MR_1 register value
84 * 93 *
94 * If the param SDRC_RFR_CTRL_1 is 0, the parameters
95 * are not programmed into the SDRC CS1 registers
85 */ 96 */
86ENTRY(omap3_sram_configure_core_dpll) 97ENTRY(omap3_sram_configure_core_dpll)
87 stmfd sp!, {r1-r12, lr} @ store regs to stack 98 stmfd sp!, {r1-r12, lr} @ store regs to stack
88 ldr r4, [sp, #52] @ pull extra args off the stack 99
89 ldr r5, [sp, #56] @ load extra args from the stack 100 @ pull the extra args off the stack
90 ldr r6, [sp, #60] @ load extra args from the stack 101 @ and store them in SRAM
91 ldr r7, [sp, #64] @ load extra args from the stack 102 ldr r4, [sp, #52]
103 str r4, omap_sdrc_rfr_ctrl_0_val
104 ldr r4, [sp, #56]
105 str r4, omap_sdrc_actim_ctrl_a_0_val
106 ldr r4, [sp, #60]
107 str r4, omap_sdrc_actim_ctrl_b_0_val
108 ldr r4, [sp, #64]
109 str r4, omap_sdrc_mr_0_val
110 ldr r4, [sp, #68]
111 str r4, omap_sdrc_rfr_ctrl_1_val
112 cmp r4, #0 @ if SDRC_RFR_CTRL_1 is 0,
113 beq skip_cs1_params @ do not use cs1 params
114 ldr r4, [sp, #72]
115 str r4, omap_sdrc_actim_ctrl_a_1_val
116 ldr r4, [sp, #76]
117 str r4, omap_sdrc_actim_ctrl_b_1_val
118 ldr r4, [sp, #80]
119 str r4, omap_sdrc_mr_1_val
120skip_cs1_params:
92 dsb @ flush buffered writes to interconnect 121 dsb @ flush buffered writes to interconnect
93 cmp r7, #1 @ if increasing SDRC clk rate, 122
123 cmp r3, #1 @ if increasing SDRC clk rate,
94 bleq configure_sdrc @ program the SDRC regs early (for RFR) 124 bleq configure_sdrc @ program the SDRC regs early (for RFR)
95 cmp r4, #SDRC_UNLOCK_DLL @ set the intended DLL state 125 cmp r1, #SDRC_UNLOCK_DLL @ set the intended DLL state
96 bleq unlock_dll 126 bleq unlock_dll
97 blne lock_dll 127 blne lock_dll
98 bl sdram_in_selfrefresh @ put SDRAM in self refresh, idle SDRC 128 bl sdram_in_selfrefresh @ put SDRAM in self refresh, idle SDRC
99 bl configure_core_dpll @ change the DPLL3 M2 divider 129 bl configure_core_dpll @ change the DPLL3 M2 divider
130 mov r12, r2
131 bl wait_clk_stable @ wait for SDRC to stabilize
100 bl enable_sdrc @ take SDRC out of idle 132 bl enable_sdrc @ take SDRC out of idle
101 cmp r4, #SDRC_UNLOCK_DLL @ wait for DLL status to change 133 cmp r1, #SDRC_UNLOCK_DLL @ wait for DLL status to change
102 bleq wait_dll_unlock 134 bleq wait_dll_unlock
103 blne wait_dll_lock 135 blne wait_dll_lock
104 cmp r7, #1 @ if increasing SDRC clk rate, 136 cmp r3, #1 @ if increasing SDRC clk rate,
105 beq return_to_sdram @ return to SDRAM code, otherwise, 137 beq return_to_sdram @ return to SDRAM code, otherwise,
106 bl configure_sdrc @ reprogram SDRC regs now 138 bl configure_sdrc @ reprogram SDRC regs now
107 mov r12, r5
108 bl wait_clk_stable @ wait for SDRC to stabilize
109return_to_sdram: 139return_to_sdram:
110 isb @ prevent speculative exec past here 140 isb @ prevent speculative exec past here
111 mov r0, #0 @ return value 141 mov r0, #0 @ return value
@@ -113,7 +143,7 @@ return_to_sdram:
113unlock_dll: 143unlock_dll:
114 ldr r11, omap3_sdrc_dlla_ctrl 144 ldr r11, omap3_sdrc_dlla_ctrl
115 ldr r12, [r11] 145 ldr r12, [r11]
116 and r12, r12, #FIXEDDELAY_MASK 146 bic r12, r12, #FIXEDDELAY_MASK
117 orr r12, r12, #FIXEDDELAY_DEFAULT 147 orr r12, r12, #FIXEDDELAY_DEFAULT
118 orr r12, r12, #DLLIDLE_MASK 148 orr r12, r12, #DLLIDLE_MASK
119 str r12, [r11] @ (no OCP barrier needed) 149 str r12, [r11] @ (no OCP barrier needed)
@@ -129,7 +159,6 @@ sdram_in_selfrefresh:
129 ldr r12, [r11] @ read the contents of SDRC_POWER 159 ldr r12, [r11] @ read the contents of SDRC_POWER
130 mov r9, r12 @ keep a copy of SDRC_POWER bits 160 mov r9, r12 @ keep a copy of SDRC_POWER bits
131 orr r12, r12, #SRFRONIDLEREQ_MASK @ enable self refresh on idle 161 orr r12, r12, #SRFRONIDLEREQ_MASK @ enable self refresh on idle
132 bic r12, r12, #PWDENA_MASK @ clear PWDENA
133 str r12, [r11] @ write back to SDRC_POWER register 162 str r12, [r11] @ write back to SDRC_POWER register
134 ldr r12, [r11] @ posted-write barrier for SDRC 163 ldr r12, [r11] @ posted-write barrier for SDRC
135idle_sdrc: 164idle_sdrc:
@@ -149,7 +178,7 @@ configure_core_dpll:
149 ldr r12, [r11] 178 ldr r12, [r11]
150 ldr r10, core_m2_mask_val @ modify m2 for core dpll 179 ldr r10, core_m2_mask_val @ modify m2 for core dpll
151 and r12, r12, r10 180 and r12, r12, r10
152 orr r12, r12, r3, lsl #CORE_DPLL_CLKOUT_DIV_SHIFT 181 orr r12, r12, r0, lsl #CORE_DPLL_CLKOUT_DIV_SHIFT
153 str r12, [r11] 182 str r12, [r11]
154 ldr r12, [r11] @ posted-write barrier for CM 183 ldr r12, [r11] @ posted-write barrier for CM
155 bx lr 184 bx lr
@@ -187,15 +216,34 @@ wait_dll_unlock:
187 bne wait_dll_unlock 216 bne wait_dll_unlock
188 bx lr 217 bx lr
189configure_sdrc: 218configure_sdrc:
190 ldr r11, omap3_sdrc_rfr_ctrl 219 ldr r12, omap_sdrc_rfr_ctrl_0_val @ fetch value from SRAM
191 str r0, [r11] 220 ldr r11, omap3_sdrc_rfr_ctrl_0 @ fetch addr from SRAM
192 ldr r11, omap3_sdrc_actim_ctrla 221 str r12, [r11] @ store
193 str r1, [r11] 222 ldr r12, omap_sdrc_actim_ctrl_a_0_val
194 ldr r11, omap3_sdrc_actim_ctrlb 223 ldr r11, omap3_sdrc_actim_ctrl_a_0
195 str r2, [r11] 224 str r12, [r11]
225 ldr r12, omap_sdrc_actim_ctrl_b_0_val
226 ldr r11, omap3_sdrc_actim_ctrl_b_0
227 str r12, [r11]
228 ldr r12, omap_sdrc_mr_0_val
196 ldr r11, omap3_sdrc_mr_0 229 ldr r11, omap3_sdrc_mr_0
197 str r6, [r11] 230 str r12, [r11]
198 ldr r6, [r11] @ posted-write barrier for SDRC 231 ldr r12, omap_sdrc_rfr_ctrl_1_val
232 cmp r12, #0 @ if SDRC_RFR_CTRL_1 is 0,
233 beq skip_cs1_prog @ do not program cs1 params
234 ldr r11, omap3_sdrc_rfr_ctrl_1
235 str r12, [r11]
236 ldr r12, omap_sdrc_actim_ctrl_a_1_val
237 ldr r11, omap3_sdrc_actim_ctrl_a_1
238 str r12, [r11]
239 ldr r12, omap_sdrc_actim_ctrl_b_1_val
240 ldr r11, omap3_sdrc_actim_ctrl_b_1
241 str r12, [r11]
242 ldr r12, omap_sdrc_mr_1_val
243 ldr r11, omap3_sdrc_mr_1
244 str r12, [r11]
245skip_cs1_prog:
246 ldr r12, [r11] @ posted-write barrier for SDRC
199 bx lr 247 bx lr
200 248
201omap3_sdrc_power: 249omap3_sdrc_power:
@@ -206,14 +254,40 @@ omap3_cm_idlest1_core:
206 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST) 254 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST)
207omap3_cm_iclken1_core: 255omap3_cm_iclken1_core:
208 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1) 256 .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1)
209omap3_sdrc_rfr_ctrl: 257
258omap3_sdrc_rfr_ctrl_0:
210 .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0) 259 .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0)
211omap3_sdrc_actim_ctrla: 260omap3_sdrc_rfr_ctrl_1:
261 .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_1)
262omap3_sdrc_actim_ctrl_a_0:
212 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0) 263 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0)
213omap3_sdrc_actim_ctrlb: 264omap3_sdrc_actim_ctrl_a_1:
265 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_1)
266omap3_sdrc_actim_ctrl_b_0:
214 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0) 267 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0)
268omap3_sdrc_actim_ctrl_b_1:
269 .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_1)
215omap3_sdrc_mr_0: 270omap3_sdrc_mr_0:
216 .word OMAP34XX_SDRC_REGADDR(SDRC_MR_0) 271 .word OMAP34XX_SDRC_REGADDR(SDRC_MR_0)
272omap3_sdrc_mr_1:
273 .word OMAP34XX_SDRC_REGADDR(SDRC_MR_1)
274omap_sdrc_rfr_ctrl_0_val:
275 .word 0xDEADBEEF
276omap_sdrc_rfr_ctrl_1_val:
277 .word 0xDEADBEEF
278omap_sdrc_actim_ctrl_a_0_val:
279 .word 0xDEADBEEF
280omap_sdrc_actim_ctrl_a_1_val:
281 .word 0xDEADBEEF
282omap_sdrc_actim_ctrl_b_0_val:
283 .word 0xDEADBEEF
284omap_sdrc_actim_ctrl_b_1_val:
285 .word 0xDEADBEEF
286omap_sdrc_mr_0_val:
287 .word 0xDEADBEEF
288omap_sdrc_mr_1_val:
289 .word 0xDEADBEEF
290
217omap3_sdrc_dlla_status: 291omap3_sdrc_dlla_status:
218 .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS) 292 .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
219omap3_sdrc_dlla_ctrl: 293omap3_sdrc_dlla_ctrl:
@@ -223,3 +297,4 @@ core_m2_mask_val:
223 297
224ENTRY(omap3_sram_configure_core_dpll_sz) 298ENTRY(omap3_sram_configure_core_dpll_sz)
225 .word . - omap3_sram_configure_core_dpll 299 .word . - omap3_sram_configure_core_dpll
300
diff --git a/arch/arm/mach-omap2/usb-musb.c b/arch/arm/mach-omap2/usb-musb.c
index d85296dc896c..739e59e8025c 100644
--- a/arch/arm/mach-omap2/usb-musb.c
+++ b/arch/arm/mach-omap2/usb-musb.c
@@ -155,20 +155,6 @@ static struct platform_device musb_device = {
155 .resource = musb_resources, 155 .resource = musb_resources,
156}; 156};
157 157
158#ifdef CONFIG_NOP_USB_XCEIV
159static u64 nop_xceiv_dmamask = DMA_BIT_MASK(32);
160
161static struct platform_device nop_xceiv_device = {
162 .name = "nop_usb_xceiv",
163 .id = -1,
164 .dev = {
165 .dma_mask = &nop_xceiv_dmamask,
166 .coherent_dma_mask = DMA_BIT_MASK(32),
167 .platform_data = NULL,
168 },
169};
170#endif
171
172void __init usb_musb_init(void) 158void __init usb_musb_init(void)
173{ 159{
174 if (cpu_is_omap243x()) 160 if (cpu_is_omap243x())
@@ -183,13 +169,6 @@ void __init usb_musb_init(void)
183 */ 169 */
184 musb_plat.clock = "ick"; 170 musb_plat.clock = "ick";
185 171
186#ifdef CONFIG_NOP_USB_XCEIV
187 if (platform_device_register(&nop_xceiv_device) < 0) {
188 printk(KERN_ERR "Unable to register NOP-XCEIV device\n");
189 return;
190 }
191#endif
192
193 if (platform_device_register(&musb_device) < 0) { 172 if (platform_device_register(&musb_device) < 0) {
194 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n"); 173 printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
195 return; 174 return;
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
index 63b10d9bb1d3..9cd09465a0e8 100644
--- a/arch/arm/mach-pxa/em-x270.c
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -1141,12 +1141,16 @@ struct power_supply_info em_x270_psy_info = {
1141 1141
1142static void em_x270_battery_low(void) 1142static void em_x270_battery_low(void)
1143{ 1143{
1144#if defined(CONFIG_APM_EMULATION)
1144 apm_queue_event(APM_LOW_BATTERY); 1145 apm_queue_event(APM_LOW_BATTERY);
1146#endif
1145} 1147}
1146 1148
1147static void em_x270_battery_critical(void) 1149static void em_x270_battery_critical(void)
1148{ 1150{
1151#if defined(CONFIG_APM_EMULATION)
1149 apm_queue_event(APM_CRITICAL_SUSPEND); 1152 apm_queue_event(APM_CRITICAL_SUSPEND);
1153#endif
1150} 1154}
1151 1155
1152struct da9030_battery_info em_x270_batterty_info = { 1156struct da9030_battery_info em_x270_batterty_info = {
diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c
index ed70f281dd09..169fcc18154e 100644
--- a/arch/arm/mach-pxa/palmld.c
+++ b/arch/arm/mach-pxa/palmld.c
@@ -128,6 +128,10 @@ static unsigned long palmld_pin_config[] __initdata = {
128 GPIO38_GPIO, /* wifi ready */ 128 GPIO38_GPIO, /* wifi ready */
129 GPIO81_GPIO, /* wifi reset */ 129 GPIO81_GPIO, /* wifi reset */
130 130
131 /* FFUART */
132 GPIO34_FFUART_RXD,
133 GPIO39_FFUART_TXD,
134
131 /* HDD */ 135 /* HDD */
132 GPIO98_GPIO, /* HDD reset */ 136 GPIO98_GPIO, /* HDD reset */
133 GPIO115_GPIO, /* HDD power */ 137 GPIO115_GPIO, /* HDD power */
diff --git a/arch/arm/mach-pxa/palmt5.c b/arch/arm/mach-pxa/palmt5.c
index aae64a12a734..33f726ff55e5 100644
--- a/arch/arm/mach-pxa/palmt5.c
+++ b/arch/arm/mach-pxa/palmt5.c
@@ -111,6 +111,10 @@ static unsigned long palmt5_pin_config[] __initdata = {
111 /* PWM */ 111 /* PWM */
112 GPIO16_PWM0_OUT, 112 GPIO16_PWM0_OUT,
113 113
114 /* FFUART */
115 GPIO34_FFUART_RXD,
116 GPIO39_FFUART_TXD,
117
114 /* MISC */ 118 /* MISC */
115 GPIO10_GPIO, /* hotsync button */ 119 GPIO10_GPIO, /* hotsync button */
116 GPIO90_GPIO, /* power detect */ 120 GPIO90_GPIO, /* power detect */
diff --git a/arch/arm/mach-pxa/palmtx.c b/arch/arm/mach-pxa/palmtx.c
index 6c15d84bde53..83d020879581 100644
--- a/arch/arm/mach-pxa/palmtx.c
+++ b/arch/arm/mach-pxa/palmtx.c
@@ -127,6 +127,10 @@ static unsigned long palmtx_pin_config[] __initdata = {
127 GPIO76_LCD_PCLK, 127 GPIO76_LCD_PCLK,
128 GPIO77_LCD_BIAS, 128 GPIO77_LCD_BIAS,
129 129
130 /* FFUART */
131 GPIO34_FFUART_RXD,
132 GPIO39_FFUART_TXD,
133
130 /* MISC. */ 134 /* MISC. */
131 GPIO10_GPIO, /* hotsync button */ 135 GPIO10_GPIO, /* hotsync button */
132 GPIO12_GPIO, /* power detect */ 136 GPIO12_GPIO, /* power detect */
diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c
index 2546c066cd6e..629e05d1196e 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.c
+++ b/arch/arm/mach-pxa/sharpsl_pm.c
@@ -678,8 +678,8 @@ static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enab
678 dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n"); 678 dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n");
679 } 679 }
680 680
681 if ((!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) || (sharpsl_fatal_check() < 0) ) 681 if ((!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) ||
682 { 682 (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_FATAL))) {
683 dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n"); 683 dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n");
684 corgi_goto_sleep(alarm_time, alarm_enable, state); 684 corgi_goto_sleep(alarm_time, alarm_enable, state);
685 return 1; 685 return 1;
diff --git a/arch/arm/mach-pxa/treo680.c b/arch/arm/mach-pxa/treo680.c
index a06f19edebb3..753ec4df17b9 100644
--- a/arch/arm/mach-pxa/treo680.c
+++ b/arch/arm/mach-pxa/treo680.c
@@ -409,7 +409,7 @@ err1:
409 409
410static void treo680_irda_shutdown(struct device *dev) 410static void treo680_irda_shutdown(struct device *dev)
411{ 411{
412 gpio_free(GPIO_NR_TREO680_AMP_EN); 412 gpio_free(GPIO_NR_TREO680_IR_EN);
413} 413}
414 414
415static struct pxaficp_platform_data treo680_ficp_info = { 415static struct pxaficp_platform_data treo680_ficp_info = {
diff --git a/arch/arm/mach-pxa/zylonite_pxa300.c b/arch/arm/mach-pxa/zylonite_pxa300.c
index cefd1c0a854a..84095440a878 100644
--- a/arch/arm/mach-pxa/zylonite_pxa300.c
+++ b/arch/arm/mach-pxa/zylonite_pxa300.c
@@ -197,10 +197,12 @@ static void __init zylonite_detect_lcd_panel(void)
197 for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { 197 for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
198 id = id << 1; 198 id = id << 1;
199 gpio = mfp_to_gpio(lcd_detect_pins[i]); 199 gpio = mfp_to_gpio(lcd_detect_pins[i]);
200 gpio_request(gpio, "LCD_ID_PINS");
200 gpio_direction_input(gpio); 201 gpio_direction_input(gpio);
201 202
202 if (gpio_get_value(gpio)) 203 if (gpio_get_value(gpio))
203 id = id | 0x1; 204 id = id | 0x1;
205 gpio_free(gpio);
204 } 206 }
205 207
206 /* lcd id, flush out bit 1 */ 208 /* lcd id, flush out bit 1 */
diff --git a/arch/arm/mach-pxa/zylonite_pxa320.c b/arch/arm/mach-pxa/zylonite_pxa320.c
index cc5a22833605..60d08f23f5e4 100644
--- a/arch/arm/mach-pxa/zylonite_pxa320.c
+++ b/arch/arm/mach-pxa/zylonite_pxa320.c
@@ -176,10 +176,12 @@ static void __init zylonite_detect_lcd_panel(void)
176 for (i = 0; i < NUM_LCD_DETECT_PINS; i++) { 176 for (i = 0; i < NUM_LCD_DETECT_PINS; i++) {
177 id = id << 1; 177 id = id << 1;
178 gpio = mfp_to_gpio(lcd_detect_pins[i]); 178 gpio = mfp_to_gpio(lcd_detect_pins[i]);
179 gpio_request(gpio, "LCD_ID_PINS");
179 gpio_direction_input(gpio); 180 gpio_direction_input(gpio);
180 181
181 if (gpio_get_value(gpio)) 182 if (gpio_get_value(gpio))
182 id = id | 0x1; 183 id = id | 0x1;
184 gpio_free(gpio);
183 } 185 }
184 186
185 /* lcd id, flush out bit 1 */ 187 /* lcd id, flush out bit 1 */
diff --git a/arch/arm/mach-u300/core.c b/arch/arm/mach-u300/core.c
index 7936085dd758..2e9b8ccd8ec2 100644
--- a/arch/arm/mach-u300/core.c
+++ b/arch/arm/mach-u300/core.c
@@ -510,7 +510,7 @@ static struct db_chip db_chips[] __initdata = {
510 } 510 }
511}; 511};
512 512
513static void u300_init_check_chip(void) 513static void __init u300_init_check_chip(void)
514{ 514{
515 515
516 u16 val; 516 u16 val;
diff --git a/arch/arm/mm/flush.c b/arch/arm/mm/flush.c
index c07222eb5ce0..575f3ad722e7 100644
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -144,7 +144,14 @@ void __flush_dcache_page(struct address_space *mapping, struct page *page)
144 * page. This ensures that data in the physical page is mutually 144 * page. This ensures that data in the physical page is mutually
145 * coherent with the kernels mapping. 145 * coherent with the kernels mapping.
146 */ 146 */
147 __cpuc_flush_dcache_page(page_address(page)); 147#ifdef CONFIG_HIGHMEM
148 /*
149 * kmap_atomic() doesn't set the page virtual address, and
150 * kunmap_atomic() takes care of cache flushing already.
151 */
152 if (page_address(page))
153#endif
154 __cpuc_flush_dcache_page(page_address(page));
148 155
149 /* 156 /*
150 * If this is a page cache page, and we have an aliasing VIPT cache, 157 * If this is a page cache page, and we have an aliasing VIPT cache,
diff --git a/arch/arm/mm/highmem.c b/arch/arm/mm/highmem.c
index a34954d9df7d..73cae57fa707 100644
--- a/arch/arm/mm/highmem.c
+++ b/arch/arm/mm/highmem.c
@@ -40,11 +40,16 @@ void *kmap_atomic(struct page *page, enum km_type type)
40{ 40{
41 unsigned int idx; 41 unsigned int idx;
42 unsigned long vaddr; 42 unsigned long vaddr;
43 void *kmap;
43 44
44 pagefault_disable(); 45 pagefault_disable();
45 if (!PageHighMem(page)) 46 if (!PageHighMem(page))
46 return page_address(page); 47 return page_address(page);
47 48
49 kmap = kmap_high_get(page);
50 if (kmap)
51 return kmap;
52
48 idx = type + KM_TYPE_NR * smp_processor_id(); 53 idx = type + KM_TYPE_NR * smp_processor_id();
49 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx); 54 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
50#ifdef CONFIG_DEBUG_HIGHMEM 55#ifdef CONFIG_DEBUG_HIGHMEM
@@ -80,6 +85,9 @@ void kunmap_atomic(void *kvaddr, enum km_type type)
80#else 85#else
81 (void) idx; /* to kill a warning */ 86 (void) idx; /* to kill a warning */
82#endif 87#endif
88 } else if (vaddr >= PKMAP_ADDR(0) && vaddr < PKMAP_ADDR(LAST_PKMAP)) {
89 /* this address was obtained through kmap_high_get() */
90 kunmap_high(pte_page(pkmap_page_table[PKMAP_NR(vaddr)]));
83 } 91 }
84 pagefault_enable(); 92 pagefault_enable();
85} 93}
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 8277802ec859..ea36186f32c3 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -15,6 +15,7 @@
15#include <linux/mman.h> 15#include <linux/mman.h>
16#include <linux/nodemask.h> 16#include <linux/nodemask.h>
17#include <linux/initrd.h> 17#include <linux/initrd.h>
18#include <linux/sort.h>
18#include <linux/highmem.h> 19#include <linux/highmem.h>
19 20
20#include <asm/mach-types.h> 21#include <asm/mach-types.h>
@@ -120,6 +121,32 @@ void show_mem(void)
120 printk("%d pages swap cached\n", cached); 121 printk("%d pages swap cached\n", cached);
121} 122}
122 123
124static void __init find_node_limits(int node, struct meminfo *mi,
125 unsigned long *min, unsigned long *max_low, unsigned long *max_high)
126{
127 int i;
128
129 *min = -1UL;
130 *max_low = *max_high = 0;
131
132 for_each_nodebank(i, mi, node) {
133 struct membank *bank = &mi->bank[i];
134 unsigned long start, end;
135
136 start = bank_pfn_start(bank);
137 end = bank_pfn_end(bank);
138
139 if (*min > start)
140 *min = start;
141 if (*max_high < end)
142 *max_high = end;
143 if (bank->highmem)
144 continue;
145 if (*max_low < end)
146 *max_low = end;
147 }
148}
149
123/* 150/*
124 * FIXME: We really want to avoid allocating the bootmap bitmap 151 * FIXME: We really want to avoid allocating the bootmap bitmap
125 * over the top of the initrd. Hopefully, this is located towards 152 * over the top of the initrd. Hopefully, this is located towards
@@ -210,41 +237,25 @@ static inline void map_memory_bank(struct membank *bank)
210#endif 237#endif
211} 238}
212 239
213static unsigned long __init bootmem_init_node(int node, struct meminfo *mi) 240static void __init bootmem_init_node(int node, struct meminfo *mi,
241 unsigned long start_pfn, unsigned long end_pfn)
214{ 242{
215 unsigned long start_pfn, end_pfn, boot_pfn; 243 unsigned long boot_pfn;
216 unsigned int boot_pages; 244 unsigned int boot_pages;
217 pg_data_t *pgdat; 245 pg_data_t *pgdat;
218 int i; 246 int i;
219 247
220 start_pfn = -1UL;
221 end_pfn = 0;
222
223 /* 248 /*
224 * Calculate the pfn range, and map the memory banks for this node. 249 * Map the memory banks for this node.
225 */ 250 */
226 for_each_nodebank(i, mi, node) { 251 for_each_nodebank(i, mi, node) {
227 struct membank *bank = &mi->bank[i]; 252 struct membank *bank = &mi->bank[i];
228 unsigned long start, end;
229
230 start = bank_pfn_start(bank);
231 end = bank_pfn_end(bank);
232
233 if (start_pfn > start)
234 start_pfn = start;
235 if (end_pfn < end)
236 end_pfn = end;
237 253
238 map_memory_bank(bank); 254 if (!bank->highmem)
255 map_memory_bank(bank);
239 } 256 }
240 257
241 /* 258 /*
242 * If there is no memory in this node, ignore it.
243 */
244 if (end_pfn == 0)
245 return end_pfn;
246
247 /*
248 * Allocate the bootmem bitmap page. 259 * Allocate the bootmem bitmap page.
249 */ 260 */
250 boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn); 261 boot_pages = bootmem_bootmap_pages(end_pfn - start_pfn);
@@ -260,7 +271,8 @@ static unsigned long __init bootmem_init_node(int node, struct meminfo *mi)
260 271
261 for_each_nodebank(i, mi, node) { 272 for_each_nodebank(i, mi, node) {
262 struct membank *bank = &mi->bank[i]; 273 struct membank *bank = &mi->bank[i];
263 free_bootmem_node(pgdat, bank_phys_start(bank), bank_phys_size(bank)); 274 if (!bank->highmem)
275 free_bootmem_node(pgdat, bank_phys_start(bank), bank_phys_size(bank));
264 memory_present(node, bank_pfn_start(bank), bank_pfn_end(bank)); 276 memory_present(node, bank_pfn_start(bank), bank_pfn_end(bank));
265 } 277 }
266 278
@@ -269,8 +281,6 @@ static unsigned long __init bootmem_init_node(int node, struct meminfo *mi)
269 */ 281 */
270 reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT, 282 reserve_bootmem_node(pgdat, boot_pfn << PAGE_SHIFT,
271 boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT); 283 boot_pages << PAGE_SHIFT, BOOTMEM_DEFAULT);
272
273 return end_pfn;
274} 284}
275 285
276static void __init bootmem_reserve_initrd(int node) 286static void __init bootmem_reserve_initrd(int node)
@@ -297,33 +307,39 @@ static void __init bootmem_reserve_initrd(int node)
297static void __init bootmem_free_node(int node, struct meminfo *mi) 307static void __init bootmem_free_node(int node, struct meminfo *mi)
298{ 308{
299 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES]; 309 unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
300 unsigned long start_pfn, end_pfn; 310 unsigned long min, max_low, max_high;
301 pg_data_t *pgdat = NODE_DATA(node);
302 int i; 311 int i;
303 312
304 start_pfn = pgdat->bdata->node_min_pfn; 313 find_node_limits(node, mi, &min, &max_low, &max_high);
305 end_pfn = pgdat->bdata->node_low_pfn;
306 314
307 /* 315 /*
308 * initialise the zones within this node. 316 * initialise the zones within this node.
309 */ 317 */
310 memset(zone_size, 0, sizeof(zone_size)); 318 memset(zone_size, 0, sizeof(zone_size));
311 memset(zhole_size, 0, sizeof(zhole_size));
312 319
313 /* 320 /*
314 * The size of this node has already been determined. If we need 321 * The size of this node has already been determined. If we need
315 * to do anything fancy with the allocation of this memory to the 322 * to do anything fancy with the allocation of this memory to the
316 * zones, now is the time to do it. 323 * zones, now is the time to do it.
317 */ 324 */
318 zone_size[0] = end_pfn - start_pfn; 325 zone_size[0] = max_low - min;
326#ifdef CONFIG_HIGHMEM
327 zone_size[ZONE_HIGHMEM] = max_high - max_low;
328#endif
319 329
320 /* 330 /*
321 * For each bank in this node, calculate the size of the holes. 331 * For each bank in this node, calculate the size of the holes.
322 * holes = node_size - sum(bank_sizes_in_node) 332 * holes = node_size - sum(bank_sizes_in_node)
323 */ 333 */
324 zhole_size[0] = zone_size[0]; 334 memcpy(zhole_size, zone_size, sizeof(zhole_size));
325 for_each_nodebank(i, mi, node) 335 for_each_nodebank(i, mi, node) {
326 zhole_size[0] -= bank_pfn_size(&mi->bank[i]); 336 int idx = 0;
337#ifdef CONFIG_HIGHMEM
338 if (mi->bank[i].highmem)
339 idx = ZONE_HIGHMEM;
340#endif
341 zhole_size[idx] -= bank_pfn_size(&mi->bank[i]);
342 }
327 343
328 /* 344 /*
329 * Adjust the sizes according to any special requirements for 345 * Adjust the sizes according to any special requirements for
@@ -331,25 +347,74 @@ static void __init bootmem_free_node(int node, struct meminfo *mi)
331 */ 347 */
332 arch_adjust_zones(node, zone_size, zhole_size); 348 arch_adjust_zones(node, zone_size, zhole_size);
333 349
334 free_area_init_node(node, zone_size, start_pfn, zhole_size); 350 free_area_init_node(node, zone_size, min, zhole_size);
351}
352
353#ifndef CONFIG_SPARSEMEM
354int pfn_valid(unsigned long pfn)
355{
356 struct meminfo *mi = &meminfo;
357 unsigned int left = 0, right = mi->nr_banks;
358
359 do {
360 unsigned int mid = (right + left) / 2;
361 struct membank *bank = &mi->bank[mid];
362
363 if (pfn < bank_pfn_start(bank))
364 right = mid;
365 else if (pfn >= bank_pfn_end(bank))
366 left = mid + 1;
367 else
368 return 1;
369 } while (left < right);
370 return 0;
371}
372EXPORT_SYMBOL(pfn_valid);
373#endif
374
375static int __init meminfo_cmp(const void *_a, const void *_b)
376{
377 const struct membank *a = _a, *b = _b;
378 long cmp = bank_pfn_start(a) - bank_pfn_start(b);
379 return cmp < 0 ? -1 : cmp > 0 ? 1 : 0;
335} 380}
336 381
337void __init bootmem_init(void) 382void __init bootmem_init(void)
338{ 383{
339 struct meminfo *mi = &meminfo; 384 struct meminfo *mi = &meminfo;
340 unsigned long memend_pfn = 0; 385 unsigned long min, max_low, max_high;
341 int node, initrd_node; 386 int node, initrd_node;
342 387
388 sort(&mi->bank, mi->nr_banks, sizeof(mi->bank[0]), meminfo_cmp, NULL);
389
343 /* 390 /*
344 * Locate which node contains the ramdisk image, if any. 391 * Locate which node contains the ramdisk image, if any.
345 */ 392 */
346 initrd_node = check_initrd(mi); 393 initrd_node = check_initrd(mi);
347 394
395 max_low = max_high = 0;
396
348 /* 397 /*
349 * Run through each node initialising the bootmem allocator. 398 * Run through each node initialising the bootmem allocator.
350 */ 399 */
351 for_each_node(node) { 400 for_each_node(node) {
352 unsigned long end_pfn = bootmem_init_node(node, mi); 401 unsigned long node_low, node_high;
402
403 find_node_limits(node, mi, &min, &node_low, &node_high);
404
405 if (node_low > max_low)
406 max_low = node_low;
407 if (node_high > max_high)
408 max_high = node_high;
409
410 /*
411 * If there is no memory in this node, ignore it.
412 * (We can't have nodes which have no lowmem)
413 */
414 if (node_low == 0)
415 continue;
416
417 bootmem_init_node(node, mi, min, node_low);
353 418
354 /* 419 /*
355 * Reserve any special node zero regions. 420 * Reserve any special node zero regions.
@@ -362,12 +427,6 @@ void __init bootmem_init(void)
362 */ 427 */
363 if (node == initrd_node) 428 if (node == initrd_node)
364 bootmem_reserve_initrd(node); 429 bootmem_reserve_initrd(node);
365
366 /*
367 * Remember the highest memory PFN.
368 */
369 if (end_pfn > memend_pfn)
370 memend_pfn = end_pfn;
371 } 430 }
372 431
373 /* 432 /*
@@ -383,7 +442,7 @@ void __init bootmem_init(void)
383 for_each_node(node) 442 for_each_node(node)
384 bootmem_free_node(node, mi); 443 bootmem_free_node(node, mi);
385 444
386 high_memory = __va((memend_pfn << PAGE_SHIFT) - 1) + 1; 445 high_memory = __va((max_low << PAGE_SHIFT) - 1) + 1;
387 446
388 /* 447 /*
389 * This doesn't seem to be used by the Linux memory manager any 448 * This doesn't seem to be used by the Linux memory manager any
@@ -393,7 +452,8 @@ void __init bootmem_init(void)
393 * Note: max_low_pfn and max_pfn reflect the number of _pages_ in 452 * Note: max_low_pfn and max_pfn reflect the number of _pages_ in
394 * the system, not the maximum PFN. 453 * the system, not the maximum PFN.
395 */ 454 */
396 max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET; 455 max_low_pfn = max_low - PHYS_PFN_OFFSET;
456 max_pfn = max_high - PHYS_PFN_OFFSET;
397} 457}
398 458
399static inline int free_area(unsigned long pfn, unsigned long end, char *s) 459static inline int free_area(unsigned long pfn, unsigned long end, char *s)
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 4722582b17b8..4426ee67ceca 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -687,13 +687,19 @@ __early_param("vmalloc=", early_vmalloc);
687 687
688static void __init sanity_check_meminfo(void) 688static void __init sanity_check_meminfo(void)
689{ 689{
690 int i, j; 690 int i, j, highmem = 0;
691 691
692 for (i = 0, j = 0; i < meminfo.nr_banks; i++) { 692 for (i = 0, j = 0; i < meminfo.nr_banks; i++) {
693 struct membank *bank = &meminfo.bank[j]; 693 struct membank *bank = &meminfo.bank[j];
694 *bank = meminfo.bank[i]; 694 *bank = meminfo.bank[i];
695 695
696#ifdef CONFIG_HIGHMEM 696#ifdef CONFIG_HIGHMEM
697 if (__va(bank->start) > VMALLOC_MIN ||
698 __va(bank->start) < (void *)PAGE_OFFSET)
699 highmem = 1;
700
701 bank->highmem = highmem;
702
697 /* 703 /*
698 * Split those memory banks which are partially overlapping 704 * Split those memory banks which are partially overlapping
699 * the vmalloc area greatly simplifying things later. 705 * the vmalloc area greatly simplifying things later.
@@ -714,6 +720,7 @@ static void __init sanity_check_meminfo(void)
714 i++; 720 i++;
715 bank[1].size -= VMALLOC_MIN - __va(bank->start); 721 bank[1].size -= VMALLOC_MIN - __va(bank->start);
716 bank[1].start = __pa(VMALLOC_MIN - 1) + 1; 722 bank[1].start = __pa(VMALLOC_MIN - 1) + 1;
723 bank[1].highmem = highmem = 1;
717 j++; 724 j++;
718 } 725 }
719 bank->size = VMALLOC_MIN - __va(bank->start); 726 bank->size = VMALLOC_MIN - __va(bank->start);
diff --git a/arch/arm/plat-omap/dma.c b/arch/arm/plat-omap/dma.c
index 7677a4a1cef2..e3ac94f09006 100644
--- a/arch/arm/plat-omap/dma.c
+++ b/arch/arm/plat-omap/dma.c
@@ -946,7 +946,9 @@ void omap_start_dma(int lch)
946 946
947 cur_lch = next_lch; 947 cur_lch = next_lch;
948 } while (next_lch != -1); 948 } while (next_lch != -1);
949 } else if (cpu_class_is_omap2()) { 949 } else if (cpu_is_omap242x() ||
950 (cpu_is_omap243x() && omap_type() <= OMAP2430_REV_ES1_0)) {
951
950 /* Errata: Need to write lch even if not using chaining */ 952 /* Errata: Need to write lch even if not using chaining */
951 dma_write(lch, CLNK_CTRL(lch)); 953 dma_write(lch, CLNK_CTRL(lch));
952 } 954 }
diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 00940dc6bb50..fd21937fe110 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -514,14 +514,12 @@ static void _set_gpio_dataout(struct gpio_bank *bank, int gpio, int enable)
514 __raw_writel(l, reg); 514 __raw_writel(l, reg);
515} 515}
516 516
517static int __omap_get_gpio_datain(int gpio) 517static int _get_gpio_datain(struct gpio_bank *bank, int gpio)
518{ 518{
519 struct gpio_bank *bank;
520 void __iomem *reg; 519 void __iomem *reg;
521 520
522 if (check_gpio(gpio) < 0) 521 if (check_gpio(gpio) < 0)
523 return -EINVAL; 522 return -EINVAL;
524 bank = get_gpio_bank(gpio);
525 reg = bank->base; 523 reg = bank->base;
526 switch (bank->method) { 524 switch (bank->method) {
527#ifdef CONFIG_ARCH_OMAP1 525#ifdef CONFIG_ARCH_OMAP1
@@ -566,6 +564,53 @@ static int __omap_get_gpio_datain(int gpio)
566 & (1 << get_gpio_index(gpio))) != 0; 564 & (1 << get_gpio_index(gpio))) != 0;
567} 565}
568 566
567static int _get_gpio_dataout(struct gpio_bank *bank, int gpio)
568{
569 void __iomem *reg;
570
571 if (check_gpio(gpio) < 0)
572 return -EINVAL;
573 reg = bank->base;
574
575 switch (bank->method) {
576#ifdef CONFIG_ARCH_OMAP1
577 case METHOD_MPUIO:
578 reg += OMAP_MPUIO_OUTPUT;
579 break;
580#endif
581#ifdef CONFIG_ARCH_OMAP15XX
582 case METHOD_GPIO_1510:
583 reg += OMAP1510_GPIO_DATA_OUTPUT;
584 break;
585#endif
586#ifdef CONFIG_ARCH_OMAP16XX
587 case METHOD_GPIO_1610:
588 reg += OMAP1610_GPIO_DATAOUT;
589 break;
590#endif
591#ifdef CONFIG_ARCH_OMAP730
592 case METHOD_GPIO_730:
593 reg += OMAP730_GPIO_DATA_OUTPUT;
594 break;
595#endif
596#ifdef CONFIG_ARCH_OMAP850
597 case METHOD_GPIO_850:
598 reg += OMAP850_GPIO_DATA_OUTPUT;
599 break;
600#endif
601#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) || \
602 defined(CONFIG_ARCH_OMAP4)
603 case METHOD_GPIO_24XX:
604 reg += OMAP24XX_GPIO_DATAOUT;
605 break;
606#endif
607 default:
608 return -EINVAL;
609 }
610
611 return (__raw_readl(reg) & (1 << get_gpio_index(gpio))) != 0;
612}
613
569#define MOD_REG_BIT(reg, bit_mask, set) \ 614#define MOD_REG_BIT(reg, bit_mask, set) \
570do { \ 615do { \
571 int l = __raw_readl(base + reg); \ 616 int l = __raw_readl(base + reg); \
@@ -1459,9 +1504,49 @@ static int gpio_input(struct gpio_chip *chip, unsigned offset)
1459 return 0; 1504 return 0;
1460} 1505}
1461 1506
1507static int gpio_is_input(struct gpio_bank *bank, int mask)
1508{
1509 void __iomem *reg = bank->base;
1510
1511 switch (bank->method) {
1512 case METHOD_MPUIO:
1513 reg += OMAP_MPUIO_IO_CNTL;
1514 break;
1515 case METHOD_GPIO_1510:
1516 reg += OMAP1510_GPIO_DIR_CONTROL;
1517 break;
1518 case METHOD_GPIO_1610:
1519 reg += OMAP1610_GPIO_DIRECTION;
1520 break;
1521 case METHOD_GPIO_730:
1522 reg += OMAP730_GPIO_DIR_CONTROL;
1523 break;
1524 case METHOD_GPIO_850:
1525 reg += OMAP850_GPIO_DIR_CONTROL;
1526 break;
1527 case METHOD_GPIO_24XX:
1528 reg += OMAP24XX_GPIO_OE;
1529 break;
1530 }
1531 return __raw_readl(reg) & mask;
1532}
1533
1462static int gpio_get(struct gpio_chip *chip, unsigned offset) 1534static int gpio_get(struct gpio_chip *chip, unsigned offset)
1463{ 1535{
1464 return __omap_get_gpio_datain(chip->base + offset); 1536 struct gpio_bank *bank;
1537 void __iomem *reg;
1538 int gpio;
1539 u32 mask;
1540
1541 gpio = chip->base + offset;
1542 bank = get_gpio_bank(gpio);
1543 reg = bank->base;
1544 mask = 1 << get_gpio_index(gpio);
1545
1546 if (gpio_is_input(bank, mask))
1547 return _get_gpio_datain(bank, gpio);
1548 else
1549 return _get_gpio_dataout(bank, gpio);
1465} 1550}
1466 1551
1467static int gpio_output(struct gpio_chip *chip, unsigned offset, int value) 1552static int gpio_output(struct gpio_chip *chip, unsigned offset, int value)
@@ -2039,34 +2124,6 @@ arch_initcall(omap_gpio_sysinit);
2039#include <linux/debugfs.h> 2124#include <linux/debugfs.h>
2040#include <linux/seq_file.h> 2125#include <linux/seq_file.h>
2041 2126
2042static int gpio_is_input(struct gpio_bank *bank, int mask)
2043{
2044 void __iomem *reg = bank->base;
2045
2046 switch (bank->method) {
2047 case METHOD_MPUIO:
2048 reg += OMAP_MPUIO_IO_CNTL;
2049 break;
2050 case METHOD_GPIO_1510:
2051 reg += OMAP1510_GPIO_DIR_CONTROL;
2052 break;
2053 case METHOD_GPIO_1610:
2054 reg += OMAP1610_GPIO_DIRECTION;
2055 break;
2056 case METHOD_GPIO_730:
2057 reg += OMAP730_GPIO_DIR_CONTROL;
2058 break;
2059 case METHOD_GPIO_850:
2060 reg += OMAP850_GPIO_DIR_CONTROL;
2061 break;
2062 case METHOD_GPIO_24XX:
2063 reg += OMAP24XX_GPIO_OE;
2064 break;
2065 }
2066 return __raw_readl(reg) & mask;
2067}
2068
2069
2070static int dbg_gpio_show(struct seq_file *s, void *unused) 2127static int dbg_gpio_show(struct seq_file *s, void *unused)
2071{ 2128{
2072 unsigned i, j, gpio; 2129 unsigned i, j, gpio;
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h
index f9f65e1ba3f1..4b8b0d65cbf2 100644
--- a/arch/arm/plat-omap/include/mach/clock.h
+++ b/arch/arm/plat-omap/include/mach/clock.h
@@ -20,6 +20,8 @@ struct clockdomain;
20struct clkops { 20struct clkops {
21 int (*enable)(struct clk *); 21 int (*enable)(struct clk *);
22 void (*disable)(struct clk *); 22 void (*disable)(struct clk *);
23 void (*find_idlest)(struct clk *, void __iomem **, u8 *);
24 void (*find_companion)(struct clk *, void __iomem **, u8 *);
23}; 25};
24 26
25#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \ 27#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \
diff --git a/arch/arm/plat-omap/include/mach/cpu.h b/arch/arm/plat-omap/include/mach/cpu.h
index 285eaa3a8275..11e73d9e8928 100644
--- a/arch/arm/plat-omap/include/mach/cpu.h
+++ b/arch/arm/plat-omap/include/mach/cpu.h
@@ -378,9 +378,6 @@ IS_OMAP_TYPE(3430, 0x3430)
378#define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx() || \ 378#define cpu_class_is_omap2() (cpu_is_omap24xx() || cpu_is_omap34xx() || \
379 cpu_is_omap44xx()) 379 cpu_is_omap44xx())
380 380
381#if defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) || \
382 defined(CONFIG_ARCH_OMAP4)
383
384/* Various silicon revisions for omap2 */ 381/* Various silicon revisions for omap2 */
385#define OMAP242X_CLASS 0x24200024 382#define OMAP242X_CLASS 0x24200024
386#define OMAP2420_REV_ES1_0 0x24200024 383#define OMAP2420_REV_ES1_0 0x24200024
@@ -436,5 +433,3 @@ IS_OMAP_TYPE(3430, 0x3430)
436 433
437int omap_chip_is(struct omap_chip_id oci); 434int omap_chip_is(struct omap_chip_id oci);
438void omap2_check_revision(void); 435void omap2_check_revision(void);
439
440#endif /* defined(CONFIG_ARCH_OMAP2) || defined(CONFIG_ARCH_OMAP3) */
diff --git a/arch/arm/plat-omap/include/mach/io.h b/arch/arm/plat-omap/include/mach/io.h
index 73f483d56ca6..21fb0efdda86 100644
--- a/arch/arm/plat-omap/include/mach/io.h
+++ b/arch/arm/plat-omap/include/mach/io.h
@@ -228,7 +228,8 @@ extern void omap1_map_common_io(void);
228extern void omap1_init_common_hw(void); 228extern void omap1_init_common_hw(void);
229 229
230extern void omap2_map_common_io(void); 230extern void omap2_map_common_io(void);
231extern void omap2_init_common_hw(struct omap_sdrc_params *sp); 231extern void omap2_init_common_hw(struct omap_sdrc_params *sdrc_cs0,
232 struct omap_sdrc_params *sdrc_cs1);
232 233
233#define __arch_ioremap(p,s,t) omap_ioremap(p,s,t) 234#define __arch_ioremap(p,s,t) omap_ioremap(p,s,t)
234#define __arch_iounmap(v) omap_iounmap(v) 235#define __arch_iounmap(v) omap_iounmap(v)
diff --git a/arch/arm/plat-omap/include/mach/mux.h b/arch/arm/plat-omap/include/mach/mux.h
index 85a621705766..80281c458baf 100644
--- a/arch/arm/plat-omap/include/mach/mux.h
+++ b/arch/arm/plat-omap/include/mach/mux.h
@@ -853,6 +853,10 @@ enum omap34xx_index {
853 AE5_34XX_GPIO143, 853 AE5_34XX_GPIO143,
854 H19_34XX_GPIO164_OUT, 854 H19_34XX_GPIO164_OUT,
855 J25_34XX_GPIO170, 855 J25_34XX_GPIO170,
856
857 /* OMAP3 SDRC CKE signals to SDR/DDR ram chips */
858 H16_34XX_SDRC_CKE0,
859 H17_34XX_SDRC_CKE1,
856}; 860};
857 861
858struct omap_mux_cfg { 862struct omap_mux_cfg {
diff --git a/arch/arm/plat-omap/include/mach/prcm.h b/arch/arm/plat-omap/include/mach/prcm.h
index 24ac3c715912..cda2a70397b4 100644
--- a/arch/arm/plat-omap/include/mach/prcm.h
+++ b/arch/arm/plat-omap/include/mach/prcm.h
@@ -25,6 +25,7 @@
25 25
26u32 omap_prcm_get_reset_sources(void); 26u32 omap_prcm_get_reset_sources(void);
27void omap_prcm_arch_reset(char mode); 27void omap_prcm_arch_reset(char mode);
28int omap2_cm_wait_idlest(void __iomem *reg, u32 mask, const char *name);
28 29
29#endif 30#endif
30 31
diff --git a/arch/arm/plat-omap/include/mach/sdrc.h b/arch/arm/plat-omap/include/mach/sdrc.h
index adc73522491f..0be18e4ff182 100644
--- a/arch/arm/plat-omap/include/mach/sdrc.h
+++ b/arch/arm/plat-omap/include/mach/sdrc.h
@@ -30,6 +30,10 @@
30#define SDRC_ACTIM_CTRL_A_0 0x09c 30#define SDRC_ACTIM_CTRL_A_0 0x09c
31#define SDRC_ACTIM_CTRL_B_0 0x0a0 31#define SDRC_ACTIM_CTRL_B_0 0x0a0
32#define SDRC_RFR_CTRL_0 0x0a4 32#define SDRC_RFR_CTRL_0 0x0a4
33#define SDRC_MR_1 0x0B4
34#define SDRC_ACTIM_CTRL_A_1 0x0C4
35#define SDRC_ACTIM_CTRL_B_1 0x0C8
36#define SDRC_RFR_CTRL_1 0x0D4
33 37
34/* 38/*
35 * These values represent the number of memory clock cycles between 39 * These values represent the number of memory clock cycles between
@@ -102,8 +106,11 @@ struct omap_sdrc_params {
102 u32 mr; 106 u32 mr;
103}; 107};
104 108
105void __init omap2_sdrc_init(struct omap_sdrc_params *sp); 109void __init omap2_sdrc_init(struct omap_sdrc_params *sdrc_cs0,
106struct omap_sdrc_params *omap2_sdrc_get_params(unsigned long r); 110 struct omap_sdrc_params *sdrc_cs1);
111int omap2_sdrc_get_params(unsigned long r,
112 struct omap_sdrc_params **sdrc_cs0,
113 struct omap_sdrc_params **sdrc_cs1);
107 114
108#ifdef CONFIG_ARCH_OMAP2 115#ifdef CONFIG_ARCH_OMAP2
109 116
diff --git a/arch/arm/plat-omap/include/mach/sram.h b/arch/arm/plat-omap/include/mach/sram.h
index 4d53cc59d7a3..8974e3fc2691 100644
--- a/arch/arm/plat-omap/include/mach/sram.h
+++ b/arch/arm/plat-omap/include/mach/sram.h
@@ -21,11 +21,12 @@ extern void omap2_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,
21 u32 mem_type); 21 u32 mem_type);
22extern u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass); 22extern u32 omap2_set_prcm(u32 dpll_ctrl_val, u32 sdrc_rfr_val, int bypass);
23 23
24extern u32 omap3_configure_core_dpll(u32 sdrc_rfr_ctrl, 24extern u32 omap3_configure_core_dpll(
25 u32 sdrc_actim_ctrla, 25 u32 m2, u32 unlock_dll, u32 f, u32 inc,
26 u32 sdrc_actim_ctrlb, u32 m2, 26 u32 sdrc_rfr_ctrl_0, u32 sdrc_actim_ctrl_a_0,
27 u32 unlock_dll, u32 f, u32 sdrc_mr, 27 u32 sdrc_actim_ctrl_b_0, u32 sdrc_mr_0,
28 u32 inc); 28 u32 sdrc_rfr_ctrl_1, u32 sdrc_actim_ctrl_a_1,
29 u32 sdrc_actim_ctrl_b_1, u32 sdrc_mr_1);
29 30
30/* Do not use these */ 31/* Do not use these */
31extern void omap1_sram_reprogram_clock(u32 ckctl, u32 dpllctl); 32extern void omap1_sram_reprogram_clock(u32 ckctl, u32 dpllctl);
@@ -59,12 +60,12 @@ extern void omap243x_sram_reprogram_sdrc(u32 perf_level, u32 dll_val,
59 u32 mem_type); 60 u32 mem_type);
60extern unsigned long omap243x_sram_reprogram_sdrc_sz; 61extern unsigned long omap243x_sram_reprogram_sdrc_sz;
61 62
62 63extern u32 omap3_sram_configure_core_dpll(
63extern u32 omap3_sram_configure_core_dpll(u32 sdrc_rfr_ctrl, 64 u32 m2, u32 unlock_dll, u32 f, u32 inc,
64 u32 sdrc_actim_ctrla, 65 u32 sdrc_rfr_ctrl_0, u32 sdrc_actim_ctrl_a_0,
65 u32 sdrc_actim_ctrlb, u32 m2, 66 u32 sdrc_actim_ctrl_b_0, u32 sdrc_mr_0,
66 u32 unlock_dll, u32 f, u32 sdrc_mr, 67 u32 sdrc_rfr_ctrl_1, u32 sdrc_actim_ctrl_a_1,
67 u32 inc); 68 u32 sdrc_actim_ctrl_b_1, u32 sdrc_mr_1);
68extern unsigned long omap3_sram_configure_core_dpll_sz; 69extern unsigned long omap3_sram_configure_core_dpll_sz;
69 70
70#endif 71#endif
diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
index 4ea73804d21e..5eae7876979c 100644
--- a/arch/arm/plat-omap/sram.c
+++ b/arch/arm/plat-omap/sram.c
@@ -44,9 +44,9 @@
44#define OMAP2_SRAM_VA 0xe3000000 44#define OMAP2_SRAM_VA 0xe3000000
45#define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800) 45#define OMAP2_SRAM_PUB_VA (OMAP2_SRAM_VA + 0x800)
46#define OMAP3_SRAM_PA 0x40200000 46#define OMAP3_SRAM_PA 0x40200000
47#define OMAP3_SRAM_VA 0xd7000000 47#define OMAP3_SRAM_VA 0xe3000000
48#define OMAP3_SRAM_PUB_PA 0x40208000 48#define OMAP3_SRAM_PUB_PA 0x40208000
49#define OMAP3_SRAM_PUB_VA 0xd7008000 49#define OMAP3_SRAM_PUB_VA (OMAP3_SRAM_VA + 0x8000)
50#define OMAP4_SRAM_PA 0x40200000 /*0x402f0000*/ 50#define OMAP4_SRAM_PA 0x40200000 /*0x402f0000*/
51#define OMAP4_SRAM_VA 0xd7000000 /*0xd70f0000*/ 51#define OMAP4_SRAM_VA 0xd7000000 /*0xd70f0000*/
52 52
@@ -373,20 +373,26 @@ static inline int omap243x_sram_init(void)
373 373
374#ifdef CONFIG_ARCH_OMAP3 374#ifdef CONFIG_ARCH_OMAP3
375 375
376static u32 (*_omap3_sram_configure_core_dpll)(u32 sdrc_rfr_ctrl, 376static u32 (*_omap3_sram_configure_core_dpll)(
377 u32 sdrc_actim_ctrla, 377 u32 m2, u32 unlock_dll, u32 f, u32 inc,
378 u32 sdrc_actim_ctrlb, 378 u32 sdrc_rfr_ctrl_0, u32 sdrc_actim_ctrl_a_0,
379 u32 m2, u32 unlock_dll, 379 u32 sdrc_actim_ctrl_b_0, u32 sdrc_mr_0,
380 u32 f, u32 sdrc_mr, u32 inc); 380 u32 sdrc_rfr_ctrl_1, u32 sdrc_actim_ctrl_a_1,
381u32 omap3_configure_core_dpll(u32 sdrc_rfr_ctrl, u32 sdrc_actim_ctrla, 381 u32 sdrc_actim_ctrl_b_1, u32 sdrc_mr_1);
382 u32 sdrc_actim_ctrlb, u32 m2, u32 unlock_dll, 382
383 u32 f, u32 sdrc_mr, u32 inc) 383u32 omap3_configure_core_dpll(u32 m2, u32 unlock_dll, u32 f, u32 inc,
384 u32 sdrc_rfr_ctrl_0, u32 sdrc_actim_ctrl_a_0,
385 u32 sdrc_actim_ctrl_b_0, u32 sdrc_mr_0,
386 u32 sdrc_rfr_ctrl_1, u32 sdrc_actim_ctrl_a_1,
387 u32 sdrc_actim_ctrl_b_1, u32 sdrc_mr_1)
384{ 388{
385 BUG_ON(!_omap3_sram_configure_core_dpll); 389 BUG_ON(!_omap3_sram_configure_core_dpll);
386 return _omap3_sram_configure_core_dpll(sdrc_rfr_ctrl, 390 return _omap3_sram_configure_core_dpll(
387 sdrc_actim_ctrla, 391 m2, unlock_dll, f, inc,
388 sdrc_actim_ctrlb, m2, 392 sdrc_rfr_ctrl_0, sdrc_actim_ctrl_a_0,
389 unlock_dll, f, sdrc_mr, inc); 393 sdrc_actim_ctrl_b_0, sdrc_mr_0,
394 sdrc_rfr_ctrl_1, sdrc_actim_ctrl_a_1,
395 sdrc_actim_ctrl_b_1, sdrc_mr_1);
390} 396}
391 397
392/* REVISIT: Should this be same as omap34xx_sram_init() after off-idle? */ 398/* REVISIT: Should this be same as omap34xx_sram_init() after off-idle? */
diff --git a/arch/arm/plat-orion/include/plat/gpio.h b/arch/arm/plat-orion/include/plat/gpio.h
index 9646a94ed3d0..07c430fdc9ef 100644
--- a/arch/arm/plat-orion/include/plat/gpio.h
+++ b/arch/arm/plat-orion/include/plat/gpio.h
@@ -11,6 +11,8 @@
11#ifndef __PLAT_GPIO_H 11#ifndef __PLAT_GPIO_H
12#define __PLAT_GPIO_H 12#define __PLAT_GPIO_H
13 13
14#include <linux/init.h>
15
14/* 16/*
15 * GENERIC_GPIO primitives. 17 * GENERIC_GPIO primitives.
16 */ 18 */
diff --git a/arch/arm/plat-s3c/pwm.c b/arch/arm/plat-s3c/pwm.c
index f3d37ac5595b..4fdc5b307fd2 100644
--- a/arch/arm/plat-s3c/pwm.c
+++ b/arch/arm/plat-s3c/pwm.c
@@ -247,6 +247,10 @@ int pwm_config(struct pwm_device *pwm, int duty_ns, int period_ns)
247 247
248 tcmp = duty_ns / tin_ns; 248 tcmp = duty_ns / tin_ns;
249 tcmp = tcnt - tcmp; 249 tcmp = tcnt - tcmp;
250 /* the pwm hw only checks the compare register after a decrement,
251 so the pin never toggles if tcmp = tcnt */
252 if (tcmp == tcnt)
253 tcmp--;
250 254
251 pwm_dbg(pwm, "tin_ns=%lu, tcmp=%ld/%lu\n", tin_ns, tcmp, tcnt); 255 pwm_dbg(pwm, "tin_ns=%lu, tcmp=%ld/%lu\n", tin_ns, tcmp, tcnt);
252 256
diff --git a/arch/arm/plat-s3c24xx/clock-dclk.c b/arch/arm/plat-s3c24xx/clock-dclk.c
index 5b75a797b5ab..0afb217a775e 100644
--- a/arch/arm/plat-s3c24xx/clock-dclk.c
+++ b/arch/arm/plat-s3c24xx/clock-dclk.c
@@ -129,7 +129,7 @@ static int s3c24xx_clkout_setparent(struct clk *clk, struct clk *parent)
129 129
130 /* calculate the MISCCR setting for the clock */ 130 /* calculate the MISCCR setting for the clock */
131 131
132 if (parent == &clk_xtal) 132 if (parent == &clk_mpll)
133 source = S3C2410_MISCCR_CLK0_MPLL; 133 source = S3C2410_MISCCR_CLK0_MPLL;
134 else if (parent == &clk_upll) 134 else if (parent == &clk_upll)
135 source = S3C2410_MISCCR_CLK0_UPLL; 135 source = S3C2410_MISCCR_CLK0_UPLL;
diff --git a/arch/arm/plat-s3c64xx/pm.c b/arch/arm/plat-s3c64xx/pm.c
index 07a6516a4f3c..47632fc7eb66 100644
--- a/arch/arm/plat-s3c64xx/pm.c
+++ b/arch/arm/plat-s3c64xx/pm.c
@@ -117,8 +117,6 @@ void s3c_pm_save_core(void)
117 * this. 117 * this.
118 */ 118 */
119 119
120#include <plat/regs-gpio.h>
121
122static void s3c64xx_cpu_suspend(void) 120static void s3c64xx_cpu_suspend(void)
123{ 121{
124 unsigned long tmp; 122 unsigned long tmp;
diff --git a/arch/avr32/boards/favr-32/setup.c b/arch/avr32/boards/favr-32/setup.c
index 46c9b0a224cf..75f19f47fb2f 100644
--- a/arch/avr32/boards/favr-32/setup.c
+++ b/arch/avr32/boards/favr-32/setup.c
@@ -72,6 +72,10 @@ static struct ads7846_platform_data ads7843_data = {
72 .debounce_max = 20, 72 .debounce_max = 20,
73 .debounce_rep = 4, 73 .debounce_rep = 4,
74 .debounce_tol = 5, 74 .debounce_tol = 5,
75
76 .keep_vref_on = true,
77 .settle_delay_usecs = 500,
78 .penirq_recheck_delay_usecs = 100,
75}; 79};
76 80
77static struct spi_board_info __initdata spi1_board_info[] = { 81static struct spi_board_info __initdata spi1_board_info[] = {
diff --git a/arch/avr32/lib/memcpy.S b/arch/avr32/lib/memcpy.S
index 0abb26142b64..c2ca49d705af 100644
--- a/arch/avr32/lib/memcpy.S
+++ b/arch/avr32/lib/memcpy.S
@@ -24,8 +24,8 @@ memcpy:
24 brne 1f 24 brne 1f
25 25
26 /* At this point, "from" is word-aligned */ 26 /* At this point, "from" is word-aligned */
272: sub r10, 4 272: mov r9, r12
28 mov r9, r12 285: sub r10, 4
29 brlt 4f 29 brlt 4f
30 30
313: ld.w r8, r11++ 313: ld.w r8, r11++
@@ -49,6 +49,7 @@ memcpy:
49 49
50 /* Handle unaligned "from" pointer */ 50 /* Handle unaligned "from" pointer */
511: sub r10, 4 511: sub r10, 4
52 movlt r9, r12
52 brlt 4b 53 brlt 4b
53 add r10, r9 54 add r10, r9
54 lsl r9, 2 55 lsl r9, 2
@@ -59,4 +60,13 @@ memcpy:
59 st.b r12++, r8 60 st.b r12++, r8
60 ld.ub r8, r11++ 61 ld.ub r8, r11++
61 st.b r12++, r8 62 st.b r12++, r8
62 rjmp 2b 63 mov r8, r12
64 add pc, pc, r9
65 sub r8, 1
66 nop
67 sub r8, 1
68 nop
69 sub r8, 1
70 nop
71 mov r9, r8
72 rjmp 5b
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 58a7e46affda..e7cbaa02cd0b 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -41,11 +41,6 @@ $(error Sorry, you need a newer version of the assember, one that is built from
41 ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz) 41 ftp://ftp.hpl.hp.com/pub/linux-ia64/gas-030124.tar.gz)
42endif 42endif
43 43
44ifeq ($(call cc-version),0304)
45 cflags-$(CONFIG_ITANIUM) += -mtune=merced
46 cflags-$(CONFIG_MCKINLEY) += -mtune=mckinley
47endif
48
49KBUILD_CFLAGS += $(cflags-y) 44KBUILD_CFLAGS += $(cflags-y)
50head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o 45head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
51 46
diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h
index e2ca80037335..57a2787bc9fb 100644
--- a/arch/ia64/include/asm/bitops.h
+++ b/arch/ia64/include/asm/bitops.h
@@ -286,7 +286,7 @@ __test_and_clear_bit(int nr, volatile void * addr)
286{ 286{
287 __u32 *p = (__u32 *) addr + (nr >> 5); 287 __u32 *p = (__u32 *) addr + (nr >> 5);
288 __u32 m = 1 << (nr & 31); 288 __u32 m = 1 << (nr & 31);
289 int oldbitset = *p & m; 289 int oldbitset = (*p & m) != 0;
290 290
291 *p &= ~m; 291 *p &= ~m;
292 return oldbitset; 292 return oldbitset;
diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
index 0a9cc73d35c7..8840a690d1e7 100644
--- a/arch/ia64/include/asm/pgtable.h
+++ b/arch/ia64/include/asm/pgtable.h
@@ -155,7 +155,6 @@
155#include <linux/bitops.h> 155#include <linux/bitops.h>
156#include <asm/cacheflush.h> 156#include <asm/cacheflush.h>
157#include <asm/mmu_context.h> 157#include <asm/mmu_context.h>
158#include <asm/processor.h>
159 158
160/* 159/*
161 * Next come the mappings that determine how mmap() protection bits 160 * Next come the mappings that determine how mmap() protection bits
diff --git a/arch/ia64/kernel/ia64_ksyms.c b/arch/ia64/kernel/ia64_ksyms.c
index 2d311864e359..8ebccb589e1c 100644
--- a/arch/ia64/kernel/ia64_ksyms.c
+++ b/arch/ia64/kernel/ia64_ksyms.c
@@ -21,6 +21,7 @@ EXPORT_SYMBOL(csum_ipv6_magic);
21 21
22#include <asm/page.h> 22#include <asm/page.h>
23EXPORT_SYMBOL(clear_page); 23EXPORT_SYMBOL(clear_page);
24EXPORT_SYMBOL(copy_page);
24 25
25#ifdef CONFIG_VIRTUAL_MEM_MAP 26#ifdef CONFIG_VIRTUAL_MEM_MAP
26#include <linux/bootmem.h> 27#include <linux/bootmem.h>
@@ -60,9 +61,6 @@ EXPORT_SYMBOL(__udivdi3);
60EXPORT_SYMBOL(__moddi3); 61EXPORT_SYMBOL(__moddi3);
61EXPORT_SYMBOL(__umoddi3); 62EXPORT_SYMBOL(__umoddi3);
62 63
63#include <asm/page.h>
64EXPORT_SYMBOL(copy_page);
65
66#if defined(CONFIG_MD_RAID456) || defined(CONFIG_MD_RAID456_MODULE) 64#if defined(CONFIG_MD_RAID456) || defined(CONFIG_MD_RAID456_MODULE)
67extern void xor_ia64_2(void); 65extern void xor_ia64_2(void);
68extern void xor_ia64_3(void); 66extern void xor_ia64_3(void);
diff --git a/arch/ia64/kernel/iosapic.c b/arch/ia64/kernel/iosapic.c
index c48b03f2b61d..dab4d393908c 100644
--- a/arch/ia64/kernel/iosapic.c
+++ b/arch/ia64/kernel/iosapic.c
@@ -1072,6 +1072,10 @@ iosapic_init (unsigned long phys_addr, unsigned int gsi_base)
1072 } 1072 }
1073 1073
1074 addr = ioremap(phys_addr, 0); 1074 addr = ioremap(phys_addr, 0);
1075 if (addr == NULL) {
1076 spin_unlock_irqrestore(&iosapic_lock, flags);
1077 return -ENOMEM;
1078 }
1075 ver = iosapic_version(addr); 1079 ver = iosapic_version(addr);
1076 if ((err = iosapic_check_gsi_range(gsi_base, ver))) { 1080 if ((err = iosapic_check_gsi_range(gsi_base, ver))) {
1077 iounmap(addr); 1081 iounmap(addr);
diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c
index 05695962fe44..f6b1ff0aea76 100644
--- a/arch/ia64/kernel/pci-dma.c
+++ b/arch/ia64/kernel/pci-dma.c
@@ -69,11 +69,6 @@ iommu_dma_init(void)
69 69
70int iommu_dma_supported(struct device *dev, u64 mask) 70int iommu_dma_supported(struct device *dev, u64 mask)
71{ 71{
72 struct dma_map_ops *ops = platform_dma_get_ops(dev);
73
74 if (ops->dma_supported)
75 return ops->dma_supported(dev, mask);
76
77 /* Copied from i386. Doesn't make much sense, because it will 72 /* Copied from i386. Doesn't make much sense, because it will
78 only work for pci_alloc_coherent. 73 only work for pci_alloc_coherent.
79 The caller just has to use GFP_DMA in this case. */ 74 The caller just has to use GFP_DMA in this case. */
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
index bc80dff1df7a..8f060352e129 100644
--- a/arch/ia64/kernel/topology.c
+++ b/arch/ia64/kernel/topology.c
@@ -372,6 +372,10 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
372 retval = kobject_init_and_add(&all_cpu_cache_info[cpu].kobj, 372 retval = kobject_init_and_add(&all_cpu_cache_info[cpu].kobj,
373 &cache_ktype_percpu_entry, &sys_dev->kobj, 373 &cache_ktype_percpu_entry, &sys_dev->kobj,
374 "%s", "cache"); 374 "%s", "cache");
375 if (unlikely(retval < 0)) {
376 cpu_cache_sysfs_exit(cpu);
377 return retval;
378 }
375 379
376 for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++) { 380 for (i = 0; i < all_cpu_cache_info[cpu].num_cache_leaves; i++) {
377 this_object = LEAF_KOBJECT_PTR(cpu,i); 381 this_object = LEAF_KOBJECT_PTR(cpu,i);
@@ -385,7 +389,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
385 } 389 }
386 kobject_put(&all_cpu_cache_info[cpu].kobj); 390 kobject_put(&all_cpu_cache_info[cpu].kobj);
387 cpu_cache_sysfs_exit(cpu); 391 cpu_cache_sysfs_exit(cpu);
388 break; 392 return retval;
389 } 393 }
390 kobject_uevent(&(this_object->kobj), KOBJ_ADD); 394 kobject_uevent(&(this_object->kobj), KOBJ_ADD);
391 } 395 }
diff --git a/arch/ia64/kvm/mmio.c b/arch/ia64/kvm/mmio.c
index 21f63fffc379..9bf55afd08d0 100644
--- a/arch/ia64/kvm/mmio.c
+++ b/arch/ia64/kvm/mmio.c
@@ -247,7 +247,8 @@ void emulate_io_inst(struct kvm_vcpu *vcpu, u64 padr, u64 ma)
247 vcpu_get_fpreg(vcpu, inst.M9.f2, &v); 247 vcpu_get_fpreg(vcpu, inst.M9.f2, &v);
248 /* Write high word. FIXME: this is a kludge! */ 248 /* Write high word. FIXME: this is a kludge! */
249 v.u.bits[1] &= 0x3ffff; 249 v.u.bits[1] &= 0x3ffff;
250 mmio_access(vcpu, padr + 8, &v.u.bits[1], 8, ma, IOREQ_WRITE); 250 mmio_access(vcpu, padr + 8, (u64 *)&v.u.bits[1], 8,
251 ma, IOREQ_WRITE);
251 data = v.u.bits[0]; 252 data = v.u.bits[0];
252 size = 3; 253 size = 3;
253 } else if (inst.M10.major == 7 && inst.M10.x6 == 0x3B) { 254 } else if (inst.M10.major == 7 && inst.M10.x6 == 0x3B) {
@@ -265,7 +266,8 @@ void emulate_io_inst(struct kvm_vcpu *vcpu, u64 padr, u64 ma)
265 266
266 /* Write high word.FIXME: this is a kludge! */ 267 /* Write high word.FIXME: this is a kludge! */
267 v.u.bits[1] &= 0x3ffff; 268 v.u.bits[1] &= 0x3ffff;
268 mmio_access(vcpu, padr + 8, &v.u.bits[1], 8, ma, IOREQ_WRITE); 269 mmio_access(vcpu, padr + 8, (u64 *)&v.u.bits[1],
270 8, ma, IOREQ_WRITE);
269 data = v.u.bits[0]; 271 data = v.u.bits[0];
270 size = 3; 272 size = 3;
271 } else if (inst.M10.major == 7 && inst.M10.x6 == 0x31) { 273 } else if (inst.M10.major == 7 && inst.M10.x6 == 0x31) {
diff --git a/arch/ia64/kvm/vcpu.c b/arch/ia64/kvm/vcpu.c
index 46b02cbcc874..cc406d064a09 100644
--- a/arch/ia64/kvm/vcpu.c
+++ b/arch/ia64/kvm/vcpu.c
@@ -461,7 +461,7 @@ void setreg(unsigned long regnum, unsigned long val,
461u64 vcpu_get_gr(struct kvm_vcpu *vcpu, unsigned long reg) 461u64 vcpu_get_gr(struct kvm_vcpu *vcpu, unsigned long reg)
462{ 462{
463 struct kvm_pt_regs *regs = vcpu_regs(vcpu); 463 struct kvm_pt_regs *regs = vcpu_regs(vcpu);
464 u64 val; 464 unsigned long val;
465 465
466 if (!reg) 466 if (!reg)
467 return 0; 467 return 0;
@@ -469,7 +469,7 @@ u64 vcpu_get_gr(struct kvm_vcpu *vcpu, unsigned long reg)
469 return val; 469 return val;
470} 470}
471 471
472void vcpu_set_gr(struct kvm_vcpu *vcpu, u64 reg, u64 value, int nat) 472void vcpu_set_gr(struct kvm_vcpu *vcpu, unsigned long reg, u64 value, int nat)
473{ 473{
474 struct kvm_pt_regs *regs = vcpu_regs(vcpu); 474 struct kvm_pt_regs *regs = vcpu_regs(vcpu);
475 long sof = (regs->cr_ifs) & 0x7f; 475 long sof = (regs->cr_ifs) & 0x7f;
@@ -1072,7 +1072,7 @@ void kvm_ttag(struct kvm_vcpu *vcpu, INST64 inst)
1072 vcpu_set_gr(vcpu, inst.M46.r1, tag, 0); 1072 vcpu_set_gr(vcpu, inst.M46.r1, tag, 0);
1073} 1073}
1074 1074
1075int vcpu_tpa(struct kvm_vcpu *vcpu, u64 vadr, u64 *padr) 1075int vcpu_tpa(struct kvm_vcpu *vcpu, u64 vadr, unsigned long *padr)
1076{ 1076{
1077 struct thash_data *data; 1077 struct thash_data *data;
1078 union ia64_isr visr, pt_isr; 1078 union ia64_isr visr, pt_isr;
diff --git a/arch/ia64/kvm/vcpu.h b/arch/ia64/kvm/vcpu.h
index 042af92ced83..360724d3ae69 100644
--- a/arch/ia64/kvm/vcpu.h
+++ b/arch/ia64/kvm/vcpu.h
@@ -686,14 +686,15 @@ static inline int highest_inservice_irq(struct kvm_vcpu *vcpu)
686 return highest_bits((int *)&(VMX(vcpu, insvc[0]))); 686 return highest_bits((int *)&(VMX(vcpu, insvc[0])));
687} 687}
688 688
689extern void vcpu_get_fpreg(struct kvm_vcpu *vcpu, u64 reg, 689extern void vcpu_get_fpreg(struct kvm_vcpu *vcpu, unsigned long reg,
690 struct ia64_fpreg *val); 690 struct ia64_fpreg *val);
691extern void vcpu_set_fpreg(struct kvm_vcpu *vcpu, u64 reg, 691extern void vcpu_set_fpreg(struct kvm_vcpu *vcpu, unsigned long reg,
692 struct ia64_fpreg *val); 692 struct ia64_fpreg *val);
693extern u64 vcpu_get_gr(struct kvm_vcpu *vcpu, u64 reg); 693extern u64 vcpu_get_gr(struct kvm_vcpu *vcpu, unsigned long reg);
694extern void vcpu_set_gr(struct kvm_vcpu *vcpu, u64 reg, u64 val, int nat); 694extern void vcpu_set_gr(struct kvm_vcpu *vcpu, unsigned long reg,
695extern u64 vcpu_get_psr(struct kvm_vcpu *vcpu); 695 u64 val, int nat);
696extern void vcpu_set_psr(struct kvm_vcpu *vcpu, u64 val); 696extern unsigned long vcpu_get_psr(struct kvm_vcpu *vcpu);
697extern void vcpu_set_psr(struct kvm_vcpu *vcpu, unsigned long val);
697extern u64 vcpu_thash(struct kvm_vcpu *vcpu, u64 vadr); 698extern u64 vcpu_thash(struct kvm_vcpu *vcpu, u64 vadr);
698extern void vcpu_bsw0(struct kvm_vcpu *vcpu); 699extern void vcpu_bsw0(struct kvm_vcpu *vcpu);
699extern void thash_vhpt_insert(struct kvm_vcpu *v, u64 pte, 700extern void thash_vhpt_insert(struct kvm_vcpu *v, u64 pte,
diff --git a/arch/m68k/amiga/config.c b/arch/m68k/amiga/config.c
index 6e562751ad51..6c74751c7b82 100644
--- a/arch/m68k/amiga/config.c
+++ b/arch/m68k/amiga/config.c
@@ -574,10 +574,11 @@ static int a2000_hwclk(int op, struct rtc_time *t)
574 574
575 tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD; 575 tod_2000.cntrl1 = TOD2000_CNTRL1_HOLD;
576 576
577 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) { 577 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt) {
578 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 578 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
579 udelay(70); 579 udelay(70);
580 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 580 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
581 --cnt;
581 } 582 }
582 583
583 if (!cnt) 584 if (!cnt)
@@ -649,10 +650,11 @@ static int amiga_set_clock_mmss(unsigned long nowtime)
649 650
650 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 651 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
651 652
652 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt--) { 653 while ((tod_2000.cntrl1 & TOD2000_CNTRL1_BUSY) && cnt) {
653 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD; 654 tod_2000.cntrl1 &= ~TOD2000_CNTRL1_HOLD;
654 udelay(70); 655 udelay(70);
655 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD; 656 tod_2000.cntrl1 |= TOD2000_CNTRL1_HOLD;
657 --cnt;
656 } 658 }
657 659
658 if (!cnt) 660 if (!cnt)
diff --git a/arch/m68k/include/asm/motorola_pgalloc.h b/arch/m68k/include/asm/motorola_pgalloc.h
index 15ee4c74a9f0..2f02f264e694 100644
--- a/arch/m68k/include/asm/motorola_pgalloc.h
+++ b/arch/m68k/include/asm/motorola_pgalloc.h
@@ -36,12 +36,10 @@ static inline pgtable_t pte_alloc_one(struct mm_struct *mm, unsigned long addres
36 return NULL; 36 return NULL;
37 37
38 pte = kmap(page); 38 pte = kmap(page);
39 if (pte) { 39 __flush_page_to_ram(pte);
40 __flush_page_to_ram(pte); 40 flush_tlb_kernel_page(pte);
41 flush_tlb_kernel_page(pte); 41 nocache_page(pte);
42 nocache_page(pte); 42 kunmap(page);
43 }
44 kunmap(pte);
45 pgtable_page_ctor(page); 43 pgtable_page_ctor(page);
46 return page; 44 return page;
47} 45}
diff --git a/arch/m68k/include/asm/pgtable_mm.h b/arch/m68k/include/asm/pgtable_mm.h
index 0b604f0f192d..fe60e1abaee8 100644
--- a/arch/m68k/include/asm/pgtable_mm.h
+++ b/arch/m68k/include/asm/pgtable_mm.h
@@ -135,8 +135,6 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
135#endif 135#endif
136 136
137#ifndef __ASSEMBLY__ 137#ifndef __ASSEMBLY__
138#include <asm-generic/pgtable.h>
139
140/* 138/*
141 * Macro to mark a page protection value as "uncacheable". 139 * Macro to mark a page protection value as "uncacheable".
142 */ 140 */
@@ -154,6 +152,7 @@ static inline void update_mmu_cache(struct vm_area_struct *vma,
154 ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \ 152 ? (__pgprot((pgprot_val(prot) & _CACHEMASK040) | _PAGE_NOCACHE_S)) \
155 : (prot))) 153 : (prot)))
156 154
155#include <asm-generic/pgtable.h>
157#endif /* !__ASSEMBLY__ */ 156#endif /* !__ASSEMBLY__ */
158 157
159/* 158/*
diff --git a/arch/m68k/include/asm/unistd.h b/arch/m68k/include/asm/unistd.h
index aa29a8640f74..946d8691f2b0 100644
--- a/arch/m68k/include/asm/unistd.h
+++ b/arch/m68k/include/asm/unistd.h
@@ -334,10 +334,12 @@
334#define __NR_inotify_init1 328 334#define __NR_inotify_init1 328
335#define __NR_preadv 329 335#define __NR_preadv 329
336#define __NR_pwritev 330 336#define __NR_pwritev 330
337#define __NR_rt_tgsigqueueinfo 331
338#define __NR_perf_counter_open 332
337 339
338#ifdef __KERNEL__ 340#ifdef __KERNEL__
339 341
340#define NR_syscalls 331 342#define NR_syscalls 333
341 343
342#define __ARCH_WANT_IPC_PARSE_VERSION 344#define __ARCH_WANT_IPC_PARSE_VERSION
343#define __ARCH_WANT_OLD_READDIR 345#define __ARCH_WANT_OLD_READDIR
diff --git a/arch/m68k/kernel/entry.S b/arch/m68k/kernel/entry.S
index 8744f60c07a9..c3735cd6207e 100644
--- a/arch/m68k/kernel/entry.S
+++ b/arch/m68k/kernel/entry.S
@@ -755,4 +755,6 @@ sys_call_table:
755 .long sys_inotify_init1 755 .long sys_inotify_init1
756 .long sys_preadv 756 .long sys_preadv
757 .long sys_pwritev /* 330 */ 757 .long sys_pwritev /* 330 */
758 .long sys_rt_tgsigqueueinfo
759 .long sys_perf_counter_open
758 760
diff --git a/arch/m68knommu/kernel/syscalltable.S b/arch/m68knommu/kernel/syscalltable.S
index c0b8782832fd..0ae123e08985 100644
--- a/arch/m68knommu/kernel/syscalltable.S
+++ b/arch/m68knommu/kernel/syscalltable.S
@@ -349,6 +349,8 @@ ENTRY(sys_call_table)
349 .long sys_inotify_init1 349 .long sys_inotify_init1
350 .long sys_preadv 350 .long sys_preadv
351 .long sys_pwritev /* 330 */ 351 .long sys_pwritev /* 330 */
352 .long sys_rt_tgsigqueueinfo
353 .long sys_perf_counter_open
352 354
353 .rept NR_syscalls-(.-sys_call_table)/4 355 .rept NR_syscalls-(.-sys_call_table)/4
354 .long sys_ni_syscall 356 .long sys_ni_syscall
diff --git a/arch/microblaze/configs/mmu_defconfig b/arch/microblaze/configs/mmu_defconfig
index bd0b85ec38f5..09c32962b66f 100644
--- a/arch/microblaze/configs/mmu_defconfig
+++ b/arch/microblaze/configs/mmu_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc6 3# Linux kernel version: 2.6.31-rc6
4# Fri May 22 10:02:33 2009 4# Tue Aug 18 11:00:02 2009
5# 5#
6CONFIG_MICROBLAZE=y 6CONFIG_MICROBLAZE=y
7# CONFIG_SWAP is not set 7# CONFIG_SWAP is not set
@@ -18,7 +18,11 @@ CONFIG_GENERIC_TIME=y
18CONFIG_GENERIC_CLOCKEVENTS=y 18CONFIG_GENERIC_CLOCKEVENTS=y
19CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 19CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
20CONFIG_GENERIC_GPIO=y 20CONFIG_GENERIC_GPIO=y
21CONFIG_GENERIC_CSUM=y
22# CONFIG_PCI is not set
23CONFIG_NO_DMA=y
21CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 24CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
25CONFIG_CONSTRUCTORS=y
22 26
23# 27#
24# General setup 28# General setup
@@ -59,8 +63,8 @@ CONFIG_INITRAMFS_ROOT_GID=0
59CONFIG_RD_GZIP=y 63CONFIG_RD_GZIP=y
60# CONFIG_RD_BZIP2 is not set 64# CONFIG_RD_BZIP2 is not set
61# CONFIG_RD_LZMA is not set 65# CONFIG_RD_LZMA is not set
62CONFIG_INITRAMFS_COMPRESSION_NONE=y 66# CONFIG_INITRAMFS_COMPRESSION_NONE is not set
63# CONFIG_INITRAMFS_COMPRESSION_GZIP is not set 67CONFIG_INITRAMFS_COMPRESSION_GZIP=y
64# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set 68# CONFIG_INITRAMFS_COMPRESSION_BZIP2 is not set
65# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set 69# CONFIG_INITRAMFS_COMPRESSION_LZMA is not set
66# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set 70# CONFIG_CC_OPTIMIZE_FOR_SIZE is not set
@@ -71,7 +75,6 @@ CONFIG_SYSCTL_SYSCALL=y
71CONFIG_KALLSYMS=y 75CONFIG_KALLSYMS=y
72CONFIG_KALLSYMS_ALL=y 76CONFIG_KALLSYMS_ALL=y
73CONFIG_KALLSYMS_EXTRA_PASS=y 77CONFIG_KALLSYMS_EXTRA_PASS=y
74# CONFIG_STRIP_ASM_SYMS is not set
75# CONFIG_HOTPLUG is not set 78# CONFIG_HOTPLUG is not set
76CONFIG_PRINTK=y 79CONFIG_PRINTK=y
77CONFIG_BUG=y 80CONFIG_BUG=y
@@ -84,13 +87,22 @@ CONFIG_TIMERFD=y
84CONFIG_EVENTFD=y 87CONFIG_EVENTFD=y
85# CONFIG_SHMEM is not set 88# CONFIG_SHMEM is not set
86CONFIG_AIO=y 89CONFIG_AIO=y
90
91#
92# Performance Counters
93#
87CONFIG_VM_EVENT_COUNTERS=y 94CONFIG_VM_EVENT_COUNTERS=y
95# CONFIG_STRIP_ASM_SYMS is not set
88CONFIG_COMPAT_BRK=y 96CONFIG_COMPAT_BRK=y
89CONFIG_SLAB=y 97CONFIG_SLAB=y
90# CONFIG_SLUB is not set 98# CONFIG_SLUB is not set
91# CONFIG_SLOB is not set 99# CONFIG_SLOB is not set
92# CONFIG_PROFILING is not set 100# CONFIG_PROFILING is not set
93# CONFIG_MARKERS is not set 101# CONFIG_MARKERS is not set
102
103#
104# GCOV-based kernel profiling
105#
94# CONFIG_SLOW_WORK is not set 106# CONFIG_SLOW_WORK is not set
95# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 107# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
96CONFIG_SLABINFO=y 108CONFIG_SLABINFO=y
@@ -102,7 +114,7 @@ CONFIG_MODULE_UNLOAD=y
102# CONFIG_MODVERSIONS is not set 114# CONFIG_MODVERSIONS is not set
103# CONFIG_MODULE_SRCVERSION_ALL is not set 115# CONFIG_MODULE_SRCVERSION_ALL is not set
104CONFIG_BLOCK=y 116CONFIG_BLOCK=y
105# CONFIG_LBD is not set 117CONFIG_LBDAF=y
106# CONFIG_BLK_DEV_BSG is not set 118# CONFIG_BLK_DEV_BSG is not set
107# CONFIG_BLK_DEV_INTEGRITY is not set 119# CONFIG_BLK_DEV_INTEGRITY is not set
108 120
@@ -194,9 +206,9 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
194# CONFIG_PHYS_ADDR_T_64BIT is not set 206# CONFIG_PHYS_ADDR_T_64BIT is not set
195CONFIG_ZONE_DMA_FLAG=0 207CONFIG_ZONE_DMA_FLAG=0
196CONFIG_VIRT_TO_BUS=y 208CONFIG_VIRT_TO_BUS=y
197CONFIG_UNEVICTABLE_LRU=y
198CONFIG_HAVE_MLOCK=y 209CONFIG_HAVE_MLOCK=y
199CONFIG_HAVE_MLOCKED_PAGE_BIT=y 210CONFIG_HAVE_MLOCKED_PAGE_BIT=y
211CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
200 212
201# 213#
202# Exectuable file formats 214# Exectuable file formats
@@ -262,6 +274,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
262# CONFIG_ECONET is not set 274# CONFIG_ECONET is not set
263# CONFIG_WAN_ROUTER is not set 275# CONFIG_WAN_ROUTER is not set
264# CONFIG_PHONET is not set 276# CONFIG_PHONET is not set
277# CONFIG_IEEE802154 is not set
265# CONFIG_NET_SCHED is not set 278# CONFIG_NET_SCHED is not set
266# CONFIG_DCB is not set 279# CONFIG_DCB is not set
267 280
@@ -325,7 +338,6 @@ CONFIG_MISC_DEVICES=y
325# CONFIG_ATA is not set 338# CONFIG_ATA is not set
326# CONFIG_MD is not set 339# CONFIG_MD is not set
327CONFIG_NETDEVICES=y 340CONFIG_NETDEVICES=y
328CONFIG_COMPAT_NET_DEV_OPS=y
329# CONFIG_DUMMY is not set 341# CONFIG_DUMMY is not set
330# CONFIG_BONDING is not set 342# CONFIG_BONDING is not set
331# CONFIG_MACVLAN is not set 343# CONFIG_MACVLAN is not set
@@ -344,7 +356,7 @@ CONFIG_NET_ETHERNET=y
344# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set 356# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
345# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set 357# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
346# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 358# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
347# CONFIG_B44 is not set 359# CONFIG_KS8842 is not set
348CONFIG_NETDEV_1000=y 360CONFIG_NETDEV_1000=y
349CONFIG_NETDEV_10000=y 361CONFIG_NETDEV_10000=y
350 362
@@ -410,6 +422,11 @@ CONFIG_LEGACY_PTY_COUNT=256
410# CONFIG_TCG_TPM is not set 422# CONFIG_TCG_TPM is not set
411# CONFIG_I2C is not set 423# CONFIG_I2C is not set
412# CONFIG_SPI is not set 424# CONFIG_SPI is not set
425
426#
427# PPS support
428#
429# CONFIG_PPS is not set
413CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 430CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
414# CONFIG_GPIOLIB is not set 431# CONFIG_GPIOLIB is not set
415# CONFIG_W1 is not set 432# CONFIG_W1 is not set
@@ -418,12 +435,6 @@ CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
418# CONFIG_THERMAL is not set 435# CONFIG_THERMAL is not set
419# CONFIG_THERMAL_HWMON is not set 436# CONFIG_THERMAL_HWMON is not set
420# CONFIG_WATCHDOG is not set 437# CONFIG_WATCHDOG is not set
421CONFIG_SSB_POSSIBLE=y
422
423#
424# Sonics Silicon Backplane
425#
426# CONFIG_SSB is not set
427 438
428# 439#
429# Multifunction device drivers 440# Multifunction device drivers
@@ -433,22 +444,7 @@ CONFIG_SSB_POSSIBLE=y
433# CONFIG_HTC_PASIC3 is not set 444# CONFIG_HTC_PASIC3 is not set
434# CONFIG_MFD_TMIO is not set 445# CONFIG_MFD_TMIO is not set
435# CONFIG_REGULATOR is not set 446# CONFIG_REGULATOR is not set
436 447# CONFIG_MEDIA_SUPPORT is not set
437#
438# Multimedia devices
439#
440
441#
442# Multimedia core support
443#
444# CONFIG_VIDEO_DEV is not set
445# CONFIG_DVB_CORE is not set
446# CONFIG_VIDEO_MEDIA is not set
447
448#
449# Multimedia drivers
450#
451# CONFIG_DAB is not set
452 448
453# 449#
454# Graphics support 450# Graphics support
@@ -469,9 +465,12 @@ CONFIG_SSB_POSSIBLE=y
469# CONFIG_NEW_LEDS is not set 465# CONFIG_NEW_LEDS is not set
470# CONFIG_ACCESSIBILITY is not set 466# CONFIG_ACCESSIBILITY is not set
471# CONFIG_RTC_CLASS is not set 467# CONFIG_RTC_CLASS is not set
472# CONFIG_DMADEVICES is not set
473# CONFIG_AUXDISPLAY is not set 468# CONFIG_AUXDISPLAY is not set
474# CONFIG_UIO is not set 469# CONFIG_UIO is not set
470
471#
472# TI VLYNQ
473#
475# CONFIG_STAGING is not set 474# CONFIG_STAGING is not set
476 475
477# 476#
@@ -485,12 +484,15 @@ CONFIG_EXT2_FS=y
485# CONFIG_REISERFS_FS is not set 484# CONFIG_REISERFS_FS is not set
486# CONFIG_JFS_FS is not set 485# CONFIG_JFS_FS is not set
487# CONFIG_FS_POSIX_ACL is not set 486# CONFIG_FS_POSIX_ACL is not set
488CONFIG_FILE_LOCKING=y
489# CONFIG_XFS_FS is not set 487# CONFIG_XFS_FS is not set
488# CONFIG_GFS2_FS is not set
490# CONFIG_OCFS2_FS is not set 489# CONFIG_OCFS2_FS is not set
491# CONFIG_BTRFS_FS is not set 490# CONFIG_BTRFS_FS is not set
491CONFIG_FILE_LOCKING=y
492CONFIG_FSNOTIFY=y
492# CONFIG_DNOTIFY is not set 493# CONFIG_DNOTIFY is not set
493# CONFIG_INOTIFY is not set 494# CONFIG_INOTIFY is not set
495CONFIG_INOTIFY_USER=y
494# CONFIG_QUOTA is not set 496# CONFIG_QUOTA is not set
495# CONFIG_AUTOFS_FS is not set 497# CONFIG_AUTOFS_FS is not set
496# CONFIG_AUTOFS4_FS is not set 498# CONFIG_AUTOFS4_FS is not set
@@ -678,6 +680,7 @@ CONFIG_DEBUG_INFO=y
678# CONFIG_SYSCTL_SYSCALL_CHECK is not set 680# CONFIG_SYSCTL_SYSCALL_CHECK is not set
679# CONFIG_PAGE_POISONING is not set 681# CONFIG_PAGE_POISONING is not set
680# CONFIG_SAMPLES is not set 682# CONFIG_SAMPLES is not set
683# CONFIG_KMEMCHECK is not set
681CONFIG_EARLY_PRINTK=y 684CONFIG_EARLY_PRINTK=y
682CONFIG_HEART_BEAT=y 685CONFIG_HEART_BEAT=y
683CONFIG_DEBUG_BOOTMEM=y 686CONFIG_DEBUG_BOOTMEM=y
@@ -793,6 +796,5 @@ CONFIG_ZLIB_INFLATE=y
793CONFIG_DECOMPRESS_GZIP=y 796CONFIG_DECOMPRESS_GZIP=y
794CONFIG_HAS_IOMEM=y 797CONFIG_HAS_IOMEM=y
795CONFIG_HAS_IOPORT=y 798CONFIG_HAS_IOPORT=y
796CONFIG_HAS_DMA=y
797CONFIG_HAVE_LMB=y 799CONFIG_HAVE_LMB=y
798CONFIG_NLATTR=y 800CONFIG_NLATTR=y
diff --git a/arch/microblaze/configs/nommu_defconfig b/arch/microblaze/configs/nommu_defconfig
index 4ef6af0a8f31..8b638615a972 100644
--- a/arch/microblaze/configs/nommu_defconfig
+++ b/arch/microblaze/configs/nommu_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc5 3# Linux kernel version: 2.6.31-rc6
4# Mon May 11 09:01:02 2009 4# Tue Aug 18 10:35:30 2009
5# 5#
6CONFIG_MICROBLAZE=y 6CONFIG_MICROBLAZE=y
7# CONFIG_SWAP is not set 7# CONFIG_SWAP is not set
@@ -17,9 +17,12 @@ CONFIG_GENERIC_TIME=y
17# CONFIG_GENERIC_TIME_VSYSCALL is not set 17# CONFIG_GENERIC_TIME_VSYSCALL is not set
18CONFIG_GENERIC_CLOCKEVENTS=y 18CONFIG_GENERIC_CLOCKEVENTS=y
19CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y 19CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
20CONFIG_GENERIC_GPIO=y
21CONFIG_GENERIC_CSUM=y
20# CONFIG_PCI is not set 22# CONFIG_PCI is not set
21# CONFIG_NO_DMA is not set 23CONFIG_NO_DMA=y
22CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 24CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
25CONFIG_CONSTRUCTORS=y
23 26
24# 27#
25# General setup 28# General setup
@@ -64,7 +67,6 @@ CONFIG_SYSCTL_SYSCALL=y
64CONFIG_KALLSYMS=y 67CONFIG_KALLSYMS=y
65CONFIG_KALLSYMS_ALL=y 68CONFIG_KALLSYMS_ALL=y
66CONFIG_KALLSYMS_EXTRA_PASS=y 69CONFIG_KALLSYMS_EXTRA_PASS=y
67# CONFIG_STRIP_ASM_SYMS is not set
68# CONFIG_HOTPLUG is not set 70# CONFIG_HOTPLUG is not set
69CONFIG_PRINTK=y 71CONFIG_PRINTK=y
70CONFIG_BUG=y 72CONFIG_BUG=y
@@ -76,13 +78,23 @@ CONFIG_SIGNALFD=y
76CONFIG_TIMERFD=y 78CONFIG_TIMERFD=y
77CONFIG_EVENTFD=y 79CONFIG_EVENTFD=y
78CONFIG_AIO=y 80CONFIG_AIO=y
81
82#
83# Performance Counters
84#
79CONFIG_VM_EVENT_COUNTERS=y 85CONFIG_VM_EVENT_COUNTERS=y
86# CONFIG_STRIP_ASM_SYMS is not set
80CONFIG_COMPAT_BRK=y 87CONFIG_COMPAT_BRK=y
81CONFIG_SLAB=y 88CONFIG_SLAB=y
82# CONFIG_SLUB is not set 89# CONFIG_SLUB is not set
83# CONFIG_SLOB is not set 90# CONFIG_SLOB is not set
84# CONFIG_PROFILING is not set 91# CONFIG_PROFILING is not set
85# CONFIG_MARKERS is not set 92# CONFIG_MARKERS is not set
93
94#
95# GCOV-based kernel profiling
96#
97# CONFIG_GCOV_KERNEL is not set
86# CONFIG_SLOW_WORK is not set 98# CONFIG_SLOW_WORK is not set
87# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 99# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
88CONFIG_SLABINFO=y 100CONFIG_SLABINFO=y
@@ -95,7 +107,7 @@ CONFIG_MODULE_UNLOAD=y
95# CONFIG_MODVERSIONS is not set 107# CONFIG_MODVERSIONS is not set
96# CONFIG_MODULE_SRCVERSION_ALL is not set 108# CONFIG_MODULE_SRCVERSION_ALL is not set
97CONFIG_BLOCK=y 109CONFIG_BLOCK=y
98# CONFIG_LBD is not set 110CONFIG_LBDAF=y
99# CONFIG_BLK_DEV_BSG is not set 111# CONFIG_BLK_DEV_BSG is not set
100# CONFIG_BLK_DEV_INTEGRITY is not set 112# CONFIG_BLK_DEV_INTEGRITY is not set
101 113
@@ -156,8 +168,16 @@ CONFIG_CMDLINE_BOOL=y
156CONFIG_CMDLINE="console=ttyUL0,115200" 168CONFIG_CMDLINE="console=ttyUL0,115200"
157# CONFIG_CMDLINE_FORCE is not set 169# CONFIG_CMDLINE_FORCE is not set
158CONFIG_OF=y 170CONFIG_OF=y
159CONFIG_OF_DEVICE=y
160CONFIG_PROC_DEVICETREE=y 171CONFIG_PROC_DEVICETREE=y
172
173#
174# Advanced setup
175#
176
177#
178# Default settings for advanced configuration options are used
179#
180CONFIG_KERNEL_START=0x90000000
161CONFIG_SELECT_MEMORY_MODEL=y 181CONFIG_SELECT_MEMORY_MODEL=y
162CONFIG_FLATMEM_MANUAL=y 182CONFIG_FLATMEM_MANUAL=y
163# CONFIG_DISCONTIGMEM_MANUAL is not set 183# CONFIG_DISCONTIGMEM_MANUAL is not set
@@ -169,7 +189,7 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
169# CONFIG_PHYS_ADDR_T_64BIT is not set 189# CONFIG_PHYS_ADDR_T_64BIT is not set
170CONFIG_ZONE_DMA_FLAG=0 190CONFIG_ZONE_DMA_FLAG=0
171CONFIG_VIRT_TO_BUS=y 191CONFIG_VIRT_TO_BUS=y
172CONFIG_UNEVICTABLE_LRU=y 192CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
173CONFIG_NOMMU_INITIAL_TRIM_EXCESS=1 193CONFIG_NOMMU_INITIAL_TRIM_EXCESS=1
174 194
175# 195#
@@ -237,6 +257,7 @@ CONFIG_DEFAULT_TCP_CONG="cubic"
237# CONFIG_ECONET is not set 257# CONFIG_ECONET is not set
238# CONFIG_WAN_ROUTER is not set 258# CONFIG_WAN_ROUTER is not set
239# CONFIG_PHONET is not set 259# CONFIG_PHONET is not set
260# CONFIG_IEEE802154 is not set
240# CONFIG_NET_SCHED is not set 261# CONFIG_NET_SCHED is not set
241# CONFIG_DCB is not set 262# CONFIG_DCB is not set
242 263
@@ -254,7 +275,11 @@ CONFIG_WIRELESS=y
254CONFIG_WIRELESS_OLD_REGULATORY=y 275CONFIG_WIRELESS_OLD_REGULATORY=y
255# CONFIG_WIRELESS_EXT is not set 276# CONFIG_WIRELESS_EXT is not set
256# CONFIG_LIB80211 is not set 277# CONFIG_LIB80211 is not set
257# CONFIG_MAC80211 is not set 278
279#
280# CFG80211 needs to be enabled for MAC80211
281#
282CONFIG_MAC80211_DEFAULT_PS_VALUE=0
258# CONFIG_WIMAX is not set 283# CONFIG_WIMAX is not set
259# CONFIG_RFKILL is not set 284# CONFIG_RFKILL is not set
260# CONFIG_NET_9P is not set 285# CONFIG_NET_9P is not set
@@ -353,6 +378,7 @@ CONFIG_MTD_UCLINUX=y
353# UBI - Unsorted block images 378# UBI - Unsorted block images
354# 379#
355# CONFIG_MTD_UBI is not set 380# CONFIG_MTD_UBI is not set
381CONFIG_OF_DEVICE=y
356# CONFIG_PARPORT is not set 382# CONFIG_PARPORT is not set
357CONFIG_BLK_DEV=y 383CONFIG_BLK_DEV=y
358# CONFIG_BLK_DEV_COW_COMMON is not set 384# CONFIG_BLK_DEV_COW_COMMON is not set
@@ -364,6 +390,7 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
364# CONFIG_BLK_DEV_XIP is not set 390# CONFIG_BLK_DEV_XIP is not set
365# CONFIG_CDROM_PKTCDVD is not set 391# CONFIG_CDROM_PKTCDVD is not set
366# CONFIG_ATA_OVER_ETH is not set 392# CONFIG_ATA_OVER_ETH is not set
393# CONFIG_XILINX_SYSACE is not set
367CONFIG_MISC_DEVICES=y 394CONFIG_MISC_DEVICES=y
368# CONFIG_ENCLOSURE_SERVICES is not set 395# CONFIG_ENCLOSURE_SERVICES is not set
369# CONFIG_C2PORT is not set 396# CONFIG_C2PORT is not set
@@ -383,7 +410,6 @@ CONFIG_MISC_DEVICES=y
383# CONFIG_ATA is not set 410# CONFIG_ATA is not set
384# CONFIG_MD is not set 411# CONFIG_MD is not set
385CONFIG_NETDEVICES=y 412CONFIG_NETDEVICES=y
386CONFIG_COMPAT_NET_DEV_OPS=y
387# CONFIG_DUMMY is not set 413# CONFIG_DUMMY is not set
388# CONFIG_BONDING is not set 414# CONFIG_BONDING is not set
389# CONFIG_MACVLAN is not set 415# CONFIG_MACVLAN is not set
@@ -402,7 +428,7 @@ CONFIG_NET_ETHERNET=y
402# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set 428# CONFIG_IBM_NEW_EMAC_NO_FLOW_CTRL is not set
403# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set 429# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
404# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 430# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
405# CONFIG_B44 is not set 431# CONFIG_KS8842 is not set
406CONFIG_NETDEV_1000=y 432CONFIG_NETDEV_1000=y
407CONFIG_NETDEV_10000=y 433CONFIG_NETDEV_10000=y
408 434
@@ -463,23 +489,25 @@ CONFIG_HW_RANDOM=y
463# CONFIG_HW_RANDOM_TIMERIOMEM is not set 489# CONFIG_HW_RANDOM_TIMERIOMEM is not set
464# CONFIG_RTC is not set 490# CONFIG_RTC is not set
465# CONFIG_GEN_RTC is not set 491# CONFIG_GEN_RTC is not set
492# CONFIG_XILINX_HWICAP is not set
466# CONFIG_R3964 is not set 493# CONFIG_R3964 is not set
467# CONFIG_RAW_DRIVER is not set 494# CONFIG_RAW_DRIVER is not set
468# CONFIG_TCG_TPM is not set 495# CONFIG_TCG_TPM is not set
469# CONFIG_I2C is not set 496# CONFIG_I2C is not set
470# CONFIG_SPI is not set 497# CONFIG_SPI is not set
498
499#
500# PPS support
501#
502# CONFIG_PPS is not set
503CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
504# CONFIG_GPIOLIB is not set
471# CONFIG_W1 is not set 505# CONFIG_W1 is not set
472# CONFIG_POWER_SUPPLY is not set 506# CONFIG_POWER_SUPPLY is not set
473# CONFIG_HWMON is not set 507# CONFIG_HWMON is not set
474# CONFIG_THERMAL is not set 508# CONFIG_THERMAL is not set
475# CONFIG_THERMAL_HWMON is not set 509# CONFIG_THERMAL_HWMON is not set
476# CONFIG_WATCHDOG is not set 510# CONFIG_WATCHDOG is not set
477CONFIG_SSB_POSSIBLE=y
478
479#
480# Sonics Silicon Backplane
481#
482# CONFIG_SSB is not set
483 511
484# 512#
485# Multifunction device drivers 513# Multifunction device drivers
@@ -489,22 +517,7 @@ CONFIG_SSB_POSSIBLE=y
489# CONFIG_HTC_PASIC3 is not set 517# CONFIG_HTC_PASIC3 is not set
490# CONFIG_MFD_TMIO is not set 518# CONFIG_MFD_TMIO is not set
491# CONFIG_REGULATOR is not set 519# CONFIG_REGULATOR is not set
492 520# CONFIG_MEDIA_SUPPORT is not set
493#
494# Multimedia devices
495#
496
497#
498# Multimedia core support
499#
500# CONFIG_VIDEO_DEV is not set
501# CONFIG_DVB_CORE is not set
502# CONFIG_VIDEO_MEDIA is not set
503
504#
505# Multimedia drivers
506#
507CONFIG_DAB=y
508 521
509# 522#
510# Graphics support 523# Graphics support
@@ -520,9 +533,10 @@ CONFIG_VIDEO_OUTPUT_CONTROL=y
520# CONFIG_DISPLAY_SUPPORT is not set 533# CONFIG_DISPLAY_SUPPORT is not set
521# CONFIG_SOUND is not set 534# CONFIG_SOUND is not set
522CONFIG_USB_SUPPORT=y 535CONFIG_USB_SUPPORT=y
523# CONFIG_USB_ARCH_HAS_HCD is not set 536CONFIG_USB_ARCH_HAS_HCD=y
524# CONFIG_USB_ARCH_HAS_OHCI is not set 537# CONFIG_USB_ARCH_HAS_OHCI is not set
525# CONFIG_USB_ARCH_HAS_EHCI is not set 538# CONFIG_USB_ARCH_HAS_EHCI is not set
539# CONFIG_USB is not set
526# CONFIG_USB_OTG_WHITELIST is not set 540# CONFIG_USB_OTG_WHITELIST is not set
527# CONFIG_USB_OTG_BLACKLIST_HUB is not set 541# CONFIG_USB_OTG_BLACKLIST_HUB is not set
528 542
@@ -543,9 +557,12 @@ CONFIG_USB_SUPPORT=y
543# CONFIG_NEW_LEDS is not set 557# CONFIG_NEW_LEDS is not set
544# CONFIG_ACCESSIBILITY is not set 558# CONFIG_ACCESSIBILITY is not set
545# CONFIG_RTC_CLASS is not set 559# CONFIG_RTC_CLASS is not set
546# CONFIG_DMADEVICES is not set
547# CONFIG_AUXDISPLAY is not set 560# CONFIG_AUXDISPLAY is not set
548# CONFIG_UIO is not set 561# CONFIG_UIO is not set
562
563#
564# TI VLYNQ
565#
549# CONFIG_STAGING is not set 566# CONFIG_STAGING is not set
550 567
551# 568#
@@ -558,12 +575,15 @@ CONFIG_EXT2_FS=y
558# CONFIG_REISERFS_FS is not set 575# CONFIG_REISERFS_FS is not set
559# CONFIG_JFS_FS is not set 576# CONFIG_JFS_FS is not set
560CONFIG_FS_POSIX_ACL=y 577CONFIG_FS_POSIX_ACL=y
561CONFIG_FILE_LOCKING=y
562# CONFIG_XFS_FS is not set 578# CONFIG_XFS_FS is not set
579# CONFIG_GFS2_FS is not set
563# CONFIG_OCFS2_FS is not set 580# CONFIG_OCFS2_FS is not set
564# CONFIG_BTRFS_FS is not set 581# CONFIG_BTRFS_FS is not set
582CONFIG_FILE_LOCKING=y
583CONFIG_FSNOTIFY=y
565# CONFIG_DNOTIFY is not set 584# CONFIG_DNOTIFY is not set
566# CONFIG_INOTIFY is not set 585# CONFIG_INOTIFY is not set
586CONFIG_INOTIFY_USER=y
567# CONFIG_QUOTA is not set 587# CONFIG_QUOTA is not set
568# CONFIG_AUTOFS_FS is not set 588# CONFIG_AUTOFS_FS is not set
569# CONFIG_AUTOFS4_FS is not set 589# CONFIG_AUTOFS4_FS is not set
@@ -813,6 +833,5 @@ CONFIG_GENERIC_FIND_LAST_BIT=y
813CONFIG_ZLIB_INFLATE=y 833CONFIG_ZLIB_INFLATE=y
814CONFIG_HAS_IOMEM=y 834CONFIG_HAS_IOMEM=y
815CONFIG_HAS_IOPORT=y 835CONFIG_HAS_IOPORT=y
816CONFIG_HAS_DMA=y
817CONFIG_HAVE_LMB=y 836CONFIG_HAVE_LMB=y
818CONFIG_NLATTR=y 837CONFIG_NLATTR=y
diff --git a/arch/microblaze/include/asm/hardirq.h b/arch/microblaze/include/asm/hardirq.h
index 41e1e1aa36ac..cd1ac9aad56c 100644
--- a/arch/microblaze/include/asm/hardirq.h
+++ b/arch/microblaze/include/asm/hardirq.h
@@ -12,8 +12,6 @@
12/* should be defined in each interrupt controller driver */ 12/* should be defined in each interrupt controller driver */
13extern unsigned int get_irq(struct pt_regs *regs); 13extern unsigned int get_irq(struct pt_regs *regs);
14 14
15#define ack_bad_irq ack_bad_irq
16void ack_bad_irq(unsigned int irq);
17#include <asm-generic/hardirq.h> 15#include <asm-generic/hardirq.h>
18 16
19#endif /* _ASM_MICROBLAZE_HARDIRQ_H */ 17#endif /* _ASM_MICROBLAZE_HARDIRQ_H */
diff --git a/arch/microblaze/kernel/intc.c b/arch/microblaze/kernel/intc.c
index b15605299a57..6eea6f92b84e 100644
--- a/arch/microblaze/kernel/intc.c
+++ b/arch/microblaze/kernel/intc.c
@@ -12,6 +12,7 @@
12#include <linux/irq.h> 12#include <linux/irq.h>
13#include <asm/page.h> 13#include <asm/page.h>
14#include <linux/io.h> 14#include <linux/io.h>
15#include <linux/bug.h>
15 16
16#include <asm/prom.h> 17#include <asm/prom.h>
17#include <asm/irq.h> 18#include <asm/irq.h>
@@ -130,6 +131,7 @@ void __init init_IRQ(void)
130 if (intc) 131 if (intc)
131 break; 132 break;
132 } 133 }
134 BUG_ON(!intc);
133 135
134 intc_baseaddr = *(int *) of_get_property(intc, "reg", NULL); 136 intc_baseaddr = *(int *) of_get_property(intc, "reg", NULL);
135 intc_baseaddr = (unsigned long) ioremap(intc_baseaddr, PAGE_SIZE); 137 intc_baseaddr = (unsigned long) ioremap(intc_baseaddr, PAGE_SIZE);
diff --git a/arch/microblaze/kernel/irq.c b/arch/microblaze/kernel/irq.c
index f688ee93e3b9..7d5ddd62d4d2 100644
--- a/arch/microblaze/kernel/irq.c
+++ b/arch/microblaze/kernel/irq.c
@@ -30,15 +30,6 @@ unsigned int irq_of_parse_and_map(struct device_node *dev, int index)
30} 30}
31EXPORT_SYMBOL_GPL(irq_of_parse_and_map); 31EXPORT_SYMBOL_GPL(irq_of_parse_and_map);
32 32
33/*
34 * 'what should we do if we get a hw irq event on an illegal vector'.
35 * each architecture has to answer this themselves.
36 */
37void ack_bad_irq(unsigned int irq)
38{
39 printk(KERN_WARNING "unexpected IRQ trap at vector %02x\n", irq);
40}
41
42static u32 concurrent_irq; 33static u32 concurrent_irq;
43 34
44void do_IRQ(struct pt_regs *regs) 35void do_IRQ(struct pt_regs *regs)
diff --git a/arch/microblaze/kernel/syscall_table.S b/arch/microblaze/kernel/syscall_table.S
index 216db817beb6..457216097dfd 100644
--- a/arch/microblaze/kernel/syscall_table.S
+++ b/arch/microblaze/kernel/syscall_table.S
@@ -313,7 +313,7 @@ ENTRY(sys_call_table)
313 .long sys_fchmodat 313 .long sys_fchmodat
314 .long sys_faccessat 314 .long sys_faccessat
315 .long sys_ni_syscall /* pselect6 */ 315 .long sys_ni_syscall /* pselect6 */
316 .long sys_ni_syscall /* sys_ppoll */ 316 .long sys_ppoll
317 .long sys_unshare /* 310 */ 317 .long sys_unshare /* 310 */
318 .long sys_set_robust_list 318 .long sys_set_robust_list
319 .long sys_get_robust_list 319 .long sys_get_robust_list
diff --git a/arch/microblaze/kernel/timer.c b/arch/microblaze/kernel/timer.c
index bdfa2f9f0c81..5499deae7fa6 100644
--- a/arch/microblaze/kernel/timer.c
+++ b/arch/microblaze/kernel/timer.c
@@ -22,6 +22,7 @@
22#include <linux/clocksource.h> 22#include <linux/clocksource.h>
23#include <linux/clockchips.h> 23#include <linux/clockchips.h>
24#include <linux/io.h> 24#include <linux/io.h>
25#include <linux/bug.h>
25#include <asm/cpuinfo.h> 26#include <asm/cpuinfo.h>
26#include <asm/setup.h> 27#include <asm/setup.h>
27#include <asm/prom.h> 28#include <asm/prom.h>
@@ -234,6 +235,7 @@ void __init time_init(void)
234 if (timer) 235 if (timer)
235 break; 236 break;
236 } 237 }
238 BUG_ON(!timer);
237 239
238 timer_baseaddr = *(int *) of_get_property(timer, "reg", NULL); 240 timer_baseaddr = *(int *) of_get_property(timer, "reg", NULL);
239 timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE); 241 timer_baseaddr = (unsigned long) ioremap(timer_baseaddr, PAGE_SIZE);
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 8d92c4efe9a4..f207f1a94dbc 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -130,13 +130,13 @@ void __init setup_memory(void)
130 * (in case the address isn't page-aligned). 130 * (in case the address isn't page-aligned).
131 */ 131 */
132#ifndef CONFIG_MMU 132#ifndef CONFIG_MMU
133 map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(TOPHYS((u32)_end)), 133 map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(TOPHYS((u32)klimit)),
134 min_low_pfn, max_low_pfn); 134 min_low_pfn, max_low_pfn);
135#else 135#else
136 map_size = init_bootmem_node(&contig_page_data, 136 map_size = init_bootmem_node(&contig_page_data,
137 PFN_UP(TOPHYS((u32)_end)), min_low_pfn, max_low_pfn); 137 PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn);
138#endif 138#endif
139 lmb_reserve(PFN_UP(TOPHYS((u32)_end)) << PAGE_SHIFT, map_size); 139 lmb_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size);
140 140
141 /* free bootmem is whole main memory */ 141 /* free bootmem is whole main memory */
142 free_bootmem(memory_start, memory_size); 142 free_bootmem(memory_start, memory_size);
diff --git a/arch/mips/alchemy/mtx-1/platform.c b/arch/mips/alchemy/mtx-1/platform.c
index 8b5914d1241f..e30e42add697 100644
--- a/arch/mips/alchemy/mtx-1/platform.c
+++ b/arch/mips/alchemy/mtx-1/platform.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * MTX-1 platform devices registration 2 * MTX-1 platform devices registration
3 * 3 *
4 * Copyright (C) 2007, Florian Fainelli <florian@openwrt.org> 4 * Copyright (C) 2007-2009, Florian Fainelli <florian@openwrt.org>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
@@ -142,7 +142,17 @@ static struct __initdata platform_device * mtx1_devs[] = {
142 142
143static int __init mtx1_register_devices(void) 143static int __init mtx1_register_devices(void)
144{ 144{
145 gpio_direction_input(207); 145 int rc;
146
147 rc = gpio_request(mtx1_gpio_button[0].gpio,
148 mtx1_gpio_button[0].desc);
149 if (rc < 0) {
150 printk(KERN_INFO "mtx1: failed to request %d\n",
151 mtx1_gpio_button[0].gpio);
152 goto out;
153 }
154 gpio_direction_input(mtx1_gpio_button[0].gpio);
155out:
146 return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); 156 return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
147} 157}
148 158
diff --git a/arch/mips/ar7/Makefile b/arch/mips/ar7/Makefile
index 7435e44b3964..26bc5da18997 100644
--- a/arch/mips/ar7/Makefile
+++ b/arch/mips/ar7/Makefile
@@ -8,3 +8,4 @@ obj-y := \
8 platform.o \ 8 platform.o \
9 gpio.o \ 9 gpio.o \
10 clock.o 10 clock.o
11EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/ar7/clock.c b/arch/mips/ar7/clock.c
index 27dc6663f2fa..cc65c8eb391b 100644
--- a/arch/mips/ar7/clock.c
+++ b/arch/mips/ar7/clock.c
@@ -264,19 +264,6 @@ static void __init tnetd7300_init_clocks(void)
264 iounmap(bootcr); 264 iounmap(bootcr);
265} 265}
266 266
267static int tnetd7200_get_clock(int base, struct tnetd7200_clock *clock,
268 u32 *bootcr, u32 bus_clock)
269{
270 int divisor = ((readl(&clock->prediv) & 0x1f) + 1) *
271 ((readl(&clock->postdiv) & 0x1f) + 1);
272
273 if (*bootcr & BOOT_PLL_BYPASS)
274 return base / divisor;
275
276 return base * ((readl(&clock->mul) & 0xf) + 1) / divisor;
277}
278
279
280static void tnetd7200_set_clock(int base, struct tnetd7200_clock *clock, 267static void tnetd7200_set_clock(int base, struct tnetd7200_clock *clock,
281 int prediv, int postdiv, int postdiv2, int mul, u32 frequency) 268 int prediv, int postdiv, int postdiv2, int mul, u32 frequency)
282{ 269{
diff --git a/arch/mips/ar7/memory.c b/arch/mips/ar7/memory.c
index 46fed44825a6..696c723dc6d4 100644
--- a/arch/mips/ar7/memory.c
+++ b/arch/mips/ar7/memory.c
@@ -52,7 +52,7 @@ static int __init memsize(void)
52 size <<= 1; 52 size <<= 1;
53 } while (size < (64 << 20)); 53 } while (size < (64 << 20));
54 54
55 writel(tmpaddr, &addr); 55 writel((u32)tmpaddr, &addr);
56 56
57 return size; 57 return size;
58} 58}
diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c
index 542244961780..2ecab6155932 100644
--- a/arch/mips/ar7/platform.c
+++ b/arch/mips/ar7/platform.c
@@ -28,7 +28,6 @@
28#include <linux/serial_8250.h> 28#include <linux/serial_8250.h>
29#include <linux/ioport.h> 29#include <linux/ioport.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/version.h>
32#include <linux/vlynq.h> 31#include <linux/vlynq.h>
33#include <linux/leds.h> 32#include <linux/leds.h>
34#include <linux/string.h> 33#include <linux/string.h>
@@ -243,13 +242,13 @@ static struct platform_device physmap_flash = {
243 .num_resources = 1, 242 .num_resources = 1,
244}; 243};
245 244
246static u64 cpmac_dma_mask = DMA_32BIT_MASK; 245static u64 cpmac_dma_mask = DMA_BIT_MASK(32);
247static struct platform_device cpmac_low = { 246static struct platform_device cpmac_low = {
248 .id = 0, 247 .id = 0,
249 .name = "cpmac", 248 .name = "cpmac",
250 .dev = { 249 .dev = {
251 .dma_mask = &cpmac_dma_mask, 250 .dma_mask = &cpmac_dma_mask,
252 .coherent_dma_mask = DMA_32BIT_MASK, 251 .coherent_dma_mask = DMA_BIT_MASK(32),
253 .platform_data = &cpmac_low_data, 252 .platform_data = &cpmac_low_data,
254 }, 253 },
255 .resource = cpmac_low_res, 254 .resource = cpmac_low_res,
@@ -261,7 +260,7 @@ static struct platform_device cpmac_high = {
261 .name = "cpmac", 260 .name = "cpmac",
262 .dev = { 261 .dev = {
263 .dma_mask = &cpmac_dma_mask, 262 .dma_mask = &cpmac_dma_mask,
264 .coherent_dma_mask = DMA_32BIT_MASK, 263 .coherent_dma_mask = DMA_BIT_MASK(32),
265 .platform_data = &cpmac_high_data, 264 .platform_data = &cpmac_high_data,
266 }, 265 },
267 .resource = cpmac_high_res, 266 .resource = cpmac_high_res,
@@ -481,6 +480,7 @@ static void __init detect_leds(void)
481static int __init ar7_register_devices(void) 480static int __init ar7_register_devices(void)
482{ 481{
483 int res; 482 int res;
483#ifdef CONFIG_SERIAL_8250
484 static struct uart_port uart_port[2]; 484 static struct uart_port uart_port[2];
485 485
486 memset(uart_port, 0, sizeof(struct uart_port) * 2); 486 memset(uart_port, 0, sizeof(struct uart_port) * 2);
@@ -512,7 +512,7 @@ static int __init ar7_register_devices(void)
512 if (res) 512 if (res)
513 return res; 513 return res;
514 } 514 }
515 515#endif /* CONFIG_SERIAL_8250 */
516 res = platform_device_register(&physmap_flash); 516 res = platform_device_register(&physmap_flash);
517 if (res) 517 if (res)
518 return res; 518 return res;
diff --git a/arch/mips/ar7/prom.c b/arch/mips/ar7/prom.c
index a320bceb2f9d..5ad6f1db6567 100644
--- a/arch/mips/ar7/prom.c
+++ b/arch/mips/ar7/prom.c
@@ -144,7 +144,7 @@ static char * __init lookup_psp_var_map(u8 num)
144{ 144{
145 int i; 145 int i;
146 146
147 for (i = 0; i < sizeof(psp_var_map); i++) 147 for (i = 0; i < ARRAY_SIZE(psp_var_map); i++)
148 if (psp_var_map[i].num == num) 148 if (psp_var_map[i].num == num)
149 return psp_var_map[i].value; 149 return psp_var_map[i].value;
150 150
diff --git a/arch/mips/ar7/setup.c b/arch/mips/ar7/setup.c
index 6ebb5f16d967..39f6b5b96463 100644
--- a/arch/mips/ar7/setup.c
+++ b/arch/mips/ar7/setup.c
@@ -15,7 +15,6 @@
15 * with this program; if not, write to the Free Software Foundation, Inc., 15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA. 16 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
17 */ 17 */
18#include <linux/version.h>
19#include <linux/init.h> 18#include <linux/init.h>
20#include <linux/ioport.h> 19#include <linux/ioport.h>
21#include <linux/pm.h> 20#include <linux/pm.h>
diff --git a/arch/mips/cavium-octeon/smp.c b/arch/mips/cavium-octeon/smp.c
index 0b891a9c6253..32d51a31dc48 100644
--- a/arch/mips/cavium-octeon/smp.c
+++ b/arch/mips/cavium-octeon/smp.c
@@ -194,11 +194,11 @@ static void octeon_init_secondary(void)
194void octeon_prepare_cpus(unsigned int max_cpus) 194void octeon_prepare_cpus(unsigned int max_cpus)
195{ 195{
196 cvmx_write_csr(CVMX_CIU_MBOX_CLRX(cvmx_get_core_num()), 0xffffffff); 196 cvmx_write_csr(CVMX_CIU_MBOX_CLRX(cvmx_get_core_num()), 0xffffffff);
197 if (request_irq(OCTEON_IRQ_MBOX0, mailbox_interrupt, IRQF_SHARED, 197 if (request_irq(OCTEON_IRQ_MBOX0, mailbox_interrupt, IRQF_DISABLED,
198 "mailbox0", mailbox_interrupt)) { 198 "mailbox0", mailbox_interrupt)) {
199 panic("Cannot request_irq(OCTEON_IRQ_MBOX0)\n"); 199 panic("Cannot request_irq(OCTEON_IRQ_MBOX0)\n");
200 } 200 }
201 if (request_irq(OCTEON_IRQ_MBOX1, mailbox_interrupt, IRQF_SHARED, 201 if (request_irq(OCTEON_IRQ_MBOX1, mailbox_interrupt, IRQF_DISABLED,
202 "mailbox1", mailbox_interrupt)) { 202 "mailbox1", mailbox_interrupt)) {
203 panic("Cannot request_irq(OCTEON_IRQ_MBOX1)\n"); 203 panic("Cannot request_irq(OCTEON_IRQ_MBOX1)\n");
204 } 204 }
diff --git a/arch/mips/dec/ecc-berr.c b/arch/mips/dec/ecc-berr.c
index 6a17c9b508ea..7abce661b90f 100644
--- a/arch/mips/dec/ecc-berr.c
+++ b/arch/mips/dec/ecc-berr.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/dec/ecc-berr.c
3 *
4 * Bus error event handling code for systems equipped with ECC 2 * Bus error event handling code for systems equipped with ECC
5 * handling logic, i.e. DECstation/DECsystem 5000/200 (KN02), 3 * handling logic, i.e. DECstation/DECsystem 5000/200 (KN02),
6 * 5000/240 (KN03), 5000/260 (KN05) and DECsystem 5900 (KN03), 4 * 5000/240 (KN03), 5000/260 (KN05) and DECsystem 5900 (KN03),
diff --git a/arch/mips/dec/int-handler.S b/arch/mips/dec/int-handler.S
index 00cecdcc75f2..82c852818781 100644
--- a/arch/mips/dec/int-handler.S
+++ b/arch/mips/dec/int-handler.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/dec/int-handler.S
3 *
4 * Copyright (C) 1995, 1996, 1997 Paul M. Antoine and Harald Koerfgen 2 * Copyright (C) 1995, 1996, 1997 Paul M. Antoine and Harald Koerfgen
5 * Copyright (C) 2000, 2001, 2002, 2003, 2005 Maciej W. Rozycki 3 * Copyright (C) 2000, 2001, 2002, 2003, 2005 Maciej W. Rozycki
6 * 4 *
diff --git a/arch/mips/dec/ioasic-irq.c b/arch/mips/dec/ioasic-irq.c
index 3acb133668dc..cb41954fc321 100644
--- a/arch/mips/dec/ioasic-irq.c
+++ b/arch/mips/dec/ioasic-irq.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/dec/ioasic-irq.c
3 *
4 * DEC I/O ASIC interrupts. 2 * DEC I/O ASIC interrupts.
5 * 3 *
6 * Copyright (c) 2002, 2003 Maciej W. Rozycki 4 * Copyright (c) 2002, 2003 Maciej W. Rozycki
diff --git a/arch/mips/dec/kn01-berr.c b/arch/mips/dec/kn01-berr.c
index d3b8002bf1e7..b0dc6d53edd6 100644
--- a/arch/mips/dec/kn01-berr.c
+++ b/arch/mips/dec/kn01-berr.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/dec/kn01-berr.c
3 *
4 * Bus error event handling code for DECstation/DECsystem 3100 2 * Bus error event handling code for DECstation/DECsystem 3100
5 * and 2100 (KN01) systems equipped with parity error detection 3 * and 2100 (KN01) systems equipped with parity error detection
6 * logic. 4 * logic.
diff --git a/arch/mips/dec/kn02-irq.c b/arch/mips/dec/kn02-irq.c
index 02439dc0ba83..ed90a8deabcc 100644
--- a/arch/mips/dec/kn02-irq.c
+++ b/arch/mips/dec/kn02-irq.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/dec/kn02-irq.c
3 *
4 * DECstation 5000/200 (KN02) Control and Status Register 2 * DECstation 5000/200 (KN02) Control and Status Register
5 * interrupts. 3 * interrupts.
6 * 4 *
diff --git a/arch/mips/dec/kn02xa-berr.c b/arch/mips/dec/kn02xa-berr.c
index 5f04545c3606..07ca5405d48d 100644
--- a/arch/mips/dec/kn02xa-berr.c
+++ b/arch/mips/dec/kn02xa-berr.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/dec/kn02xa-berr.c
3 *
4 * Bus error event handling code for 5000-series systems equipped 2 * Bus error event handling code for 5000-series systems equipped
5 * with parity error detection logic, i.e. DECstation/DECsystem 3 * with parity error detection logic, i.e. DECstation/DECsystem
6 * 5000/120, /125, /133 (KN02-BA), 5000/150 (KN04-BA) and Personal 4 * 5000/120, /125, /133 (KN02-BA), 5000/150 (KN04-BA) and Personal
diff --git a/arch/mips/dec/prom/call_o32.S b/arch/mips/dec/prom/call_o32.S
index e523454bda3a..8c8498159e43 100644
--- a/arch/mips/dec/prom/call_o32.S
+++ b/arch/mips/dec/prom/call_o32.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/dec/prom/call_o32.S
3 *
4 * O32 interface for the 64 (or N32) ABI. 2 * O32 interface for the 64 (or N32) ABI.
5 * 3 *
6 * Copyright (C) 2002 Maciej W. Rozycki 4 * Copyright (C) 2002 Maciej W. Rozycki
diff --git a/arch/mips/dec/prom/console.c b/arch/mips/dec/prom/console.c
index 078e1a12421d..caa6e047caf1 100644
--- a/arch/mips/dec/prom/console.c
+++ b/arch/mips/dec/prom/console.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/dec/prom/console.c
3 *
4 * DECstation PROM-based early console support. 2 * DECstation PROM-based early console support.
5 * 3 *
6 * Copyright (C) 2004, 2007 Maciej W. Rozycki 4 * Copyright (C) 2004, 2007 Maciej W. Rozycki
diff --git a/arch/mips/dec/time.c b/arch/mips/dec/time.c
index 1359c03ded51..463136e6685a 100644
--- a/arch/mips/dec/time.c
+++ b/arch/mips/dec/time.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/dec/time.c
3 *
4 * Copyright (C) 1991, 1992, 1995 Linus Torvalds 2 * Copyright (C) 1991, 1992, 1995 Linus Torvalds
5 * Copyright (C) 2000, 2003 Maciej W. Rozycki 3 * Copyright (C) 2000, 2003 Maciej W. Rozycki
6 * 4 *
diff --git a/arch/mips/emma/common/Makefile b/arch/mips/emma/common/Makefile
index c392d28c1ef1..f27d84d1904f 100644
--- a/arch/mips/emma/common/Makefile
+++ b/arch/mips/emma/common/Makefile
@@ -1,7 +1,4 @@
1# 1#
2# arch/mips/emma2rh/common/Makefile
3# Makefile for the common code of NEC EMMA2RH based board.
4#
5# Copyright (C) NEC Electronics Corporation 2005-2006 2# Copyright (C) NEC Electronics Corporation 2005-2006
6# 3#
7# This program is free software; you can redistribute it and/or modify 4# This program is free software; you can redistribute it and/or modify
diff --git a/arch/mips/emma/common/prom.c b/arch/mips/emma/common/prom.c
index 120f53fbdb45..708f08761406 100644
--- a/arch/mips/emma/common/prom.c
+++ b/arch/mips/emma/common/prom.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/emma2rh/common/prom.c
3 * This file is prom file.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006 2 * Copyright (C) NEC Electronics Corporation 2004-2006
6 * 3 *
7 * This file is based on the arch/mips/ddb5xxx/common/prom.c 4 * This file is based on the arch/mips/ddb5xxx/common/prom.c
diff --git a/arch/mips/emma/markeins/Makefile b/arch/mips/emma/markeins/Makefile
index 16e0017ba919..f8ba2508fa2b 100644
--- a/arch/mips/emma/markeins/Makefile
+++ b/arch/mips/emma/markeins/Makefile
@@ -1,7 +1,4 @@
1# 1#
2# arch/mips/emma2rh/markeins/Makefile
3# Makefile for the common code of NEC EMMA2RH based board.
4#
5# Copyright (C) NEC Electronics Corporation 2005-2006 2# Copyright (C) NEC Electronics Corporation 2005-2006
6# 3#
7# This program is free software; you can redistribute it and/or modify 4# This program is free software; you can redistribute it and/or modify
diff --git a/arch/mips/emma/markeins/irq.c b/arch/mips/emma/markeins/irq.c
index 43828ae796ec..9504b7ee0b7c 100644
--- a/arch/mips/emma/markeins/irq.c
+++ b/arch/mips/emma/markeins/irq.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/emma2rh/markeins/irq.c
3 * This file defines the irq handler for EMMA2RH.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006 2 * Copyright (C) NEC Electronics Corporation 2004-2006
6 * 3 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c 4 * This file is based on the arch/mips/ddb5xxx/ddb5477/irq.c
diff --git a/arch/mips/emma/markeins/led.c b/arch/mips/emma/markeins/led.c
index 377a181b6561..49755896857f 100644
--- a/arch/mips/emma/markeins/led.c
+++ b/arch/mips/emma/markeins/led.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/emma2rh/markeins/led.c
3 * This file defines the led display for Mark-eins.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006 2 * Copyright (C) NEC Electronics Corporation 2004-2006
6 * 3 *
7 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
diff --git a/arch/mips/emma/markeins/platform.c b/arch/mips/emma/markeins/platform.c
index 80ae12ef87db..b05b08b92a34 100644
--- a/arch/mips/emma/markeins/platform.c
+++ b/arch/mips/emma/markeins/platform.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/emma2rh/markeins/platofrm.c
3 * This file sets up platform devices for EMMA2RH Mark-eins.
4 *
5 * Copyright(C) MontaVista Software Inc, 2006 2 * Copyright(C) MontaVista Software Inc, 2006
6 * 3 *
7 * Author: dmitry pervushin <dpervushin@ru.mvista.com> 4 * Author: dmitry pervushin <dpervushin@ru.mvista.com>
diff --git a/arch/mips/emma/markeins/setup.c b/arch/mips/emma/markeins/setup.c
index 67f456500084..335dc8c1a1bb 100644
--- a/arch/mips/emma/markeins/setup.c
+++ b/arch/mips/emma/markeins/setup.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/emma2rh/markeins/setup.c
3 * This file is setup for EMMA2RH Mark-eins.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006 2 * Copyright (C) NEC Electronics Corporation 2004-2006
6 * 3 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c. 4 * This file is based on the arch/mips/ddb5xxx/ddb5477/setup.c.
diff --git a/arch/mips/fw/lib/call_o32.S b/arch/mips/fw/lib/call_o32.S
index bdf7d1d4081a..e0a68713b3c3 100644
--- a/arch/mips/fw/lib/call_o32.S
+++ b/arch/mips/fw/lib/call_o32.S
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/dec/prom/call_o32.S
3 *
4 * O32 interface for the 64 (or N32) ABI. 2 * O32 interface for the 64 (or N32) ABI.
5 * 3 *
6 * Copyright (C) 2002 Maciej W. Rozycki 4 * Copyright (C) 2002 Maciej W. Rozycki
diff --git a/arch/mips/include/asm/emma/emma2rh.h b/arch/mips/include/asm/emma/emma2rh.h
index 30aea91de626..2afb2fe11b30 100644
--- a/arch/mips/include/asm/emma/emma2rh.h
+++ b/arch/mips/include/asm/emma/emma2rh.h
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/include/asm/emma/emma2rh.h
3 * This file is EMMA2RH common header.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006 2 * Copyright (C) NEC Electronics Corporation 2005-2006
6 * 3 *
7 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h 4 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h
diff --git a/arch/mips/include/asm/emma/markeins.h b/arch/mips/include/asm/emma/markeins.h
index 973b0628490d..2618bf230248 100644
--- a/arch/mips/include/asm/emma/markeins.h
+++ b/arch/mips/include/asm/emma/markeins.h
@@ -1,7 +1,4 @@
1/* 1/*
2 * include/asm-mips/emma2rh/markeins.h
3 * This file is EMMA2RH board depended header.
4 *
5 * Copyright (C) NEC Electronics Corporation 2005-2006 2 * Copyright (C) NEC Electronics Corporation 2005-2006
6 * 3 *
7 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h 4 * This file based on include/asm-mips/ddb5xxx/ddb5xxx.h
diff --git a/arch/mips/include/asm/gic.h b/arch/mips/include/asm/gic.h
index 10292e37c1f7..a8f57341f123 100644
--- a/arch/mips/include/asm/gic.h
+++ b/arch/mips/include/asm/gic.h
@@ -20,7 +20,7 @@
20#define GIC_TRIG_EDGE 1 20#define GIC_TRIG_EDGE 1
21#define GIC_TRIG_LEVEL 0 21#define GIC_TRIG_LEVEL 0
22 22
23#if CONFIG_SMP 23#ifdef CONFIG_SMP
24#define GIC_NUM_INTRS (24 + NR_CPUS * 2) 24#define GIC_NUM_INTRS (24 + NR_CPUS * 2)
25#else 25#else
26#define GIC_NUM_INTRS 32 26#define GIC_NUM_INTRS 32
diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index 96a14a426a7c..4320239cf4ef 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -32,10 +32,12 @@
32#define PAGE_SIZE (1UL << PAGE_SHIFT) 32#define PAGE_SIZE (1UL << PAGE_SHIFT)
33#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1)) 33#define PAGE_MASK (~((1 << PAGE_SHIFT) - 1))
34 34
35#ifdef CONFIG_HUGETLB_PAGE
35#define HPAGE_SHIFT (PAGE_SHIFT + PAGE_SHIFT - 3) 36#define HPAGE_SHIFT (PAGE_SHIFT + PAGE_SHIFT - 3)
36#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT) 37#define HPAGE_SIZE ((1UL) << HPAGE_SHIFT)
37#define HPAGE_MASK (~(HPAGE_SIZE - 1)) 38#define HPAGE_MASK (~(HPAGE_SIZE - 1))
38#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT) 39#define HUGETLB_PAGE_ORDER (HPAGE_SHIFT - PAGE_SHIFT)
40#endif /* CONFIG_HUGETLB_PAGE */
39 41
40#ifndef __ASSEMBLY__ 42#ifndef __ASSEMBLY__
41 43
diff --git a/arch/mips/include/asm/pmc-sierra/msp71xx/war.h b/arch/mips/include/asm/pmc-sierra/msp71xx/war.h
index 0bf48fc1892b..9e2ee429c529 100644
--- a/arch/mips/include/asm/pmc-sierra/msp71xx/war.h
+++ b/arch/mips/include/asm/pmc-sierra/msp71xx/war.h
@@ -23,6 +23,8 @@
23#if defined(CONFIG_PMC_MSP7120_EVAL) || defined(CONFIG_PMC_MSP7120_GW) || \ 23#if defined(CONFIG_PMC_MSP7120_EVAL) || defined(CONFIG_PMC_MSP7120_GW) || \
24 defined(CONFIG_PMC_MSP7120_FPGA) 24 defined(CONFIG_PMC_MSP7120_FPGA)
25#define MIPS34K_MISSED_ITLB_WAR 1 25#define MIPS34K_MISSED_ITLB_WAR 1
26#else
27#define MIPS34K_MISSED_ITLB_WAR 0
26#endif 28#endif
27 29
28#endif /* __ASM_MIPS_PMC_SIERRA_WAR_H */ 30#endif /* __ASM_MIPS_PMC_SIERRA_WAR_H */
diff --git a/arch/mips/include/asm/processor.h b/arch/mips/include/asm/processor.h
index 0f926aa0cb47..087a8884ef06 100644
--- a/arch/mips/include/asm/processor.h
+++ b/arch/mips/include/asm/processor.h
@@ -311,8 +311,9 @@ extern void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long
311 311
312unsigned long get_wchan(struct task_struct *p); 312unsigned long get_wchan(struct task_struct *p);
313 313
314#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + THREAD_SIZE - 32) 314#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + \
315#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk) - 1) 315 THREAD_SIZE - 32 - sizeof(struct pt_regs))
316#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk))
316#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc) 317#define KSTK_EIP(tsk) (task_pt_regs(tsk)->cp0_epc)
317#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29]) 318#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[29])
318#define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status) 319#define KSTK_STATUS(tsk) (task_pt_regs(tsk)->cp0_status)
diff --git a/arch/mips/include/asm/unistd.h b/arch/mips/include/asm/unistd.h
index b70c49fdda26..e753a777949b 100644
--- a/arch/mips/include/asm/unistd.h
+++ b/arch/mips/include/asm/unistd.h
@@ -354,16 +354,17 @@
354#define __NR_pwritev (__NR_Linux + 331) 354#define __NR_pwritev (__NR_Linux + 331)
355#define __NR_rt_tgsigqueueinfo (__NR_Linux + 332) 355#define __NR_rt_tgsigqueueinfo (__NR_Linux + 332)
356#define __NR_perf_counter_open (__NR_Linux + 333) 356#define __NR_perf_counter_open (__NR_Linux + 333)
357#define __NR_accept4 (__NR_Linux + 334)
357 358
358/* 359/*
359 * Offset of the last Linux o32 flavoured syscall 360 * Offset of the last Linux o32 flavoured syscall
360 */ 361 */
361#define __NR_Linux_syscalls 333 362#define __NR_Linux_syscalls 334
362 363
363#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */ 364#endif /* _MIPS_SIM == _MIPS_SIM_ABI32 */
364 365
365#define __NR_O32_Linux 4000 366#define __NR_O32_Linux 4000
366#define __NR_O32_Linux_syscalls 333 367#define __NR_O32_Linux_syscalls 334
367 368
368#if _MIPS_SIM == _MIPS_SIM_ABI64 369#if _MIPS_SIM == _MIPS_SIM_ABI64
369 370
@@ -664,16 +665,17 @@
664#define __NR_pwritev (__NR_Linux + 290) 665#define __NR_pwritev (__NR_Linux + 290)
665#define __NR_rt_tgsigqueueinfo (__NR_Linux + 291) 666#define __NR_rt_tgsigqueueinfo (__NR_Linux + 291)
666#define __NR_perf_counter_open (__NR_Linux + 292) 667#define __NR_perf_counter_open (__NR_Linux + 292)
668#define __NR_accept4 (__NR_Linux + 293)
667 669
668/* 670/*
669 * Offset of the last Linux 64-bit flavoured syscall 671 * Offset of the last Linux 64-bit flavoured syscall
670 */ 672 */
671#define __NR_Linux_syscalls 292 673#define __NR_Linux_syscalls 293
672 674
673#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */ 675#endif /* _MIPS_SIM == _MIPS_SIM_ABI64 */
674 676
675#define __NR_64_Linux 5000 677#define __NR_64_Linux 5000
676#define __NR_64_Linux_syscalls 292 678#define __NR_64_Linux_syscalls 293
677 679
678#if _MIPS_SIM == _MIPS_SIM_NABI32 680#if _MIPS_SIM == _MIPS_SIM_NABI32
679 681
@@ -978,16 +980,17 @@
978#define __NR_pwritev (__NR_Linux + 294) 980#define __NR_pwritev (__NR_Linux + 294)
979#define __NR_rt_tgsigqueueinfo (__NR_Linux + 295) 981#define __NR_rt_tgsigqueueinfo (__NR_Linux + 295)
980#define __NR_perf_counter_open (__NR_Linux + 296) 982#define __NR_perf_counter_open (__NR_Linux + 296)
983#define __NR_accept4 (__NR_Linux + 297)
981 984
982/* 985/*
983 * Offset of the last N32 flavoured syscall 986 * Offset of the last N32 flavoured syscall
984 */ 987 */
985#define __NR_Linux_syscalls 296 988#define __NR_Linux_syscalls 297
986 989
987#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */ 990#endif /* _MIPS_SIM == _MIPS_SIM_NABI32 */
988 991
989#define __NR_N32_Linux 6000 992#define __NR_N32_Linux 6000
990#define __NR_N32_Linux_syscalls 296 993#define __NR_N32_Linux_syscalls 297
991 994
992#ifdef __KERNEL__ 995#ifdef __KERNEL__
993 996
diff --git a/arch/mips/jazz/jazzdma.c b/arch/mips/jazz/jazzdma.c
index f0fd636723be..0d64d0f46418 100644
--- a/arch/mips/jazz/jazzdma.c
+++ b/arch/mips/jazz/jazzdma.c
@@ -190,7 +190,7 @@ int vdma_free(unsigned long laddr)
190 return -1; 190 return -1;
191 } 191 }
192 192
193 while (pgtbl[i].owner == laddr && i < VDMA_PGTBL_ENTRIES) { 193 while (i < VDMA_PGTBL_ENTRIES && pgtbl[i].owner == laddr) {
194 pgtbl[i].owner = VDMA_PAGE_EMPTY; 194 pgtbl[i].owner = VDMA_PAGE_EMPTY;
195 i++; 195 i++;
196 } 196 }
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 492a0a8d70fb..531ce7b16124 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -188,7 +188,8 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
188 188
189 MTC0 zero, CP0_CONTEXT # clear context register 189 MTC0 zero, CP0_CONTEXT # clear context register
190 PTR_LA $28, init_thread_union 190 PTR_LA $28, init_thread_union
191 PTR_LI sp, _THREAD_SIZE - 32 191 /* Set the SP after an empty pt_regs. */
192 PTR_LI sp, _THREAD_SIZE - 32 - PT_SIZE
192 PTR_ADDU sp, $28 193 PTR_ADDU sp, $28
193 set_saved_sp sp, t0, t1 194 set_saved_sp sp, t0, t1
194 PTR_SUBU sp, 4 * SZREG # init stack pointer 195 PTR_SUBU sp, 4 * SZREG # init stack pointer
diff --git a/arch/mips/kernel/irq_txx9.c b/arch/mips/kernel/irq_txx9.c
index a4d1462c27f7..9b78029bea70 100644
--- a/arch/mips/kernel/irq_txx9.c
+++ b/arch/mips/kernel/irq_txx9.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/kernel/irq_txx9.c
3 *
4 * Based on linux/arch/mips/jmr3927/rbhma3100/irq.c, 2 * Based on linux/arch/mips/jmr3927/rbhma3100/irq.c,
5 * linux/arch/mips/tx4927/common/tx4927_irq.c, 3 * linux/arch/mips/tx4927/common/tx4927_irq.c,
6 * linux/arch/mips/tx4938/common/irq.c 4 * linux/arch/mips/tx4938/common/irq.c
diff --git a/arch/mips/kernel/module.c b/arch/mips/kernel/module.c
index 3e9100dcc12d..6f51dda87fce 100644
--- a/arch/mips/kernel/module.c
+++ b/arch/mips/kernel/module.c
@@ -98,7 +98,8 @@ static int apply_r_mips_32_rela(struct module *me, u32 *location, Elf_Addr v)
98static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v) 98static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
99{ 99{
100 if (v % 4) { 100 if (v % 4) {
101 printk(KERN_ERR "module %s: dangerous relocation\n", me->name); 101 pr_err("module %s: dangerous R_MIPS_26 REL relocation\n",
102 me->name);
102 return -ENOEXEC; 103 return -ENOEXEC;
103 } 104 }
104 105
@@ -118,7 +119,8 @@ static int apply_r_mips_26_rel(struct module *me, u32 *location, Elf_Addr v)
118static int apply_r_mips_26_rela(struct module *me, u32 *location, Elf_Addr v) 119static int apply_r_mips_26_rela(struct module *me, u32 *location, Elf_Addr v)
119{ 120{
120 if (v % 4) { 121 if (v % 4) {
121 printk(KERN_ERR "module %s: dangerous relocation\n", me->name); 122 pr_err("module %s: dangerous R_MIPS_26 RELArelocation\n",
123 me->name);
122 return -ENOEXEC; 124 return -ENOEXEC;
123 } 125 }
124 126
@@ -222,7 +224,7 @@ static int apply_r_mips_lo16_rel(struct module *me, u32 *location, Elf_Addr v)
222 return 0; 224 return 0;
223 225
224out_danger: 226out_danger:
225 printk(KERN_ERR "module %s: dangerous " "relocation\n", me->name); 227 pr_err("module %s: dangerous R_MIPS_LO16 REL relocation\n", me->name);
226 228
227 return -ENOEXEC; 229 return -ENOEXEC;
228} 230}
@@ -301,7 +303,7 @@ int apply_relocate(Elf_Shdr *sechdrs, const char *strtab,
301 /* This is the symbol it is referring to */ 303 /* This is the symbol it is referring to */
302 sym = (Elf_Sym *)sechdrs[symindex].sh_addr 304 sym = (Elf_Sym *)sechdrs[symindex].sh_addr
303 + ELF_MIPS_R_SYM(rel[i]); 305 + ELF_MIPS_R_SYM(rel[i]);
304 if (!sym->st_value) { 306 if (IS_ERR_VALUE(sym->st_value)) {
305 /* Ignore unresolved weak symbol */ 307 /* Ignore unresolved weak symbol */
306 if (ELF_ST_BIND(sym->st_info) == STB_WEAK) 308 if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
307 continue; 309 continue;
@@ -341,7 +343,7 @@ int apply_relocate_add(Elf_Shdr *sechdrs, const char *strtab,
341 /* This is the symbol it is referring to */ 343 /* This is the symbol it is referring to */
342 sym = (Elf_Sym *)sechdrs[symindex].sh_addr 344 sym = (Elf_Sym *)sechdrs[symindex].sh_addr
343 + ELF_MIPS_R_SYM(rel[i]); 345 + ELF_MIPS_R_SYM(rel[i]);
344 if (!sym->st_value) { 346 if (IS_ERR_VALUE(sym->st_value)) {
345 /* Ignore unresolved weak symbol */ 347 /* Ignore unresolved weak symbol */
346 if (ELF_ST_BIND(sym->st_info) == STB_WEAK) 348 if (ELF_ST_BIND(sym->st_info) == STB_WEAK)
347 continue; 349 continue;
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c
index e0a4ac18fa07..26109c4d5170 100644
--- a/arch/mips/kernel/proc.c
+++ b/arch/mips/kernel/proc.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/kernel/proc.c
3 *
4 * Copyright (C) 1995, 1996, 2001 Ralf Baechle 2 * Copyright (C) 1995, 1996, 2001 Ralf Baechle
5 * Copyright (C) 2001, 2004 MIPS Technologies, Inc. 3 * Copyright (C) 2001, 2004 MIPS Technologies, Inc.
6 * Copyright (C) 2004 Maciej W. Rozycki 4 * Copyright (C) 2004 Maciej W. Rozycki
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index c09d681b7181..f3d73e1831c1 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -115,7 +115,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
115{ 115{
116 struct thread_info *ti = task_thread_info(p); 116 struct thread_info *ti = task_thread_info(p);
117 struct pt_regs *childregs; 117 struct pt_regs *childregs;
118 long childksp; 118 unsigned long childksp;
119 p->set_child_tid = p->clear_child_tid = NULL; 119 p->set_child_tid = p->clear_child_tid = NULL;
120 120
121 childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32; 121 childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32;
@@ -132,6 +132,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
132 132
133 /* set up new TSS. */ 133 /* set up new TSS. */
134 childregs = (struct pt_regs *) childksp - 1; 134 childregs = (struct pt_regs *) childksp - 1;
135 /* Put the stack after the struct pt_regs. */
136 childksp = (unsigned long) childregs;
135 *childregs = *regs; 137 *childregs = *regs;
136 childregs->regs[7] = 0; /* Clear error flag */ 138 childregs->regs[7] = 0; /* Clear error flag */
137 139
diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
index 20a86e08fd58..b57082123536 100644
--- a/arch/mips/kernel/scall32-o32.S
+++ b/arch/mips/kernel/scall32-o32.S
@@ -654,6 +654,7 @@ einval: li v0, -ENOSYS
654 sys sys_pwritev 6 654 sys sys_pwritev 6
655 sys sys_rt_tgsigqueueinfo 4 655 sys sys_rt_tgsigqueueinfo 4
656 sys sys_perf_counter_open 5 656 sys sys_perf_counter_open 5
657 sys sys_accept4 4
657 .endm 658 .endm
658 659
659 /* We pre-compute the number of _instruction_ bytes needed to 660 /* We pre-compute the number of _instruction_ bytes needed to
diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
index b046130d4c5d..3d866f24e064 100644
--- a/arch/mips/kernel/scall64-64.S
+++ b/arch/mips/kernel/scall64-64.S
@@ -491,4 +491,5 @@ sys_call_table:
491 PTR sys_pwritev /* 5390 */ 491 PTR sys_pwritev /* 5390 */
492 PTR sys_rt_tgsigqueueinfo 492 PTR sys_rt_tgsigqueueinfo
493 PTR sys_perf_counter_open 493 PTR sys_perf_counter_open
494 PTR sys_accept4
494 .size sys_call_table,.-sys_call_table 495 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
index 15874f9812cc..e855b118a079 100644
--- a/arch/mips/kernel/scall64-n32.S
+++ b/arch/mips/kernel/scall64-n32.S
@@ -417,4 +417,5 @@ EXPORT(sysn32_call_table)
417 PTR sys_pwritev 417 PTR sys_pwritev
418 PTR compat_sys_rt_tgsigqueueinfo /* 5295 */ 418 PTR compat_sys_rt_tgsigqueueinfo /* 5295 */
419 PTR sys_perf_counter_open 419 PTR sys_perf_counter_open
420 PTR sys_accept4
420 .size sysn32_call_table,.-sysn32_call_table 421 .size sysn32_call_table,.-sysn32_call_table
diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
index 781e0f1e9533..0c49f1a660be 100644
--- a/arch/mips/kernel/scall64-o32.S
+++ b/arch/mips/kernel/scall64-o32.S
@@ -537,4 +537,5 @@ sys_call_table:
537 PTR compat_sys_pwritev 537 PTR compat_sys_pwritev
538 PTR compat_sys_rt_tgsigqueueinfo 538 PTR compat_sys_rt_tgsigqueueinfo
539 PTR sys_perf_counter_open 539 PTR sys_perf_counter_open
540 PTR sys_accept4
540 .size sys_call_table,.-sys_call_table 541 .size sys_call_table,.-sys_call_table
diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index 8a0626cbb108..c16bb6d6c25c 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -465,11 +465,8 @@ void smtc_prepare_cpus(int cpus)
465 smtc_configure_tlb(); 465 smtc_configure_tlb();
466 466
467 for (tc = 0, vpe = 0 ; (vpe < nvpe) && (tc < ntc) ; vpe++) { 467 for (tc = 0, vpe = 0 ; (vpe < nvpe) && (tc < ntc) ; vpe++) {
468 /* 468 if (tcpervpe[vpe] == 0)
469 * Set the MVP bits. 469 continue;
470 */
471 settc(tc);
472 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() | VPECONF0_MVP);
473 if (vpe != 0) 470 if (vpe != 0)
474 printk(", "); 471 printk(", ");
475 printk("VPE %d: TC", vpe); 472 printk("VPE %d: TC", vpe);
@@ -488,6 +485,12 @@ void smtc_prepare_cpus(int cpus)
488 } 485 }
489 if (vpe != 0) { 486 if (vpe != 0) {
490 /* 487 /*
488 * Allow this VPE to control others.
489 */
490 write_vpe_c0_vpeconf0(read_vpe_c0_vpeconf0() |
491 VPECONF0_MVP);
492
493 /*
491 * Clear any stale software interrupts from VPE's Cause 494 * Clear any stale software interrupts from VPE's Cause
492 */ 495 */
493 write_vpe_c0_cause(0); 496 write_vpe_c0_cause(0);
diff --git a/arch/mips/kernel/stacktrace.c b/arch/mips/kernel/stacktrace.c
index 58f5cd76c8c3..d52ff77baf3f 100644
--- a/arch/mips/kernel/stacktrace.c
+++ b/arch/mips/kernel/stacktrace.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/kernel/stacktrace.c
3 *
4 * Stack trace management functions 2 * Stack trace management functions
5 * 3 *
6 * Copyright (C) 2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp> 4 * Copyright (C) 2006 Atsushi Nemoto <anemo@mba.ocn.ne.jp>
diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 07b9ec2c6e3d..9a1ab7e87fd4 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -73,7 +73,7 @@ static int major;
73static const int minor = 1; /* fixed for now */ 73static const int minor = 1; /* fixed for now */
74 74
75#ifdef CONFIG_MIPS_APSP_KSPD 75#ifdef CONFIG_MIPS_APSP_KSPD
76 static struct kspd_notifications kspd_events; 76static struct kspd_notifications kspd_events;
77static int kspd_events_reqd = 0; 77static int kspd_events_reqd = 0;
78#endif 78#endif
79 79
@@ -155,10 +155,9 @@ struct {
155}; 155};
156 156
157static void release_progmem(void *ptr); 157static void release_progmem(void *ptr);
158extern void save_gp_address(unsigned int secbase, unsigned int rel);
159 158
160/* get the vpe associated with this minor */ 159/* get the vpe associated with this minor */
161struct vpe *get_vpe(int minor) 160static struct vpe *get_vpe(int minor)
162{ 161{
163 struct vpe *v; 162 struct vpe *v;
164 163
@@ -174,7 +173,7 @@ struct vpe *get_vpe(int minor)
174} 173}
175 174
176/* get the vpe associated with this minor */ 175/* get the vpe associated with this minor */
177struct tc *get_tc(int index) 176static struct tc *get_tc(int index)
178{ 177{
179 struct tc *t; 178 struct tc *t;
180 179
@@ -186,20 +185,8 @@ struct tc *get_tc(int index)
186 return NULL; 185 return NULL;
187} 186}
188 187
189struct tc *get_tc_unused(void)
190{
191 struct tc *t;
192
193 list_for_each_entry(t, &vpecontrol.tc_list, list) {
194 if (t->state == TC_STATE_UNUSED)
195 return t;
196 }
197
198 return NULL;
199}
200
201/* allocate a vpe and associate it with this minor (or index) */ 188/* allocate a vpe and associate it with this minor (or index) */
202struct vpe *alloc_vpe(int minor) 189static struct vpe *alloc_vpe(int minor)
203{ 190{
204 struct vpe *v; 191 struct vpe *v;
205 192
@@ -216,7 +203,7 @@ struct vpe *alloc_vpe(int minor)
216} 203}
217 204
218/* allocate a tc. At startup only tc0 is running, all other can be halted. */ 205/* allocate a tc. At startup only tc0 is running, all other can be halted. */
219struct tc *alloc_tc(int index) 206static struct tc *alloc_tc(int index)
220{ 207{
221 struct tc *tc; 208 struct tc *tc;
222 209
@@ -232,7 +219,7 @@ out:
232} 219}
233 220
234/* clean up and free everything */ 221/* clean up and free everything */
235void release_vpe(struct vpe *v) 222static void release_vpe(struct vpe *v)
236{ 223{
237 list_del(&v->list); 224 list_del(&v->list);
238 if (v->load_addr) 225 if (v->load_addr)
@@ -240,7 +227,7 @@ void release_vpe(struct vpe *v)
240 kfree(v); 227 kfree(v);
241} 228}
242 229
243void dump_mtregs(void) 230static void dump_mtregs(void)
244{ 231{
245 unsigned long val; 232 unsigned long val;
246 233
@@ -327,7 +314,8 @@ static void layout_sections(struct module *mod, const Elf_Ehdr * hdr,
327 || (s->sh_flags & masks[m][1]) 314 || (s->sh_flags & masks[m][1])
328 || s->sh_entsize != ~0UL) 315 || s->sh_entsize != ~0UL)
329 continue; 316 continue;
330 s->sh_entsize = get_offset(&mod->core_size, s); 317 s->sh_entsize =
318 get_offset((unsigned long *)&mod->core_size, s);
331 } 319 }
332 320
333 if (m == 0) 321 if (m == 0)
@@ -461,16 +449,15 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,
461{ 449{
462 unsigned long insnlo = *location; 450 unsigned long insnlo = *location;
463 Elf32_Addr val, vallo; 451 Elf32_Addr val, vallo;
452 struct mips_hi16 *l, *next;
464 453
465 /* Sign extend the addend we extract from the lo insn. */ 454 /* Sign extend the addend we extract from the lo insn. */
466 vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000; 455 vallo = ((insnlo & 0xffff) ^ 0x8000) - 0x8000;
467 456
468 if (mips_hi16_list != NULL) { 457 if (mips_hi16_list != NULL) {
469 struct mips_hi16 *l;
470 458
471 l = mips_hi16_list; 459 l = mips_hi16_list;
472 while (l != NULL) { 460 while (l != NULL) {
473 struct mips_hi16 *next;
474 unsigned long insn; 461 unsigned long insn;
475 462
476 /* 463 /*
@@ -480,7 +467,7 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,
480 printk(KERN_DEBUG "VPE loader: " 467 printk(KERN_DEBUG "VPE loader: "
481 "apply_r_mips_lo16/hi16: \t" 468 "apply_r_mips_lo16/hi16: \t"
482 "inconsistent value information\n"); 469 "inconsistent value information\n");
483 return -ENOEXEC; 470 goto out_free;
484 } 471 }
485 472
486 /* 473 /*
@@ -518,6 +505,16 @@ static int apply_r_mips_lo16(struct module *me, uint32_t *location,
518 *location = insnlo; 505 *location = insnlo;
519 506
520 return 0; 507 return 0;
508
509out_free:
510 while (l != NULL) {
511 next = l->next;
512 kfree(l);
513 l = next;
514 }
515 mips_hi16_list = NULL;
516
517 return -ENOEXEC;
521} 518}
522 519
523static int (*reloc_handlers[]) (struct module *me, uint32_t *location, 520static int (*reloc_handlers[]) (struct module *me, uint32_t *location,
@@ -541,7 +538,7 @@ static char *rstrs[] = {
541 [R_MIPS_PC16] = "MIPS_PC16" 538 [R_MIPS_PC16] = "MIPS_PC16"
542}; 539};
543 540
544int apply_relocations(Elf32_Shdr *sechdrs, 541static int apply_relocations(Elf32_Shdr *sechdrs,
545 const char *strtab, 542 const char *strtab,
546 unsigned int symindex, 543 unsigned int symindex,
547 unsigned int relsec, 544 unsigned int relsec,
@@ -586,7 +583,7 @@ int apply_relocations(Elf32_Shdr *sechdrs,
586 return 0; 583 return 0;
587} 584}
588 585
589void save_gp_address(unsigned int secbase, unsigned int rel) 586static inline void save_gp_address(unsigned int secbase, unsigned int rel)
590{ 587{
591 gp_addr = secbase + rel; 588 gp_addr = secbase + rel;
592 gp_offs = gp_addr - (secbase & 0xffff0000); 589 gp_offs = gp_addr - (secbase & 0xffff0000);
diff --git a/arch/mips/mipssim/sim_time.c b/arch/mips/mipssim/sim_time.c
index 0cea932f1241..5492c42f7650 100644
--- a/arch/mips/mipssim/sim_time.c
+++ b/arch/mips/mipssim/sim_time.c
@@ -89,13 +89,13 @@ unsigned __cpuinit get_c0_compare_int(void)
89 if (cpu_has_veic) { 89 if (cpu_has_veic) {
90 set_vi_handler(MSC01E_INT_CPUCTR, mips_timer_dispatch); 90 set_vi_handler(MSC01E_INT_CPUCTR, mips_timer_dispatch);
91 mips_cpu_timer_irq = MSC01E_INT_BASE + MSC01E_INT_CPUCTR; 91 mips_cpu_timer_irq = MSC01E_INT_BASE + MSC01E_INT_CPUCTR;
92 } else { 92
93#endif 93 return mips_cpu_timer_irq;
94 {
95 if (cpu_has_vint)
96 set_vi_handler(cp0_compare_irq, mips_timer_dispatch);
97 mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq;
98 } 94 }
95#endif
96 if (cpu_has_vint)
97 set_vi_handler(cp0_compare_irq, mips_timer_dispatch);
98 mips_cpu_timer_irq = MIPS_CPU_IRQ_BASE + cp0_compare_irq;
99 99
100 return mips_cpu_timer_irq; 100 return mips_cpu_timer_irq;
101} 101}
diff --git a/arch/mips/mm/c-octeon.c b/arch/mips/mm/c-octeon.c
index b165cdcb2818..10ab69f7183f 100644
--- a/arch/mips/mm/c-octeon.c
+++ b/arch/mips/mm/c-octeon.c
@@ -289,7 +289,7 @@ static void cache_parity_error_octeon(int non_recoverable)
289} 289}
290 290
291/** 291/**
292 * Called when the the exception is not recoverable 292 * Called when the the exception is recoverable
293 */ 293 */
294 294
295asmlinkage void cache_parity_error_octeon_recoverable(void) 295asmlinkage void cache_parity_error_octeon_recoverable(void)
@@ -298,7 +298,7 @@ asmlinkage void cache_parity_error_octeon_recoverable(void)
298} 298}
299 299
300/** 300/**
301 * Called when the the exception is recoverable 301 * Called when the the exception is not recoverable
302 */ 302 */
303 303
304asmlinkage void cache_parity_error_octeon_non_recoverable(void) 304asmlinkage void cache_parity_error_octeon_non_recoverable(void)
diff --git a/arch/mips/mm/extable.c b/arch/mips/mm/extable.c
index 297fb9f390dc..9d25d2ba4b9e 100644
--- a/arch/mips/mm/extable.c
+++ b/arch/mips/mm/extable.c
@@ -1,5 +1,9 @@
1/* 1/*
2 * linux/arch/mips/mm/extable.c 2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 1997, 99, 2001 - 2004 Ralf Baechle <ralf@linux-mips.org>
3 */ 7 */
4#include <linux/module.h> 8#include <linux/module.h>
5#include <linux/spinlock.h> 9#include <linux/spinlock.h>
diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
index 6751ce9ede9e..f956ecbb8136 100644
--- a/arch/mips/mm/fault.c
+++ b/arch/mips/mm/fault.c
@@ -171,6 +171,7 @@ out_of_memory:
171 * We ran out of memory, call the OOM killer, and return the userspace 171 * We ran out of memory, call the OOM killer, and return the userspace
172 * (which will retry the fault, or kill us if we got oom-killed). 172 * (which will retry the fault, or kill us if we got oom-killed).
173 */ 173 */
174 up_read(&mm->mmap_sem);
174 pagefault_out_of_memory(); 175 pagefault_out_of_memory();
175 return; 176 return;
176 177
diff --git a/arch/mips/mti-malta/malta-int.c b/arch/mips/mti-malta/malta-int.c
index a8756f82c31b..3e0a9b35ba5c 100644
--- a/arch/mips/mti-malta/malta-int.c
+++ b/arch/mips/mti-malta/malta-int.c
@@ -331,6 +331,7 @@ static struct irqaction irq_call = {
331 .flags = IRQF_DISABLED|IRQF_PERCPU, 331 .flags = IRQF_DISABLED|IRQF_PERCPU,
332 .name = "IPI_call" 332 .name = "IPI_call"
333}; 333};
334#endif /* CONFIG_MIPS_MT_SMP */
334 335
335static int gic_resched_int_base; 336static int gic_resched_int_base;
336static int gic_call_int_base; 337static int gic_call_int_base;
@@ -346,7 +347,6 @@ unsigned int plat_ipi_resched_int_xlate(unsigned int cpu)
346{ 347{
347 return GIC_RESCHED_INT(cpu); 348 return GIC_RESCHED_INT(cpu);
348} 349}
349#endif /* CONFIG_MIPS_MT_SMP */
350 350
351static struct irqaction i8259irq = { 351static struct irqaction i8259irq = {
352 .handler = no_action, 352 .handler = no_action,
diff --git a/arch/mips/nxp/pnx8550/common/time.c b/arch/mips/nxp/pnx8550/common/time.c
index 8df43e9e4d90..18b192784877 100644
--- a/arch/mips/nxp/pnx8550/common/time.c
+++ b/arch/mips/nxp/pnx8550/common/time.c
@@ -138,7 +138,7 @@ __init void plat_time_init(void)
138 * HZ timer interrupts per second. 138 * HZ timer interrupts per second.
139 */ 139 */
140 mips_hpt_frequency = 27UL * ((1000000UL * n)/(m * pow2p)); 140 mips_hpt_frequency = 27UL * ((1000000UL * n)/(m * pow2p));
141 cpj = (mips_hpt_frequency + HZ / 2) / HZ; 141 cpj = DIV_ROUND_CLOSEST(mips_hpt_frequency, HZ);
142 write_c0_count(0); 142 write_c0_count(0);
143 timer_ack(); 143 timer_ack();
144 144
diff --git a/arch/mips/pci/fixup-emma2rh.c b/arch/mips/pci/fixup-emma2rh.c
index fba5aad00d51..0d9ccf4dfc5a 100644
--- a/arch/mips/pci/fixup-emma2rh.c
+++ b/arch/mips/pci/fixup-emma2rh.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/pci/fixup-emma2rh.c
3 * This file defines the PCI configration.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006 2 * Copyright (C) NEC Electronics Corporation 2004-2006
6 * 3 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c 4 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
diff --git a/arch/mips/pci/fixup-sb1250.c b/arch/mips/pci/fixup-sb1250.c
index 0ad39e53f7b1..f0bb9146e6c0 100644
--- a/arch/mips/pci/fixup-sb1250.c
+++ b/arch/mips/pci/fixup-sb1250.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/pci/fixup-sb1250.c
3 *
4 * Copyright (C) 2004, 2006 MIPS Technologies, Inc. All rights reserved. 2 * Copyright (C) 2004, 2006 MIPS Technologies, Inc. All rights reserved.
5 * Author: Maciej W. Rozycki <macro@mips.com> 3 * Author: Maciej W. Rozycki <macro@mips.com>
6 * 4 *
diff --git a/arch/mips/pci/ops-emma2rh.c b/arch/mips/pci/ops-emma2rh.c
index 5947a70b0b7f..710aef5c070e 100644
--- a/arch/mips/pci/ops-emma2rh.c
+++ b/arch/mips/pci/ops-emma2rh.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/pci/ops-emma2rh.c
3 * This file defines the PCI operation for EMMA2RH.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006 2 * Copyright (C) NEC Electronics Corporation 2004-2006
6 * 3 *
7 * This file is based on the arch/mips/pci/ops-vr41xx.c 4 * This file is based on the arch/mips/pci/ops-vr41xx.c
diff --git a/arch/mips/pci/pci-emma2rh.c b/arch/mips/pci/pci-emma2rh.c
index 2df4190232cd..773e34ff4d1c 100644
--- a/arch/mips/pci/pci-emma2rh.c
+++ b/arch/mips/pci/pci-emma2rh.c
@@ -1,7 +1,4 @@
1/* 1/*
2 * arch/mips/pci/pci-emma2rh.c
3 * This file defines the PCI configration.
4 *
5 * Copyright (C) NEC Electronics Corporation 2004-2006 2 * Copyright (C) NEC Electronics Corporation 2004-2006
6 * 3 *
7 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c 4 * This file is based on the arch/mips/ddb5xxx/ddb5477/pci.c
diff --git a/arch/mips/pci/pci-tx4927.c b/arch/mips/pci/pci-tx4927.c
index aaa900596792..a5807406a7f1 100644
--- a/arch/mips/pci/pci-tx4927.c
+++ b/arch/mips/pci/pci-tx4927.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/pci/pci-tx4927.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c, 2 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive. 3 * and RBTX49xx patch from CELF patch archive.
6 * 4 *
diff --git a/arch/mips/pci/pci-tx4938.c b/arch/mips/pci/pci-tx4938.c
index 1ea257bc3b8f..20e45f30b2ef 100644
--- a/arch/mips/pci/pci-tx4938.c
+++ b/arch/mips/pci/pci-tx4938.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/pci/pci-tx4938.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c, 2 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive. 3 * and RBTX49xx patch from CELF patch archive.
6 * 4 *
diff --git a/arch/mips/pci/pci-tx4939.c b/arch/mips/pci/pci-tx4939.c
index 5fecf1cdc325..9ef840693baf 100644
--- a/arch/mips/pci/pci-tx4939.c
+++ b/arch/mips/pci/pci-tx4939.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/pci/pci-tx4939.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4939/setup.c, 2 * Based on linux/arch/mips/txx9/rbtx4939/setup.c,
5 * and RBTX49xx patch from CELF patch archive. 3 * and RBTX49xx patch from CELF patch archive.
6 * 4 *
diff --git a/arch/mips/pci/pcie-octeon.c b/arch/mips/pci/pcie-octeon.c
index 75262247f3e4..6aa5c542d52d 100644
--- a/arch/mips/pci/pcie-octeon.c
+++ b/arch/mips/pci/pcie-octeon.c
@@ -1040,19 +1040,29 @@ static inline int octeon_pcie_read_config(int pcie_port, struct pci_bus *bus,
1040 int bus_number = bus->number; 1040 int bus_number = bus->number;
1041 1041
1042 /* 1042 /*
1043 * We need to force the bus number to be zero on the root 1043 * For the top level bus make sure our hardware bus number
1044 * bus. Linux numbers the 2nd root bus to start after all 1044 * matches the software one.
1045 * buses on root 0.
1046 */ 1045 */
1047 if (bus->parent == NULL) 1046 if (bus->parent == NULL) {
1048 bus_number = 0; 1047 union cvmx_pciercx_cfg006 pciercx_cfg006;
1048 pciercx_cfg006.u32 = cvmx_pcie_cfgx_read(pcie_port,
1049 CVMX_PCIERCX_CFG006(pcie_port));
1050 if (pciercx_cfg006.s.pbnum != bus_number) {
1051 pciercx_cfg006.s.pbnum = bus_number;
1052 pciercx_cfg006.s.sbnum = bus_number;
1053 pciercx_cfg006.s.subbnum = bus_number;
1054 cvmx_pcie_cfgx_write(pcie_port,
1055 CVMX_PCIERCX_CFG006(pcie_port),
1056 pciercx_cfg006.u32);
1057 }
1058 }
1049 1059
1050 /* 1060 /*
1051 * PCIe only has a single device connected to Octeon. It is 1061 * PCIe only has a single device connected to Octeon. It is
1052 * always device ID 0. Don't bother doing reads for other 1062 * always device ID 0. Don't bother doing reads for other
1053 * device IDs on the first segment. 1063 * device IDs on the first segment.
1054 */ 1064 */
1055 if ((bus_number == 0) && (devfn >> 3 != 0)) 1065 if ((bus->parent == NULL) && (devfn >> 3 != 0))
1056 return PCIBIOS_FUNC_NOT_SUPPORTED; 1066 return PCIBIOS_FUNC_NOT_SUPPORTED;
1057 1067
1058 /* 1068 /*
@@ -1070,7 +1080,7 @@ static inline int octeon_pcie_read_config(int pcie_port, struct pci_bus *bus,
1070 * bridge only respondes to device ID 0, function 1080 * bridge only respondes to device ID 0, function
1071 * 0-1 1081 * 0-1
1072 */ 1082 */
1073 if ((bus_number == 0) && (devfn >= 2)) 1083 if ((bus->parent == NULL) && (devfn >= 2))
1074 return PCIBIOS_FUNC_NOT_SUPPORTED; 1084 return PCIBIOS_FUNC_NOT_SUPPORTED;
1075 /* 1085 /*
1076 * The PCI-X slots are device ID 2,3. Choose one of 1086 * The PCI-X slots are device ID 2,3. Choose one of
@@ -1167,13 +1177,6 @@ static inline int octeon_pcie_write_config(int pcie_port, struct pci_bus *bus,
1167 int size, u32 val) 1177 int size, u32 val)
1168{ 1178{
1169 int bus_number = bus->number; 1179 int bus_number = bus->number;
1170 /*
1171 * We need to force the bus number to be zero on the root
1172 * bus. Linux numbers the 2nd root bus to start after all
1173 * busses on root 0.
1174 */
1175 if (bus->parent == NULL)
1176 bus_number = 0;
1177 1180
1178 switch (size) { 1181 switch (size) {
1179 case 4: 1182 case 4:
diff --git a/arch/mips/pmc-sierra/msp71xx/gpio.c b/arch/mips/pmc-sierra/msp71xx/gpio.c
index 69848c5813e2..aaccbe524386 100644
--- a/arch/mips/pmc-sierra/msp71xx/gpio.c
+++ b/arch/mips/pmc-sierra/msp71xx/gpio.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * @file /arch/mips/pmc-sierra/msp71xx/gpio.c
3 *
4 * Generic PMC MSP71xx GPIO handling. These base gpio are controlled by two 2 * Generic PMC MSP71xx GPIO handling. These base gpio are controlled by two
5 * types of registers. The data register sets the output level when in output 3 * types of registers. The data register sets the output level when in output
6 * mode and when in input mode will contain the value at the input. The config 4 * mode and when in input mode will contain the value at the input. The config
diff --git a/arch/mips/pmc-sierra/msp71xx/gpio_extended.c b/arch/mips/pmc-sierra/msp71xx/gpio_extended.c
index fc6dbc6cf1c0..2a99f360fae4 100644
--- a/arch/mips/pmc-sierra/msp71xx/gpio_extended.c
+++ b/arch/mips/pmc-sierra/msp71xx/gpio_extended.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * @file /arch/mips/pmc-sierra/msp71xx/gpio_extended.c
3 *
4 * Generic PMC MSP71xx EXTENDED (EXD) GPIO handling. The extended gpio is 2 * Generic PMC MSP71xx EXTENDED (EXD) GPIO handling. The extended gpio is
5 * a set of hardware registers that have no need for explicit locking as 3 * a set of hardware registers that have no need for explicit locking as
6 * it is handled by unique method of writing individual set/clr bits. 4 * it is handled by unique method of writing individual set/clr bits.
diff --git a/arch/mips/pmc-sierra/msp71xx/msp_irq_slp.c b/arch/mips/pmc-sierra/msp71xx/msp_irq_slp.c
index f5f1b8d2bb9a..61f390232346 100644
--- a/arch/mips/pmc-sierra/msp71xx/msp_irq_slp.c
+++ b/arch/mips/pmc-sierra/msp71xx/msp_irq_slp.c
@@ -45,13 +45,6 @@ static inline void mask_msp_slp_irq(unsigned int irq)
45 */ 45 */
46static inline void ack_msp_slp_irq(unsigned int irq) 46static inline void ack_msp_slp_irq(unsigned int irq)
47{ 47{
48 mask_slp_irq(irq);
49
50 /*
51 * only really necessary for 18, 16-14 and sometimes 3:0 (since
52 * these can be edge sensitive) but it doesn't hurt for the others.
53 */
54
55 /* check for PER interrupt range */ 48 /* check for PER interrupt range */
56 if (irq < MSP_PER_INTBASE) 49 if (irq < MSP_PER_INTBASE)
57 *SLP_INT_STS_REG = (1 << (irq - MSP_SLP_INTBASE)); 50 *SLP_INT_STS_REG = (1 << (irq - MSP_SLP_INTBASE));
@@ -62,8 +55,7 @@ static inline void ack_msp_slp_irq(unsigned int irq)
62static struct irq_chip msp_slp_irq_controller = { 55static struct irq_chip msp_slp_irq_controller = {
63 .name = "MSP_SLP", 56 .name = "MSP_SLP",
64 .ack = ack_msp_slp_irq, 57 .ack = ack_msp_slp_irq,
65 .mask = ack_msp_slp_irq, 58 .mask = mask_msp_slp_irq,
66 .mask_ack = ack_msp_slp_irq,
67 .unmask = unmask_msp_slp_irq, 59 .unmask = unmask_msp_slp_irq,
68}; 60};
69 61
@@ -79,7 +71,7 @@ void __init msp_slp_irq_init(void)
79 71
80 /* initialize all the IRQ descriptors */ 72 /* initialize all the IRQ descriptors */
81 for (i = MSP_SLP_INTBASE; i < MSP_PER_INTBASE + 32; i++) 73 for (i = MSP_SLP_INTBASE; i < MSP_PER_INTBASE + 32; i++)
82 set_irq_chip_and_handler(i, &msp_slp_irq_controller 74 set_irq_chip_and_handler(i, &msp_slp_irq_controller,
83 handle_level_irq); 75 handle_level_irq);
84} 76}
85 77
diff --git a/arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c b/arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c
index caf5e9a0acc7..fc990cb31941 100644
--- a/arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c
+++ b/arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/pmc-sierra/yosemite/atmel_read_eeprom.c
3 *
4 * Copyright (C) 2003 PMC-Sierra Inc. 2 * Copyright (C) 2003 PMC-Sierra Inc.
5 * Author: Manish Lachwani (lachwani@pmc-sierra.com) 3 * Author: Manish Lachwani (lachwani@pmc-sierra.com)
6 * 4 *
diff --git a/arch/mips/sibyte/swarm/swarm-i2c.c b/arch/mips/sibyte/swarm/swarm-i2c.c
index 4282ac9d01d2..062505054d42 100644
--- a/arch/mips/sibyte/swarm/swarm-i2c.c
+++ b/arch/mips/sibyte/swarm/swarm-i2c.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * arch/mips/sibyte/swarm/swarm-i2c.c
3 *
4 * Broadcom BCM91250A (SWARM), etc. I2C platform setup. 2 * Broadcom BCM91250A (SWARM), etc. I2C platform setup.
5 * 3 *
6 * Copyright (c) 2008 Maciej W. Rozycki 4 * Copyright (c) 2008 Maciej W. Rozycki
diff --git a/arch/mips/txx9/generic/mem_tx4927.c b/arch/mips/txx9/generic/mem_tx4927.c
index ef6ea6e97873..70f9626f8227 100644
--- a/arch/mips/txx9/generic/mem_tx4927.c
+++ b/arch/mips/txx9/generic/mem_tx4927.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/txx9/generic/mem_tx4927.c
3 *
4 * common tx4927 memory interface 2 * common tx4927 memory interface
5 * 3 *
6 * Author: MontaVista Software, Inc. 4 * Author: MontaVista Software, Inc.
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 3b7d77d61ce0..a205e2ba8e7b 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * linux/arch/mips/txx9/generic/setup.c
3 *
4 * Based on linux/arch/mips/txx9/rbtx4938/setup.c, 2 * Based on linux/arch/mips/txx9/rbtx4938/setup.c,
5 * and RBTX49xx patch from CELF patch archive. 3 * and RBTX49xx patch from CELF patch archive.
6 * 4 *
diff --git a/arch/mips/txx9/rbtx4939/setup.c b/arch/mips/txx9/rbtx4939/setup.c
index c033ffe71cdf..b0c241ecf603 100644
--- a/arch/mips/txx9/rbtx4939/setup.c
+++ b/arch/mips/txx9/rbtx4939/setup.c
@@ -512,10 +512,10 @@ static void __init rbtx4939_setup(void)
512 rbtx4939_ebusc_setup(); 512 rbtx4939_ebusc_setup();
513 /* always enable ATA0 */ 513 /* always enable ATA0 */
514 txx9_set64(&tx4939_ccfgptr->pcfg, TX4939_PCFG_ATA0MODE); 514 txx9_set64(&tx4939_ccfgptr->pcfg, TX4939_PCFG_ATA0MODE);
515 rbtx4939_update_ioc_pen();
516 if (txx9_master_clock == 0) 515 if (txx9_master_clock == 0)
517 txx9_master_clock = 20000000; 516 txx9_master_clock = 20000000;
518 tx4939_setup(); 517 tx4939_setup();
518 rbtx4939_update_ioc_pen();
519#ifdef HAVE_RBTX4939_IOSWAB 519#ifdef HAVE_RBTX4939_IOSWAB
520 ioswabw = rbtx4939_ioswabw; 520 ioswabw = rbtx4939_ioswabw;
521 __mem_ioswabw = rbtx4939_mem_ioswabw; 521 __mem_ioswabw = rbtx4939_mem_ioswabw;
diff --git a/arch/mn10300/include/asm/pci.h b/arch/mn10300/include/asm/pci.h
index 35d2ed6396f6..19aecc90f7a4 100644
--- a/arch/mn10300/include/asm/pci.h
+++ b/arch/mn10300/include/asm/pci.h
@@ -59,7 +59,6 @@ void pcibios_penalize_isa_irq(int irq);
59#include <linux/slab.h> 59#include <linux/slab.h>
60#include <asm/scatterlist.h> 60#include <asm/scatterlist.h>
61#include <linux/string.h> 61#include <linux/string.h>
62#include <linux/mm.h>
63#include <asm/io.h> 62#include <asm/io.h>
64 63
65struct pci_dev; 64struct pci_dev;
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index ae3e70cd1e14..e552e547cb93 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -553,7 +553,7 @@
553 * on most of those machines only handles cache transactions. 553 * on most of those machines only handles cache transactions.
554 */ 554 */
555 extrd,u,*= \pte,_PAGE_NO_CACHE_BIT+32,1,%r0 555 extrd,u,*= \pte,_PAGE_NO_CACHE_BIT+32,1,%r0
556 depi 1,12,1,\prot 556 depdi 1,12,1,\prot
557 557
558 /* Drop prot bits and convert to page addr for iitlbt and idtlbt */ 558 /* Drop prot bits and convert to page addr for iitlbt and idtlbt */
559 convert_for_tlb_insert20 \pte 559 convert_for_tlb_insert20 \pte
diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
index ef5caf2e6ed0..61ee0eec4e69 100644
--- a/arch/parisc/kernel/module.c
+++ b/arch/parisc/kernel/module.c
@@ -86,8 +86,12 @@
86 * the bottom of the table, which has a maximum signed displacement of 86 * the bottom of the table, which has a maximum signed displacement of
87 * 0x3fff; however, since we're only going forward, this becomes 87 * 0x3fff; however, since we're only going forward, this becomes
88 * 0x1fff, and thus, since each GOT entry is 8 bytes long we can have 88 * 0x1fff, and thus, since each GOT entry is 8 bytes long we can have
89 * at most 1023 entries */ 89 * at most 1023 entries.
90#define MAX_GOTS 1023 90 * To overcome this 14bit displacement with some kernel modules, we'll
91 * use instead the unusal 16bit displacement method (see reassemble_16a)
92 * which gives us a maximum positive displacement of 0x7fff, and as such
93 * allows us to allocate up to 4095 GOT entries. */
94#define MAX_GOTS 4095
91 95
92/* three functions to determine where in the module core 96/* three functions to determine where in the module core
93 * or init pieces the location is */ 97 * or init pieces the location is */
@@ -145,12 +149,40 @@ struct stub_entry {
145/* The reassemble_* functions prepare an immediate value for 149/* The reassemble_* functions prepare an immediate value for
146 insertion into an opcode. pa-risc uses all sorts of weird bitfields 150 insertion into an opcode. pa-risc uses all sorts of weird bitfields
147 in the instruction to hold the value. */ 151 in the instruction to hold the value. */
152static inline int sign_unext(int x, int len)
153{
154 int len_ones;
155
156 len_ones = (1 << len) - 1;
157 return x & len_ones;
158}
159
160static inline int low_sign_unext(int x, int len)
161{
162 int sign, temp;
163
164 sign = (x >> (len-1)) & 1;
165 temp = sign_unext(x, len-1);
166 return (temp << 1) | sign;
167}
168
148static inline int reassemble_14(int as14) 169static inline int reassemble_14(int as14)
149{ 170{
150 return (((as14 & 0x1fff) << 1) | 171 return (((as14 & 0x1fff) << 1) |
151 ((as14 & 0x2000) >> 13)); 172 ((as14 & 0x2000) >> 13));
152} 173}
153 174
175static inline int reassemble_16a(int as16)
176{
177 int s, t;
178
179 /* Unusual 16-bit encoding, for wide mode only. */
180 t = (as16 << 1) & 0xffff;
181 s = (as16 & 0x8000);
182 return (t ^ s ^ (s >> 1)) | (s >> 15);
183}
184
185
154static inline int reassemble_17(int as17) 186static inline int reassemble_17(int as17)
155{ 187{
156 return (((as17 & 0x10000) >> 16) | 188 return (((as17 & 0x10000) >> 16) |
@@ -407,6 +439,7 @@ static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
407 enum elf_stub_type stub_type, Elf_Addr loc0, unsigned int targetsec) 439 enum elf_stub_type stub_type, Elf_Addr loc0, unsigned int targetsec)
408{ 440{
409 struct stub_entry *stub; 441 struct stub_entry *stub;
442 int __maybe_unused d;
410 443
411 /* initialize stub_offset to point in front of the section */ 444 /* initialize stub_offset to point in front of the section */
412 if (!me->arch.section[targetsec].stub_offset) { 445 if (!me->arch.section[targetsec].stub_offset) {
@@ -460,12 +493,19 @@ static Elf_Addr get_stub(struct module *me, unsigned long value, long addend,
460 */ 493 */
461 switch (stub_type) { 494 switch (stub_type) {
462 case ELF_STUB_GOT: 495 case ELF_STUB_GOT:
463 stub->insns[0] = 0x537b0000; /* ldd 0(%dp),%dp */ 496 d = get_got(me, value, addend);
497 if (d <= 15) {
498 /* Format 5 */
499 stub->insns[0] = 0x0f6010db; /* ldd 0(%dp),%dp */
500 stub->insns[0] |= low_sign_unext(d, 5) << 16;
501 } else {
502 /* Format 3 */
503 stub->insns[0] = 0x537b0000; /* ldd 0(%dp),%dp */
504 stub->insns[0] |= reassemble_16a(d);
505 }
464 stub->insns[1] = 0x53610020; /* ldd 10(%dp),%r1 */ 506 stub->insns[1] = 0x53610020; /* ldd 10(%dp),%r1 */
465 stub->insns[2] = 0xe820d000; /* bve (%r1) */ 507 stub->insns[2] = 0xe820d000; /* bve (%r1) */
466 stub->insns[3] = 0x537b0030; /* ldd 18(%dp),%dp */ 508 stub->insns[3] = 0x537b0030; /* ldd 18(%dp),%dp */
467
468 stub->insns[0] |= reassemble_14(get_got(me, value, addend) & 0x3fff);
469 break; 509 break;
470 case ELF_STUB_MILLI: 510 case ELF_STUB_MILLI:
471 stub->insns[0] = 0x20200000; /* ldil 0,%r1 */ 511 stub->insns[0] = 0x20200000; /* ldil 0,%r1 */
diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
index 528f0ff9b273..8b58bf0b7d5a 100644
--- a/arch/parisc/kernel/traps.c
+++ b/arch/parisc/kernel/traps.c
@@ -532,7 +532,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
532 /* Kill the user process later */ 532 /* Kill the user process later */
533 regs->iaoq[0] = 0 | 3; 533 regs->iaoq[0] = 0 | 3;
534 regs->iaoq[1] = regs->iaoq[0] + 4; 534 regs->iaoq[1] = regs->iaoq[0] + 4;
535 regs->iasq[0] = regs->iasq[0] = regs->sr[7]; 535 regs->iasq[0] = regs->iasq[1] = regs->sr[7];
536 regs->gr[0] &= ~PSW_B; 536 regs->gr[0] &= ~PSW_B;
537 return; 537 return;
538 } 538 }
diff --git a/arch/powerpc/configs/ps3_defconfig b/arch/powerpc/configs/ps3_defconfig
index e28e65e7a0e1..7de127e4ceef 100644
--- a/arch/powerpc/configs/ps3_defconfig
+++ b/arch/powerpc/configs/ps3_defconfig
@@ -1,13 +1,14 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc5 3# Linux kernel version: 2.6.31-rc7
4# Fri May 15 10:37:00 2009 4# Mon Aug 24 17:38:50 2009
5# 5#
6CONFIG_PPC64=y 6CONFIG_PPC64=y
7 7
8# 8#
9# Processor support 9# Processor support
10# 10#
11CONFIG_PPC_BOOK3S_64=y
11CONFIG_PPC_BOOK3S=y 12CONFIG_PPC_BOOK3S=y
12# CONFIG_POWER4_ONLY is not set 13# CONFIG_POWER4_ONLY is not set
13CONFIG_POWER3=y 14CONFIG_POWER3=y
@@ -20,6 +21,7 @@ CONFIG_PPC_STD_MMU=y
20CONFIG_PPC_STD_MMU_64=y 21CONFIG_PPC_STD_MMU_64=y
21CONFIG_PPC_MM_SLICES=y 22CONFIG_PPC_MM_SLICES=y
22CONFIG_VIRT_CPU_ACCOUNTING=y 23CONFIG_VIRT_CPU_ACCOUNTING=y
24CONFIG_PPC_HAVE_PMU_SUPPORT=y
23CONFIG_SMP=y 25CONFIG_SMP=y
24CONFIG_NR_CPUS=2 26CONFIG_NR_CPUS=2
25CONFIG_64BIT=y 27CONFIG_64BIT=y
@@ -31,6 +33,7 @@ CONFIG_GENERIC_TIME=y
31CONFIG_GENERIC_TIME_VSYSCALL=y 33CONFIG_GENERIC_TIME_VSYSCALL=y
32CONFIG_GENERIC_CLOCKEVENTS=y 34CONFIG_GENERIC_CLOCKEVENTS=y
33CONFIG_GENERIC_HARDIRQS=y 35CONFIG_GENERIC_HARDIRQS=y
36CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
34CONFIG_HAVE_SETUP_PER_CPU_AREA=y 37CONFIG_HAVE_SETUP_PER_CPU_AREA=y
35CONFIG_IRQ_PER_CPU=y 38CONFIG_IRQ_PER_CPU=y
36CONFIG_STACKTRACE_SUPPORT=y 39CONFIG_STACKTRACE_SUPPORT=y
@@ -41,7 +44,6 @@ CONFIG_RWSEM_XCHGADD_ALGORITHM=y
41CONFIG_ARCH_HAS_ILOG2_U32=y 44CONFIG_ARCH_HAS_ILOG2_U32=y
42CONFIG_ARCH_HAS_ILOG2_U64=y 45CONFIG_ARCH_HAS_ILOG2_U64=y
43CONFIG_GENERIC_HWEIGHT=y 46CONFIG_GENERIC_HWEIGHT=y
44CONFIG_GENERIC_CALIBRATE_DELAY=y
45CONFIG_GENERIC_FIND_NEXT_BIT=y 47CONFIG_GENERIC_FIND_NEXT_BIT=y
46CONFIG_ARCH_NO_VIRT_TO_BUS=y 48CONFIG_ARCH_NO_VIRT_TO_BUS=y
47CONFIG_PPC=y 49CONFIG_PPC=y
@@ -62,6 +64,7 @@ CONFIG_DTC=y
62# CONFIG_PPC_DCR_MMIO is not set 64# CONFIG_PPC_DCR_MMIO is not set
63CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y 65CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
64CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 66CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
67CONFIG_CONSTRUCTORS=y
65 68
66# 69#
67# General setup 70# General setup
@@ -113,7 +116,6 @@ CONFIG_SYSCTL_SYSCALL=y
113CONFIG_KALLSYMS=y 116CONFIG_KALLSYMS=y
114CONFIG_KALLSYMS_ALL=y 117CONFIG_KALLSYMS_ALL=y
115CONFIG_KALLSYMS_EXTRA_PASS=y 118CONFIG_KALLSYMS_EXTRA_PASS=y
116# CONFIG_STRIP_ASM_SYMS is not set
117CONFIG_HOTPLUG=y 119CONFIG_HOTPLUG=y
118CONFIG_PRINTK=y 120CONFIG_PRINTK=y
119CONFIG_BUG=y 121CONFIG_BUG=y
@@ -126,7 +128,14 @@ CONFIG_TIMERFD=y
126CONFIG_EVENTFD=y 128CONFIG_EVENTFD=y
127CONFIG_SHMEM=y 129CONFIG_SHMEM=y
128CONFIG_AIO=y 130CONFIG_AIO=y
131CONFIG_HAVE_PERF_COUNTERS=y
132
133#
134# Performance Counters
135#
136# CONFIG_PERF_COUNTERS is not set
129CONFIG_VM_EVENT_COUNTERS=y 137CONFIG_VM_EVENT_COUNTERS=y
138# CONFIG_STRIP_ASM_SYMS is not set
130# CONFIG_COMPAT_BRK is not set 139# CONFIG_COMPAT_BRK is not set
131CONFIG_SLAB=y 140CONFIG_SLAB=y
132# CONFIG_SLUB is not set 141# CONFIG_SLUB is not set
@@ -145,6 +154,11 @@ CONFIG_HAVE_KRETPROBES=y
145CONFIG_HAVE_ARCH_TRACEHOOK=y 154CONFIG_HAVE_ARCH_TRACEHOOK=y
146CONFIG_HAVE_DMA_ATTRS=y 155CONFIG_HAVE_DMA_ATTRS=y
147CONFIG_USE_GENERIC_SMP_HELPERS=y 156CONFIG_USE_GENERIC_SMP_HELPERS=y
157
158#
159# GCOV-based kernel profiling
160#
161# CONFIG_GCOV_KERNEL is not set
148# CONFIG_SLOW_WORK is not set 162# CONFIG_SLOW_WORK is not set
149# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 163# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
150CONFIG_SLABINFO=y 164CONFIG_SLABINFO=y
@@ -210,7 +224,7 @@ CONFIG_PPC_CELL=y
210# 224#
211# Cell Broadband Engine options 225# Cell Broadband Engine options
212# 226#
213CONFIG_SPU_FS=y 227CONFIG_SPU_FS=m
214CONFIG_SPU_FS_64K_LS=y 228CONFIG_SPU_FS_64K_LS=y
215# CONFIG_SPU_TRACE is not set 229# CONFIG_SPU_TRACE is not set
216CONFIG_SPU_BASE=y 230CONFIG_SPU_BASE=y
@@ -255,6 +269,7 @@ CONFIG_BINFMT_MISC=y
255CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=y 269CONFIG_HUGETLB_PAGE_SIZE_VARIABLE=y
256# CONFIG_IOMMU_VMERGE is not set 270# CONFIG_IOMMU_VMERGE is not set
257CONFIG_IOMMU_HELPER=y 271CONFIG_IOMMU_HELPER=y
272# CONFIG_SWIOTLB is not set
258CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 273CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
259CONFIG_ARCH_HAS_WALK_MEMORY=y 274CONFIG_ARCH_HAS_WALK_MEMORY=y
260CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y 275CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE=y
@@ -285,9 +300,9 @@ CONFIG_MIGRATION=y
285CONFIG_PHYS_ADDR_T_64BIT=y 300CONFIG_PHYS_ADDR_T_64BIT=y
286CONFIG_ZONE_DMA_FLAG=1 301CONFIG_ZONE_DMA_FLAG=1
287CONFIG_BOUNCE=y 302CONFIG_BOUNCE=y
288CONFIG_UNEVICTABLE_LRU=y
289CONFIG_HAVE_MLOCK=y 303CONFIG_HAVE_MLOCK=y
290CONFIG_HAVE_MLOCKED_PAGE_BIT=y 304CONFIG_HAVE_MLOCKED_PAGE_BIT=y
305CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
291CONFIG_ARCH_MEMORY_PROBE=y 306CONFIG_ARCH_MEMORY_PROBE=y
292CONFIG_PPC_HAS_HASH_64K=y 307CONFIG_PPC_HAS_HASH_64K=y
293CONFIG_PPC_4K_PAGES=y 308CONFIG_PPC_4K_PAGES=y
@@ -399,6 +414,7 @@ CONFIG_IPV6_NDISC_NODETYPE=y
399# CONFIG_ECONET is not set 414# CONFIG_ECONET is not set
400# CONFIG_WAN_ROUTER is not set 415# CONFIG_WAN_ROUTER is not set
401# CONFIG_PHONET is not set 416# CONFIG_PHONET is not set
417# CONFIG_IEEE802154 is not set
402# CONFIG_NET_SCHED is not set 418# CONFIG_NET_SCHED is not set
403# CONFIG_DCB is not set 419# CONFIG_DCB is not set
404 420
@@ -433,11 +449,14 @@ CONFIG_BT_HCIBTUSB=m
433CONFIG_WIRELESS=y 449CONFIG_WIRELESS=y
434CONFIG_CFG80211=m 450CONFIG_CFG80211=m
435# CONFIG_CFG80211_REG_DEBUG is not set 451# CONFIG_CFG80211_REG_DEBUG is not set
452# CONFIG_CFG80211_DEBUGFS is not set
436# CONFIG_WIRELESS_OLD_REGULATORY is not set 453# CONFIG_WIRELESS_OLD_REGULATORY is not set
437CONFIG_WIRELESS_EXT=y 454CONFIG_WIRELESS_EXT=y
438# CONFIG_WIRELESS_EXT_SYSFS is not set 455# CONFIG_WIRELESS_EXT_SYSFS is not set
439# CONFIG_LIB80211 is not set 456# CONFIG_LIB80211 is not set
440CONFIG_MAC80211=m 457CONFIG_MAC80211=m
458CONFIG_MAC80211_DEFAULT_PS=y
459CONFIG_MAC80211_DEFAULT_PS_VALUE=1
441 460
442# 461#
443# Rate control algorithm selection 462# Rate control algorithm selection
@@ -447,7 +466,6 @@ CONFIG_MAC80211_RC_PID=y
447CONFIG_MAC80211_RC_DEFAULT_PID=y 466CONFIG_MAC80211_RC_DEFAULT_PID=y
448# CONFIG_MAC80211_RC_DEFAULT_MINSTREL is not set 467# CONFIG_MAC80211_RC_DEFAULT_MINSTREL is not set
449CONFIG_MAC80211_RC_DEFAULT="pid" 468CONFIG_MAC80211_RC_DEFAULT="pid"
450# CONFIG_MAC80211_MESH is not set
451# CONFIG_MAC80211_LEDS is not set 469# CONFIG_MAC80211_LEDS is not set
452# CONFIG_MAC80211_DEBUGFS is not set 470# CONFIG_MAC80211_DEBUGFS is not set
453# CONFIG_MAC80211_DEBUG_MENU is not set 471# CONFIG_MAC80211_DEBUG_MENU is not set
@@ -472,77 +490,7 @@ CONFIG_EXTRA_FIRMWARE=""
472# CONFIG_DEBUG_DEVRES is not set 490# CONFIG_DEBUG_DEVRES is not set
473# CONFIG_SYS_HYPERVISOR is not set 491# CONFIG_SYS_HYPERVISOR is not set
474# CONFIG_CONNECTOR is not set 492# CONFIG_CONNECTOR is not set
475CONFIG_MTD=y 493# CONFIG_MTD is not set
476CONFIG_MTD_DEBUG=y
477CONFIG_MTD_DEBUG_VERBOSE=0
478# CONFIG_MTD_CONCAT is not set
479# CONFIG_MTD_PARTITIONS is not set
480# CONFIG_MTD_TESTS is not set
481
482#
483# User Modules And Translation Layers
484#
485# CONFIG_MTD_CHAR is not set
486CONFIG_MTD_BLKDEVS=y
487CONFIG_MTD_BLOCK=y
488# CONFIG_FTL is not set
489# CONFIG_NFTL is not set
490# CONFIG_INFTL is not set
491# CONFIG_RFD_FTL is not set
492# CONFIG_SSFDC is not set
493# CONFIG_MTD_OOPS is not set
494
495#
496# RAM/ROM/Flash chip drivers
497#
498# CONFIG_MTD_CFI is not set
499# CONFIG_MTD_JEDECPROBE is not set
500CONFIG_MTD_MAP_BANK_WIDTH_1=y
501CONFIG_MTD_MAP_BANK_WIDTH_2=y
502CONFIG_MTD_MAP_BANK_WIDTH_4=y
503# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
504# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
505# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
506CONFIG_MTD_CFI_I1=y
507CONFIG_MTD_CFI_I2=y
508# CONFIG_MTD_CFI_I4 is not set
509# CONFIG_MTD_CFI_I8 is not set
510# CONFIG_MTD_RAM is not set
511# CONFIG_MTD_ROM is not set
512# CONFIG_MTD_ABSENT is not set
513
514#
515# Mapping drivers for chip access
516#
517# CONFIG_MTD_COMPLEX_MAPPINGS is not set
518# CONFIG_MTD_PLATRAM is not set
519
520#
521# Self-contained MTD device drivers
522#
523# CONFIG_MTD_SLRAM is not set
524# CONFIG_MTD_PHRAM is not set
525# CONFIG_MTD_MTDRAM is not set
526# CONFIG_MTD_BLOCK2MTD is not set
527
528#
529# Disk-On-Chip Device Drivers
530#
531# CONFIG_MTD_DOC2000 is not set
532# CONFIG_MTD_DOC2001 is not set
533# CONFIG_MTD_DOC2001PLUS is not set
534# CONFIG_MTD_NAND is not set
535# CONFIG_MTD_ONENAND is not set
536
537#
538# LPDDR flash memory drivers
539#
540# CONFIG_MTD_LPDDR is not set
541
542#
543# UBI - Unsorted block images
544#
545# CONFIG_MTD_UBI is not set
546CONFIG_OF_DEVICE=y 494CONFIG_OF_DEVICE=y
547# CONFIG_PARPORT is not set 495# CONFIG_PARPORT is not set
548CONFIG_BLK_DEV=y 496CONFIG_BLK_DEV=y
@@ -590,10 +538,6 @@ CONFIG_BLK_DEV_SR=y
590# CONFIG_BLK_DEV_SR_VENDOR is not set 538# CONFIG_BLK_DEV_SR_VENDOR is not set
591CONFIG_CHR_DEV_SG=m 539CONFIG_CHR_DEV_SG=m
592# CONFIG_CHR_DEV_SCH is not set 540# CONFIG_CHR_DEV_SCH is not set
593
594#
595# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
596#
597CONFIG_SCSI_MULTI_LUN=y 541CONFIG_SCSI_MULTI_LUN=y
598# CONFIG_SCSI_CONSTANTS is not set 542# CONFIG_SCSI_CONSTANTS is not set
599# CONFIG_SCSI_LOGGING is not set 543# CONFIG_SCSI_LOGGING is not set
@@ -626,7 +570,6 @@ CONFIG_BLK_DEV_DM=m
626# CONFIG_DM_UEVENT is not set 570# CONFIG_DM_UEVENT is not set
627# CONFIG_MACINTOSH_DRIVERS is not set 571# CONFIG_MACINTOSH_DRIVERS is not set
628CONFIG_NETDEVICES=y 572CONFIG_NETDEVICES=y
629CONFIG_COMPAT_NET_DEV_OPS=y
630# CONFIG_DUMMY is not set 573# CONFIG_DUMMY is not set
631# CONFIG_BONDING is not set 574# CONFIG_BONDING is not set
632# CONFIG_MACVLAN is not set 575# CONFIG_MACVLAN is not set
@@ -646,10 +589,11 @@ CONFIG_MII=m
646# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set 589# CONFIG_IBM_NEW_EMAC_MAL_CLR_ICINTSTAT is not set
647# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 590# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
648# CONFIG_B44 is not set 591# CONFIG_B44 is not set
592# CONFIG_KS8842 is not set
649CONFIG_NETDEV_1000=y 593CONFIG_NETDEV_1000=y
650CONFIG_GELIC_NET=y 594CONFIG_GELIC_NET=y
651CONFIG_GELIC_WIRELESS=y 595CONFIG_GELIC_WIRELESS=y
652CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE=y 596# CONFIG_GELIC_WIRELESS_OLD_PSK_INTERFACE is not set
653# CONFIG_NETDEV_10000 is not set 597# CONFIG_NETDEV_10000 is not set
654 598
655# 599#
@@ -669,8 +613,7 @@ CONFIG_WLAN_80211=y
669# CONFIG_HOSTAP is not set 613# CONFIG_HOSTAP is not set
670# CONFIG_B43 is not set 614# CONFIG_B43 is not set
671# CONFIG_B43LEGACY is not set 615# CONFIG_B43LEGACY is not set
672CONFIG_ZD1211RW=m 616# CONFIG_ZD1211RW is not set
673# CONFIG_ZD1211RW_DEBUG is not set
674# CONFIG_RT2X00 is not set 617# CONFIG_RT2X00 is not set
675 618
676# 619#
@@ -682,7 +625,7 @@ CONFIG_ZD1211RW=m
682# 625#
683# CONFIG_USB_CATC is not set 626# CONFIG_USB_CATC is not set
684# CONFIG_USB_KAWETH is not set 627# CONFIG_USB_KAWETH is not set
685CONFIG_USB_PEGASUS=m 628# CONFIG_USB_PEGASUS is not set
686# CONFIG_USB_RTL8150 is not set 629# CONFIG_USB_RTL8150 is not set
687CONFIG_USB_USBNET=m 630CONFIG_USB_USBNET=m
688CONFIG_USB_NET_AX8817X=m 631CONFIG_USB_NET_AX8817X=m
@@ -693,10 +636,11 @@ CONFIG_USB_NET_AX8817X=m
693# CONFIG_USB_NET_GL620A is not set 636# CONFIG_USB_NET_GL620A is not set
694# CONFIG_USB_NET_NET1080 is not set 637# CONFIG_USB_NET_NET1080 is not set
695# CONFIG_USB_NET_PLUSB is not set 638# CONFIG_USB_NET_PLUSB is not set
696CONFIG_USB_NET_MCS7830=m 639# CONFIG_USB_NET_MCS7830 is not set
697# CONFIG_USB_NET_RNDIS_HOST is not set 640# CONFIG_USB_NET_RNDIS_HOST is not set
698# CONFIG_USB_NET_CDC_SUBSET is not set 641# CONFIG_USB_NET_CDC_SUBSET is not set
699# CONFIG_USB_NET_ZAURUS is not set 642# CONFIG_USB_NET_ZAURUS is not set
643# CONFIG_USB_NET_INT51X1 is not set
700# CONFIG_WAN is not set 644# CONFIG_WAN is not set
701CONFIG_PPP=m 645CONFIG_PPP=m
702CONFIG_PPP_MULTILINK=y 646CONFIG_PPP_MULTILINK=y
@@ -771,8 +715,7 @@ CONFIG_DEVKMEM=y
771# 715#
772CONFIG_UNIX98_PTYS=y 716CONFIG_UNIX98_PTYS=y
773# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set 717# CONFIG_DEVPTS_MULTIPLE_INSTANCES is not set
774CONFIG_LEGACY_PTYS=y 718# CONFIG_LEGACY_PTYS is not set
775CONFIG_LEGACY_PTY_COUNT=16
776# CONFIG_HVC_UDBG is not set 719# CONFIG_HVC_UDBG is not set
777# CONFIG_IPMI_HANDLER is not set 720# CONFIG_IPMI_HANDLER is not set
778# CONFIG_HW_RANDOM is not set 721# CONFIG_HW_RANDOM is not set
@@ -782,6 +725,11 @@ CONFIG_LEGACY_PTY_COUNT=16
782# CONFIG_TCG_TPM is not set 725# CONFIG_TCG_TPM is not set
783# CONFIG_I2C is not set 726# CONFIG_I2C is not set
784# CONFIG_SPI is not set 727# CONFIG_SPI is not set
728
729#
730# PPS support
731#
732# CONFIG_PPS is not set
785CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 733CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
786# CONFIG_GPIOLIB is not set 734# CONFIG_GPIOLIB is not set
787# CONFIG_W1 is not set 735# CONFIG_W1 is not set
@@ -805,22 +753,7 @@ CONFIG_SSB_POSSIBLE=y
805# CONFIG_HTC_PASIC3 is not set 753# CONFIG_HTC_PASIC3 is not set
806# CONFIG_MFD_TMIO is not set 754# CONFIG_MFD_TMIO is not set
807# CONFIG_REGULATOR is not set 755# CONFIG_REGULATOR is not set
808 756# CONFIG_MEDIA_SUPPORT is not set
809#
810# Multimedia devices
811#
812
813#
814# Multimedia core support
815#
816# CONFIG_VIDEO_DEV is not set
817# CONFIG_DVB_CORE is not set
818# CONFIG_VIDEO_MEDIA is not set
819
820#
821# Multimedia drivers
822#
823# CONFIG_DAB is not set
824 757
825# 758#
826# Graphics support 759# Graphics support
@@ -898,6 +831,11 @@ CONFIG_SND_SUPPORT_OLD_API=y
898CONFIG_SND_VERBOSE_PROCFS=y 831CONFIG_SND_VERBOSE_PROCFS=y
899# CONFIG_SND_VERBOSE_PRINTK is not set 832# CONFIG_SND_VERBOSE_PRINTK is not set
900# CONFIG_SND_DEBUG is not set 833# CONFIG_SND_DEBUG is not set
834# CONFIG_SND_RAWMIDI_SEQ is not set
835# CONFIG_SND_OPL3_LIB_SEQ is not set
836# CONFIG_SND_OPL4_LIB_SEQ is not set
837# CONFIG_SND_SBAWE_SEQ is not set
838# CONFIG_SND_EMU10K1_SEQ is not set
901# CONFIG_SND_DRIVERS is not set 839# CONFIG_SND_DRIVERS is not set
902CONFIG_SND_PPC=y 840CONFIG_SND_PPC=y
903CONFIG_SND_PS3=m 841CONFIG_SND_PS3=m
@@ -930,29 +868,34 @@ CONFIG_USB_HIDDEV=y
930# Special HID drivers 868# Special HID drivers
931# 869#
932# CONFIG_HID_A4TECH is not set 870# CONFIG_HID_A4TECH is not set
933# CONFIG_HID_APPLE is not set 871CONFIG_HID_APPLE=m
934# CONFIG_HID_BELKIN is not set 872CONFIG_HID_BELKIN=m
935# CONFIG_HID_CHERRY is not set 873CONFIG_HID_CHERRY=m
936# CONFIG_HID_CHICONY is not set 874# CONFIG_HID_CHICONY is not set
937# CONFIG_HID_CYPRESS is not set 875# CONFIG_HID_CYPRESS is not set
938# CONFIG_DRAGONRISE_FF is not set 876# CONFIG_HID_DRAGONRISE is not set
939# CONFIG_HID_EZKEY is not set 877CONFIG_HID_EZKEY=m
940# CONFIG_HID_KYE is not set 878# CONFIG_HID_KYE is not set
941# CONFIG_HID_GYRATION is not set 879# CONFIG_HID_GYRATION is not set
942# CONFIG_HID_KENSINGTON is not set 880# CONFIG_HID_KENSINGTON is not set
943# CONFIG_HID_LOGITECH is not set 881CONFIG_HID_LOGITECH=m
944# CONFIG_HID_MICROSOFT is not set 882# CONFIG_LOGITECH_FF is not set
883# CONFIG_LOGIRUMBLEPAD2_FF is not set
884CONFIG_HID_MICROSOFT=m
945# CONFIG_HID_MONTEREY is not set 885# CONFIG_HID_MONTEREY is not set
946# CONFIG_HID_NTRIG is not set 886# CONFIG_HID_NTRIG is not set
947# CONFIG_HID_PANTHERLORD is not set 887# CONFIG_HID_PANTHERLORD is not set
948# CONFIG_HID_PETALYNX is not set 888# CONFIG_HID_PETALYNX is not set
949# CONFIG_HID_SAMSUNG is not set 889# CONFIG_HID_SAMSUNG is not set
950CONFIG_HID_SONY=m 890CONFIG_HID_SONY=m
951# CONFIG_HID_SUNPLUS is not set 891CONFIG_HID_SUNPLUS=m
952# CONFIG_GREENASIA_FF is not set 892# CONFIG_HID_GREENASIA is not set
893CONFIG_HID_SMARTJOYPLUS=m
894# CONFIG_SMARTJOYPLUS_FF is not set
953# CONFIG_HID_TOPSEED is not set 895# CONFIG_HID_TOPSEED is not set
954# CONFIG_THRUSTMASTER_FF is not set 896# CONFIG_HID_THRUSTMASTER is not set
955# CONFIG_ZEROPLUS_FF is not set 897# CONFIG_HID_WACOM is not set
898# CONFIG_HID_ZEROPLUS is not set
956CONFIG_USB_SUPPORT=y 899CONFIG_USB_SUPPORT=y
957CONFIG_USB_ARCH_HAS_HCD=y 900CONFIG_USB_ARCH_HAS_HCD=y
958CONFIG_USB_ARCH_HAS_OHCI=y 901CONFIG_USB_ARCH_HAS_OHCI=y
@@ -988,6 +931,8 @@ CONFIG_USB_EHCI_BIG_ENDIAN_MMIO=y
988# CONFIG_USB_ISP116X_HCD is not set 931# CONFIG_USB_ISP116X_HCD is not set
989# CONFIG_USB_ISP1760_HCD is not set 932# CONFIG_USB_ISP1760_HCD is not set
990CONFIG_USB_OHCI_HCD=m 933CONFIG_USB_OHCI_HCD=m
934# CONFIG_USB_OHCI_HCD_PPC_OF_BE is not set
935# CONFIG_USB_OHCI_HCD_PPC_OF_LE is not set
991# CONFIG_USB_OHCI_HCD_PPC_OF is not set 936# CONFIG_USB_OHCI_HCD_PPC_OF is not set
992# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set 937# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
993CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y 938CONFIG_USB_OHCI_BIG_ENDIAN_MMIO=y
@@ -1115,6 +1060,10 @@ CONFIG_RTC_DRV_PS3=m
1115# CONFIG_DMADEVICES is not set 1060# CONFIG_DMADEVICES is not set
1116# CONFIG_AUXDISPLAY is not set 1061# CONFIG_AUXDISPLAY is not set
1117# CONFIG_UIO is not set 1062# CONFIG_UIO is not set
1063
1064#
1065# TI VLYNQ
1066#
1118# CONFIG_STAGING is not set 1067# CONFIG_STAGING is not set
1119 1068
1120# 1069#
@@ -1141,11 +1090,12 @@ CONFIG_FS_MBCACHE=y
1141# CONFIG_REISERFS_FS is not set 1090# CONFIG_REISERFS_FS is not set
1142# CONFIG_JFS_FS is not set 1091# CONFIG_JFS_FS is not set
1143# CONFIG_FS_POSIX_ACL is not set 1092# CONFIG_FS_POSIX_ACL is not set
1144CONFIG_FILE_LOCKING=y
1145# CONFIG_XFS_FS is not set 1093# CONFIG_XFS_FS is not set
1146# CONFIG_GFS2_FS is not set 1094# CONFIG_GFS2_FS is not set
1147# CONFIG_OCFS2_FS is not set 1095# CONFIG_OCFS2_FS is not set
1148# CONFIG_BTRFS_FS is not set 1096# CONFIG_BTRFS_FS is not set
1097CONFIG_FILE_LOCKING=y
1098CONFIG_FSNOTIFY=y
1149CONFIG_DNOTIFY=y 1099CONFIG_DNOTIFY=y
1150CONFIG_INOTIFY=y 1100CONFIG_INOTIFY=y
1151CONFIG_INOTIFY_USER=y 1101CONFIG_INOTIFY_USER=y
@@ -1205,7 +1155,6 @@ CONFIG_MISC_FILESYSTEMS=y
1205# CONFIG_BEFS_FS is not set 1155# CONFIG_BEFS_FS is not set
1206# CONFIG_BFS_FS is not set 1156# CONFIG_BFS_FS is not set
1207# CONFIG_EFS_FS is not set 1157# CONFIG_EFS_FS is not set
1208# CONFIG_JFFS2_FS is not set
1209# CONFIG_CRAMFS is not set 1158# CONFIG_CRAMFS is not set
1210# CONFIG_SQUASHFS is not set 1159# CONFIG_SQUASHFS is not set
1211# CONFIG_VXFS_FS is not set 1160# CONFIG_VXFS_FS is not set
@@ -1222,6 +1171,7 @@ CONFIG_NFS_FS=y
1222CONFIG_NFS_V3=y 1171CONFIG_NFS_V3=y
1223# CONFIG_NFS_V3_ACL is not set 1172# CONFIG_NFS_V3_ACL is not set
1224CONFIG_NFS_V4=y 1173CONFIG_NFS_V4=y
1174# CONFIG_NFS_V4_1 is not set
1225CONFIG_ROOT_NFS=y 1175CONFIG_ROOT_NFS=y
1226# CONFIG_NFSD is not set 1176# CONFIG_NFSD is not set
1227CONFIG_LOCKD=y 1177CONFIG_LOCKD=y
@@ -1359,7 +1309,6 @@ CONFIG_DEBUG_MEMORY_INIT=y
1359CONFIG_DEBUG_LIST=y 1309CONFIG_DEBUG_LIST=y
1360# CONFIG_DEBUG_SG is not set 1310# CONFIG_DEBUG_SG is not set
1361# CONFIG_DEBUG_NOTIFIERS is not set 1311# CONFIG_DEBUG_NOTIFIERS is not set
1362# CONFIG_BOOT_PRINTK_DELAY is not set
1363# CONFIG_RCU_TORTURE_TEST is not set 1312# CONFIG_RCU_TORTURE_TEST is not set
1364# CONFIG_RCU_CPU_STALL_DETECTOR is not set 1313# CONFIG_RCU_CPU_STALL_DETECTOR is not set
1365# CONFIG_BACKTRACE_SELF_TEST is not set 1314# CONFIG_BACKTRACE_SELF_TEST is not set
@@ -1374,31 +1323,21 @@ CONFIG_HAVE_FUNCTION_GRAPH_TRACER=y
1374CONFIG_HAVE_DYNAMIC_FTRACE=y 1323CONFIG_HAVE_DYNAMIC_FTRACE=y
1375CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y 1324CONFIG_HAVE_FTRACE_MCOUNT_RECORD=y
1376CONFIG_RING_BUFFER=y 1325CONFIG_RING_BUFFER=y
1326CONFIG_EVENT_TRACING=y
1327CONFIG_CONTEXT_SWITCH_TRACER=y
1377CONFIG_TRACING=y 1328CONFIG_TRACING=y
1378CONFIG_TRACING_SUPPORT=y 1329CONFIG_TRACING_SUPPORT=y
1379 1330# CONFIG_FTRACE is not set
1380#
1381# Tracers
1382#
1383# CONFIG_FUNCTION_TRACER is not set
1384# CONFIG_IRQSOFF_TRACER is not set
1385# CONFIG_SCHED_TRACER is not set
1386# CONFIG_CONTEXT_SWITCH_TRACER is not set
1387# CONFIG_EVENT_TRACER is not set
1388# CONFIG_BOOT_TRACER is not set
1389# CONFIG_TRACE_BRANCH_PROFILING is not set
1390# CONFIG_STACK_TRACER is not set
1391# CONFIG_KMEMTRACE is not set
1392# CONFIG_WORKQUEUE_TRACER is not set
1393# CONFIG_BLK_DEV_IO_TRACE is not set
1394# CONFIG_FTRACE_STARTUP_TEST is not set
1395# CONFIG_DYNAMIC_DEBUG is not set 1331# CONFIG_DYNAMIC_DEBUG is not set
1396# CONFIG_SAMPLES is not set 1332# CONFIG_SAMPLES is not set
1397CONFIG_HAVE_ARCH_KGDB=y 1333CONFIG_HAVE_ARCH_KGDB=y
1398# CONFIG_KGDB is not set 1334# CONFIG_KGDB is not set
1335# CONFIG_PPC_DISABLE_WERROR is not set
1336CONFIG_PPC_WERROR=y
1399CONFIG_PRINT_STACK_DEPTH=64 1337CONFIG_PRINT_STACK_DEPTH=64
1400CONFIG_DEBUG_STACKOVERFLOW=y 1338CONFIG_DEBUG_STACKOVERFLOW=y
1401# CONFIG_DEBUG_STACK_USAGE is not set 1339# CONFIG_DEBUG_STACK_USAGE is not set
1340# CONFIG_PPC_EMULATED_STATS is not set
1402# CONFIG_CODE_PATCHING_SELFTEST is not set 1341# CONFIG_CODE_PATCHING_SELFTEST is not set
1403# CONFIG_FTR_FIXUP_SELFTEST is not set 1342# CONFIG_FTR_FIXUP_SELFTEST is not set
1404# CONFIG_MSI_BITMAP_SELFTEST is not set 1343# CONFIG_MSI_BITMAP_SELFTEST is not set
diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
index dfdf13c9fefd..fddc3ed715fa 100644
--- a/arch/powerpc/include/asm/kvm_host.h
+++ b/arch/powerpc/include/asm/kvm_host.h
@@ -34,7 +34,7 @@
34#define KVM_COALESCED_MMIO_PAGE_OFFSET 1 34#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
35 35
36/* We don't currently support large pages. */ 36/* We don't currently support large pages. */
37#define KVM_PAGES_PER_HPAGE (1<<31) 37#define KVM_PAGES_PER_HPAGE (1UL << 31)
38 38
39struct kvm; 39struct kvm;
40struct kvm_run; 40struct kvm_run;
diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
index 20a60d661ba8..ccf129d47d84 100644
--- a/arch/powerpc/kernel/dma.c
+++ b/arch/powerpc/kernel/dma.c
@@ -7,6 +7,7 @@
7 7
8#include <linux/device.h> 8#include <linux/device.h>
9#include <linux/dma-mapping.h> 9#include <linux/dma-mapping.h>
10#include <linux/lmb.h>
10#include <asm/bug.h> 11#include <asm/bug.h>
11#include <asm/abs_addr.h> 12#include <asm/abs_addr.h>
12 13
@@ -90,11 +91,10 @@ static void dma_direct_unmap_sg(struct device *dev, struct scatterlist *sg,
90static int dma_direct_dma_supported(struct device *dev, u64 mask) 91static int dma_direct_dma_supported(struct device *dev, u64 mask)
91{ 92{
92#ifdef CONFIG_PPC64 93#ifdef CONFIG_PPC64
93 /* Could be improved to check for memory though it better be 94 /* Could be improved so platforms can set the limit in case
94 * done via some global so platforms can set the limit in case
95 * they have limited DMA windows 95 * they have limited DMA windows
96 */ 96 */
97 return mask >= DMA_BIT_MASK(32); 97 return mask >= (lmb_end_of_DRAM() - 1);
98#else 98#else
99 return 1; 99 return 1;
100#endif 100#endif
diff --git a/arch/powerpc/kernel/mpc7450-pmu.c b/arch/powerpc/kernel/mpc7450-pmu.c
index c244133c67a6..cc466d039af6 100644
--- a/arch/powerpc/kernel/mpc7450-pmu.c
+++ b/arch/powerpc/kernel/mpc7450-pmu.c
@@ -407,7 +407,8 @@ struct power_pmu mpc7450_pmu = {
407 407
408static int init_mpc7450_pmu(void) 408static int init_mpc7450_pmu(void)
409{ 409{
410 if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/7450")) 410 if (!cur_cpu_spec->oprofile_cpu_type ||
411 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc/7450"))
411 return -ENODEV; 412 return -ENODEV;
412 413
413 return register_power_pmu(&mpc7450_pmu); 414 return register_power_pmu(&mpc7450_pmu);
diff --git a/arch/powerpc/kernel/perf_counter.c b/arch/powerpc/kernel/perf_counter.c
index 809fdf94b95f..70e1f57f7dd8 100644
--- a/arch/powerpc/kernel/perf_counter.c
+++ b/arch/powerpc/kernel/perf_counter.c
@@ -518,6 +518,8 @@ void hw_perf_disable(void)
518 struct cpu_hw_counters *cpuhw; 518 struct cpu_hw_counters *cpuhw;
519 unsigned long flags; 519 unsigned long flags;
520 520
521 if (!ppmu)
522 return;
521 local_irq_save(flags); 523 local_irq_save(flags);
522 cpuhw = &__get_cpu_var(cpu_hw_counters); 524 cpuhw = &__get_cpu_var(cpu_hw_counters);
523 525
@@ -572,6 +574,8 @@ void hw_perf_enable(void)
572 int n_lim; 574 int n_lim;
573 int idx; 575 int idx;
574 576
577 if (!ppmu)
578 return;
575 local_irq_save(flags); 579 local_irq_save(flags);
576 cpuhw = &__get_cpu_var(cpu_hw_counters); 580 cpuhw = &__get_cpu_var(cpu_hw_counters);
577 if (!cpuhw->disabled) { 581 if (!cpuhw->disabled) {
@@ -737,6 +741,8 @@ int hw_perf_group_sched_in(struct perf_counter *group_leader,
737 long i, n, n0; 741 long i, n, n0;
738 struct perf_counter *sub; 742 struct perf_counter *sub;
739 743
744 if (!ppmu)
745 return 0;
740 cpuhw = &__get_cpu_var(cpu_hw_counters); 746 cpuhw = &__get_cpu_var(cpu_hw_counters);
741 n0 = cpuhw->n_counters; 747 n0 = cpuhw->n_counters;
742 n = collect_events(group_leader, ppmu->n_counter - n0, 748 n = collect_events(group_leader, ppmu->n_counter - n0,
@@ -1281,6 +1287,8 @@ void hw_perf_counter_setup(int cpu)
1281{ 1287{
1282 struct cpu_hw_counters *cpuhw = &per_cpu(cpu_hw_counters, cpu); 1288 struct cpu_hw_counters *cpuhw = &per_cpu(cpu_hw_counters, cpu);
1283 1289
1290 if (!ppmu)
1291 return;
1284 memset(cpuhw, 0, sizeof(*cpuhw)); 1292 memset(cpuhw, 0, sizeof(*cpuhw));
1285 cpuhw->mmcr[0] = MMCR0_FC; 1293 cpuhw->mmcr[0] = MMCR0_FC;
1286} 1294}
diff --git a/arch/powerpc/kernel/power4-pmu.c b/arch/powerpc/kernel/power4-pmu.c
index db90b0c5c27b..3c90a3d9173e 100644
--- a/arch/powerpc/kernel/power4-pmu.c
+++ b/arch/powerpc/kernel/power4-pmu.c
@@ -606,7 +606,8 @@ static struct power_pmu power4_pmu = {
606 606
607static int init_power4_pmu(void) 607static int init_power4_pmu(void)
608{ 608{
609 if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power4")) 609 if (!cur_cpu_spec->oprofile_cpu_type ||
610 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power4"))
610 return -ENODEV; 611 return -ENODEV;
611 612
612 return register_power_pmu(&power4_pmu); 613 return register_power_pmu(&power4_pmu);
diff --git a/arch/powerpc/kernel/power5+-pmu.c b/arch/powerpc/kernel/power5+-pmu.c
index f4adca8e98a4..31918af3e355 100644
--- a/arch/powerpc/kernel/power5+-pmu.c
+++ b/arch/powerpc/kernel/power5+-pmu.c
@@ -678,8 +678,9 @@ static struct power_pmu power5p_pmu = {
678 678
679static int init_power5p_pmu(void) 679static int init_power5p_pmu(void)
680{ 680{
681 if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+") 681 if (!cur_cpu_spec->oprofile_cpu_type ||
682 && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5++")) 682 (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5+")
683 && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5++")))
683 return -ENODEV; 684 return -ENODEV;
684 685
685 return register_power_pmu(&power5p_pmu); 686 return register_power_pmu(&power5p_pmu);
diff --git a/arch/powerpc/kernel/power5-pmu.c b/arch/powerpc/kernel/power5-pmu.c
index 29b2c6c0e83a..867f6f663963 100644
--- a/arch/powerpc/kernel/power5-pmu.c
+++ b/arch/powerpc/kernel/power5-pmu.c
@@ -618,7 +618,8 @@ static struct power_pmu power5_pmu = {
618 618
619static int init_power5_pmu(void) 619static int init_power5_pmu(void)
620{ 620{
621 if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5")) 621 if (!cur_cpu_spec->oprofile_cpu_type ||
622 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power5"))
622 return -ENODEV; 623 return -ENODEV;
623 624
624 return register_power_pmu(&power5_pmu); 625 return register_power_pmu(&power5_pmu);
diff --git a/arch/powerpc/kernel/power6-pmu.c b/arch/powerpc/kernel/power6-pmu.c
index 09ae5bf5bda7..fa21890531da 100644
--- a/arch/powerpc/kernel/power6-pmu.c
+++ b/arch/powerpc/kernel/power6-pmu.c
@@ -537,7 +537,8 @@ static struct power_pmu power6_pmu = {
537 537
538static int init_power6_pmu(void) 538static int init_power6_pmu(void)
539{ 539{
540 if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6")) 540 if (!cur_cpu_spec->oprofile_cpu_type ||
541 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power6"))
541 return -ENODEV; 542 return -ENODEV;
542 543
543 return register_power_pmu(&power6_pmu); 544 return register_power_pmu(&power6_pmu);
diff --git a/arch/powerpc/kernel/power7-pmu.c b/arch/powerpc/kernel/power7-pmu.c
index 5a9f5cbd40a4..388cf57ad827 100644
--- a/arch/powerpc/kernel/power7-pmu.c
+++ b/arch/powerpc/kernel/power7-pmu.c
@@ -366,7 +366,8 @@ static struct power_pmu power7_pmu = {
366 366
367static int init_power7_pmu(void) 367static int init_power7_pmu(void)
368{ 368{
369 if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7")) 369 if (!cur_cpu_spec->oprofile_cpu_type ||
370 strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/power7"))
370 return -ENODEV; 371 return -ENODEV;
371 372
372 return register_power_pmu(&power7_pmu); 373 return register_power_pmu(&power7_pmu);
diff --git a/arch/powerpc/kernel/ppc970-pmu.c b/arch/powerpc/kernel/ppc970-pmu.c
index 833097ac45dc..75dccb71a043 100644
--- a/arch/powerpc/kernel/ppc970-pmu.c
+++ b/arch/powerpc/kernel/ppc970-pmu.c
@@ -488,8 +488,9 @@ static struct power_pmu ppc970_pmu = {
488 488
489static int init_ppc970_pmu(void) 489static int init_ppc970_pmu(void)
490{ 490{
491 if (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970") 491 if (!cur_cpu_spec->oprofile_cpu_type ||
492 && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970MP")) 492 (strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970")
493 && strcmp(cur_cpu_spec->oprofile_cpu_type, "ppc64/970MP")))
493 return -ENODEV; 494 return -ENODEV;
494 495
495 return register_power_pmu(&ppc970_pmu); 496 return register_power_pmu(&ppc970_pmu);
diff --git a/arch/powerpc/platforms/ps3/time.c b/arch/powerpc/platforms/ps3/time.c
index b178a1e66c91..40b5cb433005 100644
--- a/arch/powerpc/platforms/ps3/time.c
+++ b/arch/powerpc/platforms/ps3/time.c
@@ -21,6 +21,7 @@
21#include <linux/kernel.h> 21#include <linux/kernel.h>
22#include <linux/platform_device.h> 22#include <linux/platform_device.h>
23 23
24#include <asm/firmware.h>
24#include <asm/rtc.h> 25#include <asm/rtc.h>
25#include <asm/lv1call.h> 26#include <asm/lv1call.h>
26#include <asm/ps3.h> 27#include <asm/ps3.h>
@@ -84,6 +85,9 @@ static int __init ps3_rtc_init(void)
84{ 85{
85 struct platform_device *pdev; 86 struct platform_device *pdev;
86 87
88 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
89 return -ENODEV;
90
87 pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0); 91 pdev = platform_device_register_simple("rtc-ps3", -1, NULL, 0);
88 if (IS_ERR(pdev)) 92 if (IS_ERR(pdev))
89 return PTR_ERR(pdev); 93 return PTR_ERR(pdev);
diff --git a/arch/s390/kernel/early.c b/arch/s390/kernel/early.c
index 8d15314381e0..cae14c499511 100644
--- a/arch/s390/kernel/early.c
+++ b/arch/s390/kernel/early.c
@@ -208,6 +208,9 @@ static noinline __init void detect_machine_type(void)
208 machine_flags |= MACHINE_FLAG_KVM; 208 machine_flags |= MACHINE_FLAG_KVM;
209 else 209 else
210 machine_flags |= MACHINE_FLAG_VM; 210 machine_flags |= MACHINE_FLAG_VM;
211
212 /* Store machine flags for setting up lowcore early */
213 S390_lowcore.machine_flags = machine_flags;
211} 214}
212 215
213static __init void early_pgm_check_handler(void) 216static __init void early_pgm_check_handler(void)
diff --git a/arch/s390/kernel/setup.c b/arch/s390/kernel/setup.c
index 9717717c6fea..cbb897bc50bd 100644
--- a/arch/s390/kernel/setup.c
+++ b/arch/s390/kernel/setup.c
@@ -154,6 +154,20 @@ static int __init condev_setup(char *str)
154 154
155__setup("condev=", condev_setup); 155__setup("condev=", condev_setup);
156 156
157static void __init set_preferred_console(void)
158{
159 if (MACHINE_IS_KVM) {
160 add_preferred_console("hvc", 0, NULL);
161 s390_virtio_console_init();
162 return;
163 }
164
165 if (CONSOLE_IS_3215 || CONSOLE_IS_SCLP)
166 add_preferred_console("ttyS", 0, NULL);
167 if (CONSOLE_IS_3270)
168 add_preferred_console("tty3270", 0, NULL);
169}
170
157static int __init conmode_setup(char *str) 171static int __init conmode_setup(char *str)
158{ 172{
159#if defined(CONFIG_SCLP_CONSOLE) || defined(CONFIG_SCLP_VT220_CONSOLE) 173#if defined(CONFIG_SCLP_CONSOLE) || defined(CONFIG_SCLP_VT220_CONSOLE)
@@ -168,6 +182,7 @@ static int __init conmode_setup(char *str)
168 if (strncmp(str, "3270", 5) == 0) 182 if (strncmp(str, "3270", 5) == 0)
169 SET_CONSOLE_3270; 183 SET_CONSOLE_3270;
170#endif 184#endif
185 set_preferred_console();
171 return 1; 186 return 1;
172} 187}
173 188
@@ -780,9 +795,6 @@ static void __init setup_hwcaps(void)
780void __init 795void __init
781setup_arch(char **cmdline_p) 796setup_arch(char **cmdline_p)
782{ 797{
783 /* set up preferred console */
784 add_preferred_console("ttyS", 0, NULL);
785
786 /* 798 /*
787 * print what head.S has found out about the machine 799 * print what head.S has found out about the machine
788 */ 800 */
@@ -802,11 +814,9 @@ setup_arch(char **cmdline_p)
802 if (MACHINE_IS_VM) 814 if (MACHINE_IS_VM)
803 pr_info("Linux is running as a z/VM " 815 pr_info("Linux is running as a z/VM "
804 "guest operating system in 64-bit mode\n"); 816 "guest operating system in 64-bit mode\n");
805 else if (MACHINE_IS_KVM) { 817 else if (MACHINE_IS_KVM)
806 pr_info("Linux is running under KVM in 64-bit mode\n"); 818 pr_info("Linux is running under KVM in 64-bit mode\n");
807 add_preferred_console("hvc", 0, NULL); 819 else
808 s390_virtio_console_init();
809 } else
810 pr_info("Linux is running natively in 64-bit mode\n"); 820 pr_info("Linux is running natively in 64-bit mode\n");
811#endif /* CONFIG_64BIT */ 821#endif /* CONFIG_64BIT */
812 822
@@ -851,6 +861,7 @@ setup_arch(char **cmdline_p)
851 861
852 /* Setup default console */ 862 /* Setup default console */
853 conmode_default(); 863 conmode_default();
864 set_preferred_console();
854 865
855 /* Setup zfcpdump support */ 866 /* Setup zfcpdump support */
856 setup_zfcpdump(console_devno); 867 setup_zfcpdump(console_devno);
diff --git a/arch/s390/kvm/interrupt.c b/arch/s390/kvm/interrupt.c
index f04f5301b1b4..4d613415c435 100644
--- a/arch/s390/kvm/interrupt.c
+++ b/arch/s390/kvm/interrupt.c
@@ -386,7 +386,7 @@ no_timer:
386 } 386 }
387 __unset_cpu_idle(vcpu); 387 __unset_cpu_idle(vcpu);
388 __set_current_state(TASK_RUNNING); 388 __set_current_state(TASK_RUNNING);
389 remove_wait_queue(&vcpu->wq, &wait); 389 remove_wait_queue(&vcpu->arch.local_int.wq, &wait);
390 spin_unlock_bh(&vcpu->arch.local_int.lock); 390 spin_unlock_bh(&vcpu->arch.local_int.lock);
391 spin_unlock(&vcpu->arch.local_int.float_int->lock); 391 spin_unlock(&vcpu->arch.local_int.float_int->lock);
392 hrtimer_try_to_cancel(&vcpu->arch.ckc_timer); 392 hrtimer_try_to_cancel(&vcpu->arch.ckc_timer);
diff --git a/arch/s390/kvm/sigp.c b/arch/s390/kvm/sigp.c
index 36678835034d..0ef81d6776e9 100644
--- a/arch/s390/kvm/sigp.c
+++ b/arch/s390/kvm/sigp.c
@@ -169,7 +169,7 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
169 unsigned long *reg) 169 unsigned long *reg)
170{ 170{
171 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int; 171 struct kvm_s390_float_interrupt *fi = &vcpu->kvm->arch.float_int;
172 struct kvm_s390_local_interrupt *li; 172 struct kvm_s390_local_interrupt *li = NULL;
173 struct kvm_s390_interrupt_info *inti; 173 struct kvm_s390_interrupt_info *inti;
174 int rc; 174 int rc;
175 u8 tmp; 175 u8 tmp;
@@ -189,9 +189,10 @@ static int __sigp_set_prefix(struct kvm_vcpu *vcpu, u16 cpu_addr, u32 address,
189 return 2; /* busy */ 189 return 2; /* busy */
190 190
191 spin_lock(&fi->lock); 191 spin_lock(&fi->lock);
192 li = fi->local_int[cpu_addr]; 192 if (cpu_addr < KVM_MAX_VCPUS)
193 li = fi->local_int[cpu_addr];
193 194
194 if ((cpu_addr >= KVM_MAX_VCPUS) || (li == NULL)) { 195 if (li == NULL) {
195 rc = 1; /* incorrect state */ 196 rc = 1; /* incorrect state */
196 *reg &= SIGP_STAT_INCORRECT_STATE; 197 *reg &= SIGP_STAT_INCORRECT_STATE;
197 kfree(inti); 198 kfree(inti);
diff --git a/arch/sh/boards/board-ap325rxa.c b/arch/sh/boards/board-ap325rxa.c
index 7ffd1b4315bd..b9c88cc519e2 100644
--- a/arch/sh/boards/board-ap325rxa.c
+++ b/arch/sh/boards/board-ap325rxa.c
@@ -547,7 +547,7 @@ static int __init ap325rxa_devices_setup(void)
547 return platform_add_devices(ap325rxa_devices, 547 return platform_add_devices(ap325rxa_devices,
548 ARRAY_SIZE(ap325rxa_devices)); 548 ARRAY_SIZE(ap325rxa_devices));
549} 549}
550device_initcall(ap325rxa_devices_setup); 550arch_initcall(ap325rxa_devices_setup);
551 551
552/* Return the board specific boot mode pin configuration */ 552/* Return the board specific boot mode pin configuration */
553static int ap325rxa_mode_pins(void) 553static int ap325rxa_mode_pins(void)
diff --git a/arch/sh/boards/mach-migor/setup.c b/arch/sh/boards/mach-migor/setup.c
index f70f4644deb4..f9b2e4df35b9 100644
--- a/arch/sh/boards/mach-migor/setup.c
+++ b/arch/sh/boards/mach-migor/setup.c
@@ -608,7 +608,7 @@ static int __init migor_devices_setup(void)
608 608
609 return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices)); 609 return platform_add_devices(migor_devices, ARRAY_SIZE(migor_devices));
610} 610}
611__initcall(migor_devices_setup); 611arch_initcall(migor_devices_setup);
612 612
613/* Return the board specific boot mode pin configuration */ 613/* Return the board specific boot mode pin configuration */
614static int migor_mode_pins(void) 614static int migor_mode_pins(void)
diff --git a/arch/sh/boards/mach-se/7724/setup.c b/arch/sh/boards/mach-se/7724/setup.c
index 8fed45a2fb85..15456a0773bf 100644
--- a/arch/sh/boards/mach-se/7724/setup.c
+++ b/arch/sh/boards/mach-se/7724/setup.c
@@ -238,7 +238,7 @@ static struct platform_device ceu1_device = {
238 }, 238 },
239}; 239};
240 240
241/* KEYSC */ 241/* KEYSC in SoC (Needs SW33-2 set to ON) */
242static struct sh_keysc_info keysc_info = { 242static struct sh_keysc_info keysc_info = {
243 .mode = SH_KEYSC_MODE_1, 243 .mode = SH_KEYSC_MODE_1,
244 .scan_timing = 10, 244 .scan_timing = 10,
@@ -255,12 +255,13 @@ static struct sh_keysc_info keysc_info = {
255 255
256static struct resource keysc_resources[] = { 256static struct resource keysc_resources[] = {
257 [0] = { 257 [0] = {
258 .start = 0x1a204000, 258 .name = "KEYSC",
259 .end = 0x1a20400f, 259 .start = 0x044b0000,
260 .end = 0x044b000f,
260 .flags = IORESOURCE_MEM, 261 .flags = IORESOURCE_MEM,
261 }, 262 },
262 [1] = { 263 [1] = {
263 .start = IRQ0_KEY, 264 .start = 79,
264 .flags = IORESOURCE_IRQ, 265 .flags = IORESOURCE_IRQ,
265 }, 266 },
266}; 267};
diff --git a/arch/sh/kernel/cpu/sh2/setup-sh7619.c b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
index 13798733f2db..8555c05e8667 100644
--- a/arch/sh/kernel/cpu/sh2/setup-sh7619.c
+++ b/arch/sh/kernel/cpu/sh2/setup-sh7619.c
@@ -187,7 +187,7 @@ static int __init sh7619_devices_setup(void)
187 return platform_add_devices(sh7619_devices, 187 return platform_add_devices(sh7619_devices,
188 ARRAY_SIZE(sh7619_devices)); 188 ARRAY_SIZE(sh7619_devices));
189} 189}
190__initcall(sh7619_devices_setup); 190arch_initcall(sh7619_devices_setup);
191 191
192void __init plat_irq_setup(void) 192void __init plat_irq_setup(void)
193{ 193{
diff --git a/arch/sh/kernel/cpu/sh2a/setup-mxg.c b/arch/sh/kernel/cpu/sh2a/setup-mxg.c
index 869c2da4820b..b67376445315 100644
--- a/arch/sh/kernel/cpu/sh2a/setup-mxg.c
+++ b/arch/sh/kernel/cpu/sh2a/setup-mxg.c
@@ -238,7 +238,7 @@ static int __init mxg_devices_setup(void)
238 return platform_add_devices(mxg_devices, 238 return platform_add_devices(mxg_devices,
239 ARRAY_SIZE(mxg_devices)); 239 ARRAY_SIZE(mxg_devices));
240} 240}
241__initcall(mxg_devices_setup); 241arch_initcall(mxg_devices_setup);
242 242
243void __init plat_irq_setup(void) 243void __init plat_irq_setup(void)
244{ 244{
diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7201.c b/arch/sh/kernel/cpu/sh2a/setup-sh7201.c
index d8febe128066..fbde5b75deb9 100644
--- a/arch/sh/kernel/cpu/sh2a/setup-sh7201.c
+++ b/arch/sh/kernel/cpu/sh2a/setup-sh7201.c
@@ -357,7 +357,7 @@ static int __init sh7201_devices_setup(void)
357 return platform_add_devices(sh7201_devices, 357 return platform_add_devices(sh7201_devices,
358 ARRAY_SIZE(sh7201_devices)); 358 ARRAY_SIZE(sh7201_devices));
359} 359}
360__initcall(sh7201_devices_setup); 360arch_initcall(sh7201_devices_setup);
361 361
362void __init plat_irq_setup(void) 362void __init plat_irq_setup(void)
363{ 363{
diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c
index 62e3039d2398..d3fd536c9a84 100644
--- a/arch/sh/kernel/cpu/sh2a/setup-sh7203.c
+++ b/arch/sh/kernel/cpu/sh2a/setup-sh7203.c
@@ -367,7 +367,7 @@ static int __init sh7203_devices_setup(void)
367 return platform_add_devices(sh7203_devices, 367 return platform_add_devices(sh7203_devices,
368 ARRAY_SIZE(sh7203_devices)); 368 ARRAY_SIZE(sh7203_devices));
369} 369}
370__initcall(sh7203_devices_setup); 370arch_initcall(sh7203_devices_setup);
371 371
372void __init plat_irq_setup(void) 372void __init plat_irq_setup(void)
373{ 373{
diff --git a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
index 3e6f3d7a58be..a9ccc5e8d9e9 100644
--- a/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
+++ b/arch/sh/kernel/cpu/sh2a/setup-sh7206.c
@@ -338,7 +338,7 @@ static int __init sh7206_devices_setup(void)
338 return platform_add_devices(sh7206_devices, 338 return platform_add_devices(sh7206_devices,
339 ARRAY_SIZE(sh7206_devices)); 339 ARRAY_SIZE(sh7206_devices));
340} 340}
341__initcall(sh7206_devices_setup); 341arch_initcall(sh7206_devices_setup);
342 342
343void __init plat_irq_setup(void) 343void __init plat_irq_setup(void)
344{ 344{
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7705.c b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
index 88f742fed9ed..c23105983878 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7705.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7705.c
@@ -222,7 +222,7 @@ static int __init sh7705_devices_setup(void)
222 return platform_add_devices(sh7705_devices, 222 return platform_add_devices(sh7705_devices,
223 ARRAY_SIZE(sh7705_devices)); 223 ARRAY_SIZE(sh7705_devices));
224} 224}
225__initcall(sh7705_devices_setup); 225arch_initcall(sh7705_devices_setup);
226 226
227static struct platform_device *sh7705_early_devices[] __initdata = { 227static struct platform_device *sh7705_early_devices[] __initdata = {
228 &tmu0_device, 228 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh770x.c b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
index c56306798584..347ab35d0697 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh770x.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh770x.c
@@ -250,7 +250,7 @@ static int __init sh770x_devices_setup(void)
250 return platform_add_devices(sh770x_devices, 250 return platform_add_devices(sh770x_devices,
251 ARRAY_SIZE(sh770x_devices)); 251 ARRAY_SIZE(sh770x_devices));
252} 252}
253__initcall(sh770x_devices_setup); 253arch_initcall(sh770x_devices_setup);
254 254
255static struct platform_device *sh770x_early_devices[] __initdata = { 255static struct platform_device *sh770x_early_devices[] __initdata = {
256 &tmu0_device, 256 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7710.c b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
index efa76c8148f4..717e90ae1097 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7710.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7710.c
@@ -226,7 +226,7 @@ static int __init sh7710_devices_setup(void)
226 return platform_add_devices(sh7710_devices, 226 return platform_add_devices(sh7710_devices,
227 ARRAY_SIZE(sh7710_devices)); 227 ARRAY_SIZE(sh7710_devices));
228} 228}
229__initcall(sh7710_devices_setup); 229arch_initcall(sh7710_devices_setup);
230 230
231static struct platform_device *sh7710_early_devices[] __initdata = { 231static struct platform_device *sh7710_early_devices[] __initdata = {
232 &tmu0_device, 232 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh3/setup-sh7720.c b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
index 5b2107798edb..74d8baaf8e96 100644
--- a/arch/sh/kernel/cpu/sh3/setup-sh7720.c
+++ b/arch/sh/kernel/cpu/sh3/setup-sh7720.c
@@ -388,7 +388,7 @@ static int __init sh7720_devices_setup(void)
388 return platform_add_devices(sh7720_devices, 388 return platform_add_devices(sh7720_devices,
389 ARRAY_SIZE(sh7720_devices)); 389 ARRAY_SIZE(sh7720_devices));
390} 390}
391__initcall(sh7720_devices_setup); 391arch_initcall(sh7720_devices_setup);
392 392
393static struct platform_device *sh7720_early_devices[] __initdata = { 393static struct platform_device *sh7720_early_devices[] __initdata = {
394 &cmt0_device, 394 &cmt0_device,
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh4-202.c b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
index 6d088d123591..de4827df19aa 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh4-202.c
@@ -138,7 +138,7 @@ static int __init sh4202_devices_setup(void)
138 return platform_add_devices(sh4202_devices, 138 return platform_add_devices(sh4202_devices,
139 ARRAY_SIZE(sh4202_devices)); 139 ARRAY_SIZE(sh4202_devices));
140} 140}
141__initcall(sh4202_devices_setup); 141arch_initcall(sh4202_devices_setup);
142 142
143static struct platform_device *sh4202_early_devices[] __initdata = { 143static struct platform_device *sh4202_early_devices[] __initdata = {
144 &tmu0_device, 144 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7750.c b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
index 851672d15cf4..1b8b122e8f3d 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7750.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7750.c
@@ -239,7 +239,7 @@ static int __init sh7750_devices_setup(void)
239 return platform_add_devices(sh7750_devices, 239 return platform_add_devices(sh7750_devices,
240 ARRAY_SIZE(sh7750_devices)); 240 ARRAY_SIZE(sh7750_devices));
241} 241}
242__initcall(sh7750_devices_setup); 242arch_initcall(sh7750_devices_setup);
243 243
244static struct platform_device *sh7750_early_devices[] __initdata = { 244static struct platform_device *sh7750_early_devices[] __initdata = {
245 &tmu0_device, 245 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh4/setup-sh7760.c b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
index 5b822519bd90..7fbb7be9284c 100644
--- a/arch/sh/kernel/cpu/sh4/setup-sh7760.c
+++ b/arch/sh/kernel/cpu/sh4/setup-sh7760.c
@@ -265,7 +265,7 @@ static int __init sh7760_devices_setup(void)
265 return platform_add_devices(sh7760_devices, 265 return platform_add_devices(sh7760_devices,
266 ARRAY_SIZE(sh7760_devices)); 266 ARRAY_SIZE(sh7760_devices));
267} 267}
268__initcall(sh7760_devices_setup); 268arch_initcall(sh7760_devices_setup);
269 269
270static struct platform_device *sh7760_early_devices[] __initdata = { 270static struct platform_device *sh7760_early_devices[] __initdata = {
271 &tmu0_device, 271 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
index 6307e087c864..ac4d5672ec1a 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7343.c
@@ -325,7 +325,7 @@ static int __init sh7343_devices_setup(void)
325 return platform_add_devices(sh7343_devices, 325 return platform_add_devices(sh7343_devices,
326 ARRAY_SIZE(sh7343_devices)); 326 ARRAY_SIZE(sh7343_devices));
327} 327}
328__initcall(sh7343_devices_setup); 328arch_initcall(sh7343_devices_setup);
329 329
330static struct platform_device *sh7343_early_devices[] __initdata = { 330static struct platform_device *sh7343_early_devices[] __initdata = {
331 &cmt_device, 331 &cmt_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
index c18f7d09281b..1a956b1beccc 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7366.c
@@ -318,7 +318,7 @@ static int __init sh7366_devices_setup(void)
318 return platform_add_devices(sh7366_devices, 318 return platform_add_devices(sh7366_devices,
319 ARRAY_SIZE(sh7366_devices)); 319 ARRAY_SIZE(sh7366_devices));
320} 320}
321__initcall(sh7366_devices_setup); 321arch_initcall(sh7366_devices_setup);
322 322
323static struct platform_device *sh7366_early_devices[] __initdata = { 323static struct platform_device *sh7366_early_devices[] __initdata = {
324 &cmt_device, 324 &cmt_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
index ea524a2da3e4..cda76ebf87c3 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7722.c
@@ -359,7 +359,7 @@ static int __init sh7722_devices_setup(void)
359 return platform_add_devices(sh7722_devices, 359 return platform_add_devices(sh7722_devices,
360 ARRAY_SIZE(sh7722_devices)); 360 ARRAY_SIZE(sh7722_devices));
361} 361}
362__initcall(sh7722_devices_setup); 362arch_initcall(sh7722_devices_setup);
363 363
364static struct platform_device *sh7722_early_devices[] __initdata = { 364static struct platform_device *sh7722_early_devices[] __initdata = {
365 &cmt_device, 365 &cmt_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
index e1bb80b2a27b..b45dace9539f 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7723.c
@@ -473,7 +473,7 @@ static int __init sh7723_devices_setup(void)
473 return platform_add_devices(sh7723_devices, 473 return platform_add_devices(sh7723_devices,
474 ARRAY_SIZE(sh7723_devices)); 474 ARRAY_SIZE(sh7723_devices));
475} 475}
476__initcall(sh7723_devices_setup); 476arch_initcall(sh7723_devices_setup);
477 477
478static struct platform_device *sh7723_early_devices[] __initdata = { 478static struct platform_device *sh7723_early_devices[] __initdata = {
479 &cmt_device, 479 &cmt_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
index e5ac9eb11c63..a04edaab9a29 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7724.c
@@ -508,7 +508,7 @@ static int __init sh7724_devices_setup(void)
508 return platform_add_devices(sh7724_devices, 508 return platform_add_devices(sh7724_devices,
509 ARRAY_SIZE(sh7724_devices)); 509 ARRAY_SIZE(sh7724_devices));
510} 510}
511device_initcall(sh7724_devices_setup); 511arch_initcall(sh7724_devices_setup);
512 512
513static struct platform_device *sh7724_early_devices[] __initdata = { 513static struct platform_device *sh7724_early_devices[] __initdata = {
514 &cmt_device, 514 &cmt_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
index f1e0c0d36da7..4659fff6b842 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7763.c
@@ -314,7 +314,7 @@ static int __init sh7763_devices_setup(void)
314 return platform_add_devices(sh7763_devices, 314 return platform_add_devices(sh7763_devices,
315 ARRAY_SIZE(sh7763_devices)); 315 ARRAY_SIZE(sh7763_devices));
316} 316}
317__initcall(sh7763_devices_setup); 317arch_initcall(sh7763_devices_setup);
318 318
319static struct platform_device *sh7763_early_devices[] __initdata = { 319static struct platform_device *sh7763_early_devices[] __initdata = {
320 &tmu0_device, 320 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7770.c b/arch/sh/kernel/cpu/sh4a/setup-sh7770.c
index 1e86209db284..eead08d89d32 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7770.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7770.c
@@ -368,7 +368,7 @@ static int __init sh7770_devices_setup(void)
368 return platform_add_devices(sh7770_devices, 368 return platform_add_devices(sh7770_devices,
369 ARRAY_SIZE(sh7770_devices)); 369 ARRAY_SIZE(sh7770_devices));
370} 370}
371__initcall(sh7770_devices_setup); 371arch_initcall(sh7770_devices_setup);
372 372
373static struct platform_device *sh7770_early_devices[] __initdata = { 373static struct platform_device *sh7770_early_devices[] __initdata = {
374 &tmu0_device, 374 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
index 715e05b431e5..2c901f446959 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7780.c
@@ -256,7 +256,7 @@ static int __init sh7780_devices_setup(void)
256 return platform_add_devices(sh7780_devices, 256 return platform_add_devices(sh7780_devices,
257 ARRAY_SIZE(sh7780_devices)); 257 ARRAY_SIZE(sh7780_devices));
258} 258}
259__initcall(sh7780_devices_setup); 259arch_initcall(sh7780_devices_setup);
260 260
261static struct platform_device *sh7780_early_devices[] __initdata = { 261static struct platform_device *sh7780_early_devices[] __initdata = {
262 &tmu0_device, 262 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
index af561402570b..7f6c718b6c36 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7785.c
@@ -263,7 +263,7 @@ static int __init sh7785_devices_setup(void)
263 return platform_add_devices(sh7785_devices, 263 return platform_add_devices(sh7785_devices,
264 ARRAY_SIZE(sh7785_devices)); 264 ARRAY_SIZE(sh7785_devices));
265} 265}
266__initcall(sh7785_devices_setup); 266arch_initcall(sh7785_devices_setup);
267 267
268static struct platform_device *sh7785_early_devices[] __initdata = { 268static struct platform_device *sh7785_early_devices[] __initdata = {
269 &tmu0_device, 269 &tmu0_device,
diff --git a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
index b70049470a0b..0104a8ec5369 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-sh7786.c
@@ -547,7 +547,7 @@ static int __init sh7786_devices_setup(void)
547 return platform_add_devices(sh7786_devices, 547 return platform_add_devices(sh7786_devices,
548 ARRAY_SIZE(sh7786_devices)); 548 ARRAY_SIZE(sh7786_devices));
549} 549}
550device_initcall(sh7786_devices_setup); 550arch_initcall(sh7786_devices_setup);
551 551
552void __init plat_early_device_setup(void) 552void __init plat_early_device_setup(void)
553{ 553{
diff --git a/arch/sh/kernel/cpu/sh4a/setup-shx3.c b/arch/sh/kernel/cpu/sh4a/setup-shx3.c
index 53c65fd9ccef..07f078961c71 100644
--- a/arch/sh/kernel/cpu/sh4a/setup-shx3.c
+++ b/arch/sh/kernel/cpu/sh4a/setup-shx3.c
@@ -256,7 +256,7 @@ static int __init shx3_devices_setup(void)
256 return platform_add_devices(shx3_devices, 256 return platform_add_devices(shx3_devices,
257 ARRAY_SIZE(shx3_devices)); 257 ARRAY_SIZE(shx3_devices));
258} 258}
259__initcall(shx3_devices_setup); 259arch_initcall(shx3_devices_setup);
260 260
261void __init plat_early_device_setup(void) 261void __init plat_early_device_setup(void)
262{ 262{
diff --git a/arch/sh/kernel/cpu/sh5/setup-sh5.c b/arch/sh/kernel/cpu/sh5/setup-sh5.c
index f5ff1ac57fc2..6a0f82f70032 100644
--- a/arch/sh/kernel/cpu/sh5/setup-sh5.c
+++ b/arch/sh/kernel/cpu/sh5/setup-sh5.c
@@ -186,7 +186,7 @@ static int __init sh5_devices_setup(void)
186 return platform_add_devices(sh5_devices, 186 return platform_add_devices(sh5_devices,
187 ARRAY_SIZE(sh5_devices)); 187 ARRAY_SIZE(sh5_devices));
188} 188}
189__initcall(sh5_devices_setup); 189arch_initcall(sh5_devices_setup);
190 190
191void __init plat_early_device_setup(void) 191void __init plat_early_device_setup(void)
192{ 192{
diff --git a/arch/sh/kernel/cpu/shmobile/sleep.S b/arch/sh/kernel/cpu/shmobile/sleep.S
index 5d888ef53d82..baf2d7d46b05 100644
--- a/arch/sh/kernel/cpu/shmobile/sleep.S
+++ b/arch/sh/kernel/cpu/shmobile/sleep.S
@@ -26,8 +26,30 @@ ENTRY(sh_mobile_standby)
26 26
27 tst #SUSP_SH_SF, r0 27 tst #SUSP_SH_SF, r0
28 bt skip_set_sf 28 bt skip_set_sf
29#ifdef CONFIG_CPU_SUBTYPE_SH7724
30 /* DBSC: put memory in self-refresh mode */
29 31
30 /* SDRAM: disable power down and put in self-refresh mode */ 32 mov.l dben_reg, r4
33 mov.l dben_data0, r1
34 mov.l r1, @r4
35
36 mov.l dbrfpdn0_reg, r4
37 mov.l dbrfpdn0_data0, r1
38 mov.l r1, @r4
39
40 mov.l dbcmdcnt_reg, r4
41 mov.l dbcmdcnt_data0, r1
42 mov.l r1, @r4
43
44 mov.l dbcmdcnt_reg, r4
45 mov.l dbcmdcnt_data1, r1
46 mov.l r1, @r4
47
48 mov.l dbrfpdn0_reg, r4
49 mov.l dbrfpdn0_data1, r1
50 mov.l r1, @r4
51#else
52 /* SBSC: disable power down and put in self-refresh mode */
31 mov.l 1f, r4 53 mov.l 1f, r4
32 mov.l 2f, r1 54 mov.l 2f, r1
33 mov.l @r4, r2 55 mov.l @r4, r2
@@ -35,6 +57,7 @@ ENTRY(sh_mobile_standby)
35 mov.l 3f, r3 57 mov.l 3f, r3
36 and r3, r2 58 and r3, r2
37 mov.l r2, @r4 59 mov.l r2, @r4
60#endif
38 61
39skip_set_sf: 62skip_set_sf:
40 tst #SUSP_SH_SLEEP, r0 63 tst #SUSP_SH_SLEEP, r0
@@ -84,7 +107,36 @@ done_sleep:
84 tst #SUSP_SH_SF, r0 107 tst #SUSP_SH_SF, r0
85 bt skip_restore_sf 108 bt skip_restore_sf
86 109
87 /* SDRAM: set auto-refresh mode */ 110#ifdef CONFIG_CPU_SUBTYPE_SH7724
111 /* DBSC: put memory in auto-refresh mode */
112
113 mov.l dbrfpdn0_reg, r4
114 mov.l dbrfpdn0_data0, r1
115 mov.l r1, @r4
116
117 /* sleep 140 ns */
118 nop
119 nop
120 nop
121 nop
122
123 mov.l dbcmdcnt_reg, r4
124 mov.l dbcmdcnt_data0, r1
125 mov.l r1, @r4
126
127 mov.l dbcmdcnt_reg, r4
128 mov.l dbcmdcnt_data1, r1
129 mov.l r1, @r4
130
131 mov.l dben_reg, r4
132 mov.l dben_data1, r1
133 mov.l r1, @r4
134
135 mov.l dbrfpdn0_reg, r4
136 mov.l dbrfpdn0_data2, r1
137 mov.l r1, @r4
138#else
139 /* SBSC: set auto-refresh mode */
88 mov.l 1f, r4 140 mov.l 1f, r4
89 mov.l @r4, r2 141 mov.l @r4, r2
90 mov.l 4f, r3 142 mov.l 4f, r3
@@ -98,15 +150,29 @@ done_sleep:
98 add r4, r3 150 add r4, r3
99 or r2, r3 151 or r2, r3
100 mov.l r3, @r1 152 mov.l r3, @r1
153#endif
101skip_restore_sf: 154skip_restore_sf:
102 rts 155 rts
103 nop 156 nop
104 157
105 .balign 4 158 .balign 4
159#ifdef CONFIG_CPU_SUBTYPE_SH7724
160dben_reg: .long 0xfd000010 /* DBEN */
161dben_data0: .long 0
162dben_data1: .long 1
163dbrfpdn0_reg: .long 0xfd000040 /* DBRFPDN0 */
164dbrfpdn0_data0: .long 0
165dbrfpdn0_data1: .long 1
166dbrfpdn0_data2: .long 0x00010000
167dbcmdcnt_reg: .long 0xfd000014 /* DBCMDCNT */
168dbcmdcnt_data0: .long 2
169dbcmdcnt_data1: .long 4
170#else
1061: .long 0xfe400008 /* SDCR0 */ 1711: .long 0xfe400008 /* SDCR0 */
1072: .long 0x00000400 1722: .long 0x00000400
1083: .long 0xffff7fff 1733: .long 0xffff7fff
1094: .long 0xfffffbff 1744: .long 0xfffffbff
175#endif
1105: .long 0xa4150020 /* STBCR */ 1765: .long 0xa4150020 /* STBCR */
1116: .long 0xfe40001c /* RTCOR */ 1776: .long 0xfe40001c /* RTCOR */
1127: .long 0xfe400018 /* RTCNT */ 1787: .long 0xfe400018 /* RTCNT */
diff --git a/arch/sparc/configs/sparc32_defconfig b/arch/sparc/configs/sparc32_defconfig
index 8bcd27af724b..a0f62a808edb 100644
--- a/arch/sparc/configs/sparc32_defconfig
+++ b/arch/sparc/configs/sparc32_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30-rc2 3# Linux kernel version: 2.6.31-rc1
4# Fri Apr 17 04:04:46 2009 4# Tue Aug 18 23:45:52 2009
5# 5#
6# CONFIG_64BIT is not set 6# CONFIG_64BIT is not set
7CONFIG_SPARC=y 7CONFIG_SPARC=y
@@ -17,6 +17,7 @@ CONFIG_GENERIC_ISA_DMA=y
17CONFIG_ARCH_NO_VIRT_TO_BUS=y 17CONFIG_ARCH_NO_VIRT_TO_BUS=y
18CONFIG_OF=y 18CONFIG_OF=y
19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 19CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
20CONFIG_CONSTRUCTORS=y
20 21
21# 22#
22# General setup 23# General setup
@@ -74,7 +75,6 @@ CONFIG_SYSCTL_SYSCALL=y
74CONFIG_KALLSYMS=y 75CONFIG_KALLSYMS=y
75# CONFIG_KALLSYMS_ALL is not set 76# CONFIG_KALLSYMS_ALL is not set
76# CONFIG_KALLSYMS_EXTRA_PASS is not set 77# CONFIG_KALLSYMS_EXTRA_PASS is not set
77# CONFIG_STRIP_ASM_SYMS is not set
78CONFIG_HOTPLUG=y 78CONFIG_HOTPLUG=y
79CONFIG_PRINTK=y 79CONFIG_PRINTK=y
80CONFIG_BUG=y 80CONFIG_BUG=y
@@ -87,8 +87,13 @@ CONFIG_TIMERFD=y
87CONFIG_EVENTFD=y 87CONFIG_EVENTFD=y
88CONFIG_SHMEM=y 88CONFIG_SHMEM=y
89CONFIG_AIO=y 89CONFIG_AIO=y
90
91#
92# Performance Counters
93#
90CONFIG_VM_EVENT_COUNTERS=y 94CONFIG_VM_EVENT_COUNTERS=y
91CONFIG_PCI_QUIRKS=y 95CONFIG_PCI_QUIRKS=y
96# CONFIG_STRIP_ASM_SYMS is not set
92CONFIG_COMPAT_BRK=y 97CONFIG_COMPAT_BRK=y
93CONFIG_SLAB=y 98CONFIG_SLAB=y
94# CONFIG_SLUB is not set 99# CONFIG_SLUB is not set
@@ -97,6 +102,10 @@ CONFIG_SLAB=y
97# CONFIG_MARKERS is not set 102# CONFIG_MARKERS is not set
98CONFIG_HAVE_OPROFILE=y 103CONFIG_HAVE_OPROFILE=y
99CONFIG_HAVE_ARCH_TRACEHOOK=y 104CONFIG_HAVE_ARCH_TRACEHOOK=y
105
106#
107# GCOV-based kernel profiling
108#
100# CONFIG_SLOW_WORK is not set 109# CONFIG_SLOW_WORK is not set
101# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 110# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
102CONFIG_SLABINFO=y 111CONFIG_SLABINFO=y
@@ -109,7 +118,7 @@ CONFIG_MODULE_UNLOAD=y
109# CONFIG_MODVERSIONS is not set 118# CONFIG_MODVERSIONS is not set
110# CONFIG_MODULE_SRCVERSION_ALL is not set 119# CONFIG_MODULE_SRCVERSION_ALL is not set
111CONFIG_BLOCK=y 120CONFIG_BLOCK=y
112# CONFIG_LBD is not set 121CONFIG_LBDAF=y
113# CONFIG_BLK_DEV_BSG is not set 122# CONFIG_BLK_DEV_BSG is not set
114# CONFIG_BLK_DEV_INTEGRITY is not set 123# CONFIG_BLK_DEV_INTEGRITY is not set
115 124
@@ -154,9 +163,9 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
154# CONFIG_PHYS_ADDR_T_64BIT is not set 163# CONFIG_PHYS_ADDR_T_64BIT is not set
155CONFIG_ZONE_DMA_FLAG=1 164CONFIG_ZONE_DMA_FLAG=1
156CONFIG_BOUNCE=y 165CONFIG_BOUNCE=y
157CONFIG_UNEVICTABLE_LRU=y
158CONFIG_HAVE_MLOCK=y 166CONFIG_HAVE_MLOCK=y
159CONFIG_HAVE_MLOCKED_PAGE_BIT=y 167CONFIG_HAVE_MLOCKED_PAGE_BIT=y
168CONFIG_DEFAULT_MMAP_MIN_ADDR=4096
160CONFIG_SUN_PM=y 169CONFIG_SUN_PM=y
161# CONFIG_SPARC_LED is not set 170# CONFIG_SPARC_LED is not set
162CONFIG_SERIAL_CONSOLE=y 171CONFIG_SERIAL_CONSOLE=y
@@ -264,6 +273,7 @@ CONFIG_IPV6_TUNNEL=m
264# CONFIG_ECONET is not set 273# CONFIG_ECONET is not set
265# CONFIG_WAN_ROUTER is not set 274# CONFIG_WAN_ROUTER is not set
266# CONFIG_PHONET is not set 275# CONFIG_PHONET is not set
276# CONFIG_IEEE802154 is not set
267# CONFIG_NET_SCHED is not set 277# CONFIG_NET_SCHED is not set
268# CONFIG_DCB is not set 278# CONFIG_DCB is not set
269 279
@@ -281,7 +291,11 @@ CONFIG_WIRELESS=y
281CONFIG_WIRELESS_OLD_REGULATORY=y 291CONFIG_WIRELESS_OLD_REGULATORY=y
282# CONFIG_WIRELESS_EXT is not set 292# CONFIG_WIRELESS_EXT is not set
283# CONFIG_LIB80211 is not set 293# CONFIG_LIB80211 is not set
284# CONFIG_MAC80211 is not set 294
295#
296# CFG80211 needs to be enabled for MAC80211
297#
298CONFIG_MAC80211_DEFAULT_PS_VALUE=0
285# CONFIG_WIMAX is not set 299# CONFIG_WIMAX is not set
286# CONFIG_RFKILL is not set 300# CONFIG_RFKILL is not set
287# CONFIG_NET_9P is not set 301# CONFIG_NET_9P is not set
@@ -335,6 +349,7 @@ CONFIG_MISC_DEVICES=y
335# EEPROM support 349# EEPROM support
336# 350#
337# CONFIG_EEPROM_93CX6 is not set 351# CONFIG_EEPROM_93CX6 is not set
352# CONFIG_CB710_CORE is not set
338CONFIG_HAVE_IDE=y 353CONFIG_HAVE_IDE=y
339# CONFIG_IDE is not set 354# CONFIG_IDE is not set
340 355
@@ -358,10 +373,6 @@ CONFIG_BLK_DEV_SR=m
358# CONFIG_BLK_DEV_SR_VENDOR is not set 373# CONFIG_BLK_DEV_SR_VENDOR is not set
359CONFIG_CHR_DEV_SG=m 374CONFIG_CHR_DEV_SG=m
360# CONFIG_CHR_DEV_SCH is not set 375# CONFIG_CHR_DEV_SCH is not set
361
362#
363# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
364#
365# CONFIG_SCSI_MULTI_LUN is not set 376# CONFIG_SCSI_MULTI_LUN is not set
366# CONFIG_SCSI_CONSTANTS is not set 377# CONFIG_SCSI_CONSTANTS is not set
367# CONFIG_SCSI_LOGGING is not set 378# CONFIG_SCSI_LOGGING is not set
@@ -379,6 +390,7 @@ CONFIG_SCSI_SPI_ATTRS=y
379CONFIG_SCSI_LOWLEVEL=y 390CONFIG_SCSI_LOWLEVEL=y
380# CONFIG_ISCSI_TCP is not set 391# CONFIG_ISCSI_TCP is not set
381# CONFIG_SCSI_CXGB3_ISCSI is not set 392# CONFIG_SCSI_CXGB3_ISCSI is not set
393# CONFIG_SCSI_BNX2_ISCSI is not set
382# CONFIG_BLK_DEV_3W_XXXX_RAID is not set 394# CONFIG_BLK_DEV_3W_XXXX_RAID is not set
383# CONFIG_SCSI_3W_9XXX is not set 395# CONFIG_SCSI_3W_9XXX is not set
384# CONFIG_SCSI_ACARD is not set 396# CONFIG_SCSI_ACARD is not set
@@ -387,6 +399,7 @@ CONFIG_SCSI_LOWLEVEL=y
387# CONFIG_SCSI_AIC7XXX_OLD is not set 399# CONFIG_SCSI_AIC7XXX_OLD is not set
388# CONFIG_SCSI_AIC79XX is not set 400# CONFIG_SCSI_AIC79XX is not set
389# CONFIG_SCSI_AIC94XX is not set 401# CONFIG_SCSI_AIC94XX is not set
402# CONFIG_SCSI_MVSAS is not set
390# CONFIG_SCSI_ARCMSR is not set 403# CONFIG_SCSI_ARCMSR is not set
391# CONFIG_MEGARAID_NEWGEN is not set 404# CONFIG_MEGARAID_NEWGEN is not set
392# CONFIG_MEGARAID_LEGACY is not set 405# CONFIG_MEGARAID_LEGACY is not set
@@ -401,7 +414,6 @@ CONFIG_SCSI_LOWLEVEL=y
401# CONFIG_SCSI_IPS is not set 414# CONFIG_SCSI_IPS is not set
402# CONFIG_SCSI_INITIO is not set 415# CONFIG_SCSI_INITIO is not set
403# CONFIG_SCSI_INIA100 is not set 416# CONFIG_SCSI_INIA100 is not set
404# CONFIG_SCSI_MVSAS is not set
405# CONFIG_SCSI_STEX is not set 417# CONFIG_SCSI_STEX is not set
406# CONFIG_SCSI_SYM53C8XX_2 is not set 418# CONFIG_SCSI_SYM53C8XX_2 is not set
407# CONFIG_SCSI_QLOGIC_1280 is not set 419# CONFIG_SCSI_QLOGIC_1280 is not set
@@ -426,13 +438,16 @@ CONFIG_SCSI_SUNESP=y
426# 438#
427 439
428# 440#
429# Enable only one of the two stacks, unless you know what you are doing 441# You can enable one or both FireWire driver stacks.
442#
443
444#
445# See the help texts for more information.
430# 446#
431# CONFIG_FIREWIRE is not set 447# CONFIG_FIREWIRE is not set
432# CONFIG_IEEE1394 is not set 448# CONFIG_IEEE1394 is not set
433# CONFIG_I2O is not set 449# CONFIG_I2O is not set
434CONFIG_NETDEVICES=y 450CONFIG_NETDEVICES=y
435CONFIG_COMPAT_NET_DEV_OPS=y
436CONFIG_DUMMY=m 451CONFIG_DUMMY=m
437# CONFIG_BONDING is not set 452# CONFIG_BONDING is not set
438# CONFIG_MACVLAN is not set 453# CONFIG_MACVLAN is not set
@@ -463,6 +478,7 @@ CONFIG_SUNQE=m
463# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set 478# CONFIG_IBM_NEW_EMAC_MAL_COMMON_ERR is not set
464# CONFIG_NET_PCI is not set 479# CONFIG_NET_PCI is not set
465# CONFIG_B44 is not set 480# CONFIG_B44 is not set
481# CONFIG_KS8842 is not set
466# CONFIG_ATL2 is not set 482# CONFIG_ATL2 is not set
467CONFIG_NETDEV_1000=y 483CONFIG_NETDEV_1000=y
468# CONFIG_ACENIC is not set 484# CONFIG_ACENIC is not set
@@ -482,6 +498,7 @@ CONFIG_NETDEV_1000=y
482# CONFIG_VIA_VELOCITY is not set 498# CONFIG_VIA_VELOCITY is not set
483# CONFIG_TIGON3 is not set 499# CONFIG_TIGON3 is not set
484# CONFIG_BNX2 is not set 500# CONFIG_BNX2 is not set
501# CONFIG_CNIC is not set
485# CONFIG_QLA3XXX is not set 502# CONFIG_QLA3XXX is not set
486# CONFIG_ATL1 is not set 503# CONFIG_ATL1 is not set
487# CONFIG_ATL1E is not set 504# CONFIG_ATL1E is not set
@@ -629,6 +646,11 @@ CONFIG_HW_RANDOM=m
629CONFIG_DEVPORT=y 646CONFIG_DEVPORT=y
630# CONFIG_I2C is not set 647# CONFIG_I2C is not set
631# CONFIG_SPI is not set 648# CONFIG_SPI is not set
649
650#
651# PPS support
652#
653# CONFIG_PPS is not set
632CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 654CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
633# CONFIG_GPIOLIB is not set 655# CONFIG_GPIOLIB is not set
634# CONFIG_W1 is not set 656# CONFIG_W1 is not set
@@ -668,22 +690,7 @@ CONFIG_SSB_POSSIBLE=y
668# CONFIG_HTC_PASIC3 is not set 690# CONFIG_HTC_PASIC3 is not set
669# CONFIG_MFD_TMIO is not set 691# CONFIG_MFD_TMIO is not set
670# CONFIG_REGULATOR is not set 692# CONFIG_REGULATOR is not set
671 693# CONFIG_MEDIA_SUPPORT is not set
672#
673# Multimedia devices
674#
675
676#
677# Multimedia core support
678#
679# CONFIG_VIDEO_DEV is not set
680# CONFIG_DVB_CORE is not set
681# CONFIG_VIDEO_MEDIA is not set
682
683#
684# Multimedia drivers
685#
686# CONFIG_DAB is not set
687 694
688# 695#
689# Graphics support 696# Graphics support
@@ -776,6 +783,10 @@ CONFIG_RTC_DRV_M48T59=y
776# CONFIG_DMADEVICES is not set 783# CONFIG_DMADEVICES is not set
777# CONFIG_AUXDISPLAY is not set 784# CONFIG_AUXDISPLAY is not set
778# CONFIG_UIO is not set 785# CONFIG_UIO is not set
786
787#
788# TI VLYNQ
789#
779# CONFIG_STAGING is not set 790# CONFIG_STAGING is not set
780 791
781# 792#
@@ -799,10 +810,12 @@ CONFIG_FS_MBCACHE=y
799# CONFIG_REISERFS_FS is not set 810# CONFIG_REISERFS_FS is not set
800# CONFIG_JFS_FS is not set 811# CONFIG_JFS_FS is not set
801CONFIG_FS_POSIX_ACL=y 812CONFIG_FS_POSIX_ACL=y
802CONFIG_FILE_LOCKING=y
803# CONFIG_XFS_FS is not set 813# CONFIG_XFS_FS is not set
814# CONFIG_GFS2_FS is not set
804# CONFIG_OCFS2_FS is not set 815# CONFIG_OCFS2_FS is not set
805# CONFIG_BTRFS_FS is not set 816# CONFIG_BTRFS_FS is not set
817CONFIG_FILE_LOCKING=y
818CONFIG_FSNOTIFY=y
806CONFIG_DNOTIFY=y 819CONFIG_DNOTIFY=y
807CONFIG_INOTIFY=y 820CONFIG_INOTIFY=y
808CONFIG_INOTIFY_USER=y 821CONFIG_INOTIFY_USER=y
@@ -985,6 +998,7 @@ CONFIG_KGDB=y
985CONFIG_KGDB_SERIAL_CONSOLE=y 998CONFIG_KGDB_SERIAL_CONSOLE=y
986CONFIG_KGDB_TESTS=y 999CONFIG_KGDB_TESTS=y
987# CONFIG_KGDB_TESTS_ON_BOOT is not set 1000# CONFIG_KGDB_TESTS_ON_BOOT is not set
1001# CONFIG_KMEMCHECK is not set
988# CONFIG_DEBUG_STACK_USAGE is not set 1002# CONFIG_DEBUG_STACK_USAGE is not set
989# CONFIG_STACK_DEBUG is not set 1003# CONFIG_STACK_DEBUG is not set
990 1004
diff --git a/arch/sparc/configs/sparc64_defconfig b/arch/sparc/configs/sparc64_defconfig
index 0123a4c596ce..fdddf7a6f725 100644
--- a/arch/sparc/configs/sparc64_defconfig
+++ b/arch/sparc/configs/sparc64_defconfig
@@ -1,7 +1,7 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.30 3# Linux kernel version: 2.6.31-rc1
4# Tue Jun 16 04:59:36 2009 4# Tue Aug 18 23:56:02 2009
5# 5#
6CONFIG_64BIT=y 6CONFIG_64BIT=y
7CONFIG_SPARC=y 7CONFIG_SPARC=y
@@ -26,6 +26,7 @@ CONFIG_ARCH_NO_VIRT_TO_BUS=y
26CONFIG_OF=y 26CONFIG_OF=y
27CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y 27CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC=y
28CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 28CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
29CONFIG_CONSTRUCTORS=y
29 30
30# 31#
31# General setup 32# General setup
@@ -119,6 +120,11 @@ CONFIG_HAVE_KPROBES=y
119CONFIG_HAVE_KRETPROBES=y 120CONFIG_HAVE_KRETPROBES=y
120CONFIG_HAVE_ARCH_TRACEHOOK=y 121CONFIG_HAVE_ARCH_TRACEHOOK=y
121CONFIG_USE_GENERIC_SMP_HELPERS=y 122CONFIG_USE_GENERIC_SMP_HELPERS=y
123
124#
125# GCOV-based kernel profiling
126#
127# CONFIG_GCOV_KERNEL is not set
122# CONFIG_SLOW_WORK is not set 128# CONFIG_SLOW_WORK is not set
123# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set 129# CONFIG_HAVE_GENERIC_DMA_COHERENT is not set
124CONFIG_SLABINFO=y 130CONFIG_SLABINFO=y
@@ -204,7 +210,6 @@ CONFIG_MIGRATION=y
204CONFIG_PHYS_ADDR_T_64BIT=y 210CONFIG_PHYS_ADDR_T_64BIT=y
205CONFIG_ZONE_DMA_FLAG=0 211CONFIG_ZONE_DMA_FLAG=0
206CONFIG_NR_QUICK=1 212CONFIG_NR_QUICK=1
207CONFIG_UNEVICTABLE_LRU=y
208CONFIG_HAVE_MLOCK=y 213CONFIG_HAVE_MLOCK=y
209CONFIG_HAVE_MLOCKED_PAGE_BIT=y 214CONFIG_HAVE_MLOCKED_PAGE_BIT=y
210CONFIG_DEFAULT_MMAP_MIN_ADDR=8192 215CONFIG_DEFAULT_MMAP_MIN_ADDR=8192
@@ -410,6 +415,7 @@ CONFIG_MISC_DEVICES=y
410# 415#
411# CONFIG_EEPROM_AT24 is not set 416# CONFIG_EEPROM_AT24 is not set
412# CONFIG_EEPROM_LEGACY is not set 417# CONFIG_EEPROM_LEGACY is not set
418# CONFIG_EEPROM_MAX6875 is not set
413# CONFIG_EEPROM_93CX6 is not set 419# CONFIG_EEPROM_93CX6 is not set
414# CONFIG_CB710_CORE is not set 420# CONFIG_CB710_CORE is not set
415CONFIG_HAVE_IDE=y 421CONFIG_HAVE_IDE=y
@@ -562,6 +568,7 @@ CONFIG_BLK_DEV_DM=m
562CONFIG_DM_CRYPT=m 568CONFIG_DM_CRYPT=m
563CONFIG_DM_SNAPSHOT=m 569CONFIG_DM_SNAPSHOT=m
564CONFIG_DM_MIRROR=m 570CONFIG_DM_MIRROR=m
571# CONFIG_DM_LOG_USERSPACE is not set
565CONFIG_DM_ZERO=m 572CONFIG_DM_ZERO=m
566# CONFIG_DM_MULTIPATH is not set 573# CONFIG_DM_MULTIPATH is not set
567# CONFIG_DM_DELAY is not set 574# CONFIG_DM_DELAY is not set
@@ -573,7 +580,11 @@ CONFIG_DM_ZERO=m
573# 580#
574 581
575# 582#
576# Enable only one of the two stacks, unless you know what you are doing 583# You can enable one or both FireWire driver stacks.
584#
585
586#
587# See the help texts for more information.
577# 588#
578# CONFIG_FIREWIRE is not set 589# CONFIG_FIREWIRE is not set
579# CONFIG_IEEE1394 is not set 590# CONFIG_IEEE1394 is not set
@@ -667,6 +678,7 @@ CONFIG_E1000E=m
667# CONFIG_VIA_VELOCITY is not set 678# CONFIG_VIA_VELOCITY is not set
668CONFIG_TIGON3=m 679CONFIG_TIGON3=m
669CONFIG_BNX2=m 680CONFIG_BNX2=m
681# CONFIG_CNIC is not set
670# CONFIG_QLA3XXX is not set 682# CONFIG_QLA3XXX is not set
671# CONFIG_ATL1 is not set 683# CONFIG_ATL1 is not set
672# CONFIG_ATL1E is not set 684# CONFIG_ATL1E is not set
@@ -773,6 +785,7 @@ CONFIG_MOUSE_SERIAL=y
773# CONFIG_MOUSE_APPLETOUCH is not set 785# CONFIG_MOUSE_APPLETOUCH is not set
774# CONFIG_MOUSE_BCM5974 is not set 786# CONFIG_MOUSE_BCM5974 is not set
775# CONFIG_MOUSE_VSXXXAA is not set 787# CONFIG_MOUSE_VSXXXAA is not set
788# CONFIG_MOUSE_SYNAPTICS_I2C is not set
776# CONFIG_INPUT_JOYSTICK is not set 789# CONFIG_INPUT_JOYSTICK is not set
777# CONFIG_INPUT_TABLET is not set 790# CONFIG_INPUT_TABLET is not set
778# CONFIG_INPUT_TOUCHSCREEN is not set 791# CONFIG_INPUT_TOUCHSCREEN is not set
@@ -870,6 +883,7 @@ CONFIG_I2C_ALGOBIT=y
870# 883#
871# I2C system bus drivers (mostly embedded / system-on-chip) 884# I2C system bus drivers (mostly embedded / system-on-chip)
872# 885#
886# CONFIG_I2C_DESIGNWARE is not set
873# CONFIG_I2C_OCORES is not set 887# CONFIG_I2C_OCORES is not set
874# CONFIG_I2C_SIMTEC is not set 888# CONFIG_I2C_SIMTEC is not set
875 889
@@ -898,13 +912,17 @@ CONFIG_I2C_ALGOBIT=y
898# CONFIG_SENSORS_PCF8574 is not set 912# CONFIG_SENSORS_PCF8574 is not set
899# CONFIG_PCF8575 is not set 913# CONFIG_PCF8575 is not set
900# CONFIG_SENSORS_PCA9539 is not set 914# CONFIG_SENSORS_PCA9539 is not set
901# CONFIG_SENSORS_MAX6875 is not set
902# CONFIG_SENSORS_TSL2550 is not set 915# CONFIG_SENSORS_TSL2550 is not set
903# CONFIG_I2C_DEBUG_CORE is not set 916# CONFIG_I2C_DEBUG_CORE is not set
904# CONFIG_I2C_DEBUG_ALGO is not set 917# CONFIG_I2C_DEBUG_ALGO is not set
905# CONFIG_I2C_DEBUG_BUS is not set 918# CONFIG_I2C_DEBUG_BUS is not set
906# CONFIG_I2C_DEBUG_CHIP is not set 919# CONFIG_I2C_DEBUG_CHIP is not set
907# CONFIG_SPI is not set 920# CONFIG_SPI is not set
921
922#
923# PPS support
924#
925# CONFIG_PPS is not set
908CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y 926CONFIG_ARCH_WANT_OPTIONAL_GPIOLIB=y
909# CONFIG_GPIOLIB is not set 927# CONFIG_GPIOLIB is not set
910# CONFIG_W1 is not set 928# CONFIG_W1 is not set
@@ -959,6 +977,7 @@ CONFIG_HWMON=y
959# CONFIG_SENSORS_SMSC47B397 is not set 977# CONFIG_SENSORS_SMSC47B397 is not set
960# CONFIG_SENSORS_ADS7828 is not set 978# CONFIG_SENSORS_ADS7828 is not set
961# CONFIG_SENSORS_THMC50 is not set 979# CONFIG_SENSORS_THMC50 is not set
980# CONFIG_SENSORS_TMP401 is not set
962# CONFIG_SENSORS_VIA686A is not set 981# CONFIG_SENSORS_VIA686A is not set
963# CONFIG_SENSORS_VT1211 is not set 982# CONFIG_SENSORS_VT1211 is not set
964# CONFIG_SENSORS_VT8231 is not set 983# CONFIG_SENSORS_VT8231 is not set
@@ -994,23 +1013,9 @@ CONFIG_SSB_POSSIBLE=y
994# CONFIG_MFD_WM8400 is not set 1013# CONFIG_MFD_WM8400 is not set
995# CONFIG_MFD_WM8350_I2C is not set 1014# CONFIG_MFD_WM8350_I2C is not set
996# CONFIG_MFD_PCF50633 is not set 1015# CONFIG_MFD_PCF50633 is not set
1016# CONFIG_AB3100_CORE is not set
997# CONFIG_REGULATOR is not set 1017# CONFIG_REGULATOR is not set
998 1018# CONFIG_MEDIA_SUPPORT is not set
999#
1000# Multimedia devices
1001#
1002
1003#
1004# Multimedia core support
1005#
1006# CONFIG_VIDEO_DEV is not set
1007# CONFIG_DVB_CORE is not set
1008# CONFIG_VIDEO_MEDIA is not set
1009
1010#
1011# Multimedia drivers
1012#
1013# CONFIG_DAB is not set
1014 1019
1015# 1020#
1016# Graphics support 1021# Graphics support
@@ -1284,7 +1289,6 @@ CONFIG_USB=y
1284# 1289#
1285# Miscellaneous USB options 1290# Miscellaneous USB options
1286# 1291#
1287CONFIG_USB_DEVICEFS=y
1288# CONFIG_USB_DEVICE_CLASS is not set 1292# CONFIG_USB_DEVICE_CLASS is not set
1289# CONFIG_USB_DYNAMIC_MINORS is not set 1293# CONFIG_USB_DYNAMIC_MINORS is not set
1290# CONFIG_USB_OTG is not set 1294# CONFIG_USB_OTG is not set
@@ -1296,6 +1300,7 @@ CONFIG_USB_DEVICEFS=y
1296# USB Host Controller Drivers 1300# USB Host Controller Drivers
1297# 1301#
1298# CONFIG_USB_C67X00_HCD is not set 1302# CONFIG_USB_C67X00_HCD is not set
1303# CONFIG_USB_XHCI_HCD is not set
1299CONFIG_USB_EHCI_HCD=m 1304CONFIG_USB_EHCI_HCD=m
1300# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 1305# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1301# CONFIG_USB_EHCI_TT_NEWSCHED is not set 1306# CONFIG_USB_EHCI_TT_NEWSCHED is not set
@@ -1374,7 +1379,6 @@ CONFIG_USB_STORAGE=m
1374# CONFIG_USB_LD is not set 1379# CONFIG_USB_LD is not set
1375# CONFIG_USB_TRANCEVIBRATOR is not set 1380# CONFIG_USB_TRANCEVIBRATOR is not set
1376# CONFIG_USB_IOWARRIOR is not set 1381# CONFIG_USB_IOWARRIOR is not set
1377# CONFIG_USB_TEST is not set
1378# CONFIG_USB_ISIGHTFW is not set 1382# CONFIG_USB_ISIGHTFW is not set
1379# CONFIG_USB_VST is not set 1383# CONFIG_USB_VST is not set
1380# CONFIG_USB_GADGET is not set 1384# CONFIG_USB_GADGET is not set
@@ -1420,6 +1424,7 @@ CONFIG_RTC_INTF_DEV=y
1420# CONFIG_RTC_DRV_S35390A is not set 1424# CONFIG_RTC_DRV_S35390A is not set
1421# CONFIG_RTC_DRV_FM3130 is not set 1425# CONFIG_RTC_DRV_FM3130 is not set
1422# CONFIG_RTC_DRV_RX8581 is not set 1426# CONFIG_RTC_DRV_RX8581 is not set
1427# CONFIG_RTC_DRV_RX8025 is not set
1423 1428
1424# 1429#
1425# SPI RTC drivers 1430# SPI RTC drivers
@@ -1448,6 +1453,10 @@ CONFIG_RTC_DRV_STARFIRE=y
1448# CONFIG_DMADEVICES is not set 1453# CONFIG_DMADEVICES is not set
1449# CONFIG_AUXDISPLAY is not set 1454# CONFIG_AUXDISPLAY is not set
1450# CONFIG_UIO is not set 1455# CONFIG_UIO is not set
1456
1457#
1458# TI VLYNQ
1459#
1451# CONFIG_STAGING is not set 1460# CONFIG_STAGING is not set
1452 1461
1453# 1462#
@@ -1480,11 +1489,11 @@ CONFIG_FS_MBCACHE=y
1480# CONFIG_REISERFS_FS is not set 1489# CONFIG_REISERFS_FS is not set
1481# CONFIG_JFS_FS is not set 1490# CONFIG_JFS_FS is not set
1482CONFIG_FS_POSIX_ACL=y 1491CONFIG_FS_POSIX_ACL=y
1483CONFIG_FILE_LOCKING=y
1484# CONFIG_XFS_FS is not set 1492# CONFIG_XFS_FS is not set
1485# CONFIG_GFS2_FS is not set 1493# CONFIG_GFS2_FS is not set
1486# CONFIG_OCFS2_FS is not set 1494# CONFIG_OCFS2_FS is not set
1487# CONFIG_BTRFS_FS is not set 1495# CONFIG_BTRFS_FS is not set
1496CONFIG_FILE_LOCKING=y
1488CONFIG_FSNOTIFY=y 1497CONFIG_FSNOTIFY=y
1489CONFIG_DNOTIFY=y 1498CONFIG_DNOTIFY=y
1490CONFIG_INOTIFY=y 1499CONFIG_INOTIFY=y
@@ -1560,7 +1569,7 @@ CONFIG_NETWORK_FILESYSTEMS=y
1560# CONFIG_PARTITION_ADVANCED is not set 1569# CONFIG_PARTITION_ADVANCED is not set
1561CONFIG_MSDOS_PARTITION=y 1570CONFIG_MSDOS_PARTITION=y
1562CONFIG_SUN_PARTITION=y 1571CONFIG_SUN_PARTITION=y
1563CONFIG_NLS=m 1572CONFIG_NLS=y
1564CONFIG_NLS_DEFAULT="iso8859-1" 1573CONFIG_NLS_DEFAULT="iso8859-1"
1565# CONFIG_NLS_CODEPAGE_437 is not set 1574# CONFIG_NLS_CODEPAGE_437 is not set
1566# CONFIG_NLS_CODEPAGE_737 is not set 1575# CONFIG_NLS_CODEPAGE_737 is not set
diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h
index b049abf9902f..0ff92fa22064 100644
--- a/arch/sparc/include/asm/pgtable_64.h
+++ b/arch/sparc/include/asm/pgtable_64.h
@@ -726,11 +726,17 @@ extern unsigned long pte_file(pte_t);
726extern pte_t pgoff_to_pte(unsigned long); 726extern pte_t pgoff_to_pte(unsigned long);
727#define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL) 727#define PTE_FILE_MAX_BITS (64UL - PAGE_SHIFT - 1UL)
728 728
729extern unsigned long *sparc64_valid_addr_bitmap; 729extern unsigned long sparc64_valid_addr_bitmap[];
730 730
731/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */ 731/* Needs to be defined here and not in linux/mm.h, as it is arch dependent */
732#define kern_addr_valid(addr) \ 732static inline bool kern_addr_valid(unsigned long addr)
733 (test_bit(__pa((unsigned long)(addr))>>22, sparc64_valid_addr_bitmap)) 733{
734 unsigned long paddr = __pa(addr);
735
736 if ((paddr >> 41UL) != 0UL)
737 return false;
738 return test_bit(paddr >> 22, sparc64_valid_addr_bitmap);
739}
734 740
735extern int page_in_phys_avail(unsigned long paddr); 741extern int page_in_phys_avail(unsigned long paddr);
736 742
diff --git a/arch/sparc/kernel/ktlb.S b/arch/sparc/kernel/ktlb.S
index cef8defcd7a9..3ea6e8cde8c5 100644
--- a/arch/sparc/kernel/ktlb.S
+++ b/arch/sparc/kernel/ktlb.S
@@ -151,12 +151,46 @@ kvmap_dtlb_4v:
151 * Must preserve %g1 and %g6 (TAG). 151 * Must preserve %g1 and %g6 (TAG).
152 */ 152 */
153kvmap_dtlb_tsb4m_miss: 153kvmap_dtlb_tsb4m_miss:
154 sethi %hi(kpte_linear_bitmap), %g2 154 /* Clear the PAGE_OFFSET top virtual bits, shift
155 or %g2, %lo(kpte_linear_bitmap), %g2 155 * down to get PFN, and make sure PFN is in range.
156 */
157 sllx %g4, 21, %g5
156 158
157 /* Clear the PAGE_OFFSET top virtual bits, then shift 159 /* Check to see if we know about valid memory at the 4MB
158 * down to get a 256MB physical address index. 160 * chunk this physical address will reside within.
159 */ 161 */
162 srlx %g5, 21 + 41, %g2
163 brnz,pn %g2, kvmap_dtlb_longpath
164 nop
165
166 /* This unconditional branch and delay-slot nop gets patched
167 * by the sethi sequence once the bitmap is properly setup.
168 */
169 .globl valid_addr_bitmap_insn
170valid_addr_bitmap_insn:
171 ba,pt %xcc, 2f
172 nop
173 .subsection 2
174 .globl valid_addr_bitmap_patch
175valid_addr_bitmap_patch:
176 sethi %hi(sparc64_valid_addr_bitmap), %g7
177 or %g7, %lo(sparc64_valid_addr_bitmap), %g7
178 .previous
179
180 srlx %g5, 21 + 22, %g2
181 srlx %g2, 6, %g5
182 and %g2, 63, %g2
183 sllx %g5, 3, %g5
184 ldx [%g7 + %g5], %g5
185 mov 1, %g7
186 sllx %g7, %g2, %g7
187 andcc %g5, %g7, %g0
188 be,pn %xcc, kvmap_dtlb_longpath
189
1902: sethi %hi(kpte_linear_bitmap), %g2
191 or %g2, %lo(kpte_linear_bitmap), %g2
192
193 /* Get the 256MB physical address index. */
160 sllx %g4, 21, %g5 194 sllx %g4, 21, %g5
161 mov 1, %g7 195 mov 1, %g7
162 srlx %g5, 21 + 28, %g5 196 srlx %g5, 21 + 28, %g5
diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
index fa44eaf8d897..3691907a43b4 100644
--- a/arch/sparc/kernel/smp_64.c
+++ b/arch/sparc/kernel/smp_64.c
@@ -1499,7 +1499,7 @@ void __init setup_per_cpu_areas(void)
1499 dyn_size = pcpur_size - static_size - PERCPU_MODULE_RESERVE; 1499 dyn_size = pcpur_size - static_size - PERCPU_MODULE_RESERVE;
1500 1500
1501 1501
1502 ptrs_size = PFN_ALIGN(num_possible_cpus() * sizeof(pcpur_ptrs[0])); 1502 ptrs_size = PFN_ALIGN(nr_cpu_ids * sizeof(pcpur_ptrs[0]));
1503 pcpur_ptrs = alloc_bootmem(ptrs_size); 1503 pcpur_ptrs = alloc_bootmem(ptrs_size);
1504 1504
1505 for_each_possible_cpu(cpu) { 1505 for_each_possible_cpu(cpu) {
@@ -1514,7 +1514,7 @@ void __init setup_per_cpu_areas(void)
1514 1514
1515 /* allocate address and map */ 1515 /* allocate address and map */
1516 vm.flags = VM_ALLOC; 1516 vm.flags = VM_ALLOC;
1517 vm.size = num_possible_cpus() * PCPU_CHUNK_SIZE; 1517 vm.size = nr_cpu_ids * PCPU_CHUNK_SIZE;
1518 vm_area_register_early(&vm, PCPU_CHUNK_SIZE); 1518 vm_area_register_early(&vm, PCPU_CHUNK_SIZE);
1519 1519
1520 for_each_possible_cpu(cpu) { 1520 for_each_possible_cpu(cpu) {
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index 54fb02468f0d..68791cad7b74 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -162,9 +162,6 @@ extern void cpu_panic(void);
162 */ 162 */
163 163
164extern struct linux_prom_registers smp_penguin_ctable; 164extern struct linux_prom_registers smp_penguin_ctable;
165extern unsigned long trapbase_cpu1[];
166extern unsigned long trapbase_cpu2[];
167extern unsigned long trapbase_cpu3[];
168 165
169void __init smp4d_boot_cpus(void) 166void __init smp4d_boot_cpus(void)
170{ 167{
@@ -235,25 +232,6 @@ void __init smp4d_smp_done(void)
235 *prev = first; 232 *prev = first;
236 local_flush_cache_all(); 233 local_flush_cache_all();
237 234
238 /* Free unneeded trap tables */
239 ClearPageReserved(virt_to_page(trapbase_cpu1));
240 init_page_count(virt_to_page(trapbase_cpu1));
241 free_page((unsigned long)trapbase_cpu1);
242 totalram_pages++;
243 num_physpages++;
244
245 ClearPageReserved(virt_to_page(trapbase_cpu2));
246 init_page_count(virt_to_page(trapbase_cpu2));
247 free_page((unsigned long)trapbase_cpu2);
248 totalram_pages++;
249 num_physpages++;
250
251 ClearPageReserved(virt_to_page(trapbase_cpu3));
252 init_page_count(virt_to_page(trapbase_cpu3));
253 free_page((unsigned long)trapbase_cpu3);
254 totalram_pages++;
255 num_physpages++;
256
257 /* Ok, they are spinning and ready to go. */ 235 /* Ok, they are spinning and ready to go. */
258 smp_processors_ready = 1; 236 smp_processors_ready = 1;
259 sun4d_distribute_irqs(); 237 sun4d_distribute_irqs();
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index 960b113d0006..762d6eedd944 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -121,9 +121,6 @@ void __cpuinit smp4m_callin(void)
121 */ 121 */
122 122
123extern struct linux_prom_registers smp_penguin_ctable; 123extern struct linux_prom_registers smp_penguin_ctable;
124extern unsigned long trapbase_cpu1[];
125extern unsigned long trapbase_cpu2[];
126extern unsigned long trapbase_cpu3[];
127 124
128void __init smp4m_boot_cpus(void) 125void __init smp4m_boot_cpus(void)
129{ 126{
@@ -193,29 +190,6 @@ void __init smp4m_smp_done(void)
193 *prev = first; 190 *prev = first;
194 local_flush_cache_all(); 191 local_flush_cache_all();
195 192
196 /* Free unneeded trap tables */
197 if (!cpu_isset(1, cpu_present_map)) {
198 ClearPageReserved(virt_to_page(trapbase_cpu1));
199 init_page_count(virt_to_page(trapbase_cpu1));
200 free_page((unsigned long)trapbase_cpu1);
201 totalram_pages++;
202 num_physpages++;
203 }
204 if (!cpu_isset(2, cpu_present_map)) {
205 ClearPageReserved(virt_to_page(trapbase_cpu2));
206 init_page_count(virt_to_page(trapbase_cpu2));
207 free_page((unsigned long)trapbase_cpu2);
208 totalram_pages++;
209 num_physpages++;
210 }
211 if (!cpu_isset(3, cpu_present_map)) {
212 ClearPageReserved(virt_to_page(trapbase_cpu3));
213 init_page_count(virt_to_page(trapbase_cpu3));
214 free_page((unsigned long)trapbase_cpu3);
215 totalram_pages++;
216 num_physpages++;
217 }
218
219 /* Ok, they are spinning and ready to go. */ 193 /* Ok, they are spinning and ready to go. */
220} 194}
221 195
diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S
index f061c4dda9ef..aed94869ad6a 100644
--- a/arch/sparc/kernel/sys32.S
+++ b/arch/sparc/kernel/sys32.S
@@ -134,10 +134,12 @@ SIGN1(sys32_getpeername, sys_getpeername, %o0)
134SIGN1(sys32_getsockname, sys_getsockname, %o0) 134SIGN1(sys32_getsockname, sys_getsockname, %o0)
135SIGN2(sys32_ioprio_get, sys_ioprio_get, %o0, %o1) 135SIGN2(sys32_ioprio_get, sys_ioprio_get, %o0, %o1)
136SIGN3(sys32_ioprio_set, sys_ioprio_set, %o0, %o1, %o2) 136SIGN3(sys32_ioprio_set, sys_ioprio_set, %o0, %o1, %o2)
137SIGN2(sys32_splice, sys_splice, %o0, %o1) 137SIGN2(sys32_splice, sys_splice, %o0, %o2)
138SIGN2(sys32_sync_file_range, compat_sync_file_range, %o0, %o5) 138SIGN2(sys32_sync_file_range, compat_sync_file_range, %o0, %o5)
139SIGN2(sys32_tee, sys_tee, %o0, %o1) 139SIGN2(sys32_tee, sys_tee, %o0, %o1)
140SIGN1(sys32_vmsplice, compat_sys_vmsplice, %o0) 140SIGN1(sys32_vmsplice, compat_sys_vmsplice, %o0)
141SIGN1(sys32_truncate, sys_truncate, %o1)
142SIGN1(sys32_ftruncate, sys_ftruncate, %o1)
141 143
142 .globl sys32_mmap2 144 .globl sys32_mmap2
143sys32_mmap2: 145sys32_mmap2:
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S
index 6b3ee88e253c..2ee7250ba7ae 100644
--- a/arch/sparc/kernel/systbls_64.S
+++ b/arch/sparc/kernel/systbls_64.S
@@ -43,8 +43,8 @@ sys_call_table32:
43/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall 43/*110*/ .word sys_setresgid, sys_getresgid, sys_setregid, sys_nis_syscall, sys_nis_syscall
44 .word sys32_getgroups, compat_sys_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd 44 .word sys32_getgroups, compat_sys_gettimeofday, sys32_getrusage, sys_nis_syscall, sys_getcwd
45/*120*/ .word compat_sys_readv, compat_sys_writev, compat_sys_settimeofday, sys_fchown16, sys_fchmod 45/*120*/ .word compat_sys_readv, compat_sys_writev, compat_sys_settimeofday, sys_fchown16, sys_fchmod
46 .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys_truncate 46 .word sys_nis_syscall, sys_setreuid16, sys_setregid16, sys_rename, sys32_truncate
47/*130*/ .word sys_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall 47/*130*/ .word sys32_ftruncate, sys_flock, compat_sys_lstat64, sys_nis_syscall, sys_nis_syscall
48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64 48 .word sys_nis_syscall, sys32_mkdir, sys_rmdir, compat_sys_utimes, compat_sys_stat64
49/*140*/ .word sys32_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit 49/*140*/ .word sys32_sendfile64, sys_nis_syscall, sys32_futex, sys_gettid, compat_sys_getrlimit
50 .word compat_sys_setrlimit, sys_pivot_root, sys32_prctl, sys_pciconfig_read, sys_pciconfig_write 50 .word compat_sys_setrlimit, sys_pivot_root, sys32_prctl, sys_pciconfig_read, sys_pciconfig_write
diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
index a5e30c642ee3..b99f81c4906f 100644
--- a/arch/sparc/mm/fault_32.c
+++ b/arch/sparc/mm/fault_32.c
@@ -319,9 +319,10 @@ no_context:
319 */ 319 */
320out_of_memory: 320out_of_memory:
321 up_read(&mm->mmap_sem); 321 up_read(&mm->mmap_sem);
322 printk("VM: killing process %s\n", tsk->comm); 322 if (from_user) {
323 if (from_user) 323 pagefault_out_of_memory();
324 do_group_exit(SIGKILL); 324 return;
325 }
325 goto no_context; 326 goto no_context;
326 327
327do_sigbus: 328do_sigbus:
diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
index e5620b27c8bf..43b0da96a4fb 100644
--- a/arch/sparc/mm/fault_64.c
+++ b/arch/sparc/mm/fault_64.c
@@ -447,9 +447,10 @@ handle_kernel_fault:
447out_of_memory: 447out_of_memory:
448 insn = get_fault_insn(regs, insn); 448 insn = get_fault_insn(regs, insn);
449 up_read(&mm->mmap_sem); 449 up_read(&mm->mmap_sem);
450 printk("VM: killing process %s\n", current->comm); 450 if (!(regs->tstate & TSTATE_PRIV)) {
451 if (!(regs->tstate & TSTATE_PRIV)) 451 pagefault_out_of_memory();
452 do_group_exit(SIGKILL); 452 return;
453 }
453 goto handle_kernel_fault; 454 goto handle_kernel_fault;
454 455
455intr_or_no_mm: 456intr_or_no_mm:
diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
index ed6be6ba2f4e..a70a5e1904d9 100644
--- a/arch/sparc/mm/init_64.c
+++ b/arch/sparc/mm/init_64.c
@@ -145,7 +145,8 @@ static void __init read_obp_memory(const char *property,
145 cmp_p64, NULL); 145 cmp_p64, NULL);
146} 146}
147 147
148unsigned long *sparc64_valid_addr_bitmap __read_mostly; 148unsigned long sparc64_valid_addr_bitmap[VALID_ADDR_BITMAP_BYTES /
149 sizeof(unsigned long)];
149EXPORT_SYMBOL(sparc64_valid_addr_bitmap); 150EXPORT_SYMBOL(sparc64_valid_addr_bitmap);
150 151
151/* Kernel physical address base and size in bytes. */ 152/* Kernel physical address base and size in bytes. */
@@ -1874,7 +1875,7 @@ static int pavail_rescan_ents __initdata;
1874 * memory list again, and make sure it provides at least as much 1875 * memory list again, and make sure it provides at least as much
1875 * memory as 'pavail' does. 1876 * memory as 'pavail' does.
1876 */ 1877 */
1877static void __init setup_valid_addr_bitmap_from_pavail(void) 1878static void __init setup_valid_addr_bitmap_from_pavail(unsigned long *bitmap)
1878{ 1879{
1879 int i; 1880 int i;
1880 1881
@@ -1897,8 +1898,7 @@ static void __init setup_valid_addr_bitmap_from_pavail(void)
1897 1898
1898 if (new_start <= old_start && 1899 if (new_start <= old_start &&
1899 new_end >= (old_start + PAGE_SIZE)) { 1900 new_end >= (old_start + PAGE_SIZE)) {
1900 set_bit(old_start >> 22, 1901 set_bit(old_start >> 22, bitmap);
1901 sparc64_valid_addr_bitmap);
1902 goto do_next_page; 1902 goto do_next_page;
1903 } 1903 }
1904 } 1904 }
@@ -1919,20 +1919,21 @@ static void __init setup_valid_addr_bitmap_from_pavail(void)
1919 } 1919 }
1920} 1920}
1921 1921
1922static void __init patch_tlb_miss_handler_bitmap(void)
1923{
1924 extern unsigned int valid_addr_bitmap_insn[];
1925 extern unsigned int valid_addr_bitmap_patch[];
1926
1927 valid_addr_bitmap_insn[1] = valid_addr_bitmap_patch[1];
1928 mb();
1929 valid_addr_bitmap_insn[0] = valid_addr_bitmap_patch[0];
1930 flushi(&valid_addr_bitmap_insn[0]);
1931}
1932
1922void __init mem_init(void) 1933void __init mem_init(void)
1923{ 1934{
1924 unsigned long codepages, datapages, initpages; 1935 unsigned long codepages, datapages, initpages;
1925 unsigned long addr, last; 1936 unsigned long addr, last;
1926 int i;
1927
1928 i = last_valid_pfn >> ((22 - PAGE_SHIFT) + 6);
1929 i += 1;
1930 sparc64_valid_addr_bitmap = (unsigned long *) alloc_bootmem(i << 3);
1931 if (sparc64_valid_addr_bitmap == NULL) {
1932 prom_printf("mem_init: Cannot alloc valid_addr_bitmap.\n");
1933 prom_halt();
1934 }
1935 memset(sparc64_valid_addr_bitmap, 0, i << 3);
1936 1937
1937 addr = PAGE_OFFSET + kern_base; 1938 addr = PAGE_OFFSET + kern_base;
1938 last = PAGE_ALIGN(kern_size) + addr; 1939 last = PAGE_ALIGN(kern_size) + addr;
@@ -1941,15 +1942,19 @@ void __init mem_init(void)
1941 addr += PAGE_SIZE; 1942 addr += PAGE_SIZE;
1942 } 1943 }
1943 1944
1944 setup_valid_addr_bitmap_from_pavail(); 1945 setup_valid_addr_bitmap_from_pavail(sparc64_valid_addr_bitmap);
1946 patch_tlb_miss_handler_bitmap();
1945 1947
1946 high_memory = __va(last_valid_pfn << PAGE_SHIFT); 1948 high_memory = __va(last_valid_pfn << PAGE_SHIFT);
1947 1949
1948#ifdef CONFIG_NEED_MULTIPLE_NODES 1950#ifdef CONFIG_NEED_MULTIPLE_NODES
1949 for_each_online_node(i) { 1951 {
1950 if (NODE_DATA(i)->node_spanned_pages != 0) { 1952 int i;
1951 totalram_pages += 1953 for_each_online_node(i) {
1952 free_all_bootmem_node(NODE_DATA(i)); 1954 if (NODE_DATA(i)->node_spanned_pages != 0) {
1955 totalram_pages +=
1956 free_all_bootmem_node(NODE_DATA(i));
1957 }
1953 } 1958 }
1954 } 1959 }
1955#else 1960#else
diff --git a/arch/sparc/mm/init_64.h b/arch/sparc/mm/init_64.h
index 16063870a489..c2f772dbd556 100644
--- a/arch/sparc/mm/init_64.h
+++ b/arch/sparc/mm/init_64.h
@@ -5,10 +5,13 @@
5 * marked non-static so that assembler code can get at them. 5 * marked non-static so that assembler code can get at them.
6 */ 6 */
7 7
8#define MAX_PHYS_ADDRESS (1UL << 42UL) 8#define MAX_PHYS_ADDRESS (1UL << 41UL)
9#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL) 9#define KPTE_BITMAP_CHUNK_SZ (256UL * 1024UL * 1024UL)
10#define KPTE_BITMAP_BYTES \ 10#define KPTE_BITMAP_BYTES \
11 ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 8) 11 ((MAX_PHYS_ADDRESS / KPTE_BITMAP_CHUNK_SZ) / 8)
12#define VALID_ADDR_BITMAP_CHUNK_SZ (4UL * 1024UL * 1024UL)
13#define VALID_ADDR_BITMAP_BYTES \
14 ((MAX_PHYS_ADDRESS / VALID_ADDR_BITMAP_CHUNK_SZ) / 8)
12 15
13extern unsigned long kern_linear_pte_xor[2]; 16extern unsigned long kern_linear_pte_xor[2];
14extern unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)]; 17extern unsigned long kpte_linear_bitmap[KPTE_BITMAP_BYTES / sizeof(unsigned long)];
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 738bdc6b0f8b..13ffa5df37d7 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -24,6 +24,7 @@ config X86
24 select HAVE_UNSTABLE_SCHED_CLOCK 24 select HAVE_UNSTABLE_SCHED_CLOCK
25 select HAVE_IDE 25 select HAVE_IDE
26 select HAVE_OPROFILE 26 select HAVE_OPROFILE
27 select HAVE_PERF_COUNTERS if (!M386 && !M486)
27 select HAVE_IOREMAP_PROT 28 select HAVE_IOREMAP_PROT
28 select HAVE_KPROBES 29 select HAVE_KPROBES
29 select ARCH_WANT_OPTIONAL_GPIOLIB 30 select ARCH_WANT_OPTIONAL_GPIOLIB
@@ -742,7 +743,6 @@ config X86_UP_IOAPIC
742config X86_LOCAL_APIC 743config X86_LOCAL_APIC
743 def_bool y 744 def_bool y
744 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC 745 depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC
745 select HAVE_PERF_COUNTERS if (!M386 && !M486)
746 746
747config X86_IO_APIC 747config X86_IO_APIC
748 def_bool y 748 def_bool y
diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
index e2ff504b4ddc..f8ed0658404c 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -4,7 +4,7 @@
4# create a compressed vmlinux image from the original vmlinux 4# create a compressed vmlinux image from the original vmlinux
5# 5#
6 6
7targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma head_$(BITS).o misc.o piggy.o 7targets := vmlinux.lds vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2 vmlinux.bin.lzma head_$(BITS).o misc.o piggy.o
8 8
9KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2 9KBUILD_CFLAGS := -m$(BITS) -D__KERNEL__ $(LINUX_INCLUDE) -O2
10KBUILD_CFLAGS += -fno-strict-aliasing -fPIC 10KBUILD_CFLAGS += -fno-strict-aliasing -fPIC
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index edc90f23e708..8406ed7f9926 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -33,7 +33,7 @@ extern unsigned long asmlinkage efi_call_phys(void *, ...);
33#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \ 33#define efi_call_virt6(f, a1, a2, a3, a4, a5, a6) \
34 efi_call_virt(f, a1, a2, a3, a4, a5, a6) 34 efi_call_virt(f, a1, a2, a3, a4, a5, a6)
35 35
36#define efi_ioremap(addr, size) ioremap_cache(addr, size) 36#define efi_ioremap(addr, size, type) ioremap_cache(addr, size)
37 37
38#else /* !CONFIG_X86_32 */ 38#else /* !CONFIG_X86_32 */
39 39
@@ -84,7 +84,8 @@ extern u64 efi_call6(void *fp, u64 arg1, u64 arg2, u64 arg3,
84 efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \ 84 efi_call6((void *)(efi.systab->runtime->f), (u64)(a1), (u64)(a2), \
85 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6)) 85 (u64)(a3), (u64)(a4), (u64)(a5), (u64)(a6))
86 86
87extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size); 87extern void __iomem *efi_ioremap(unsigned long addr, unsigned long size,
88 u32 type);
88 89
89#endif /* CONFIG_X86_32 */ 90#endif /* CONFIG_X86_32 */
90 91
diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
index 2bdab21f0898..c6ccbe7e81ad 100644
--- a/arch/x86/include/asm/irqflags.h
+++ b/arch/x86/include/asm/irqflags.h
@@ -12,9 +12,15 @@ static inline unsigned long native_save_fl(void)
12{ 12{
13 unsigned long flags; 13 unsigned long flags;
14 14
15 /*
16 * Note: this needs to be "=r" not "=rm", because we have the
17 * stack offset from what gcc expects at the time the "pop" is
18 * executed, and so a memory reference with respect to the stack
19 * would end up using the wrong address.
20 */
15 asm volatile("# __raw_save_flags\n\t" 21 asm volatile("# __raw_save_flags\n\t"
16 "pushf ; pop %0" 22 "pushf ; pop %0"
17 : "=g" (flags) 23 : "=r" (flags)
18 : /* no input */ 24 : /* no input */
19 : "memory"); 25 : "memory");
20 26
diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
index 3cc06e3fceb8..16748077559a 100644
--- a/arch/x86/include/asm/pgtable.h
+++ b/arch/x86/include/asm/pgtable.h
@@ -2,6 +2,7 @@
2#define _ASM_X86_PGTABLE_H 2#define _ASM_X86_PGTABLE_H
3 3
4#include <asm/page.h> 4#include <asm/page.h>
5#include <asm/e820.h>
5 6
6#include <asm/pgtable_types.h> 7#include <asm/pgtable_types.h>
7 8
@@ -269,10 +270,17 @@ static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
269 270
270#define canon_pgprot(p) __pgprot(massage_pgprot(p)) 271#define canon_pgprot(p) __pgprot(massage_pgprot(p))
271 272
272static inline int is_new_memtype_allowed(unsigned long flags, 273static inline int is_new_memtype_allowed(u64 paddr, unsigned long size,
273 unsigned long new_flags) 274 unsigned long flags,
275 unsigned long new_flags)
274{ 276{
275 /* 277 /*
278 * PAT type is always WB for ISA. So no need to check.
279 */
280 if (is_ISA_range(paddr, paddr + size - 1))
281 return 1;
282
283 /*
276 * Certain new memtypes are not allowed with certain 284 * Certain new memtypes are not allowed with certain
277 * requested memtype: 285 * requested memtype:
278 * - request is uncached, return cannot be write-back 286 * - request is uncached, return cannot be write-back
diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index bddd44f2f0ab..80e2984f521c 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -133,7 +133,7 @@ struct bau_msg_payload {
133 * see table 4.2.3.0.1 in broacast_assist spec. 133 * see table 4.2.3.0.1 in broacast_assist spec.
134 */ 134 */
135struct bau_msg_header { 135struct bau_msg_header {
136 unsigned int dest_subnodeid:6; /* must be zero */ 136 unsigned int dest_subnodeid:6; /* must be 0x10, for the LB */
137 /* bits 5:0 */ 137 /* bits 5:0 */
138 unsigned int base_dest_nodeid:15; /* nasid>>1 (pnode) of */ 138 unsigned int base_dest_nodeid:15; /* nasid>>1 (pnode) of */
139 /* bits 20:6 */ /* first bit in node_map */ 139 /* bits 20:6 */ /* first bit in node_map */
diff --git a/arch/x86/include/asm/uv/uv_hub.h b/arch/x86/include/asm/uv/uv_hub.h
index 341070f7ad5c..77a68505419a 100644
--- a/arch/x86/include/asm/uv/uv_hub.h
+++ b/arch/x86/include/asm/uv/uv_hub.h
@@ -175,7 +175,7 @@ DECLARE_PER_CPU(struct uv_hub_info_s, __uv_hub_info);
175#define UV_GLOBAL_MMR32_PNODE_BITS(p) ((p) << (UV_GLOBAL_MMR32_PNODE_SHIFT)) 175#define UV_GLOBAL_MMR32_PNODE_BITS(p) ((p) << (UV_GLOBAL_MMR32_PNODE_SHIFT))
176 176
177#define UV_GLOBAL_MMR64_PNODE_BITS(p) \ 177#define UV_GLOBAL_MMR64_PNODE_BITS(p) \
178 ((unsigned long)(UV_PNODE_TO_GNODE(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT) 178 (((unsigned long)(p)) << UV_GLOBAL_MMR64_PNODE_SHIFT)
179 179
180#define UV_APIC_PNODE_SHIFT 6 180#define UV_APIC_PNODE_SHIFT 6
181 181
@@ -327,6 +327,7 @@ struct uv_blade_info {
327 unsigned short nr_possible_cpus; 327 unsigned short nr_possible_cpus;
328 unsigned short nr_online_cpus; 328 unsigned short nr_online_cpus;
329 unsigned short pnode; 329 unsigned short pnode;
330 short memory_nid;
330}; 331};
331extern struct uv_blade_info *uv_blade_info; 332extern struct uv_blade_info *uv_blade_info;
332extern short *uv_node_to_blade; 333extern short *uv_node_to_blade;
@@ -363,6 +364,12 @@ static inline int uv_blade_to_pnode(int bid)
363 return uv_blade_info[bid].pnode; 364 return uv_blade_info[bid].pnode;
364} 365}
365 366
367/* Nid of memory node on blade. -1 if no blade-local memory */
368static inline int uv_blade_to_memory_nid(int bid)
369{
370 return uv_blade_info[bid].memory_nid;
371}
372
366/* Determine the number of possible cpus on a blade */ 373/* Determine the number of possible cpus on a blade */
367static inline int uv_blade_nr_possible_cpus(int bid) 374static inline int uv_blade_nr_possible_cpus(int bid)
368{ 375{
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 2284a4812b68..d2ed6c5ddc80 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -3793,6 +3793,9 @@ int arch_enable_uv_irq(char *irq_name, unsigned int irq, int cpu, int mmr_blade,
3793 mmr_pnode = uv_blade_to_pnode(mmr_blade); 3793 mmr_pnode = uv_blade_to_pnode(mmr_blade);
3794 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value); 3794 uv_write_global_mmr64(mmr_pnode, mmr_offset, mmr_value);
3795 3795
3796 if (cfg->move_in_progress)
3797 send_cleanup_vector(cfg);
3798
3796 return irq; 3799 return irq;
3797} 3800}
3798 3801
diff --git a/arch/x86/kernel/apic/ipi.c b/arch/x86/kernel/apic/ipi.c
index dbf5445727a9..6ef00ba4c886 100644
--- a/arch/x86/kernel/apic/ipi.c
+++ b/arch/x86/kernel/apic/ipi.c
@@ -106,6 +106,9 @@ void default_send_IPI_mask_logical(const struct cpumask *cpumask, int vector)
106 unsigned long mask = cpumask_bits(cpumask)[0]; 106 unsigned long mask = cpumask_bits(cpumask)[0];
107 unsigned long flags; 107 unsigned long flags;
108 108
109 if (WARN_ONCE(!mask, "empty IPI mask"))
110 return;
111
109 local_irq_save(flags); 112 local_irq_save(flags);
110 WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]); 113 WARN_ON(mask & ~cpumask_bits(cpu_online_mask)[0]);
111 __default_send_IPI_dest_field(mask, vector, apic->dest_logical); 114 __default_send_IPI_dest_field(mask, vector, apic->dest_logical);
diff --git a/arch/x86/kernel/apic/probe_64.c b/arch/x86/kernel/apic/probe_64.c
index bc3e880f9b82..fcec2f1d34a1 100644
--- a/arch/x86/kernel/apic/probe_64.c
+++ b/arch/x86/kernel/apic/probe_64.c
@@ -44,6 +44,11 @@ static struct apic *apic_probe[] __initdata = {
44 NULL, 44 NULL,
45}; 45};
46 46
47static int apicid_phys_pkg_id(int initial_apic_id, int index_msb)
48{
49 return hard_smp_processor_id() >> index_msb;
50}
51
47/* 52/*
48 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode. 53 * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
49 */ 54 */
@@ -69,6 +74,11 @@ void __init default_setup_apic_routing(void)
69 printk(KERN_INFO "Setting APIC routing to %s\n", apic->name); 74 printk(KERN_INFO "Setting APIC routing to %s\n", apic->name);
70 } 75 }
71 76
77 if (is_vsmp_box()) {
78 /* need to update phys_pkg_id */
79 apic->phys_pkg_id = apicid_phys_pkg_id;
80 }
81
72 /* 82 /*
73 * Now that apic routing model is selected, configure the 83 * Now that apic routing model is selected, configure the
74 * fault handling for intr remapping. 84 * fault handling for intr remapping.
diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
index 8e4cbb255c38..a5371ec36776 100644
--- a/arch/x86/kernel/apic/x2apic_cluster.c
+++ b/arch/x86/kernel/apic/x2apic_cluster.c
@@ -17,11 +17,13 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
17 return x2apic_enabled(); 17 return x2apic_enabled();
18} 18}
19 19
20/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ 20/*
21 21 * need to use more than cpu 0, because we need more vectors when
22 * MSI-X are used.
23 */
22static const struct cpumask *x2apic_target_cpus(void) 24static const struct cpumask *x2apic_target_cpus(void)
23{ 25{
24 return cpumask_of(0); 26 return cpu_online_mask;
25} 27}
26 28
27/* 29/*
@@ -170,7 +172,7 @@ static unsigned long set_apic_id(unsigned int id)
170 172
171static int x2apic_cluster_phys_pkg_id(int initial_apicid, int index_msb) 173static int x2apic_cluster_phys_pkg_id(int initial_apicid, int index_msb)
172{ 174{
173 return current_cpu_data.initial_apicid >> index_msb; 175 return initial_apicid >> index_msb;
174} 176}
175 177
176static void x2apic_send_IPI_self(int vector) 178static void x2apic_send_IPI_self(int vector)
diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
index a284359627e7..a8989aadc99a 100644
--- a/arch/x86/kernel/apic/x2apic_phys.c
+++ b/arch/x86/kernel/apic/x2apic_phys.c
@@ -27,11 +27,13 @@ static int x2apic_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
27 return 0; 27 return 0;
28} 28}
29 29
30/* Start with all IRQs pointing to boot CPU. IRQ balancing will shift them. */ 30/*
31 31 * need to use more than cpu 0, because we need more vectors when
32 * MSI-X are used.
33 */
32static const struct cpumask *x2apic_target_cpus(void) 34static const struct cpumask *x2apic_target_cpus(void)
33{ 35{
34 return cpumask_of(0); 36 return cpu_online_mask;
35} 37}
36 38
37static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask) 39static void x2apic_vector_allocation_domain(int cpu, struct cpumask *retmask)
@@ -162,7 +164,7 @@ static unsigned long set_apic_id(unsigned int id)
162 164
163static int x2apic_phys_pkg_id(int initial_apicid, int index_msb) 165static int x2apic_phys_pkg_id(int initial_apicid, int index_msb)
164{ 166{
165 return current_cpu_data.initial_apicid >> index_msb; 167 return initial_apicid >> index_msb;
166} 168}
167 169
168static void x2apic_send_IPI_self(int vector) 170static void x2apic_send_IPI_self(int vector)
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
index 096d19aea2f7..601159374e87 100644
--- a/arch/x86/kernel/apic/x2apic_uv_x.c
+++ b/arch/x86/kernel/apic/x2apic_uv_x.c
@@ -46,7 +46,7 @@ static int early_get_nodeid(void)
46 return node_id.s.node_id; 46 return node_id.s.node_id;
47} 47}
48 48
49static int uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id) 49static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
50{ 50{
51 if (!strcmp(oem_id, "SGI")) { 51 if (!strcmp(oem_id, "SGI")) {
52 if (!strcmp(oem_table_id, "UVL")) 52 if (!strcmp(oem_table_id, "UVL"))
@@ -253,7 +253,7 @@ static void uv_send_IPI_self(int vector)
253 apic_write(APIC_SELF_IPI, vector); 253 apic_write(APIC_SELF_IPI, vector);
254} 254}
255 255
256struct apic apic_x2apic_uv_x = { 256struct apic __refdata apic_x2apic_uv_x = {
257 257
258 .name = "UV large system", 258 .name = "UV large system",
259 .probe = NULL, 259 .probe = NULL,
@@ -261,7 +261,7 @@ struct apic apic_x2apic_uv_x = {
261 .apic_id_registered = uv_apic_id_registered, 261 .apic_id_registered = uv_apic_id_registered,
262 262
263 .irq_delivery_mode = dest_Fixed, 263 .irq_delivery_mode = dest_Fixed,
264 .irq_dest_mode = 1, /* logical */ 264 .irq_dest_mode = 0, /* physical */
265 265
266 .target_cpus = uv_target_cpus, 266 .target_cpus = uv_target_cpus,
267 .disable_esr = 0, 267 .disable_esr = 0,
@@ -362,12 +362,6 @@ static __init void get_lowmem_redirect(unsigned long *base, unsigned long *size)
362 BUG(); 362 BUG();
363} 363}
364 364
365static __init void map_low_mmrs(void)
366{
367 init_extra_mapping_uc(UV_GLOBAL_MMR32_BASE, UV_GLOBAL_MMR32_SIZE);
368 init_extra_mapping_uc(UV_LOCAL_MMR_BASE, UV_LOCAL_MMR_SIZE);
369}
370
371enum map_type {map_wb, map_uc}; 365enum map_type {map_wb, map_uc};
372 366
373static __init void map_high(char *id, unsigned long base, int shift, 367static __init void map_high(char *id, unsigned long base, int shift,
@@ -395,26 +389,6 @@ static __init void map_gru_high(int max_pnode)
395 map_high("GRU", gru.s.base, shift, max_pnode, map_wb); 389 map_high("GRU", gru.s.base, shift, max_pnode, map_wb);
396} 390}
397 391
398static __init void map_config_high(int max_pnode)
399{
400 union uvh_rh_gam_cfg_overlay_config_mmr_u cfg;
401 int shift = UVH_RH_GAM_CFG_OVERLAY_CONFIG_MMR_BASE_SHFT;
402
403 cfg.v = uv_read_local_mmr(UVH_RH_GAM_CFG_OVERLAY_CONFIG_MMR);
404 if (cfg.s.enable)
405 map_high("CONFIG", cfg.s.base, shift, max_pnode, map_uc);
406}
407
408static __init void map_mmr_high(int max_pnode)
409{
410 union uvh_rh_gam_mmr_overlay_config_mmr_u mmr;
411 int shift = UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR_BASE_SHFT;
412
413 mmr.v = uv_read_local_mmr(UVH_RH_GAM_MMR_OVERLAY_CONFIG_MMR);
414 if (mmr.s.enable)
415 map_high("MMR", mmr.s.base, shift, max_pnode, map_uc);
416}
417
418static __init void map_mmioh_high(int max_pnode) 392static __init void map_mmioh_high(int max_pnode)
419{ 393{
420 union uvh_rh_gam_mmioh_overlay_config_mmr_u mmioh; 394 union uvh_rh_gam_mmioh_overlay_config_mmr_u mmioh;
@@ -566,8 +540,6 @@ void __init uv_system_init(void)
566 unsigned long mmr_base, present, paddr; 540 unsigned long mmr_base, present, paddr;
567 unsigned short pnode_mask; 541 unsigned short pnode_mask;
568 542
569 map_low_mmrs();
570
571 m_n_config.v = uv_read_local_mmr(UVH_SI_ADDR_MAP_CONFIG); 543 m_n_config.v = uv_read_local_mmr(UVH_SI_ADDR_MAP_CONFIG);
572 m_val = m_n_config.s.m_skt; 544 m_val = m_n_config.s.m_skt;
573 n_val = m_n_config.s.n_skt; 545 n_val = m_n_config.s.n_skt;
@@ -591,6 +563,8 @@ void __init uv_system_init(void)
591 bytes = sizeof(struct uv_blade_info) * uv_num_possible_blades(); 563 bytes = sizeof(struct uv_blade_info) * uv_num_possible_blades();
592 uv_blade_info = kmalloc(bytes, GFP_KERNEL); 564 uv_blade_info = kmalloc(bytes, GFP_KERNEL);
593 BUG_ON(!uv_blade_info); 565 BUG_ON(!uv_blade_info);
566 for (blade = 0; blade < uv_num_possible_blades(); blade++)
567 uv_blade_info[blade].memory_nid = -1;
594 568
595 get_lowmem_redirect(&lowmem_redir_base, &lowmem_redir_size); 569 get_lowmem_redirect(&lowmem_redir_base, &lowmem_redir_size);
596 570
@@ -629,6 +603,9 @@ void __init uv_system_init(void)
629 lcpu = uv_blade_info[blade].nr_possible_cpus; 603 lcpu = uv_blade_info[blade].nr_possible_cpus;
630 uv_blade_info[blade].nr_possible_cpus++; 604 uv_blade_info[blade].nr_possible_cpus++;
631 605
606 /* Any node on the blade, else will contain -1. */
607 uv_blade_info[blade].memory_nid = nid;
608
632 uv_cpu_hub_info(cpu)->lowmem_remap_base = lowmem_redir_base; 609 uv_cpu_hub_info(cpu)->lowmem_remap_base = lowmem_redir_base;
633 uv_cpu_hub_info(cpu)->lowmem_remap_top = lowmem_redir_size; 610 uv_cpu_hub_info(cpu)->lowmem_remap_top = lowmem_redir_size;
634 uv_cpu_hub_info(cpu)->m_val = m_val; 611 uv_cpu_hub_info(cpu)->m_val = m_val;
@@ -662,11 +639,10 @@ void __init uv_system_init(void)
662 pnode = (paddr >> m_val) & pnode_mask; 639 pnode = (paddr >> m_val) & pnode_mask;
663 blade = boot_pnode_to_blade(pnode); 640 blade = boot_pnode_to_blade(pnode);
664 uv_node_to_blade[nid] = blade; 641 uv_node_to_blade[nid] = blade;
642 max_pnode = max(pnode, max_pnode);
665 } 643 }
666 644
667 map_gru_high(max_pnode); 645 map_gru_high(max_pnode);
668 map_mmr_high(max_pnode);
669 map_config_high(max_pnode);
670 map_mmioh_high(max_pnode); 646 map_mmioh_high(max_pnode);
671 647
672 uv_cpu_init(); 648 uv_cpu_init();
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
index 79302e9a33a4..442b5508893f 100644
--- a/arch/x86/kernel/apm_32.c
+++ b/arch/x86/kernel/apm_32.c
@@ -811,7 +811,7 @@ static int apm_do_idle(void)
811 u8 ret = 0; 811 u8 ret = 0;
812 int idled = 0; 812 int idled = 0;
813 int polling; 813 int polling;
814 int err; 814 int err = 0;
815 815
816 polling = !!(current_thread_info()->status & TS_POLLING); 816 polling = !!(current_thread_info()->status & TS_POLLING);
817 if (polling) { 817 if (polling) {
diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
index 3efcb2b96a15..c1f253dac155 100644
--- a/arch/x86/kernel/cpu/Makefile
+++ b/arch/x86/kernel/cpu/Makefile
@@ -7,6 +7,10 @@ ifdef CONFIG_FUNCTION_TRACER
7CFLAGS_REMOVE_common.o = -pg 7CFLAGS_REMOVE_common.o = -pg
8endif 8endif
9 9
10# Make sure load_percpu_segment has no stackprotector
11nostackp := $(call cc-option, -fno-stack-protector)
12CFLAGS_common.o := $(nostackp)
13
10obj-y := intel_cacheinfo.o addon_cpuid_features.o 14obj-y := intel_cacheinfo.o addon_cpuid_features.o
11obj-y += proc.o capflags.o powerflags.o common.o 15obj-y += proc.o capflags.o powerflags.o common.o
12obj-y += vmware.o hypervisor.o 16obj-y += vmware.o hypervisor.o
diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index e2485b03f1cf..63fddcd082cd 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -400,6 +400,13 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
400 level = cpuid_eax(1); 400 level = cpuid_eax(1);
401 if((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58) 401 if((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)
402 set_cpu_cap(c, X86_FEATURE_REP_GOOD); 402 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
403
404 /*
405 * Some BIOSes incorrectly force this feature, but only K8
406 * revision D (model = 0x14) and later actually support it.
407 */
408 if (c->x86_model < 0x14)
409 clear_cpu_cap(c, X86_FEATURE_LAHF_LM);
403 } 410 }
404 if (c->x86 == 0x10 || c->x86 == 0x11) 411 if (c->x86 == 0x10 || c->x86 == 0x11)
405 set_cpu_cap(c, X86_FEATURE_REP_GOOD); 412 set_cpu_cap(c, X86_FEATURE_REP_GOOD);
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index f1961c07af9a..5ce60a88027b 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -59,7 +59,30 @@ void __init setup_cpu_local_masks(void)
59 alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask); 59 alloc_bootmem_cpumask_var(&cpu_sibling_setup_mask);
60} 60}
61 61
62static const struct cpu_dev *this_cpu __cpuinitdata; 62static void __cpuinit default_init(struct cpuinfo_x86 *c)
63{
64#ifdef CONFIG_X86_64
65 display_cacheinfo(c);
66#else
67 /* Not much we can do here... */
68 /* Check if at least it has cpuid */
69 if (c->cpuid_level == -1) {
70 /* No cpuid. It must be an ancient CPU */
71 if (c->x86 == 4)
72 strcpy(c->x86_model_id, "486");
73 else if (c->x86 == 3)
74 strcpy(c->x86_model_id, "386");
75 }
76#endif
77}
78
79static const struct cpu_dev __cpuinitconst default_cpu = {
80 .c_init = default_init,
81 .c_vendor = "Unknown",
82 .c_x86_vendor = X86_VENDOR_UNKNOWN,
83};
84
85static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
63 86
64DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = { 87DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
65#ifdef CONFIG_X86_64 88#ifdef CONFIG_X86_64
@@ -332,29 +355,6 @@ void switch_to_new_gdt(int cpu)
332 355
333static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {}; 356static const struct cpu_dev *__cpuinitdata cpu_devs[X86_VENDOR_NUM] = {};
334 357
335static void __cpuinit default_init(struct cpuinfo_x86 *c)
336{
337#ifdef CONFIG_X86_64
338 display_cacheinfo(c);
339#else
340 /* Not much we can do here... */
341 /* Check if at least it has cpuid */
342 if (c->cpuid_level == -1) {
343 /* No cpuid. It must be an ancient CPU */
344 if (c->x86 == 4)
345 strcpy(c->x86_model_id, "486");
346 else if (c->x86 == 3)
347 strcpy(c->x86_model_id, "386");
348 }
349#endif
350}
351
352static const struct cpu_dev __cpuinitconst default_cpu = {
353 .c_init = default_init,
354 .c_vendor = "Unknown",
355 .c_x86_vendor = X86_VENDOR_UNKNOWN,
356};
357
358static void __cpuinit get_model_name(struct cpuinfo_x86 *c) 358static void __cpuinit get_model_name(struct cpuinfo_x86 *c)
359{ 359{
360 unsigned int *v; 360 unsigned int *v;
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 1cfb623ce11c..01213048f62f 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -1226,8 +1226,13 @@ static void mce_init(void)
1226} 1226}
1227 1227
1228/* Add per CPU specific workarounds here */ 1228/* Add per CPU specific workarounds here */
1229static void mce_cpu_quirks(struct cpuinfo_x86 *c) 1229static int mce_cpu_quirks(struct cpuinfo_x86 *c)
1230{ 1230{
1231 if (c->x86_vendor == X86_VENDOR_UNKNOWN) {
1232 pr_info("MCE: unknown CPU type - not enabling MCE support.\n");
1233 return -EOPNOTSUPP;
1234 }
1235
1231 /* This should be disabled by the BIOS, but isn't always */ 1236 /* This should be disabled by the BIOS, but isn't always */
1232 if (c->x86_vendor == X86_VENDOR_AMD) { 1237 if (c->x86_vendor == X86_VENDOR_AMD) {
1233 if (c->x86 == 15 && banks > 4) { 1238 if (c->x86 == 15 && banks > 4) {
@@ -1273,11 +1278,20 @@ static void mce_cpu_quirks(struct cpuinfo_x86 *c)
1273 if ((c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xe)) && 1278 if ((c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xe)) &&
1274 monarch_timeout < 0) 1279 monarch_timeout < 0)
1275 monarch_timeout = USEC_PER_SEC; 1280 monarch_timeout = USEC_PER_SEC;
1281
1282 /*
1283 * There are also broken BIOSes on some Pentium M and
1284 * earlier systems:
1285 */
1286 if (c->x86 == 6 && c->x86_model <= 13 && mce_bootlog < 0)
1287 mce_bootlog = 0;
1276 } 1288 }
1277 if (monarch_timeout < 0) 1289 if (monarch_timeout < 0)
1278 monarch_timeout = 0; 1290 monarch_timeout = 0;
1279 if (mce_bootlog != 0) 1291 if (mce_bootlog != 0)
1280 mce_panic_timeout = 30; 1292 mce_panic_timeout = 30;
1293
1294 return 0;
1281} 1295}
1282 1296
1283static void __cpuinit mce_ancient_init(struct cpuinfo_x86 *c) 1297static void __cpuinit mce_ancient_init(struct cpuinfo_x86 *c)
@@ -1338,11 +1352,10 @@ void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
1338 if (!mce_available(c)) 1352 if (!mce_available(c))
1339 return; 1353 return;
1340 1354
1341 if (mce_cap_init() < 0) { 1355 if (mce_cap_init() < 0 || mce_cpu_quirks(c) < 0) {
1342 mce_disabled = 1; 1356 mce_disabled = 1;
1343 return; 1357 return;
1344 } 1358 }
1345 mce_cpu_quirks(c);
1346 1359
1347 machine_check_vector = do_machine_check; 1360 machine_check_vector = do_machine_check;
1348 1361
diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index bff8dd191dd5..5957a93e5173 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -36,6 +36,7 @@
36 36
37static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES; 37static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
38static DEFINE_PER_CPU(unsigned long, thermal_throttle_count); 38static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
39static DEFINE_PER_CPU(bool, thermal_throttle_active);
39 40
40static atomic_t therm_throt_en = ATOMIC_INIT(0); 41static atomic_t therm_throt_en = ATOMIC_INIT(0);
41 42
@@ -96,27 +97,33 @@ static int therm_throt_process(int curr)
96{ 97{
97 unsigned int cpu = smp_processor_id(); 98 unsigned int cpu = smp_processor_id();
98 __u64 tmp_jiffs = get_jiffies_64(); 99 __u64 tmp_jiffs = get_jiffies_64();
100 bool was_throttled = __get_cpu_var(thermal_throttle_active);
101 bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;
99 102
100 if (curr) 103 if (is_throttled)
101 __get_cpu_var(thermal_throttle_count)++; 104 __get_cpu_var(thermal_throttle_count)++;
102 105
103 if (time_before64(tmp_jiffs, __get_cpu_var(next_check))) 106 if (!(was_throttled ^ is_throttled) &&
107 time_before64(tmp_jiffs, __get_cpu_var(next_check)))
104 return 0; 108 return 0;
105 109
106 __get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL; 110 __get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
107 111
108 /* if we just entered the thermal event */ 112 /* if we just entered the thermal event */
109 if (curr) { 113 if (is_throttled) {
110 printk(KERN_CRIT "CPU%d: Temperature above threshold, " 114 printk(KERN_CRIT "CPU%d: Temperature above threshold, "
111 "cpu clock throttled (total events = %lu)\n", cpu, 115 "cpu clock throttled (total events = %lu)\n",
112 __get_cpu_var(thermal_throttle_count)); 116 cpu, __get_cpu_var(thermal_throttle_count));
113 117
114 add_taint(TAINT_MACHINE_CHECK); 118 add_taint(TAINT_MACHINE_CHECK);
115 } else { 119 return 1;
116 printk(KERN_CRIT "CPU%d: Temperature/speed normal\n", cpu); 120 }
121 if (was_throttled) {
122 printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
123 return 1;
117 } 124 }
118 125
119 return 1; 126 return 0;
120} 127}
121 128
122#ifdef CONFIG_SYSFS 129#ifdef CONFIG_SYSFS
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index a7aa8f900954..900332b800f8 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -55,6 +55,7 @@ struct x86_pmu {
55 int num_counters_fixed; 55 int num_counters_fixed;
56 int counter_bits; 56 int counter_bits;
57 u64 counter_mask; 57 u64 counter_mask;
58 int apic;
58 u64 max_period; 59 u64 max_period;
59 u64 intel_ctrl; 60 u64 intel_ctrl;
60}; 61};
@@ -72,8 +73,8 @@ static const u64 p6_perfmon_event_map[] =
72{ 73{
73 [PERF_COUNT_HW_CPU_CYCLES] = 0x0079, 74 [PERF_COUNT_HW_CPU_CYCLES] = 0x0079,
74 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0, 75 [PERF_COUNT_HW_INSTRUCTIONS] = 0x00c0,
75 [PERF_COUNT_HW_CACHE_REFERENCES] = 0x0000, 76 [PERF_COUNT_HW_CACHE_REFERENCES] = 0x0f2e,
76 [PERF_COUNT_HW_CACHE_MISSES] = 0x0000, 77 [PERF_COUNT_HW_CACHE_MISSES] = 0x012e,
77 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4, 78 [PERF_COUNT_HW_BRANCH_INSTRUCTIONS] = 0x00c4,
78 [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5, 79 [PERF_COUNT_HW_BRANCH_MISSES] = 0x00c5,
79 [PERF_COUNT_HW_BUS_CYCLES] = 0x0062, 80 [PERF_COUNT_HW_BUS_CYCLES] = 0x0062,
@@ -613,6 +614,7 @@ static DEFINE_MUTEX(pmc_reserve_mutex);
613 614
614static bool reserve_pmc_hardware(void) 615static bool reserve_pmc_hardware(void)
615{ 616{
617#ifdef CONFIG_X86_LOCAL_APIC
616 int i; 618 int i;
617 619
618 if (nmi_watchdog == NMI_LOCAL_APIC) 620 if (nmi_watchdog == NMI_LOCAL_APIC)
@@ -627,9 +629,11 @@ static bool reserve_pmc_hardware(void)
627 if (!reserve_evntsel_nmi(x86_pmu.eventsel + i)) 629 if (!reserve_evntsel_nmi(x86_pmu.eventsel + i))
628 goto eventsel_fail; 630 goto eventsel_fail;
629 } 631 }
632#endif
630 633
631 return true; 634 return true;
632 635
636#ifdef CONFIG_X86_LOCAL_APIC
633eventsel_fail: 637eventsel_fail:
634 for (i--; i >= 0; i--) 638 for (i--; i >= 0; i--)
635 release_evntsel_nmi(x86_pmu.eventsel + i); 639 release_evntsel_nmi(x86_pmu.eventsel + i);
@@ -644,10 +648,12 @@ perfctr_fail:
644 enable_lapic_nmi_watchdog(); 648 enable_lapic_nmi_watchdog();
645 649
646 return false; 650 return false;
651#endif
647} 652}
648 653
649static void release_pmc_hardware(void) 654static void release_pmc_hardware(void)
650{ 655{
656#ifdef CONFIG_X86_LOCAL_APIC
651 int i; 657 int i;
652 658
653 for (i = 0; i < x86_pmu.num_counters; i++) { 659 for (i = 0; i < x86_pmu.num_counters; i++) {
@@ -657,6 +663,7 @@ static void release_pmc_hardware(void)
657 663
658 if (nmi_watchdog == NMI_LOCAL_APIC) 664 if (nmi_watchdog == NMI_LOCAL_APIC)
659 enable_lapic_nmi_watchdog(); 665 enable_lapic_nmi_watchdog();
666#endif
660} 667}
661 668
662static void hw_perf_counter_destroy(struct perf_counter *counter) 669static void hw_perf_counter_destroy(struct perf_counter *counter)
@@ -748,6 +755,15 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
748 hwc->sample_period = x86_pmu.max_period; 755 hwc->sample_period = x86_pmu.max_period;
749 hwc->last_period = hwc->sample_period; 756 hwc->last_period = hwc->sample_period;
750 atomic64_set(&hwc->period_left, hwc->sample_period); 757 atomic64_set(&hwc->period_left, hwc->sample_period);
758 } else {
759 /*
760 * If we have a PMU initialized but no APIC
761 * interrupts, we cannot sample hardware
762 * counters (user-space has to fall back and
763 * sample via a hrtimer based software counter):
764 */
765 if (!x86_pmu.apic)
766 return -EOPNOTSUPP;
751 } 767 }
752 768
753 counter->destroy = hw_perf_counter_destroy; 769 counter->destroy = hw_perf_counter_destroy;
@@ -1449,18 +1465,22 @@ void smp_perf_pending_interrupt(struct pt_regs *regs)
1449 1465
1450void set_perf_counter_pending(void) 1466void set_perf_counter_pending(void)
1451{ 1467{
1468#ifdef CONFIG_X86_LOCAL_APIC
1452 apic->send_IPI_self(LOCAL_PENDING_VECTOR); 1469 apic->send_IPI_self(LOCAL_PENDING_VECTOR);
1470#endif
1453} 1471}
1454 1472
1455void perf_counters_lapic_init(void) 1473void perf_counters_lapic_init(void)
1456{ 1474{
1457 if (!x86_pmu_initialized()) 1475#ifdef CONFIG_X86_LOCAL_APIC
1476 if (!x86_pmu.apic || !x86_pmu_initialized())
1458 return; 1477 return;
1459 1478
1460 /* 1479 /*
1461 * Always use NMI for PMU 1480 * Always use NMI for PMU
1462 */ 1481 */
1463 apic_write(APIC_LVTPC, APIC_DM_NMI); 1482 apic_write(APIC_LVTPC, APIC_DM_NMI);
1483#endif
1464} 1484}
1465 1485
1466static int __kprobes 1486static int __kprobes
@@ -1484,7 +1504,9 @@ perf_counter_nmi_handler(struct notifier_block *self,
1484 1504
1485 regs = args->regs; 1505 regs = args->regs;
1486 1506
1507#ifdef CONFIG_X86_LOCAL_APIC
1487 apic_write(APIC_LVTPC, APIC_DM_NMI); 1508 apic_write(APIC_LVTPC, APIC_DM_NMI);
1509#endif
1488 /* 1510 /*
1489 * Can't rely on the handled return value to say it was our NMI, two 1511 * Can't rely on the handled return value to say it was our NMI, two
1490 * counters could trigger 'simultaneously' raising two back-to-back NMIs. 1512 * counters could trigger 'simultaneously' raising two back-to-back NMIs.
@@ -1515,6 +1537,7 @@ static struct x86_pmu p6_pmu = {
1515 .event_map = p6_pmu_event_map, 1537 .event_map = p6_pmu_event_map,
1516 .raw_event = p6_pmu_raw_event, 1538 .raw_event = p6_pmu_raw_event,
1517 .max_events = ARRAY_SIZE(p6_perfmon_event_map), 1539 .max_events = ARRAY_SIZE(p6_perfmon_event_map),
1540 .apic = 1,
1518 .max_period = (1ULL << 31) - 1, 1541 .max_period = (1ULL << 31) - 1,
1519 .version = 0, 1542 .version = 0,
1520 .num_counters = 2, 1543 .num_counters = 2,
@@ -1541,6 +1564,7 @@ static struct x86_pmu intel_pmu = {
1541 .event_map = intel_pmu_event_map, 1564 .event_map = intel_pmu_event_map,
1542 .raw_event = intel_pmu_raw_event, 1565 .raw_event = intel_pmu_raw_event,
1543 .max_events = ARRAY_SIZE(intel_perfmon_event_map), 1566 .max_events = ARRAY_SIZE(intel_perfmon_event_map),
1567 .apic = 1,
1544 /* 1568 /*
1545 * Intel PMCs cannot be accessed sanely above 32 bit width, 1569 * Intel PMCs cannot be accessed sanely above 32 bit width,
1546 * so we install an artificial 1<<31 period regardless of 1570 * so we install an artificial 1<<31 period regardless of
@@ -1564,6 +1588,7 @@ static struct x86_pmu amd_pmu = {
1564 .num_counters = 4, 1588 .num_counters = 4,
1565 .counter_bits = 48, 1589 .counter_bits = 48,
1566 .counter_mask = (1ULL << 48) - 1, 1590 .counter_mask = (1ULL << 48) - 1,
1591 .apic = 1,
1567 /* use highest bit to detect overflow */ 1592 /* use highest bit to detect overflow */
1568 .max_period = (1ULL << 47) - 1, 1593 .max_period = (1ULL << 47) - 1,
1569}; 1594};
@@ -1589,13 +1614,14 @@ static int p6_pmu_init(void)
1589 return -ENODEV; 1614 return -ENODEV;
1590 } 1615 }
1591 1616
1617 x86_pmu = p6_pmu;
1618
1592 if (!cpu_has_apic) { 1619 if (!cpu_has_apic) {
1593 pr_info("no Local APIC, try rebooting with lapic"); 1620 pr_info("no APIC, boot with the \"lapic\" boot parameter to force-enable it.\n");
1594 return -ENODEV; 1621 pr_info("no hardware sampling interrupt available.\n");
1622 x86_pmu.apic = 0;
1595 } 1623 }
1596 1624
1597 x86_pmu = p6_pmu;
1598
1599 return 0; 1625 return 0;
1600} 1626}
1601 1627
diff --git a/arch/x86/kernel/efi.c b/arch/x86/kernel/efi.c
index 96f7ac0bbf01..fe26ba3e3451 100644
--- a/arch/x86/kernel/efi.c
+++ b/arch/x86/kernel/efi.c
@@ -354,7 +354,7 @@ void __init efi_init(void)
354 */ 354 */
355 c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2); 355 c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2);
356 if (c16) { 356 if (c16) {
357 for (i = 0; i < sizeof(vendor) && *c16; ++i) 357 for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
358 vendor[i] = *c16++; 358 vendor[i] = *c16++;
359 vendor[i] = '\0'; 359 vendor[i] = '\0';
360 } else 360 } else
@@ -512,7 +512,7 @@ void __init efi_enter_virtual_mode(void)
512 && end_pfn <= max_pfn_mapped)) 512 && end_pfn <= max_pfn_mapped))
513 va = __va(md->phys_addr); 513 va = __va(md->phys_addr);
514 else 514 else
515 va = efi_ioremap(md->phys_addr, size); 515 va = efi_ioremap(md->phys_addr, size, md->type);
516 516
517 md->virt_addr = (u64) (unsigned long) va; 517 md->virt_addr = (u64) (unsigned long) va;
518 518
diff --git a/arch/x86/kernel/efi_64.c b/arch/x86/kernel/efi_64.c
index 22c3b7828c50..ac0621a7ac3d 100644
--- a/arch/x86/kernel/efi_64.c
+++ b/arch/x86/kernel/efi_64.c
@@ -98,10 +98,14 @@ void __init efi_call_phys_epilog(void)
98 early_runtime_code_mapping_set_exec(0); 98 early_runtime_code_mapping_set_exec(0);
99} 99}
100 100
101void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size) 101void __iomem *__init efi_ioremap(unsigned long phys_addr, unsigned long size,
102 u32 type)
102{ 103{
103 unsigned long last_map_pfn; 104 unsigned long last_map_pfn;
104 105
106 if (type == EFI_MEMORY_MAPPED_IO)
107 return ioremap(phys_addr, size);
108
105 last_map_pfn = init_memory_mapping(phys_addr, phys_addr + size); 109 last_map_pfn = init_memory_mapping(phys_addr, phys_addr + size);
106 if ((last_map_pfn << PAGE_SHIFT) < phys_addr + size) 110 if ((last_map_pfn << PAGE_SHIFT) < phys_addr + size)
107 return NULL; 111 return NULL;
diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
index 8663afb56535..cc827ac9e8d3 100644
--- a/arch/x86/kernel/head_32.S
+++ b/arch/x86/kernel/head_32.S
@@ -261,9 +261,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
261 * which will be freed later 261 * which will be freed later
262 */ 262 */
263 263
264#ifndef CONFIG_HOTPLUG_CPU 264__CPUINIT
265.section .init.text,"ax",@progbits
266#endif
267 265
268#ifdef CONFIG_SMP 266#ifdef CONFIG_SMP
269ENTRY(startup_32_smp) 267ENTRY(startup_32_smp)
@@ -602,7 +600,7 @@ ignore_int:
602#endif 600#endif
603 iret 601 iret
604 602
605.section .cpuinit.data,"wa" 603 __REFDATA
606.align 4 604.align 4
607ENTRY(initial_code) 605ENTRY(initial_code)
608 .long i386_start_kernel 606 .long i386_start_kernel
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 994dd6a4a2a0..071166a4ba83 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -519,16 +519,12 @@ static void c1e_idle(void)
519 if (!cpumask_test_cpu(cpu, c1e_mask)) { 519 if (!cpumask_test_cpu(cpu, c1e_mask)) {
520 cpumask_set_cpu(cpu, c1e_mask); 520 cpumask_set_cpu(cpu, c1e_mask);
521 /* 521 /*
522 * Force broadcast so ACPI can not interfere. Needs 522 * Force broadcast so ACPI can not interfere.
523 * to run with interrupts enabled as it uses
524 * smp_function_call.
525 */ 523 */
526 local_irq_enable();
527 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE, 524 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_FORCE,
528 &cpu); 525 &cpu);
529 printk(KERN_INFO "Switch to broadcast mode on CPU%d\n", 526 printk(KERN_INFO "Switch to broadcast mode on CPU%d\n",
530 cpu); 527 cpu);
531 local_irq_disable();
532 } 528 }
533 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); 529 clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu);
534 530
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
index 508e982dd072..a06e8d101844 100644
--- a/arch/x86/kernel/reboot.c
+++ b/arch/x86/kernel/reboot.c
@@ -3,6 +3,7 @@
3#include <linux/init.h> 3#include <linux/init.h>
4#include <linux/pm.h> 4#include <linux/pm.h>
5#include <linux/efi.h> 5#include <linux/efi.h>
6#include <linux/dmi.h>
6#include <acpi/reboot.h> 7#include <acpi/reboot.h>
7#include <asm/io.h> 8#include <asm/io.h>
8#include <asm/apic.h> 9#include <asm/apic.h>
@@ -17,7 +18,6 @@
17#include <asm/cpu.h> 18#include <asm/cpu.h>
18 19
19#ifdef CONFIG_X86_32 20#ifdef CONFIG_X86_32
20# include <linux/dmi.h>
21# include <linux/ctype.h> 21# include <linux/ctype.h>
22# include <linux/mc146818rtc.h> 22# include <linux/mc146818rtc.h>
23#else 23#else
@@ -404,6 +404,46 @@ EXPORT_SYMBOL(machine_real_restart);
404 404
405#endif /* CONFIG_X86_32 */ 405#endif /* CONFIG_X86_32 */
406 406
407/*
408 * Some Apple MacBook and MacBookPro's needs reboot=p to be able to reboot
409 */
410static int __init set_pci_reboot(const struct dmi_system_id *d)
411{
412 if (reboot_type != BOOT_CF9) {
413 reboot_type = BOOT_CF9;
414 printk(KERN_INFO "%s series board detected. "
415 "Selecting PCI-method for reboots.\n", d->ident);
416 }
417 return 0;
418}
419
420static struct dmi_system_id __initdata pci_reboot_dmi_table[] = {
421 { /* Handle problems with rebooting on Apple MacBook5 */
422 .callback = set_pci_reboot,
423 .ident = "Apple MacBook5",
424 .matches = {
425 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
426 DMI_MATCH(DMI_PRODUCT_NAME, "MacBook5"),
427 },
428 },
429 { /* Handle problems with rebooting on Apple MacBookPro5 */
430 .callback = set_pci_reboot,
431 .ident = "Apple MacBookPro5",
432 .matches = {
433 DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
434 DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro5"),
435 },
436 },
437 { }
438};
439
440static int __init pci_reboot_init(void)
441{
442 dmi_check_system(pci_reboot_dmi_table);
443 return 0;
444}
445core_initcall(pci_reboot_init);
446
407static inline void kb_wait(void) 447static inline void kb_wait(void)
408{ 448{
409 int i; 449 int i;
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index 29a3eef7cf4a..07d81916f212 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -165,7 +165,7 @@ static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen)
165 165
166 if (!chosen) { 166 if (!chosen) {
167 size_t vm_size = VMALLOC_END - VMALLOC_START; 167 size_t vm_size = VMALLOC_END - VMALLOC_START;
168 size_t tot_size = num_possible_cpus() * PMD_SIZE; 168 size_t tot_size = nr_cpu_ids * PMD_SIZE;
169 169
170 /* on non-NUMA, embedding is better */ 170 /* on non-NUMA, embedding is better */
171 if (!pcpu_need_numa()) 171 if (!pcpu_need_numa())
@@ -199,7 +199,7 @@ static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen)
199 dyn_size = pcpul_size - static_size - PERCPU_FIRST_CHUNK_RESERVE; 199 dyn_size = pcpul_size - static_size - PERCPU_FIRST_CHUNK_RESERVE;
200 200
201 /* allocate pointer array and alloc large pages */ 201 /* allocate pointer array and alloc large pages */
202 map_size = PFN_ALIGN(num_possible_cpus() * sizeof(pcpul_map[0])); 202 map_size = PFN_ALIGN(nr_cpu_ids * sizeof(pcpul_map[0]));
203 pcpul_map = alloc_bootmem(map_size); 203 pcpul_map = alloc_bootmem(map_size);
204 204
205 for_each_possible_cpu(cpu) { 205 for_each_possible_cpu(cpu) {
@@ -228,7 +228,7 @@ static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen)
228 228
229 /* allocate address and map */ 229 /* allocate address and map */
230 pcpul_vm.flags = VM_ALLOC; 230 pcpul_vm.flags = VM_ALLOC;
231 pcpul_vm.size = num_possible_cpus() * PMD_SIZE; 231 pcpul_vm.size = nr_cpu_ids * PMD_SIZE;
232 vm_area_register_early(&pcpul_vm, PMD_SIZE); 232 vm_area_register_early(&pcpul_vm, PMD_SIZE);
233 233
234 for_each_possible_cpu(cpu) { 234 for_each_possible_cpu(cpu) {
@@ -250,8 +250,8 @@ static ssize_t __init setup_pcpu_lpage(size_t static_size, bool chosen)
250 PMD_SIZE, pcpul_vm.addr, NULL); 250 PMD_SIZE, pcpul_vm.addr, NULL);
251 251
252 /* sort pcpul_map array for pcpu_lpage_remapped() */ 252 /* sort pcpul_map array for pcpu_lpage_remapped() */
253 for (i = 0; i < num_possible_cpus() - 1; i++) 253 for (i = 0; i < nr_cpu_ids - 1; i++)
254 for (j = i + 1; j < num_possible_cpus(); j++) 254 for (j = i + 1; j < nr_cpu_ids; j++)
255 if (pcpul_map[i].ptr > pcpul_map[j].ptr) { 255 if (pcpul_map[i].ptr > pcpul_map[j].ptr) {
256 struct pcpul_ent tmp = pcpul_map[i]; 256 struct pcpul_ent tmp = pcpul_map[i];
257 pcpul_map[i] = pcpul_map[j]; 257 pcpul_map[i] = pcpul_map[j];
@@ -288,7 +288,7 @@ void *pcpu_lpage_remapped(void *kaddr)
288{ 288{
289 void *pmd_addr = (void *)((unsigned long)kaddr & PMD_MASK); 289 void *pmd_addr = (void *)((unsigned long)kaddr & PMD_MASK);
290 unsigned long offset = (unsigned long)kaddr & ~PMD_MASK; 290 unsigned long offset = (unsigned long)kaddr & ~PMD_MASK;
291 int left = 0, right = num_possible_cpus() - 1; 291 int left = 0, right = nr_cpu_ids - 1;
292 int pos; 292 int pos;
293 293
294 /* pcpul in use at all? */ 294 /* pcpul in use at all? */
@@ -377,7 +377,7 @@ static ssize_t __init setup_pcpu_4k(size_t static_size)
377 pcpu4k_nr_static_pages = PFN_UP(static_size); 377 pcpu4k_nr_static_pages = PFN_UP(static_size);
378 378
379 /* unaligned allocations can't be freed, round up to page size */ 379 /* unaligned allocations can't be freed, round up to page size */
380 pages_size = PFN_ALIGN(pcpu4k_nr_static_pages * num_possible_cpus() 380 pages_size = PFN_ALIGN(pcpu4k_nr_static_pages * nr_cpu_ids
381 * sizeof(pcpu4k_pages[0])); 381 * sizeof(pcpu4k_pages[0]));
382 pcpu4k_pages = alloc_bootmem(pages_size); 382 pcpu4k_pages = alloc_bootmem(pages_size);
383 383
diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index 8ccabb8a2f6a..77b9689f8edb 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -744,6 +744,7 @@ uv_activation_descriptor_init(int node, int pnode)
744 * note that base_dest_nodeid is actually a nasid. 744 * note that base_dest_nodeid is actually a nasid.
745 */ 745 */
746 ad2->header.base_dest_nodeid = uv_partition_base_pnode << 1; 746 ad2->header.base_dest_nodeid = uv_partition_base_pnode << 1;
747 ad2->header.dest_subnodeid = 0x10; /* the LB */
747 ad2->header.command = UV_NET_ENDPOINT_INTD; 748 ad2->header.command = UV_NET_ENDPOINT_INTD;
748 ad2->header.int_both = 1; 749 ad2->header.int_both = 1;
749 /* 750 /*
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 6e1a368d21d4..71f4368b357e 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -275,15 +275,20 @@ static unsigned long pit_calibrate_tsc(u32 latch, unsigned long ms, int loopmin)
275 * use the TSC value at the transitions to calculate a pretty 275 * use the TSC value at the transitions to calculate a pretty
276 * good value for the TSC frequencty. 276 * good value for the TSC frequencty.
277 */ 277 */
278static inline int pit_verify_msb(unsigned char val)
279{
280 /* Ignore LSB */
281 inb(0x42);
282 return inb(0x42) == val;
283}
284
278static inline int pit_expect_msb(unsigned char val, u64 *tscp, unsigned long *deltap) 285static inline int pit_expect_msb(unsigned char val, u64 *tscp, unsigned long *deltap)
279{ 286{
280 int count; 287 int count;
281 u64 tsc = 0; 288 u64 tsc = 0;
282 289
283 for (count = 0; count < 50000; count++) { 290 for (count = 0; count < 50000; count++) {
284 /* Ignore LSB */ 291 if (!pit_verify_msb(val))
285 inb(0x42);
286 if (inb(0x42) != val)
287 break; 292 break;
288 tsc = get_cycles(); 293 tsc = get_cycles();
289 } 294 }
@@ -336,8 +341,7 @@ static unsigned long quick_pit_calibrate(void)
336 * to do that is to just read back the 16-bit counter 341 * to do that is to just read back the 16-bit counter
337 * once from the PIT. 342 * once from the PIT.
338 */ 343 */
339 inb(0x42); 344 pit_verify_msb(0);
340 inb(0x42);
341 345
342 if (pit_expect_msb(0xff, &tsc, &d1)) { 346 if (pit_expect_msb(0xff, &tsc, &d1)) {
343 for (i = 1; i <= MAX_QUICK_PIT_ITERATIONS; i++) { 347 for (i = 1; i <= MAX_QUICK_PIT_ITERATIONS; i++) {
@@ -348,8 +352,19 @@ static unsigned long quick_pit_calibrate(void)
348 * Iterate until the error is less than 500 ppm 352 * Iterate until the error is less than 500 ppm
349 */ 353 */
350 delta -= tsc; 354 delta -= tsc;
351 if (d1+d2 < delta >> 11) 355 if (d1+d2 >= delta >> 11)
352 goto success; 356 continue;
357
358 /*
359 * Check the PIT one more time to verify that
360 * all TSC reads were stable wrt the PIT.
361 *
362 * This also guarantees serialization of the
363 * last cycle read ('d2') in pit_expect_msb.
364 */
365 if (!pit_verify_msb(0xfe - i))
366 break;
367 goto success;
353 } 368 }
354 } 369 }
355 printk("Fast TSC calibration failed\n"); 370 printk("Fast TSC calibration failed\n");
diff --git a/arch/x86/kernel/vmi_32.c b/arch/x86/kernel/vmi_32.c
index b263423fbe2a..95a7289e4b0c 100644
--- a/arch/x86/kernel/vmi_32.c
+++ b/arch/x86/kernel/vmi_32.c
@@ -441,7 +441,7 @@ vmi_startup_ipi_hook(int phys_apicid, unsigned long start_eip,
441 ap.ds = __USER_DS; 441 ap.ds = __USER_DS;
442 ap.es = __USER_DS; 442 ap.es = __USER_DS;
443 ap.fs = __KERNEL_PERCPU; 443 ap.fs = __KERNEL_PERCPU;
444 ap.gs = 0; 444 ap.gs = __KERNEL_STACK_CANARY;
445 445
446 ap.eflags = 0; 446 ap.eflags = 0;
447 447
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 59f31d2dd435..9fc178255c04 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -46,11 +46,10 @@ PHDRS {
46 data PT_LOAD FLAGS(7); /* RWE */ 46 data PT_LOAD FLAGS(7); /* RWE */
47#ifdef CONFIG_X86_64 47#ifdef CONFIG_X86_64
48 user PT_LOAD FLAGS(7); /* RWE */ 48 user PT_LOAD FLAGS(7); /* RWE */
49 data.init PT_LOAD FLAGS(7); /* RWE */
50#ifdef CONFIG_SMP 49#ifdef CONFIG_SMP
51 percpu PT_LOAD FLAGS(7); /* RWE */ 50 percpu PT_LOAD FLAGS(7); /* RWE */
52#endif 51#endif
53 data.init2 PT_LOAD FLAGS(7); /* RWE */ 52 init PT_LOAD FLAGS(7); /* RWE */
54#endif 53#endif
55 note PT_NOTE FLAGS(0); /* ___ */ 54 note PT_NOTE FLAGS(0); /* ___ */
56} 55}
@@ -103,65 +102,43 @@ SECTIONS
103 __stop___ex_table = .; 102 __stop___ex_table = .;
104 } :text = 0x9090 103 } :text = 0x9090
105 104
106 RODATA 105 RO_DATA(PAGE_SIZE)
107 106
108 /* Data */ 107 /* Data */
109 . = ALIGN(PAGE_SIZE);
110 .data : AT(ADDR(.data) - LOAD_OFFSET) { 108 .data : AT(ADDR(.data) - LOAD_OFFSET) {
111 /* Start of data section */ 109 /* Start of data section */
112 _sdata = .; 110 _sdata = .;
113 DATA_DATA 111
114 CONSTRUCTORS 112 /* init_task */
115 } :data 113 INIT_TASK_DATA(THREAD_SIZE)
116 114
117#ifdef CONFIG_X86_32 115#ifdef CONFIG_X86_32
118 /* 32 bit has nosave before _edata */ 116 /* 32 bit has nosave before _edata */
119 . = ALIGN(PAGE_SIZE); 117 NOSAVE_DATA
120 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
121 __nosave_begin = .;
122 *(.data.nosave)
123 . = ALIGN(PAGE_SIZE);
124 __nosave_end = .;
125 }
126#endif 118#endif
127 119
128 . = ALIGN(PAGE_SIZE); 120 PAGE_ALIGNED_DATA(PAGE_SIZE)
129 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) {
130 *(.data.page_aligned)
131 *(.data.idt) 121 *(.data.idt)
132 }
133 122
134#ifdef CONFIG_X86_32 123 CACHELINE_ALIGNED_DATA(CONFIG_X86_L1_CACHE_BYTES)
135 . = ALIGN(32);
136#else
137 . = ALIGN(PAGE_SIZE);
138 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
139#endif
140 .data.cacheline_aligned :
141 AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) {
142 *(.data.cacheline_aligned)
143 }
144 124
145 /* rarely changed data like cpu maps */ 125 DATA_DATA
146#ifdef CONFIG_X86_32 126 CONSTRUCTORS
147 . = ALIGN(32); 127
148#else 128 /* rarely changed data like cpu maps */
149 . = ALIGN(CONFIG_X86_INTERNODE_CACHE_BYTES); 129 READ_MOSTLY_DATA(CONFIG_X86_INTERNODE_CACHE_BYTES)
150#endif
151 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) {
152 *(.data.read_mostly)
153 130
154 /* End of data section */ 131 /* End of data section */
155 _edata = .; 132 _edata = .;
156 } 133 } :data
157 134
158#ifdef CONFIG_X86_64 135#ifdef CONFIG_X86_64
159 136
160#define VSYSCALL_ADDR (-10*1024*1024) 137#define VSYSCALL_ADDR (-10*1024*1024)
161#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data.read_mostly) + \ 138#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data) + SIZEOF(.data) + \
162 SIZEOF(.data.read_mostly) + 4095) & ~(4095)) 139 PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
163#define VSYSCALL_VIRT_ADDR ((ADDR(.data.read_mostly) + \ 140#define VSYSCALL_VIRT_ADDR ((ADDR(.data) + SIZEOF(.data) + \
164 SIZEOF(.data.read_mostly) + 4095) & ~(4095)) 141 PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
165 142
166#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR) 143#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
167#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET) 144#define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
@@ -227,35 +204,29 @@ SECTIONS
227 204
228#endif /* CONFIG_X86_64 */ 205#endif /* CONFIG_X86_64 */
229 206
230 /* init_task */ 207 /* Init code and data - will be freed after init */
231 . = ALIGN(THREAD_SIZE); 208 . = ALIGN(PAGE_SIZE);
232 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { 209 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
233 *(.data.init_task) 210 __init_begin = .; /* paired with __init_end */
234 } 211 }
235#ifdef CONFIG_X86_64
236 :data.init
237#endif
238 212
213#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
239 /* 214 /*
240 * smp_locks might be freed after init 215 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
241 * start/end must be page aligned 216 * output PHDR, so the next output section - .init.text - should
217 * start another segment - init.
242 */ 218 */
243 . = ALIGN(PAGE_SIZE); 219 PERCPU_VADDR(0, :percpu)
244 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) { 220#endif
245 __smp_locks = .;
246 *(.smp_locks)
247 __smp_locks_end = .;
248 . = ALIGN(PAGE_SIZE);
249 }
250 221
251 /* Init code and data - will be freed after init */
252 . = ALIGN(PAGE_SIZE);
253 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { 222 .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
254 __init_begin = .; /* paired with __init_end */
255 _sinittext = .; 223 _sinittext = .;
256 INIT_TEXT 224 INIT_TEXT
257 _einittext = .; 225 _einittext = .;
258 } 226 }
227#ifdef CONFIG_X86_64
228 :init
229#endif
259 230
260 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { 231 .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
261 INIT_DATA 232 INIT_DATA
@@ -326,17 +297,7 @@ SECTIONS
326 } 297 }
327#endif 298#endif
328 299
329#if defined(CONFIG_X86_64) && defined(CONFIG_SMP) 300#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
330 /*
331 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
332 * output PHDR, so the next output section - __data_nosave - should
333 * start another section data.init2. Also, pda should be at the head of
334 * percpu area. Preallocate it and define the percpu offset symbol
335 * so that it can be accessed as a percpu variable.
336 */
337 . = ALIGN(PAGE_SIZE);
338 PERCPU_VADDR(0, :percpu)
339#else
340 PERCPU(PAGE_SIZE) 301 PERCPU(PAGE_SIZE)
341#endif 302#endif
342 303
@@ -347,15 +308,22 @@ SECTIONS
347 __init_end = .; 308 __init_end = .;
348 } 309 }
349 310
311 /*
312 * smp_locks might be freed after init
313 * start/end must be page aligned
314 */
315 . = ALIGN(PAGE_SIZE);
316 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
317 __smp_locks = .;
318 *(.smp_locks)
319 __smp_locks_end = .;
320 . = ALIGN(PAGE_SIZE);
321 }
322
350#ifdef CONFIG_X86_64 323#ifdef CONFIG_X86_64
351 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) { 324 .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
352 . = ALIGN(PAGE_SIZE); 325 NOSAVE_DATA
353 __nosave_begin = .; 326 }
354 *(.data.nosave)
355 . = ALIGN(PAGE_SIZE);
356 __nosave_end = .;
357 } :data.init2
358 /* use another section data.init2, see PERCPU_VADDR() above */
359#endif 327#endif
360 328
361 /* BSS */ 329 /* BSS */
@@ -393,8 +361,8 @@ SECTIONS
393 361
394 362
395#ifdef CONFIG_X86_32 363#ifdef CONFIG_X86_32
396ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE), 364. = ASSERT((_end - LOAD_OFFSET <= KERNEL_IMAGE_SIZE),
397 "kernel image bigger than KERNEL_IMAGE_SIZE") 365 "kernel image bigger than KERNEL_IMAGE_SIZE");
398#else 366#else
399/* 367/*
400 * Per-cpu symbols which need to be offset from __per_cpu_load 368 * Per-cpu symbols which need to be offset from __per_cpu_load
@@ -407,12 +375,12 @@ INIT_PER_CPU(irq_stack_union);
407/* 375/*
408 * Build-time check on the image size: 376 * Build-time check on the image size:
409 */ 377 */
410ASSERT((_end - _text <= KERNEL_IMAGE_SIZE), 378. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
411 "kernel image bigger than KERNEL_IMAGE_SIZE") 379 "kernel image bigger than KERNEL_IMAGE_SIZE");
412 380
413#ifdef CONFIG_SMP 381#ifdef CONFIG_SMP
414ASSERT((per_cpu__irq_stack_union == 0), 382. = ASSERT((per_cpu__irq_stack_union == 0),
415 "irq_stack_union is not at start of per-cpu area"); 383 "irq_stack_union is not at start of per-cpu area");
416#endif 384#endif
417 385
418#endif /* CONFIG_X86_32 */ 386#endif /* CONFIG_X86_32 */
@@ -420,7 +388,7 @@ ASSERT((per_cpu__irq_stack_union == 0),
420#ifdef CONFIG_KEXEC 388#ifdef CONFIG_KEXEC
421#include <asm/kexec.h> 389#include <asm/kexec.h>
422 390
423ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE, 391. = ASSERT(kexec_control_code_size <= KEXEC_CONTROL_CODE_MAX_SIZE,
424 "kexec control code size is too big") 392 "kexec control code size is too big");
425#endif 393#endif
426 394
diff --git a/arch/x86/kvm/i8254.c b/arch/x86/kvm/i8254.c
index 4d6f0d293ee2..21f68e00524f 100644
--- a/arch/x86/kvm/i8254.c
+++ b/arch/x86/kvm/i8254.c
@@ -104,6 +104,9 @@ static s64 __kpit_elapsed(struct kvm *kvm)
104 ktime_t remaining; 104 ktime_t remaining;
105 struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state; 105 struct kvm_kpit_state *ps = &kvm->arch.vpit->pit_state;
106 106
107 if (!ps->pit_timer.period)
108 return 0;
109
107 /* 110 /*
108 * The Counter does not stop when it reaches zero. In 111 * The Counter does not stop when it reaches zero. In
109 * Modes 0, 1, 4, and 5 the Counter ``wraps around'' to 112 * Modes 0, 1, 4, and 5 the Counter ``wraps around'' to
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 7030b5f911bf..0ef5bb2b4043 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -489,16 +489,20 @@ static unsigned long *gfn_to_rmap(struct kvm *kvm, gfn_t gfn, int lpage)
489 * 489 *
490 * If rmapp bit zero is one, (then rmap & ~1) points to a struct kvm_rmap_desc 490 * If rmapp bit zero is one, (then rmap & ~1) points to a struct kvm_rmap_desc
491 * containing more mappings. 491 * containing more mappings.
492 *
493 * Returns the number of rmap entries before the spte was added or zero if
494 * the spte was not added.
495 *
492 */ 496 */
493static void rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn, int lpage) 497static int rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn, int lpage)
494{ 498{
495 struct kvm_mmu_page *sp; 499 struct kvm_mmu_page *sp;
496 struct kvm_rmap_desc *desc; 500 struct kvm_rmap_desc *desc;
497 unsigned long *rmapp; 501 unsigned long *rmapp;
498 int i; 502 int i, count = 0;
499 503
500 if (!is_rmap_pte(*spte)) 504 if (!is_rmap_pte(*spte))
501 return; 505 return count;
502 gfn = unalias_gfn(vcpu->kvm, gfn); 506 gfn = unalias_gfn(vcpu->kvm, gfn);
503 sp = page_header(__pa(spte)); 507 sp = page_header(__pa(spte));
504 sp->gfns[spte - sp->spt] = gfn; 508 sp->gfns[spte - sp->spt] = gfn;
@@ -515,8 +519,10 @@ static void rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn, int lpage)
515 } else { 519 } else {
516 rmap_printk("rmap_add: %p %llx many->many\n", spte, *spte); 520 rmap_printk("rmap_add: %p %llx many->many\n", spte, *spte);
517 desc = (struct kvm_rmap_desc *)(*rmapp & ~1ul); 521 desc = (struct kvm_rmap_desc *)(*rmapp & ~1ul);
518 while (desc->shadow_ptes[RMAP_EXT-1] && desc->more) 522 while (desc->shadow_ptes[RMAP_EXT-1] && desc->more) {
519 desc = desc->more; 523 desc = desc->more;
524 count += RMAP_EXT;
525 }
520 if (desc->shadow_ptes[RMAP_EXT-1]) { 526 if (desc->shadow_ptes[RMAP_EXT-1]) {
521 desc->more = mmu_alloc_rmap_desc(vcpu); 527 desc->more = mmu_alloc_rmap_desc(vcpu);
522 desc = desc->more; 528 desc = desc->more;
@@ -525,6 +531,7 @@ static void rmap_add(struct kvm_vcpu *vcpu, u64 *spte, gfn_t gfn, int lpage)
525 ; 531 ;
526 desc->shadow_ptes[i] = spte; 532 desc->shadow_ptes[i] = spte;
527 } 533 }
534 return count;
528} 535}
529 536
530static void rmap_desc_remove_entry(unsigned long *rmapp, 537static void rmap_desc_remove_entry(unsigned long *rmapp,
@@ -754,6 +761,19 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp)
754 return young; 761 return young;
755} 762}
756 763
764#define RMAP_RECYCLE_THRESHOLD 1000
765
766static void rmap_recycle(struct kvm_vcpu *vcpu, gfn_t gfn, int lpage)
767{
768 unsigned long *rmapp;
769
770 gfn = unalias_gfn(vcpu->kvm, gfn);
771 rmapp = gfn_to_rmap(vcpu->kvm, gfn, lpage);
772
773 kvm_unmap_rmapp(vcpu->kvm, rmapp);
774 kvm_flush_remote_tlbs(vcpu->kvm);
775}
776
757int kvm_age_hva(struct kvm *kvm, unsigned long hva) 777int kvm_age_hva(struct kvm *kvm, unsigned long hva)
758{ 778{
759 return kvm_handle_hva(kvm, hva, kvm_age_rmapp); 779 return kvm_handle_hva(kvm, hva, kvm_age_rmapp);
@@ -1407,24 +1427,25 @@ static int kvm_mmu_zap_page(struct kvm *kvm, struct kvm_mmu_page *sp)
1407 */ 1427 */
1408void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages) 1428void kvm_mmu_change_mmu_pages(struct kvm *kvm, unsigned int kvm_nr_mmu_pages)
1409{ 1429{
1430 int used_pages;
1431
1432 used_pages = kvm->arch.n_alloc_mmu_pages - kvm->arch.n_free_mmu_pages;
1433 used_pages = max(0, used_pages);
1434
1410 /* 1435 /*
1411 * If we set the number of mmu pages to be smaller be than the 1436 * If we set the number of mmu pages to be smaller be than the
1412 * number of actived pages , we must to free some mmu pages before we 1437 * number of actived pages , we must to free some mmu pages before we
1413 * change the value 1438 * change the value
1414 */ 1439 */
1415 1440
1416 if ((kvm->arch.n_alloc_mmu_pages - kvm->arch.n_free_mmu_pages) > 1441 if (used_pages > kvm_nr_mmu_pages) {
1417 kvm_nr_mmu_pages) { 1442 while (used_pages > kvm_nr_mmu_pages) {
1418 int n_used_mmu_pages = kvm->arch.n_alloc_mmu_pages
1419 - kvm->arch.n_free_mmu_pages;
1420
1421 while (n_used_mmu_pages > kvm_nr_mmu_pages) {
1422 struct kvm_mmu_page *page; 1443 struct kvm_mmu_page *page;
1423 1444
1424 page = container_of(kvm->arch.active_mmu_pages.prev, 1445 page = container_of(kvm->arch.active_mmu_pages.prev,
1425 struct kvm_mmu_page, link); 1446 struct kvm_mmu_page, link);
1426 kvm_mmu_zap_page(kvm, page); 1447 kvm_mmu_zap_page(kvm, page);
1427 n_used_mmu_pages--; 1448 used_pages--;
1428 } 1449 }
1429 kvm->arch.n_free_mmu_pages = 0; 1450 kvm->arch.n_free_mmu_pages = 0;
1430 } 1451 }
@@ -1740,6 +1761,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1740{ 1761{
1741 int was_rmapped = 0; 1762 int was_rmapped = 0;
1742 int was_writeble = is_writeble_pte(*shadow_pte); 1763 int was_writeble = is_writeble_pte(*shadow_pte);
1764 int rmap_count;
1743 1765
1744 pgprintk("%s: spte %llx access %x write_fault %d" 1766 pgprintk("%s: spte %llx access %x write_fault %d"
1745 " user_fault %d gfn %lx\n", 1767 " user_fault %d gfn %lx\n",
@@ -1781,9 +1803,11 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
1781 1803
1782 page_header_update_slot(vcpu->kvm, shadow_pte, gfn); 1804 page_header_update_slot(vcpu->kvm, shadow_pte, gfn);
1783 if (!was_rmapped) { 1805 if (!was_rmapped) {
1784 rmap_add(vcpu, shadow_pte, gfn, largepage); 1806 rmap_count = rmap_add(vcpu, shadow_pte, gfn, largepage);
1785 if (!is_rmap_pte(*shadow_pte)) 1807 if (!is_rmap_pte(*shadow_pte))
1786 kvm_release_pfn_clean(pfn); 1808 kvm_release_pfn_clean(pfn);
1809 if (rmap_count > RMAP_RECYCLE_THRESHOLD)
1810 rmap_recycle(vcpu, gfn, largepage);
1787 } else { 1811 } else {
1788 if (was_writeble) 1812 if (was_writeble)
1789 kvm_release_pfn_dirty(pfn); 1813 kvm_release_pfn_dirty(pfn);
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 71510e07e69e..b1f658ad2f06 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -711,6 +711,7 @@ static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
711 svm->vmcb->control.tsc_offset += delta; 711 svm->vmcb->control.tsc_offset += delta;
712 vcpu->cpu = cpu; 712 vcpu->cpu = cpu;
713 kvm_migrate_timers(vcpu); 713 kvm_migrate_timers(vcpu);
714 svm->asid_generation = 0;
714 } 715 }
715 716
716 for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++) 717 for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)
@@ -1031,7 +1032,6 @@ static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *svm_data)
1031 svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID; 1032 svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID;
1032 } 1033 }
1033 1034
1034 svm->vcpu.cpu = svm_data->cpu;
1035 svm->asid_generation = svm_data->asid_generation; 1035 svm->asid_generation = svm_data->asid_generation;
1036 svm->vmcb->control.asid = svm_data->next_asid++; 1036 svm->vmcb->control.asid = svm_data->next_asid++;
1037} 1037}
@@ -2300,8 +2300,8 @@ static void pre_svm_run(struct vcpu_svm *svm)
2300 struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu); 2300 struct svm_cpu_data *svm_data = per_cpu(svm_data, cpu);
2301 2301
2302 svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING; 2302 svm->vmcb->control.tlb_ctl = TLB_CONTROL_DO_NOTHING;
2303 if (svm->vcpu.cpu != cpu || 2303 /* FIXME: handle wraparound of asid_generation */
2304 svm->asid_generation != svm_data->asid_generation) 2304 if (svm->asid_generation != svm_data->asid_generation)
2305 new_asid(svm, svm_data); 2305 new_asid(svm, svm_data);
2306} 2306}
2307 2307
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index 356a0ce85c68..29f912927a58 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -3157,8 +3157,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
3157 struct vcpu_vmx *vmx = to_vmx(vcpu); 3157 struct vcpu_vmx *vmx = to_vmx(vcpu);
3158 enum emulation_result err = EMULATE_DONE; 3158 enum emulation_result err = EMULATE_DONE;
3159 3159
3160 preempt_enable();
3161 local_irq_enable(); 3160 local_irq_enable();
3161 preempt_enable();
3162 3162
3163 while (!guest_state_valid(vcpu)) { 3163 while (!guest_state_valid(vcpu)) {
3164 err = emulate_instruction(vcpu, kvm_run, 0, 0, 0); 3164 err = emulate_instruction(vcpu, kvm_run, 0, 0, 0);
@@ -3168,7 +3168,7 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
3168 3168
3169 if (err != EMULATE_DONE) { 3169 if (err != EMULATE_DONE) {
3170 kvm_report_emulation_failure(vcpu, "emulation failure"); 3170 kvm_report_emulation_failure(vcpu, "emulation failure");
3171 return; 3171 break;
3172 } 3172 }
3173 3173
3174 if (signal_pending(current)) 3174 if (signal_pending(current))
@@ -3177,8 +3177,8 @@ static void handle_invalid_guest_state(struct kvm_vcpu *vcpu,
3177 schedule(); 3177 schedule();
3178 } 3178 }
3179 3179
3180 local_irq_disable();
3181 preempt_disable(); 3180 preempt_disable();
3181 local_irq_disable();
3182 3182
3183 vmx->invalid_state_emulation_result = err; 3183 vmx->invalid_state_emulation_result = err;
3184} 3184}
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index fe5474aec41a..3d4529011828 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -704,11 +704,48 @@ static bool msr_mtrr_valid(unsigned msr)
704 return false; 704 return false;
705} 705}
706 706
707static bool valid_pat_type(unsigned t)
708{
709 return t < 8 && (1 << t) & 0xf3; /* 0, 1, 4, 5, 6, 7 */
710}
711
712static bool valid_mtrr_type(unsigned t)
713{
714 return t < 8 && (1 << t) & 0x73; /* 0, 1, 4, 5, 6 */
715}
716
717static bool mtrr_valid(struct kvm_vcpu *vcpu, u32 msr, u64 data)
718{
719 int i;
720
721 if (!msr_mtrr_valid(msr))
722 return false;
723
724 if (msr == MSR_IA32_CR_PAT) {
725 for (i = 0; i < 8; i++)
726 if (!valid_pat_type((data >> (i * 8)) & 0xff))
727 return false;
728 return true;
729 } else if (msr == MSR_MTRRdefType) {
730 if (data & ~0xcff)
731 return false;
732 return valid_mtrr_type(data & 0xff);
733 } else if (msr >= MSR_MTRRfix64K_00000 && msr <= MSR_MTRRfix4K_F8000) {
734 for (i = 0; i < 8 ; i++)
735 if (!valid_mtrr_type((data >> (i * 8)) & 0xff))
736 return false;
737 return true;
738 }
739
740 /* variable MTRRs */
741 return valid_mtrr_type(data & 0xff);
742}
743
707static int set_msr_mtrr(struct kvm_vcpu *vcpu, u32 msr, u64 data) 744static int set_msr_mtrr(struct kvm_vcpu *vcpu, u32 msr, u64 data)
708{ 745{
709 u64 *p = (u64 *)&vcpu->arch.mtrr_state.fixed_ranges; 746 u64 *p = (u64 *)&vcpu->arch.mtrr_state.fixed_ranges;
710 747
711 if (!msr_mtrr_valid(msr)) 748 if (!mtrr_valid(vcpu, msr, data))
712 return 1; 749 return 1;
713 750
714 if (msr == MSR_MTRRdefType) { 751 if (msr == MSR_MTRRdefType) {
@@ -1079,14 +1116,13 @@ long kvm_arch_dev_ioctl(struct file *filp,
1079 if (copy_to_user(user_msr_list, &msr_list, sizeof msr_list)) 1116 if (copy_to_user(user_msr_list, &msr_list, sizeof msr_list))
1080 goto out; 1117 goto out;
1081 r = -E2BIG; 1118 r = -E2BIG;
1082 if (n < num_msrs_to_save) 1119 if (n < msr_list.nmsrs)
1083 goto out; 1120 goto out;
1084 r = -EFAULT; 1121 r = -EFAULT;
1085 if (copy_to_user(user_msr_list->indices, &msrs_to_save, 1122 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
1086 num_msrs_to_save * sizeof(u32))) 1123 num_msrs_to_save * sizeof(u32)))
1087 goto out; 1124 goto out;
1088 if (copy_to_user(user_msr_list->indices 1125 if (copy_to_user(user_msr_list->indices + num_msrs_to_save,
1089 + num_msrs_to_save * sizeof(u32),
1090 &emulated_msrs, 1126 &emulated_msrs,
1091 ARRAY_SIZE(emulated_msrs) * sizeof(u32))) 1127 ARRAY_SIZE(emulated_msrs) * sizeof(u32)))
1092 goto out; 1128 goto out;
diff --git a/arch/x86/lib/msr.c b/arch/x86/lib/msr.c
index 1440b9c0547e..caa24aca8115 100644
--- a/arch/x86/lib/msr.c
+++ b/arch/x86/lib/msr.c
@@ -89,16 +89,13 @@ void rdmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs)
89 rv.msrs = msrs; 89 rv.msrs = msrs;
90 rv.msr_no = msr_no; 90 rv.msr_no = msr_no;
91 91
92 preempt_disable(); 92 this_cpu = get_cpu();
93 /* 93
94 * FIXME: handle the CPU we're executing on separately for now until 94 if (cpumask_test_cpu(this_cpu, mask))
95 * smp_call_function_many has been fixed to not skip it. 95 __rdmsr_on_cpu(&rv);
96 */
97 this_cpu = raw_smp_processor_id();
98 smp_call_function_single(this_cpu, __rdmsr_on_cpu, &rv, 1);
99 96
100 smp_call_function_many(mask, __rdmsr_on_cpu, &rv, 1); 97 smp_call_function_many(mask, __rdmsr_on_cpu, &rv, 1);
101 preempt_enable(); 98 put_cpu();
102} 99}
103EXPORT_SYMBOL(rdmsr_on_cpus); 100EXPORT_SYMBOL(rdmsr_on_cpus);
104 101
@@ -121,16 +118,13 @@ void wrmsr_on_cpus(const cpumask_t *mask, u32 msr_no, struct msr *msrs)
121 rv.msrs = msrs; 118 rv.msrs = msrs;
122 rv.msr_no = msr_no; 119 rv.msr_no = msr_no;
123 120
124 preempt_disable(); 121 this_cpu = get_cpu();
125 /* 122
126 * FIXME: handle the CPU we're executing on separately for now until 123 if (cpumask_test_cpu(this_cpu, mask))
127 * smp_call_function_many has been fixed to not skip it. 124 __wrmsr_on_cpu(&rv);
128 */
129 this_cpu = raw_smp_processor_id();
130 smp_call_function_single(this_cpu, __wrmsr_on_cpu, &rv, 1);
131 125
132 smp_call_function_many(mask, __wrmsr_on_cpu, &rv, 1); 126 smp_call_function_many(mask, __wrmsr_on_cpu, &rv, 1);
133 preempt_enable(); 127 put_cpu();
134} 128}
135EXPORT_SYMBOL(wrmsr_on_cpus); 129EXPORT_SYMBOL(wrmsr_on_cpus);
136 130
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 6176fe8f29e0..ea56b8cbb6a6 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -796,7 +796,7 @@ int __init reserve_bootmem_generic(unsigned long phys, unsigned long len,
796 return ret; 796 return ret;
797 797
798#else 798#else
799 reserve_bootmem(phys, len, BOOTMEM_DEFAULT); 799 reserve_bootmem(phys, len, flags);
800#endif 800#endif
801 801
802 if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) { 802 if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 1b734d7a8966..7e600c1962db 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -591,9 +591,12 @@ static int __change_page_attr(struct cpa_data *cpa, int primary)
591 unsigned int level; 591 unsigned int level;
592 pte_t *kpte, old_pte; 592 pte_t *kpte, old_pte;
593 593
594 if (cpa->flags & CPA_PAGES_ARRAY) 594 if (cpa->flags & CPA_PAGES_ARRAY) {
595 address = (unsigned long)page_address(cpa->pages[cpa->curpage]); 595 struct page *page = cpa->pages[cpa->curpage];
596 else if (cpa->flags & CPA_ARRAY) 596 if (unlikely(PageHighMem(page)))
597 return 0;
598 address = (unsigned long)page_address(page);
599 } else if (cpa->flags & CPA_ARRAY)
597 address = cpa->vaddr[cpa->curpage]; 600 address = cpa->vaddr[cpa->curpage];
598 else 601 else
599 address = *cpa->vaddr; 602 address = *cpa->vaddr;
@@ -697,9 +700,12 @@ static int cpa_process_alias(struct cpa_data *cpa)
697 * No need to redo, when the primary call touched the direct 700 * No need to redo, when the primary call touched the direct
698 * mapping already: 701 * mapping already:
699 */ 702 */
700 if (cpa->flags & CPA_PAGES_ARRAY) 703 if (cpa->flags & CPA_PAGES_ARRAY) {
701 vaddr = (unsigned long)page_address(cpa->pages[cpa->curpage]); 704 struct page *page = cpa->pages[cpa->curpage];
702 else if (cpa->flags & CPA_ARRAY) 705 if (unlikely(PageHighMem(page)))
706 return 0;
707 vaddr = (unsigned long)page_address(page);
708 } else if (cpa->flags & CPA_ARRAY)
703 vaddr = cpa->vaddr[cpa->curpage]; 709 vaddr = cpa->vaddr[cpa->curpage];
704 else 710 else
705 vaddr = *cpa->vaddr; 711 vaddr = *cpa->vaddr;
@@ -997,12 +1003,15 @@ EXPORT_SYMBOL(set_memory_array_uc);
997int _set_memory_wc(unsigned long addr, int numpages) 1003int _set_memory_wc(unsigned long addr, int numpages)
998{ 1004{
999 int ret; 1005 int ret;
1006 unsigned long addr_copy = addr;
1007
1000 ret = change_page_attr_set(&addr, numpages, 1008 ret = change_page_attr_set(&addr, numpages,
1001 __pgprot(_PAGE_CACHE_UC_MINUS), 0); 1009 __pgprot(_PAGE_CACHE_UC_MINUS), 0);
1002
1003 if (!ret) { 1010 if (!ret) {
1004 ret = change_page_attr_set(&addr, numpages, 1011 ret = change_page_attr_set_clr(&addr_copy, numpages,
1005 __pgprot(_PAGE_CACHE_WC), 0); 1012 __pgprot(_PAGE_CACHE_WC),
1013 __pgprot(_PAGE_CACHE_MASK),
1014 0, 0, NULL);
1006 } 1015 }
1007 return ret; 1016 return ret;
1008} 1017}
@@ -1119,7 +1128,9 @@ int set_pages_array_uc(struct page **pages, int addrinarray)
1119 int free_idx; 1128 int free_idx;
1120 1129
1121 for (i = 0; i < addrinarray; i++) { 1130 for (i = 0; i < addrinarray; i++) {
1122 start = (unsigned long)page_address(pages[i]); 1131 if (PageHighMem(pages[i]))
1132 continue;
1133 start = page_to_pfn(pages[i]) << PAGE_SHIFT;
1123 end = start + PAGE_SIZE; 1134 end = start + PAGE_SIZE;
1124 if (reserve_memtype(start, end, _PAGE_CACHE_UC_MINUS, NULL)) 1135 if (reserve_memtype(start, end, _PAGE_CACHE_UC_MINUS, NULL))
1125 goto err_out; 1136 goto err_out;
@@ -1132,7 +1143,9 @@ int set_pages_array_uc(struct page **pages, int addrinarray)
1132err_out: 1143err_out:
1133 free_idx = i; 1144 free_idx = i;
1134 for (i = 0; i < free_idx; i++) { 1145 for (i = 0; i < free_idx; i++) {
1135 start = (unsigned long)page_address(pages[i]); 1146 if (PageHighMem(pages[i]))
1147 continue;
1148 start = page_to_pfn(pages[i]) << PAGE_SHIFT;
1136 end = start + PAGE_SIZE; 1149 end = start + PAGE_SIZE;
1137 free_memtype(start, end); 1150 free_memtype(start, end);
1138 } 1151 }
@@ -1161,7 +1174,9 @@ int set_pages_array_wb(struct page **pages, int addrinarray)
1161 return retval; 1174 return retval;
1162 1175
1163 for (i = 0; i < addrinarray; i++) { 1176 for (i = 0; i < addrinarray; i++) {
1164 start = (unsigned long)page_address(pages[i]); 1177 if (PageHighMem(pages[i]))
1178 continue;
1179 start = page_to_pfn(pages[i]) << PAGE_SHIFT;
1165 end = start + PAGE_SIZE; 1180 end = start + PAGE_SIZE;
1166 free_memtype(start, end); 1181 free_memtype(start, end);
1167 } 1182 }
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index e6718bb28065..352aa9e927e2 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -623,7 +623,8 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
623 return ret; 623 return ret;
624 624
625 if (flags != want_flags) { 625 if (flags != want_flags) {
626 if (strict_prot || !is_new_memtype_allowed(want_flags, flags)) { 626 if (strict_prot ||
627 !is_new_memtype_allowed(paddr, size, want_flags, flags)) {
627 free_memtype(paddr, paddr + size); 628 free_memtype(paddr, paddr + size);
628 printk(KERN_ERR "%s:%d map pfn expected mapping type %s" 629 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
629 " for %Lx-%Lx, got %s\n", 630 " for %Lx-%Lx, got %s\n",
diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index af8f9650058c..ed34f5e35999 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -329,7 +329,6 @@ void __init reserve_top_address(unsigned long reserve)
329 printk(KERN_INFO "Reserving virtual address space above 0x%08x\n", 329 printk(KERN_INFO "Reserving virtual address space above 0x%08x\n",
330 (int)-reserve); 330 (int)-reserve);
331 __FIXADDR_TOP = -reserve - PAGE_SIZE; 331 __FIXADDR_TOP = -reserve - PAGE_SIZE;
332 __VMALLOC_RESERVE += reserve;
333#endif 332#endif
334} 333}
335 334
diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index 821e97017e95..c814e144a3f0 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -183,18 +183,17 @@ static void flush_tlb_others_ipi(const struct cpumask *cpumask,
183 183
184 f->flush_mm = mm; 184 f->flush_mm = mm;
185 f->flush_va = va; 185 f->flush_va = va;
186 cpumask_andnot(to_cpumask(f->flush_cpumask), 186 if (cpumask_andnot(to_cpumask(f->flush_cpumask), cpumask, cpumask_of(smp_processor_id()))) {
187 cpumask, cpumask_of(smp_processor_id())); 187 /*
188 188 * We have to send the IPI only to
189 /* 189 * CPUs affected.
190 * We have to send the IPI only to 190 */
191 * CPUs affected. 191 apic->send_IPI_mask(to_cpumask(f->flush_cpumask),
192 */ 192 INVALIDATE_TLB_VECTOR_START + sender);
193 apic->send_IPI_mask(to_cpumask(f->flush_cpumask),
194 INVALIDATE_TLB_VECTOR_START + sender);
195 193
196 while (!cpumask_empty(to_cpumask(f->flush_cpumask))) 194 while (!cpumask_empty(to_cpumask(f->flush_cpumask)))
197 cpu_relax(); 195 cpu_relax();
196 }
198 197
199 f->flush_mm = NULL; 198 f->flush_mm = NULL;
200 f->flush_va = 0; 199 f->flush_va = 0;
diff --git a/arch/x86/xen/Makefile b/arch/x86/xen/Makefile
index 172438f86a02..7410640db173 100644
--- a/arch/x86/xen/Makefile
+++ b/arch/x86/xen/Makefile
@@ -5,6 +5,10 @@ CFLAGS_REMOVE_time.o = -pg
5CFLAGS_REMOVE_irq.o = -pg 5CFLAGS_REMOVE_irq.o = -pg
6endif 6endif
7 7
8# Make sure early boot has no stackprotector
9nostackp := $(call cc-option, -fno-stack-protector)
10CFLAGS_enlighten.o := $(nostackp)
11
8obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \ 12obj-y := enlighten.o setup.o multicalls.o mmu.o irq.o \
9 time.o xen-asm.o xen-asm_$(BITS).o \ 13 time.o xen-asm.o xen-asm_$(BITS).o \
10 grant-table.o suspend.o 14 grant-table.o suspend.o
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 0a1700a2be9c..eb33aaa8415d 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -215,6 +215,7 @@ static __init void xen_init_cpuid_mask(void)
215 (1 << X86_FEATURE_ACPI)); /* disable ACPI */ 215 (1 << X86_FEATURE_ACPI)); /* disable ACPI */
216 216
217 ax = 1; 217 ax = 1;
218 cx = 0;
218 xen_cpuid(&ax, &bx, &cx, &dx); 219 xen_cpuid(&ax, &bx, &cx, &dx);
219 220
220 /* cpuid claims we support xsave; try enabling it to see what happens */ 221 /* cpuid claims we support xsave; try enabling it to see what happens */
@@ -974,10 +975,6 @@ asmlinkage void __init xen_start_kernel(void)
974 975
975 xen_domain_type = XEN_PV_DOMAIN; 976 xen_domain_type = XEN_PV_DOMAIN;
976 977
977 BUG_ON(memcmp(xen_start_info->magic, "xen-3", 5) != 0);
978
979 xen_setup_features();
980
981 /* Install Xen paravirt ops */ 978 /* Install Xen paravirt ops */
982 pv_info = xen_info; 979 pv_info = xen_info;
983 pv_init_ops = xen_init_ops; 980 pv_init_ops = xen_init_ops;
@@ -986,8 +983,15 @@ asmlinkage void __init xen_start_kernel(void)
986 pv_apic_ops = xen_apic_ops; 983 pv_apic_ops = xen_apic_ops;
987 pv_mmu_ops = xen_mmu_ops; 984 pv_mmu_ops = xen_mmu_ops;
988 985
989 xen_init_irq_ops(); 986#ifdef CONFIG_X86_64
987 /*
988 * Setup percpu state. We only need to do this for 64-bit
989 * because 32-bit already has %fs set properly.
990 */
991 load_percpu_segment(0);
992#endif
990 993
994 xen_init_irq_ops();
991 xen_init_cpuid_mask(); 995 xen_init_cpuid_mask();
992 996
993#ifdef CONFIG_X86_LOCAL_APIC 997#ifdef CONFIG_X86_LOCAL_APIC
@@ -997,6 +1001,8 @@ asmlinkage void __init xen_start_kernel(void)
997 set_xen_basic_apic_ops(); 1001 set_xen_basic_apic_ops();
998#endif 1002#endif
999 1003
1004 xen_setup_features();
1005
1000 if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) { 1006 if (xen_feature(XENFEAT_mmu_pt_update_preserve_ad)) {
1001 pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start; 1007 pv_mmu_ops.ptep_modify_prot_start = xen_ptep_modify_prot_start;
1002 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit; 1008 pv_mmu_ops.ptep_modify_prot_commit = xen_ptep_modify_prot_commit;
@@ -1004,13 +1010,6 @@ asmlinkage void __init xen_start_kernel(void)
1004 1010
1005 machine_ops = xen_machine_ops; 1011 machine_ops = xen_machine_ops;
1006 1012
1007#ifdef CONFIG_X86_64
1008 /*
1009 * Setup percpu state. We only need to do this for 64-bit
1010 * because 32-bit already has %fs set properly.
1011 */
1012 load_percpu_segment(0);
1013#endif
1014 /* 1013 /*
1015 * The only reliable way to retain the initial address of the 1014 * The only reliable way to retain the initial address of the
1016 * percpu gdt_page is to remember it here, so we can go and 1015 * percpu gdt_page is to remember it here, so we can go and
@@ -1061,6 +1060,7 @@ asmlinkage void __init xen_start_kernel(void)
1061 /* set up basic CPUID stuff */ 1060 /* set up basic CPUID stuff */
1062 cpu_detect(&new_cpu_data); 1061 cpu_detect(&new_cpu_data);
1063 new_cpu_data.hard_math = 1; 1062 new_cpu_data.hard_math = 1;
1063 new_cpu_data.wp_works_ok = 1;
1064 new_cpu_data.x86_capability[0] = cpuid_edx(1); 1064 new_cpu_data.x86_capability[0] = cpuid_edx(1);
1065#endif 1065#endif
1066 1066
diff --git a/block/Kconfig b/block/Kconfig
index 95a86adc33a1..9be0b56eaee1 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -48,9 +48,9 @@ config LBDAF
48 If unsure, say Y. 48 If unsure, say Y.
49 49
50config BLK_DEV_BSG 50config BLK_DEV_BSG
51 bool "Block layer SG support v4 (EXPERIMENTAL)" 51 bool "Block layer SG support v4"
52 depends on EXPERIMENTAL 52 default y
53 ---help--- 53 help
54 Saying Y here will enable generic SG (SCSI generic) v4 support 54 Saying Y here will enable generic SG (SCSI generic) v4 support
55 for any block device. 55 for any block device.
56 56
@@ -60,7 +60,10 @@ config BLK_DEV_BSG
60 protocols (e.g. Task Management Functions and SMP in Serial 60 protocols (e.g. Task Management Functions and SMP in Serial
61 Attached SCSI). 61 Attached SCSI).
62 62
63 If unsure, say N. 63 This option is required by recent UDEV versions to properly
64 access device serial numbers, etc.
65
66 If unsure, say Y.
64 67
65config BLK_DEV_INTEGRITY 68config BLK_DEV_INTEGRITY
66 bool "Block layer data integrity support" 69 bool "Block layer data integrity support"
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 8a3ea3bba10d..476d87065073 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -7,6 +7,7 @@
7#include <linux/bio.h> 7#include <linux/bio.h>
8#include <linux/blkdev.h> 8#include <linux/blkdev.h>
9#include <linux/bootmem.h> /* for max_pfn/max_low_pfn */ 9#include <linux/bootmem.h> /* for max_pfn/max_low_pfn */
10#include <linux/gcd.h>
10 11
11#include "blk.h" 12#include "blk.h"
12 13
@@ -384,8 +385,8 @@ void blk_queue_alignment_offset(struct request_queue *q, unsigned int offset)
384EXPORT_SYMBOL(blk_queue_alignment_offset); 385EXPORT_SYMBOL(blk_queue_alignment_offset);
385 386
386/** 387/**
387 * blk_queue_io_min - set minimum request size for the queue 388 * blk_limits_io_min - set minimum request size for a device
388 * @q: the request queue for the device 389 * @limits: the queue limits
389 * @min: smallest I/O size in bytes 390 * @min: smallest I/O size in bytes
390 * 391 *
391 * Description: 392 * Description:
@@ -394,15 +395,35 @@ EXPORT_SYMBOL(blk_queue_alignment_offset);
394 * smallest I/O the device can perform without incurring a performance 395 * smallest I/O the device can perform without incurring a performance
395 * penalty. 396 * penalty.
396 */ 397 */
397void blk_queue_io_min(struct request_queue *q, unsigned int min) 398void blk_limits_io_min(struct queue_limits *limits, unsigned int min)
398{ 399{
399 q->limits.io_min = min; 400 limits->io_min = min;
400 401
401 if (q->limits.io_min < q->limits.logical_block_size) 402 if (limits->io_min < limits->logical_block_size)
402 q->limits.io_min = q->limits.logical_block_size; 403 limits->io_min = limits->logical_block_size;
403 404
404 if (q->limits.io_min < q->limits.physical_block_size) 405 if (limits->io_min < limits->physical_block_size)
405 q->limits.io_min = q->limits.physical_block_size; 406 limits->io_min = limits->physical_block_size;
407}
408EXPORT_SYMBOL(blk_limits_io_min);
409
410/**
411 * blk_queue_io_min - set minimum request size for the queue
412 * @q: the request queue for the device
413 * @min: smallest I/O size in bytes
414 *
415 * Description:
416 * Storage devices may report a granularity or preferred minimum I/O
417 * size which is the smallest request the device can perform without
418 * incurring a performance penalty. For disk drives this is often the
419 * physical block size. For RAID arrays it is often the stripe chunk
420 * size. A properly aligned multiple of minimum_io_size is the
421 * preferred request size for workloads where a high number of I/O
422 * operations is desired.
423 */
424void blk_queue_io_min(struct request_queue *q, unsigned int min)
425{
426 blk_limits_io_min(&q->limits, min);
406} 427}
407EXPORT_SYMBOL(blk_queue_io_min); 428EXPORT_SYMBOL(blk_queue_io_min);
408 429
@@ -412,8 +433,12 @@ EXPORT_SYMBOL(blk_queue_io_min);
412 * @opt: optimal request size in bytes 433 * @opt: optimal request size in bytes
413 * 434 *
414 * Description: 435 * Description:
415 * Drivers can call this function to set the preferred I/O request 436 * Storage devices may report an optimal I/O size, which is the
416 * size for devices that report such a value. 437 * device's preferred unit for sustained I/O. This is rarely reported
438 * for disk drives. For RAID arrays it is usually the stripe width or
439 * the internal track size. A properly aligned multiple of
440 * optimal_io_size is the preferred request size for workloads where
441 * sustained throughput is desired.
417 */ 442 */
418void blk_queue_io_opt(struct request_queue *q, unsigned int opt) 443void blk_queue_io_opt(struct request_queue *q, unsigned int opt)
419{ 444{
@@ -433,27 +458,7 @@ EXPORT_SYMBOL(blk_queue_io_opt);
433 **/ 458 **/
434void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b) 459void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
435{ 460{
436 /* zero is "infinity" */ 461 blk_stack_limits(&t->limits, &b->limits, 0);
437 t->limits.max_sectors = min_not_zero(queue_max_sectors(t),
438 queue_max_sectors(b));
439
440 t->limits.max_hw_sectors = min_not_zero(queue_max_hw_sectors(t),
441 queue_max_hw_sectors(b));
442
443 t->limits.seg_boundary_mask = min_not_zero(queue_segment_boundary(t),
444 queue_segment_boundary(b));
445
446 t->limits.max_phys_segments = min_not_zero(queue_max_phys_segments(t),
447 queue_max_phys_segments(b));
448
449 t->limits.max_hw_segments = min_not_zero(queue_max_hw_segments(t),
450 queue_max_hw_segments(b));
451
452 t->limits.max_segment_size = min_not_zero(queue_max_segment_size(t),
453 queue_max_segment_size(b));
454
455 t->limits.logical_block_size = max(queue_logical_block_size(t),
456 queue_logical_block_size(b));
457 462
458 if (!t->queue_lock) 463 if (!t->queue_lock)
459 WARN_ON_ONCE(1); 464 WARN_ON_ONCE(1);
@@ -523,6 +528,16 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
523 return -1; 528 return -1;
524 } 529 }
525 530
531 /* Find lcm() of optimal I/O size */
532 if (t->io_opt && b->io_opt)
533 t->io_opt = (t->io_opt * b->io_opt) / gcd(t->io_opt, b->io_opt);
534 else if (b->io_opt)
535 t->io_opt = b->io_opt;
536
537 /* Verify that optimal I/O size is a multiple of io_min */
538 if (t->io_min && t->io_opt % t->io_min)
539 return -1;
540
526 return 0; 541 return 0;
527} 542}
528EXPORT_SYMBOL(blk_stack_limits); 543EXPORT_SYMBOL(blk_stack_limits);
diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c
index 7a0f4aa4fa1e..9a62224cc278 100644
--- a/drivers/acpi/acpi_memhotplug.c
+++ b/drivers/acpi/acpi_memhotplug.c
@@ -38,6 +38,9 @@
38 38
39#define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT 39#define _COMPONENT ACPI_MEMORY_DEVICE_COMPONENT
40 40
41#undef PREFIX
42#define PREFIX "ACPI:memory_hp:"
43
41ACPI_MODULE_NAME("acpi_memhotplug"); 44ACPI_MODULE_NAME("acpi_memhotplug");
42MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>"); 45MODULE_AUTHOR("Naveen B S <naveen.b.s@intel.com>");
43MODULE_DESCRIPTION("Hotplug Mem Driver"); 46MODULE_DESCRIPTION("Hotplug Mem Driver");
@@ -153,6 +156,7 @@ acpi_memory_get_device(acpi_handle handle,
153 acpi_handle phandle; 156 acpi_handle phandle;
154 struct acpi_device *device = NULL; 157 struct acpi_device *device = NULL;
155 struct acpi_device *pdevice = NULL; 158 struct acpi_device *pdevice = NULL;
159 int result;
156 160
157 161
158 if (!acpi_bus_get_device(handle, &device) && device) 162 if (!acpi_bus_get_device(handle, &device) && device)
@@ -165,9 +169,9 @@ acpi_memory_get_device(acpi_handle handle,
165 } 169 }
166 170
167 /* Get the parent device */ 171 /* Get the parent device */
168 status = acpi_bus_get_device(phandle, &pdevice); 172 result = acpi_bus_get_device(phandle, &pdevice);
169 if (ACPI_FAILURE(status)) { 173 if (result) {
170 ACPI_EXCEPTION((AE_INFO, status, "Cannot get acpi bus device")); 174 printk(KERN_WARNING PREFIX "Cannot get acpi bus device");
171 return -EINVAL; 175 return -EINVAL;
172 } 176 }
173 177
@@ -175,9 +179,9 @@ acpi_memory_get_device(acpi_handle handle,
175 * Now add the notified device. This creates the acpi_device 179 * Now add the notified device. This creates the acpi_device
176 * and invokes .add function 180 * and invokes .add function
177 */ 181 */
178 status = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE); 182 result = acpi_bus_add(&device, pdevice, handle, ACPI_BUS_TYPE_DEVICE);
179 if (ACPI_FAILURE(status)) { 183 if (result) {
180 ACPI_EXCEPTION((AE_INFO, status, "Cannot add acpi bus")); 184 printk(KERN_WARNING PREFIX "Cannot add acpi bus");
181 return -EINVAL; 185 return -EINVAL;
182 } 186 }
183 187
@@ -238,7 +242,12 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
238 num_enabled++; 242 num_enabled++;
239 continue; 243 continue;
240 } 244 }
241 245 /*
246 * If the memory block size is zero, please ignore it.
247 * Don't try to do the following memory hotplug flowchart.
248 */
249 if (!info->length)
250 continue;
242 if (node < 0) 251 if (node < 0)
243 node = memory_add_physaddr_to_nid(info->start_addr); 252 node = memory_add_physaddr_to_nid(info->start_addr);
244 253
@@ -253,8 +262,15 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)
253 mem_device->state = MEMORY_INVALID_STATE; 262 mem_device->state = MEMORY_INVALID_STATE;
254 return -EINVAL; 263 return -EINVAL;
255 } 264 }
256 265 /*
257 return result; 266 * Sometimes the memory device will contain several memory blocks.
267 * When one memory block is hot-added to the system memory, it will
268 * be regarded as a success.
269 * Otherwise if the last memory block can't be hot-added to the system
270 * memory, it will be failure and the memory device can't be bound with
271 * driver.
272 */
273 return 0;
258} 274}
259 275
260static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device) 276static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)
diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h
index 544dcf834922..eb6f038b03d9 100644
--- a/drivers/acpi/acpica/acobject.h
+++ b/drivers/acpi/acpica/acobject.h
@@ -97,6 +97,7 @@
97#define AOPOBJ_OBJECT_INITIALIZED 0x08 97#define AOPOBJ_OBJECT_INITIALIZED 0x08
98#define AOPOBJ_SETUP_COMPLETE 0x10 98#define AOPOBJ_SETUP_COMPLETE 0x10
99#define AOPOBJ_SINGLE_DATUM 0x20 99#define AOPOBJ_SINGLE_DATUM 0x20
100#define AOPOBJ_INVALID 0x40 /* Used if host OS won't allow an op_region address */
100 101
101/****************************************************************************** 102/******************************************************************************
102 * 103 *
diff --git a/drivers/acpi/acpica/dsopcode.c b/drivers/acpi/acpica/dsopcode.c
index 584d766e6f12..b79978f7bc71 100644
--- a/drivers/acpi/acpica/dsopcode.c
+++ b/drivers/acpi/acpica/dsopcode.c
@@ -397,6 +397,30 @@ acpi_status acpi_ds_get_region_arguments(union acpi_operand_object *obj_desc)
397 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node), 397 status = acpi_ds_execute_arguments(node, acpi_ns_get_parent_node(node),
398 extra_desc->extra.aml_length, 398 extra_desc->extra.aml_length,
399 extra_desc->extra.aml_start); 399 extra_desc->extra.aml_start);
400 if (ACPI_FAILURE(status)) {
401 return_ACPI_STATUS(status);
402 }
403
404 /* Validate the region address/length via the host OS */
405
406 status = acpi_os_validate_address(obj_desc->region.space_id,
407 obj_desc->region.address,
408 (acpi_size) obj_desc->region.length,
409 acpi_ut_get_node_name(node));
410
411 if (ACPI_FAILURE(status)) {
412 /*
413 * Invalid address/length. We will emit an error message and mark
414 * the region as invalid, so that it will cause an additional error if
415 * it is ever used. Then return AE_OK.
416 */
417 ACPI_EXCEPTION((AE_INFO, status,
418 "During address validation of OpRegion [%4.4s]",
419 node->name.ascii));
420 obj_desc->common.flags |= AOPOBJ_INVALID;
421 status = AE_OK;
422 }
423
400 return_ACPI_STATUS(status); 424 return_ACPI_STATUS(status);
401} 425}
402 426
diff --git a/drivers/acpi/acpica/exfldio.c b/drivers/acpi/acpica/exfldio.c
index d4075b821021..6687be167f5f 100644
--- a/drivers/acpi/acpica/exfldio.c
+++ b/drivers/acpi/acpica/exfldio.c
@@ -113,6 +113,12 @@ acpi_ex_setup_region(union acpi_operand_object *obj_desc,
113 } 113 }
114 } 114 }
115 115
116 /* Exit if Address/Length have been disallowed by the host OS */
117
118 if (rgn_desc->common.flags & AOPOBJ_INVALID) {
119 return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS);
120 }
121
116 /* 122 /*
117 * Exit now for SMBus address space, it has a non-linear address space 123 * Exit now for SMBus address space, it has a non-linear address space
118 * and the request cannot be directly validated 124 * and the request cannot be directly validated
diff --git a/drivers/acpi/acpica/exstorob.c b/drivers/acpi/acpica/exstorob.c
index 67340cc70142..257706e7734f 100644
--- a/drivers/acpi/acpica/exstorob.c
+++ b/drivers/acpi/acpica/exstorob.c
@@ -70,6 +70,12 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
70 70
71 ACPI_FUNCTION_TRACE_PTR(ex_store_buffer_to_buffer, source_desc); 71 ACPI_FUNCTION_TRACE_PTR(ex_store_buffer_to_buffer, source_desc);
72 72
73 /* If Source and Target are the same, just return */
74
75 if (source_desc == target_desc) {
76 return_ACPI_STATUS(AE_OK);
77 }
78
73 /* We know that source_desc is a buffer by now */ 79 /* We know that source_desc is a buffer by now */
74 80
75 buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer); 81 buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer);
@@ -161,6 +167,12 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
161 167
162 ACPI_FUNCTION_TRACE_PTR(ex_store_string_to_string, source_desc); 168 ACPI_FUNCTION_TRACE_PTR(ex_store_string_to_string, source_desc);
163 169
170 /* If Source and Target are the same, just return */
171
172 if (source_desc == target_desc) {
173 return_ACPI_STATUS(AE_OK);
174 }
175
164 /* We know that source_desc is a string by now */ 176 /* We know that source_desc is a string by now */
165 177
166 buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer); 178 buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer);
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 71670719d61a..5691f165a952 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -189,11 +189,36 @@ acpi_status __init acpi_os_initialize(void)
189 return AE_OK; 189 return AE_OK;
190} 190}
191 191
192static void bind_to_cpu0(struct work_struct *work)
193{
194 set_cpus_allowed(current, cpumask_of_cpu(0));
195 kfree(work);
196}
197
198static void bind_workqueue(struct workqueue_struct *wq)
199{
200 struct work_struct *work;
201
202 work = kzalloc(sizeof(struct work_struct), GFP_KERNEL);
203 INIT_WORK(work, bind_to_cpu0);
204 queue_work(wq, work);
205}
206
192acpi_status acpi_os_initialize1(void) 207acpi_status acpi_os_initialize1(void)
193{ 208{
209 /*
210 * On some machines, a software-initiated SMI causes corruption unless
211 * the SMI runs on CPU 0. An SMI can be initiated by any AML, but
212 * typically it's done in GPE-related methods that are run via
213 * workqueues, so we can avoid the known corruption cases by binding
214 * the workqueues to CPU 0.
215 */
194 kacpid_wq = create_singlethread_workqueue("kacpid"); 216 kacpid_wq = create_singlethread_workqueue("kacpid");
217 bind_workqueue(kacpid_wq);
195 kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify"); 218 kacpi_notify_wq = create_singlethread_workqueue("kacpi_notify");
219 bind_workqueue(kacpi_notify_wq);
196 kacpi_hotplug_wq = create_singlethread_workqueue("kacpi_hotplug"); 220 kacpi_hotplug_wq = create_singlethread_workqueue("kacpi_hotplug");
221 bind_workqueue(kacpi_hotplug_wq);
197 BUG_ON(!kacpid_wq); 222 BUG_ON(!kacpid_wq);
198 BUG_ON(!kacpi_notify_wq); 223 BUG_ON(!kacpi_notify_wq);
199 BUG_ON(!kacpi_hotplug_wq); 224 BUG_ON(!kacpi_hotplug_wq);
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index 84e0f3c07442..2cc4b3033872 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -1151,6 +1151,9 @@ static int __init acpi_processor_init(void)
1151{ 1151{
1152 int result = 0; 1152 int result = 0;
1153 1153
1154 if (acpi_disabled)
1155 return 0;
1156
1154 memset(&errata, 0, sizeof(errata)); 1157 memset(&errata, 0, sizeof(errata));
1155 1158
1156#ifdef CONFIG_SMP 1159#ifdef CONFIG_SMP
@@ -1197,6 +1200,9 @@ out_proc:
1197 1200
1198static void __exit acpi_processor_exit(void) 1201static void __exit acpi_processor_exit(void)
1199{ 1202{
1203 if (acpi_disabled)
1204 return;
1205
1200 acpi_processor_ppc_exit(); 1206 acpi_processor_ppc_exit();
1201 1207
1202 acpi_thermal_cpufreq_exit(); 1208 acpi_thermal_cpufreq_exit();
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index 0efa59e7e3af..66393d5c4c7c 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -162,8 +162,9 @@ static void lapic_timer_check_state(int state, struct acpi_processor *pr,
162 pr->power.timer_broadcast_on_state = state; 162 pr->power.timer_broadcast_on_state = state;
163} 163}
164 164
165static void lapic_timer_propagate_broadcast(struct acpi_processor *pr) 165static void lapic_timer_propagate_broadcast(void *arg)
166{ 166{
167 struct acpi_processor *pr = (struct acpi_processor *) arg;
167 unsigned long reason; 168 unsigned long reason;
168 169
169 reason = pr->power.timer_broadcast_on_state < INT_MAX ? 170 reason = pr->power.timer_broadcast_on_state < INT_MAX ?
@@ -635,7 +636,8 @@ static int acpi_processor_power_verify(struct acpi_processor *pr)
635 working++; 636 working++;
636 } 637 }
637 638
638 lapic_timer_propagate_broadcast(pr); 639 smp_call_function_single(pr->id, lapic_timer_propagate_broadcast,
640 pr, 1);
639 641
640 return (working); 642 return (working);
641} 643}
diff --git a/drivers/acpi/processor_thermal.c b/drivers/acpi/processor_thermal.c
index 39838c666032..31adda1099e0 100644
--- a/drivers/acpi/processor_thermal.c
+++ b/drivers/acpi/processor_thermal.c
@@ -66,7 +66,7 @@ static int acpi_processor_apply_limit(struct acpi_processor *pr)
66 if (pr->limit.thermal.tx > tx) 66 if (pr->limit.thermal.tx > tx)
67 tx = pr->limit.thermal.tx; 67 tx = pr->limit.thermal.tx;
68 68
69 result = acpi_processor_set_throttling(pr, tx); 69 result = acpi_processor_set_throttling(pr, tx, false);
70 if (result) 70 if (result)
71 goto end; 71 goto end;
72 } 72 }
@@ -421,12 +421,12 @@ processor_set_cur_state(struct thermal_cooling_device *cdev,
421 421
422 if (state <= max_pstate) { 422 if (state <= max_pstate) {
423 if (pr->flags.throttling && pr->throttling.state) 423 if (pr->flags.throttling && pr->throttling.state)
424 result = acpi_processor_set_throttling(pr, 0); 424 result = acpi_processor_set_throttling(pr, 0, false);
425 cpufreq_set_cur_state(pr->id, state); 425 cpufreq_set_cur_state(pr->id, state);
426 } else { 426 } else {
427 cpufreq_set_cur_state(pr->id, max_pstate); 427 cpufreq_set_cur_state(pr->id, max_pstate);
428 result = acpi_processor_set_throttling(pr, 428 result = acpi_processor_set_throttling(pr,
429 state - max_pstate); 429 state - max_pstate, false);
430 } 430 }
431 return result; 431 return result;
432} 432}
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 227543789ba9..ae39797aab55 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -62,7 +62,8 @@ struct throttling_tstate {
62#define THROTTLING_POSTCHANGE (2) 62#define THROTTLING_POSTCHANGE (2)
63 63
64static int acpi_processor_get_throttling(struct acpi_processor *pr); 64static int acpi_processor_get_throttling(struct acpi_processor *pr);
65int acpi_processor_set_throttling(struct acpi_processor *pr, int state); 65int acpi_processor_set_throttling(struct acpi_processor *pr,
66 int state, bool force);
66 67
67static int acpi_processor_update_tsd_coord(void) 68static int acpi_processor_update_tsd_coord(void)
68{ 69{
@@ -361,7 +362,7 @@ int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
361 */ 362 */
362 target_state = throttling_limit; 363 target_state = throttling_limit;
363 } 364 }
364 return acpi_processor_set_throttling(pr, target_state); 365 return acpi_processor_set_throttling(pr, target_state, false);
365} 366}
366 367
367/* 368/*
@@ -839,10 +840,10 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
839 if (ret >= 0) { 840 if (ret >= 0) {
840 state = acpi_get_throttling_state(pr, value); 841 state = acpi_get_throttling_state(pr, value);
841 if (state == -1) { 842 if (state == -1) {
842 ACPI_WARNING((AE_INFO, 843 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
843 "Invalid throttling state, reset")); 844 "Invalid throttling state, reset\n"));
844 state = 0; 845 state = 0;
845 ret = acpi_processor_set_throttling(pr, state); 846 ret = acpi_processor_set_throttling(pr, state, true);
846 if (ret) 847 if (ret)
847 return ret; 848 return ret;
848 } 849 }
@@ -915,7 +916,7 @@ static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
915} 916}
916 917
917static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, 918static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
918 int state) 919 int state, bool force)
919{ 920{
920 u32 value = 0; 921 u32 value = 0;
921 u32 duty_mask = 0; 922 u32 duty_mask = 0;
@@ -930,7 +931,7 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
930 if (!pr->flags.throttling) 931 if (!pr->flags.throttling)
931 return -ENODEV; 932 return -ENODEV;
932 933
933 if (state == pr->throttling.state) 934 if (!force && (state == pr->throttling.state))
934 return 0; 935 return 0;
935 936
936 if (state < pr->throttling_platform_limit) 937 if (state < pr->throttling_platform_limit)
@@ -988,7 +989,7 @@ static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
988} 989}
989 990
990static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr, 991static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
991 int state) 992 int state, bool force)
992{ 993{
993 int ret; 994 int ret;
994 acpi_integer value; 995 acpi_integer value;
@@ -1002,7 +1003,7 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
1002 if (!pr->flags.throttling) 1003 if (!pr->flags.throttling)
1003 return -ENODEV; 1004 return -ENODEV;
1004 1005
1005 if (state == pr->throttling.state) 1006 if (!force && (state == pr->throttling.state))
1006 return 0; 1007 return 0;
1007 1008
1008 if (state < pr->throttling_platform_limit) 1009 if (state < pr->throttling_platform_limit)
@@ -1018,7 +1019,8 @@ static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
1018 return 0; 1019 return 0;
1019} 1020}
1020 1021
1021int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 1022int acpi_processor_set_throttling(struct acpi_processor *pr,
1023 int state, bool force)
1022{ 1024{
1023 cpumask_var_t saved_mask; 1025 cpumask_var_t saved_mask;
1024 int ret = 0; 1026 int ret = 0;
@@ -1070,7 +1072,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1070 /* FIXME: use work_on_cpu() */ 1072 /* FIXME: use work_on_cpu() */
1071 set_cpus_allowed_ptr(current, cpumask_of(pr->id)); 1073 set_cpus_allowed_ptr(current, cpumask_of(pr->id));
1072 ret = p_throttling->acpi_processor_set_throttling(pr, 1074 ret = p_throttling->acpi_processor_set_throttling(pr,
1073 t_state.target_state); 1075 t_state.target_state, force);
1074 } else { 1076 } else {
1075 /* 1077 /*
1076 * When the T-state coordination is SW_ALL or HW_ALL, 1078 * When the T-state coordination is SW_ALL or HW_ALL,
@@ -1103,7 +1105,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1103 set_cpus_allowed_ptr(current, cpumask_of(i)); 1105 set_cpus_allowed_ptr(current, cpumask_of(i));
1104 ret = match_pr->throttling. 1106 ret = match_pr->throttling.
1105 acpi_processor_set_throttling( 1107 acpi_processor_set_throttling(
1106 match_pr, t_state.target_state); 1108 match_pr, t_state.target_state, force);
1107 } 1109 }
1108 } 1110 }
1109 /* 1111 /*
@@ -1201,7 +1203,7 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
1201 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 1203 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1202 "Disabling throttling (was T%d)\n", 1204 "Disabling throttling (was T%d)\n",
1203 pr->throttling.state)); 1205 pr->throttling.state));
1204 result = acpi_processor_set_throttling(pr, 0); 1206 result = acpi_processor_set_throttling(pr, 0, false);
1205 if (result) 1207 if (result)
1206 goto end; 1208 goto end;
1207 } 1209 }
@@ -1307,7 +1309,7 @@ static ssize_t acpi_processor_write_throttling(struct file *file,
1307 if (strcmp(tmpbuf, charp) != 0) 1309 if (strcmp(tmpbuf, charp) != 0)
1308 return -EINVAL; 1310 return -EINVAL;
1309 1311
1310 result = acpi_processor_set_throttling(pr, state_val); 1312 result = acpi_processor_set_throttling(pr, state_val, false);
1311 if (result) 1313 if (result)
1312 return result; 1314 return result;
1313 1315
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 0944daec064f..9c61ab2177cf 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -121,7 +121,7 @@ static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
121 table_attr->attr.size = 0; 121 table_attr->attr.size = 0;
122 table_attr->attr.read = acpi_table_show; 122 table_attr->attr.read = acpi_table_show;
123 table_attr->attr.attr.name = table_attr->name; 123 table_attr->attr.attr.name = table_attr->name;
124 table_attr->attr.attr.mode = 0444; 124 table_attr->attr.attr.mode = 0400;
125 125
126 return; 126 return;
127} 127}
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 8851315ce858..60ea984c84a0 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -2004,8 +2004,11 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
2004 status = acpi_remove_notify_handler(device->dev->handle, 2004 status = acpi_remove_notify_handler(device->dev->handle,
2005 ACPI_DEVICE_NOTIFY, 2005 ACPI_DEVICE_NOTIFY,
2006 acpi_video_device_notify); 2006 acpi_video_device_notify);
2007 sysfs_remove_link(&device->backlight->dev.kobj, "device"); 2007 if (device->backlight) {
2008 backlight_device_unregister(device->backlight); 2008 sysfs_remove_link(&device->backlight->dev.kobj, "device");
2009 backlight_device_unregister(device->backlight);
2010 device->backlight = NULL;
2011 }
2009 if (device->cdev) { 2012 if (device->cdev) {
2010 sysfs_remove_link(&device->dev->dev.kobj, 2013 sysfs_remove_link(&device->dev->dev.kobj,
2011 "thermal_cooling"); 2014 "thermal_cooling");
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 958c1fa41900..fe3eba5d6b3e 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -219,6 +219,8 @@ enum {
219 AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */ 219 AHCI_HFLAG_SECT255 = (1 << 8), /* max 255 sectors */
220 AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */ 220 AHCI_HFLAG_YES_NCQ = (1 << 9), /* force NCQ cap on */
221 AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */ 221 AHCI_HFLAG_NO_SUSPEND = (1 << 10), /* don't suspend */
222 AHCI_HFLAG_SRST_TOUT_IS_OFFLINE = (1 << 11), /* treat SRST timeout as
223 link offline */
222 224
223 /* ap->flags bits */ 225 /* ap->flags bits */
224 226
@@ -1663,6 +1665,7 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1663 int (*check_ready)(struct ata_link *link)) 1665 int (*check_ready)(struct ata_link *link))
1664{ 1666{
1665 struct ata_port *ap = link->ap; 1667 struct ata_port *ap = link->ap;
1668 struct ahci_host_priv *hpriv = ap->host->private_data;
1666 const char *reason = NULL; 1669 const char *reason = NULL;
1667 unsigned long now, msecs; 1670 unsigned long now, msecs;
1668 struct ata_taskfile tf; 1671 struct ata_taskfile tf;
@@ -1701,12 +1704,21 @@ static int ahci_do_softreset(struct ata_link *link, unsigned int *class,
1701 1704
1702 /* wait for link to become ready */ 1705 /* wait for link to become ready */
1703 rc = ata_wait_after_reset(link, deadline, check_ready); 1706 rc = ata_wait_after_reset(link, deadline, check_ready);
1704 /* link occupied, -ENODEV too is an error */ 1707 if (rc == -EBUSY && hpriv->flags & AHCI_HFLAG_SRST_TOUT_IS_OFFLINE) {
1705 if (rc) { 1708 /*
1709 * Workaround for cases where link online status can't
1710 * be trusted. Treat device readiness timeout as link
1711 * offline.
1712 */
1713 ata_link_printk(link, KERN_INFO,
1714 "device not ready, treating as offline\n");
1715 *class = ATA_DEV_NONE;
1716 } else if (rc) {
1717 /* link occupied, -ENODEV too is an error */
1706 reason = "device not ready"; 1718 reason = "device not ready";
1707 goto fail; 1719 goto fail;
1708 } 1720 } else
1709 *class = ahci_dev_classify(ap); 1721 *class = ahci_dev_classify(ap);
1710 1722
1711 DPRINTK("EXIT, class=%u\n", *class); 1723 DPRINTK("EXIT, class=%u\n", *class);
1712 return 0; 1724 return 0;
@@ -1773,7 +1785,8 @@ static int ahci_sb600_softreset(struct ata_link *link, unsigned int *class,
1773 irq_sts = readl(port_mmio + PORT_IRQ_STAT); 1785 irq_sts = readl(port_mmio + PORT_IRQ_STAT);
1774 if (irq_sts & PORT_IRQ_BAD_PMP) { 1786 if (irq_sts & PORT_IRQ_BAD_PMP) {
1775 ata_link_printk(link, KERN_WARNING, 1787 ata_link_printk(link, KERN_WARNING,
1776 "failed due to HW bug, retry pmp=0\n"); 1788 "applying SB600 PMP SRST workaround "
1789 "and retrying\n");
1777 rc = ahci_do_softreset(link, class, 0, deadline, 1790 rc = ahci_do_softreset(link, class, 0, deadline,
1778 ahci_check_ready); 1791 ahci_check_ready);
1779 } 1792 }
@@ -2726,6 +2739,56 @@ static bool ahci_broken_suspend(struct pci_dev *pdev)
2726 return !ver || strcmp(ver, dmi->driver_data) < 0; 2739 return !ver || strcmp(ver, dmi->driver_data) < 0;
2727} 2740}
2728 2741
2742static bool ahci_broken_online(struct pci_dev *pdev)
2743{
2744#define ENCODE_BUSDEVFN(bus, slot, func) \
2745 (void *)(unsigned long)(((bus) << 8) | PCI_DEVFN((slot), (func)))
2746 static const struct dmi_system_id sysids[] = {
2747 /*
2748 * There are several gigabyte boards which use
2749 * SIMG5723s configured as hardware RAID. Certain
2750 * 5723 firmware revisions shipped there keep the link
2751 * online but fail to answer properly to SRST or
2752 * IDENTIFY when no device is attached downstream
2753 * causing libata to retry quite a few times leading
2754 * to excessive detection delay.
2755 *
2756 * As these firmwares respond to the second reset try
2757 * with invalid device signature, considering unknown
2758 * sig as offline works around the problem acceptably.
2759 */
2760 {
2761 .ident = "EP45-DQ6",
2762 .matches = {
2763 DMI_MATCH(DMI_BOARD_VENDOR,
2764 "Gigabyte Technology Co., Ltd."),
2765 DMI_MATCH(DMI_BOARD_NAME, "EP45-DQ6"),
2766 },
2767 .driver_data = ENCODE_BUSDEVFN(0x0a, 0x00, 0),
2768 },
2769 {
2770 .ident = "EP45-DS5",
2771 .matches = {
2772 DMI_MATCH(DMI_BOARD_VENDOR,
2773 "Gigabyte Technology Co., Ltd."),
2774 DMI_MATCH(DMI_BOARD_NAME, "EP45-DS5"),
2775 },
2776 .driver_data = ENCODE_BUSDEVFN(0x03, 0x00, 0),
2777 },
2778 { } /* terminate list */
2779 };
2780#undef ENCODE_BUSDEVFN
2781 const struct dmi_system_id *dmi = dmi_first_match(sysids);
2782 unsigned int val;
2783
2784 if (!dmi)
2785 return false;
2786
2787 val = (unsigned long)dmi->driver_data;
2788
2789 return pdev->bus->number == (val >> 8) && pdev->devfn == (val & 0xff);
2790}
2791
2729static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 2792static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2730{ 2793{
2731 static int printed_version; 2794 static int printed_version;
@@ -2841,6 +2904,12 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2841 "BIOS update required for suspend/resume\n"); 2904 "BIOS update required for suspend/resume\n");
2842 } 2905 }
2843 2906
2907 if (ahci_broken_online(pdev)) {
2908 hpriv->flags |= AHCI_HFLAG_SRST_TOUT_IS_OFFLINE;
2909 dev_info(&pdev->dev,
2910 "online status unreliable, applying workaround\n");
2911 }
2912
2844 /* CAP.NP sometimes indicate the index of the last enabled 2913 /* CAP.NP sometimes indicate the index of the last enabled
2845 * port, at other times, that of the last possible port, so 2914 * port, at other times, that of the last possible port, so
2846 * determining the maximum port number requires looking at 2915 * determining the maximum port number requires looking at
diff --git a/drivers/ata/ata_piix.c b/drivers/ata/ata_piix.c
index 56b8a3ff1286..9ac4e378992e 100644
--- a/drivers/ata/ata_piix.c
+++ b/drivers/ata/ata_piix.c
@@ -664,6 +664,8 @@ static int piix_pata_prereset(struct ata_link *link, unsigned long deadline)
664 return ata_sff_prereset(link, deadline); 664 return ata_sff_prereset(link, deadline);
665} 665}
666 666
667static DEFINE_SPINLOCK(piix_lock);
668
667/** 669/**
668 * piix_set_piomode - Initialize host controller PATA PIO timings 670 * piix_set_piomode - Initialize host controller PATA PIO timings
669 * @ap: Port whose timings we are configuring 671 * @ap: Port whose timings we are configuring
@@ -677,8 +679,9 @@ static int piix_pata_prereset(struct ata_link *link, unsigned long deadline)
677 679
678static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev) 680static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev)
679{ 681{
680 unsigned int pio = adev->pio_mode - XFER_PIO_0;
681 struct pci_dev *dev = to_pci_dev(ap->host->dev); 682 struct pci_dev *dev = to_pci_dev(ap->host->dev);
683 unsigned long flags;
684 unsigned int pio = adev->pio_mode - XFER_PIO_0;
682 unsigned int is_slave = (adev->devno != 0); 685 unsigned int is_slave = (adev->devno != 0);
683 unsigned int master_port= ap->port_no ? 0x42 : 0x40; 686 unsigned int master_port= ap->port_no ? 0x42 : 0x40;
684 unsigned int slave_port = 0x44; 687 unsigned int slave_port = 0x44;
@@ -708,6 +711,8 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev)
708 if (adev->class == ATA_DEV_ATA) 711 if (adev->class == ATA_DEV_ATA)
709 control |= 4; /* PPE enable */ 712 control |= 4; /* PPE enable */
710 713
714 spin_lock_irqsave(&piix_lock, flags);
715
711 /* PIO configuration clears DTE unconditionally. It will be 716 /* PIO configuration clears DTE unconditionally. It will be
712 * programmed in set_dmamode which is guaranteed to be called 717 * programmed in set_dmamode which is guaranteed to be called
713 * after set_piomode if any DMA mode is available. 718 * after set_piomode if any DMA mode is available.
@@ -747,6 +752,8 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev)
747 udma_enable &= ~(1 << (2 * ap->port_no + adev->devno)); 752 udma_enable &= ~(1 << (2 * ap->port_no + adev->devno));
748 pci_write_config_byte(dev, 0x48, udma_enable); 753 pci_write_config_byte(dev, 0x48, udma_enable);
749 } 754 }
755
756 spin_unlock_irqrestore(&piix_lock, flags);
750} 757}
751 758
752/** 759/**
@@ -764,6 +771,7 @@ static void piix_set_piomode(struct ata_port *ap, struct ata_device *adev)
764static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, int isich) 771static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, int isich)
765{ 772{
766 struct pci_dev *dev = to_pci_dev(ap->host->dev); 773 struct pci_dev *dev = to_pci_dev(ap->host->dev);
774 unsigned long flags;
767 u8 master_port = ap->port_no ? 0x42 : 0x40; 775 u8 master_port = ap->port_no ? 0x42 : 0x40;
768 u16 master_data; 776 u16 master_data;
769 u8 speed = adev->dma_mode; 777 u8 speed = adev->dma_mode;
@@ -777,6 +785,8 @@ static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, in
777 { 2, 1 }, 785 { 2, 1 },
778 { 2, 3 }, }; 786 { 2, 3 }, };
779 787
788 spin_lock_irqsave(&piix_lock, flags);
789
780 pci_read_config_word(dev, master_port, &master_data); 790 pci_read_config_word(dev, master_port, &master_data);
781 if (ap->udma_mask) 791 if (ap->udma_mask)
782 pci_read_config_byte(dev, 0x48, &udma_enable); 792 pci_read_config_byte(dev, 0x48, &udma_enable);
@@ -867,6 +877,8 @@ static void do_pata_set_dmamode(struct ata_port *ap, struct ata_device *adev, in
867 /* Don't scribble on 0x48 if the controller does not support UDMA */ 877 /* Don't scribble on 0x48 if the controller does not support UDMA */
868 if (ap->udma_mask) 878 if (ap->udma_mask)
869 pci_write_config_byte(dev, 0x48, udma_enable); 879 pci_write_config_byte(dev, 0x48, udma_enable);
880
881 spin_unlock_irqrestore(&piix_lock, flags);
870} 882}
871 883
872/** 884/**
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 8ac98ff16d7d..072ba5ea138f 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4302,6 +4302,9 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = {
4302 { "WDC WD2500JD-00HBB0", "WD-WMAL71490727", ATA_HORKAGE_BROKEN_HPA }, 4302 { "WDC WD2500JD-00HBB0", "WD-WMAL71490727", ATA_HORKAGE_BROKEN_HPA },
4303 { "MAXTOR 6L080L4", "A93.0500", ATA_HORKAGE_BROKEN_HPA }, 4303 { "MAXTOR 6L080L4", "A93.0500", ATA_HORKAGE_BROKEN_HPA },
4304 4304
4305 /* this one allows HPA unlocking but fails IOs on the area */
4306 { "OCZ-VERTEX", "1.30", ATA_HORKAGE_BROKEN_HPA },
4307
4305 /* Devices which report 1 sector over size HPA */ 4308 /* Devices which report 1 sector over size HPA */
4306 { "ST340823A", NULL, ATA_HORKAGE_HPA_SIZE, }, 4309 { "ST340823A", NULL, ATA_HORKAGE_HPA_SIZE, },
4307 { "ST320413A", NULL, ATA_HORKAGE_HPA_SIZE, }, 4310 { "ST320413A", NULL, ATA_HORKAGE_HPA_SIZE, },
diff --git a/drivers/ata/pata_at91.c b/drivers/ata/pata_at91.c
index 5702affcb325..41c94b1ae493 100644
--- a/drivers/ata/pata_at91.c
+++ b/drivers/ata/pata_at91.c
@@ -250,7 +250,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
250 ata_port_desc(ap, "no IRQ, using PIO polling"); 250 ata_port_desc(ap, "no IRQ, using PIO polling");
251 } 251 }
252 252
253 info = kzalloc(sizeof(*info), GFP_KERNEL); 253 info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
254 254
255 if (!info) { 255 if (!info) {
256 dev_err(dev, "failed to allocate memory for private data\n"); 256 dev_err(dev, "failed to allocate memory for private data\n");
@@ -275,7 +275,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
275 if (!info->ide_addr) { 275 if (!info->ide_addr) {
276 dev_err(dev, "failed to map IO base\n"); 276 dev_err(dev, "failed to map IO base\n");
277 ret = -ENOMEM; 277 ret = -ENOMEM;
278 goto err_ide_ioremap; 278 goto err_put;
279 } 279 }
280 280
281 info->alt_addr = devm_ioremap(dev, 281 info->alt_addr = devm_ioremap(dev,
@@ -284,7 +284,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
284 if (!info->alt_addr) { 284 if (!info->alt_addr) {
285 dev_err(dev, "failed to map CTL base\n"); 285 dev_err(dev, "failed to map CTL base\n");
286 ret = -ENOMEM; 286 ret = -ENOMEM;
287 goto err_alt_ioremap; 287 goto err_put;
288 } 288 }
289 289
290 ap->ioaddr.cmd_addr = info->ide_addr; 290 ap->ioaddr.cmd_addr = info->ide_addr;
@@ -303,13 +303,8 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
303 irq ? ata_sff_interrupt : NULL, 303 irq ? ata_sff_interrupt : NULL,
304 irq_flags, &pata_at91_sht); 304 irq_flags, &pata_at91_sht);
305 305
306err_alt_ioremap: 306err_put:
307 devm_iounmap(dev, info->ide_addr);
308
309err_ide_ioremap:
310 clk_put(info->mck); 307 clk_put(info->mck);
311 kfree(info);
312
313 return ret; 308 return ret;
314} 309}
315 310
@@ -317,7 +312,6 @@ static int __devexit pata_at91_remove(struct platform_device *pdev)
317{ 312{
318 struct ata_host *host = dev_get_drvdata(&pdev->dev); 313 struct ata_host *host = dev_get_drvdata(&pdev->dev);
319 struct at91_ide_info *info; 314 struct at91_ide_info *info;
320 struct device *dev = &pdev->dev;
321 315
322 if (!host) 316 if (!host)
323 return 0; 317 return 0;
@@ -328,11 +322,8 @@ static int __devexit pata_at91_remove(struct platform_device *pdev)
328 if (!info) 322 if (!info)
329 return 0; 323 return 0;
330 324
331 devm_iounmap(dev, info->ide_addr);
332 devm_iounmap(dev, info->alt_addr);
333 clk_put(info->mck); 325 clk_put(info->mck);
334 326
335 kfree(info);
336 return 0; 327 return 0;
337} 328}
338 329
diff --git a/drivers/ata/pata_atiixp.c b/drivers/ata/pata_atiixp.c
index bec0b8ade66d..45915566e4e9 100644
--- a/drivers/ata/pata_atiixp.c
+++ b/drivers/ata/pata_atiixp.c
@@ -1,6 +1,7 @@
1/* 1/*
2 * pata_atiixp.c - ATI PATA for new ATA layer 2 * pata_atiixp.c - ATI PATA for new ATA layer
3 * (C) 2005 Red Hat Inc 3 * (C) 2005 Red Hat Inc
4 * (C) 2009 Bartlomiej Zolnierkiewicz
4 * 5 *
5 * Based on 6 * Based on
6 * 7 *
@@ -61,20 +62,19 @@ static void atiixp_set_pio_timing(struct ata_port *ap, struct ata_device *adev,
61 62
62 struct pci_dev *pdev = to_pci_dev(ap->host->dev); 63 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
63 int dn = 2 * ap->port_no + adev->devno; 64 int dn = 2 * ap->port_no + adev->devno;
64
65 /* Check this is correct - the order is odd in both drivers */
66 int timing_shift = (16 * ap->port_no) + 8 * (adev->devno ^ 1); 65 int timing_shift = (16 * ap->port_no) + 8 * (adev->devno ^ 1);
67 u16 pio_mode_data, pio_timing_data; 66 u32 pio_timing_data;
67 u16 pio_mode_data;
68 68
69 pci_read_config_word(pdev, ATIIXP_IDE_PIO_MODE, &pio_mode_data); 69 pci_read_config_word(pdev, ATIIXP_IDE_PIO_MODE, &pio_mode_data);
70 pio_mode_data &= ~(0x7 << (4 * dn)); 70 pio_mode_data &= ~(0x7 << (4 * dn));
71 pio_mode_data |= pio << (4 * dn); 71 pio_mode_data |= pio << (4 * dn);
72 pci_write_config_word(pdev, ATIIXP_IDE_PIO_MODE, pio_mode_data); 72 pci_write_config_word(pdev, ATIIXP_IDE_PIO_MODE, pio_mode_data);
73 73
74 pci_read_config_word(pdev, ATIIXP_IDE_PIO_TIMING, &pio_timing_data); 74 pci_read_config_dword(pdev, ATIIXP_IDE_PIO_TIMING, &pio_timing_data);
75 pio_timing_data &= ~(0xFF << timing_shift); 75 pio_timing_data &= ~(0xFF << timing_shift);
76 pio_timing_data |= (pio_timings[pio] << timing_shift); 76 pio_timing_data |= (pio_timings[pio] << timing_shift);
77 pci_write_config_word(pdev, ATIIXP_IDE_PIO_TIMING, pio_timing_data); 77 pci_write_config_dword(pdev, ATIIXP_IDE_PIO_TIMING, pio_timing_data);
78} 78}
79 79
80/** 80/**
@@ -119,16 +119,17 @@ static void atiixp_set_dmamode(struct ata_port *ap, struct ata_device *adev)
119 udma_mode_data |= dma << (4 * dn); 119 udma_mode_data |= dma << (4 * dn);
120 pci_write_config_word(pdev, ATIIXP_IDE_UDMA_MODE, udma_mode_data); 120 pci_write_config_word(pdev, ATIIXP_IDE_UDMA_MODE, udma_mode_data);
121 } else { 121 } else {
122 u16 mwdma_timing_data;
123 /* Check this is correct - the order is odd in both drivers */
124 int timing_shift = (16 * ap->port_no) + 8 * (adev->devno ^ 1); 122 int timing_shift = (16 * ap->port_no) + 8 * (adev->devno ^ 1);
123 u32 mwdma_timing_data;
125 124
126 dma -= XFER_MW_DMA_0; 125 dma -= XFER_MW_DMA_0;
127 126
128 pci_read_config_word(pdev, ATIIXP_IDE_MWDMA_TIMING, &mwdma_timing_data); 127 pci_read_config_dword(pdev, ATIIXP_IDE_MWDMA_TIMING,
128 &mwdma_timing_data);
129 mwdma_timing_data &= ~(0xFF << timing_shift); 129 mwdma_timing_data &= ~(0xFF << timing_shift);
130 mwdma_timing_data |= (mwdma_timings[dma] << timing_shift); 130 mwdma_timing_data |= (mwdma_timings[dma] << timing_shift);
131 pci_write_config_word(pdev, ATIIXP_IDE_MWDMA_TIMING, mwdma_timing_data); 131 pci_write_config_dword(pdev, ATIIXP_IDE_MWDMA_TIMING,
132 mwdma_timing_data);
132 } 133 }
133 /* 134 /*
134 * We must now look at the PIO mode situation. We may need to 135 * We must now look at the PIO mode situation. We may need to
diff --git a/drivers/ata/sata_nv.c b/drivers/ata/sata_nv.c
index b2d11f300c39..86a40582999c 100644
--- a/drivers/ata/sata_nv.c
+++ b/drivers/ata/sata_nv.c
@@ -602,6 +602,7 @@ MODULE_VERSION(DRV_VERSION);
602 602
603static int adma_enabled; 603static int adma_enabled;
604static int swncq_enabled = 1; 604static int swncq_enabled = 1;
605static int msi_enabled;
605 606
606static void nv_adma_register_mode(struct ata_port *ap) 607static void nv_adma_register_mode(struct ata_port *ap)
607{ 608{
@@ -2459,6 +2460,11 @@ static int nv_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2459 } else if (type == SWNCQ) 2460 } else if (type == SWNCQ)
2460 nv_swncq_host_init(host); 2461 nv_swncq_host_init(host);
2461 2462
2463 if (msi_enabled) {
2464 dev_printk(KERN_NOTICE, &pdev->dev, "Using MSI\n");
2465 pci_enable_msi(pdev);
2466 }
2467
2462 pci_set_master(pdev); 2468 pci_set_master(pdev);
2463 return ata_host_activate(host, pdev->irq, ipriv->irq_handler, 2469 return ata_host_activate(host, pdev->irq, ipriv->irq_handler,
2464 IRQF_SHARED, ipriv->sht); 2470 IRQF_SHARED, ipriv->sht);
@@ -2558,4 +2564,6 @@ module_param_named(adma, adma_enabled, bool, 0444);
2558MODULE_PARM_DESC(adma, "Enable use of ADMA (Default: false)"); 2564MODULE_PARM_DESC(adma, "Enable use of ADMA (Default: false)");
2559module_param_named(swncq, swncq_enabled, bool, 0444); 2565module_param_named(swncq, swncq_enabled, bool, 0444);
2560MODULE_PARM_DESC(swncq, "Enable use of SWNCQ (Default: true)"); 2566MODULE_PARM_DESC(swncq, "Enable use of SWNCQ (Default: true)");
2567module_param_named(msi, msi_enabled, bool, 0444);
2568MODULE_PARM_DESC(msi, "Enable use of MSI (Default: false)");
2561 2569
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 81cb01bfc356..456594bd97bc 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -483,9 +483,6 @@ int platform_driver_register(struct platform_driver *drv)
483 drv->driver.remove = platform_drv_remove; 483 drv->driver.remove = platform_drv_remove;
484 if (drv->shutdown) 484 if (drv->shutdown)
485 drv->driver.shutdown = platform_drv_shutdown; 485 drv->driver.shutdown = platform_drv_shutdown;
486 if (drv->suspend || drv->resume)
487 pr_warning("Platform driver '%s' needs updating - please use "
488 "dev_pm_ops\n", drv->driver.name);
489 486
490 return driver_register(&drv->driver); 487 return driver_register(&drv->driver);
491} 488}
diff --git a/drivers/char/agp/parisc-agp.c b/drivers/char/agp/parisc-agp.c
index f4bb43fb8016..e077701ae3d9 100644
--- a/drivers/char/agp/parisc-agp.c
+++ b/drivers/char/agp/parisc-agp.c
@@ -225,7 +225,7 @@ static const struct agp_bridge_driver parisc_agp_driver = {
225 .configure = parisc_agp_configure, 225 .configure = parisc_agp_configure,
226 .fetch_size = parisc_agp_fetch_size, 226 .fetch_size = parisc_agp_fetch_size,
227 .tlb_flush = parisc_agp_tlbflush, 227 .tlb_flush = parisc_agp_tlbflush,
228 .mask_memory = parisc_agp_mask_memory, 228 .mask_memory = parisc_agp_page_mask_memory,
229 .masks = parisc_agp_masks, 229 .masks = parisc_agp_masks,
230 .agp_enable = parisc_agp_enable, 230 .agp_enable = parisc_agp_enable,
231 .cache_flush = global_cache_flush, 231 .cache_flush = global_cache_flush,
diff --git a/drivers/char/pty.c b/drivers/char/pty.c
index 6e6942c45f5b..d083c73d784a 100644
--- a/drivers/char/pty.c
+++ b/drivers/char/pty.c
@@ -144,6 +144,8 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf,
144 144
145static int pty_write_room(struct tty_struct *tty) 145static int pty_write_room(struct tty_struct *tty)
146{ 146{
147 if (tty->stopped)
148 return 0;
147 return pty_space(tty->link); 149 return pty_space(tty->link);
148} 150}
149 151
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c
index acd76b767d4c..e48af9f79219 100644
--- a/drivers/char/tty_ldisc.c
+++ b/drivers/char/tty_ldisc.c
@@ -48,6 +48,41 @@ static DECLARE_WAIT_QUEUE_HEAD(tty_ldisc_wait);
48/* Line disc dispatch table */ 48/* Line disc dispatch table */
49static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS]; 49static struct tty_ldisc_ops *tty_ldiscs[NR_LDISCS];
50 50
51static inline struct tty_ldisc *get_ldisc(struct tty_ldisc *ld)
52{
53 if (ld)
54 atomic_inc(&ld->users);
55 return ld;
56}
57
58static void put_ldisc(struct tty_ldisc *ld)
59{
60 unsigned long flags;
61
62 if (WARN_ON_ONCE(!ld))
63 return;
64
65 /*
66 * If this is the last user, free the ldisc, and
67 * release the ldisc ops.
68 *
69 * We really want an "atomic_dec_and_lock_irqsave()",
70 * but we don't have it, so this does it by hand.
71 */
72 local_irq_save(flags);
73 if (atomic_dec_and_lock(&ld->users, &tty_ldisc_lock)) {
74 struct tty_ldisc_ops *ldo = ld->ops;
75
76 ldo->refcount--;
77 module_put(ldo->owner);
78 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
79
80 kfree(ld);
81 return;
82 }
83 local_irq_restore(flags);
84}
85
51/** 86/**
52 * tty_register_ldisc - install a line discipline 87 * tty_register_ldisc - install a line discipline
53 * @disc: ldisc number 88 * @disc: ldisc number
@@ -142,7 +177,7 @@ static struct tty_ldisc *tty_ldisc_try_get(int disc)
142 /* lock it */ 177 /* lock it */
143 ldops->refcount++; 178 ldops->refcount++;
144 ld->ops = ldops; 179 ld->ops = ldops;
145 ld->refcount = 0; 180 atomic_set(&ld->users, 1);
146 err = 0; 181 err = 0;
147 } 182 }
148 } 183 }
@@ -181,35 +216,6 @@ static struct tty_ldisc *tty_ldisc_get(int disc)
181 return ld; 216 return ld;
182} 217}
183 218
184/**
185 * tty_ldisc_put - drop ldisc reference
186 * @ld: ldisc
187 *
188 * Drop a reference to a line discipline. Manage refcounts and
189 * module usage counts. Free the ldisc once the recount hits zero.
190 *
191 * Locking:
192 * takes tty_ldisc_lock to guard against ldisc races
193 */
194
195static void tty_ldisc_put(struct tty_ldisc *ld)
196{
197 unsigned long flags;
198 int disc = ld->ops->num;
199 struct tty_ldisc_ops *ldo;
200
201 BUG_ON(disc < N_TTY || disc >= NR_LDISCS);
202
203 spin_lock_irqsave(&tty_ldisc_lock, flags);
204 ldo = tty_ldiscs[disc];
205 BUG_ON(ldo->refcount == 0);
206 ldo->refcount--;
207 module_put(ldo->owner);
208 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
209 WARN_ON(ld->refcount);
210 kfree(ld);
211}
212
213static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos) 219static void *tty_ldiscs_seq_start(struct seq_file *m, loff_t *pos)
214{ 220{
215 return (*pos < NR_LDISCS) ? pos : NULL; 221 return (*pos < NR_LDISCS) ? pos : NULL;
@@ -234,7 +240,7 @@ static int tty_ldiscs_seq_show(struct seq_file *m, void *v)
234 if (IS_ERR(ld)) 240 if (IS_ERR(ld))
235 return 0; 241 return 0;
236 seq_printf(m, "%-10s %2d\n", ld->ops->name ? ld->ops->name : "???", i); 242 seq_printf(m, "%-10s %2d\n", ld->ops->name ? ld->ops->name : "???", i);
237 tty_ldisc_put(ld); 243 put_ldisc(ld);
238 return 0; 244 return 0;
239} 245}
240 246
@@ -288,20 +294,17 @@ static void tty_ldisc_assign(struct tty_struct *tty, struct tty_ldisc *ld)
288 * Locking: takes tty_ldisc_lock 294 * Locking: takes tty_ldisc_lock
289 */ 295 */
290 296
291static int tty_ldisc_try(struct tty_struct *tty) 297static struct tty_ldisc *tty_ldisc_try(struct tty_struct *tty)
292{ 298{
293 unsigned long flags; 299 unsigned long flags;
294 struct tty_ldisc *ld; 300 struct tty_ldisc *ld;
295 int ret = 0;
296 301
297 spin_lock_irqsave(&tty_ldisc_lock, flags); 302 spin_lock_irqsave(&tty_ldisc_lock, flags);
298 ld = tty->ldisc; 303 ld = NULL;
299 if (test_bit(TTY_LDISC, &tty->flags)) { 304 if (test_bit(TTY_LDISC, &tty->flags))
300 ld->refcount++; 305 ld = get_ldisc(tty->ldisc);
301 ret = 1;
302 }
303 spin_unlock_irqrestore(&tty_ldisc_lock, flags); 306 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
304 return ret; 307 return ld;
305} 308}
306 309
307/** 310/**
@@ -322,10 +325,11 @@ static int tty_ldisc_try(struct tty_struct *tty)
322 325
323struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *tty) 326struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *tty)
324{ 327{
328 struct tty_ldisc *ld;
329
325 /* wait_event is a macro */ 330 /* wait_event is a macro */
326 wait_event(tty_ldisc_wait, tty_ldisc_try(tty)); 331 wait_event(tty_ldisc_wait, (ld = tty_ldisc_try(tty)) != NULL);
327 WARN_ON(tty->ldisc->refcount == 0); 332 return ld;
328 return tty->ldisc;
329} 333}
330EXPORT_SYMBOL_GPL(tty_ldisc_ref_wait); 334EXPORT_SYMBOL_GPL(tty_ldisc_ref_wait);
331 335
@@ -342,9 +346,7 @@ EXPORT_SYMBOL_GPL(tty_ldisc_ref_wait);
342 346
343struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty) 347struct tty_ldisc *tty_ldisc_ref(struct tty_struct *tty)
344{ 348{
345 if (tty_ldisc_try(tty)) 349 return tty_ldisc_try(tty);
346 return tty->ldisc;
347 return NULL;
348} 350}
349EXPORT_SYMBOL_GPL(tty_ldisc_ref); 351EXPORT_SYMBOL_GPL(tty_ldisc_ref);
350 352
@@ -360,21 +362,15 @@ EXPORT_SYMBOL_GPL(tty_ldisc_ref);
360 362
361void tty_ldisc_deref(struct tty_ldisc *ld) 363void tty_ldisc_deref(struct tty_ldisc *ld)
362{ 364{
363 unsigned long flags; 365 put_ldisc(ld);
364
365 BUG_ON(ld == NULL);
366
367 spin_lock_irqsave(&tty_ldisc_lock, flags);
368 if (ld->refcount == 0)
369 printk(KERN_ERR "tty_ldisc_deref: no references.\n");
370 else
371 ld->refcount--;
372 if (ld->refcount == 0)
373 wake_up(&tty_ldisc_wait);
374 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
375} 366}
376EXPORT_SYMBOL_GPL(tty_ldisc_deref); 367EXPORT_SYMBOL_GPL(tty_ldisc_deref);
377 368
369static inline void tty_ldisc_put(struct tty_ldisc *ld)
370{
371 put_ldisc(ld);
372}
373
378/** 374/**
379 * tty_ldisc_enable - allow ldisc use 375 * tty_ldisc_enable - allow ldisc use
380 * @tty: terminal to activate ldisc on 376 * @tty: terminal to activate ldisc on
@@ -512,8 +508,9 @@ static void tty_ldisc_restore(struct tty_struct *tty, struct tty_ldisc *old)
512 * be obtained while the delayed work queue halt ensures that no more 508 * be obtained while the delayed work queue halt ensures that no more
513 * data is fed to the ldisc. 509 * data is fed to the ldisc.
514 * 510 *
515 * In order to wait for any existing references to complete see 511 * You need to do a 'flush_scheduled_work()' (outside the ldisc_mutex)
516 * tty_ldisc_wait_idle. 512 * in order to make sure any currently executing ldisc work is also
513 * flushed.
517 */ 514 */
518 515
519static int tty_ldisc_halt(struct tty_struct *tty) 516static int tty_ldisc_halt(struct tty_struct *tty)
@@ -523,31 +520,6 @@ static int tty_ldisc_halt(struct tty_struct *tty)
523} 520}
524 521
525/** 522/**
526 * tty_ldisc_wait_idle - wait for the ldisc to become idle
527 * @tty: tty to wait for
528 *
529 * Wait for the line discipline to become idle. The discipline must
530 * have been halted for this to guarantee it remains idle.
531 *
532 * tty_ldisc_lock protects the ref counts currently.
533 */
534
535static int tty_ldisc_wait_idle(struct tty_struct *tty)
536{
537 unsigned long flags;
538 spin_lock_irqsave(&tty_ldisc_lock, flags);
539 while (tty->ldisc->refcount) {
540 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
541 if (wait_event_timeout(tty_ldisc_wait,
542 tty->ldisc->refcount == 0, 5 * HZ) == 0)
543 return -EBUSY;
544 spin_lock_irqsave(&tty_ldisc_lock, flags);
545 }
546 spin_unlock_irqrestore(&tty_ldisc_lock, flags);
547 return 0;
548}
549
550/**
551 * tty_set_ldisc - set line discipline 523 * tty_set_ldisc - set line discipline
552 * @tty: the terminal to set 524 * @tty: the terminal to set
553 * @ldisc: the line discipline 525 * @ldisc: the line discipline
@@ -642,14 +614,6 @@ int tty_set_ldisc(struct tty_struct *tty, int ldisc)
642 614
643 flush_scheduled_work(); 615 flush_scheduled_work();
644 616
645 /* Let any existing reference holders finish */
646 retval = tty_ldisc_wait_idle(tty);
647 if (retval < 0) {
648 clear_bit(TTY_LDISC_CHANGING, &tty->flags);
649 tty_ldisc_put(new_ldisc);
650 return retval;
651 }
652
653 mutex_lock(&tty->ldisc_mutex); 617 mutex_lock(&tty->ldisc_mutex);
654 if (test_bit(TTY_HUPPED, &tty->flags)) { 618 if (test_bit(TTY_HUPPED, &tty->flags)) {
655 /* We were raced by the hangup method. It will have stomped 619 /* We were raced by the hangup method. It will have stomped
@@ -790,12 +754,14 @@ void tty_ldisc_hangup(struct tty_struct *tty)
790 * N_TTY. 754 * N_TTY.
791 */ 755 */
792 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) { 756 if (tty->driver->flags & TTY_DRIVER_RESET_TERMIOS) {
757 /* Make sure the old ldisc is quiescent */
758 tty_ldisc_halt(tty);
759 flush_scheduled_work();
760
793 /* Avoid racing set_ldisc or tty_ldisc_release */ 761 /* Avoid racing set_ldisc or tty_ldisc_release */
794 mutex_lock(&tty->ldisc_mutex); 762 mutex_lock(&tty->ldisc_mutex);
795 if (tty->ldisc) { /* Not yet closed */ 763 if (tty->ldisc) { /* Not yet closed */
796 /* Switch back to N_TTY */ 764 /* Switch back to N_TTY */
797 tty_ldisc_halt(tty);
798 tty_ldisc_wait_idle(tty);
799 tty_ldisc_reinit(tty); 765 tty_ldisc_reinit(tty);
800 /* At this point we have a closed ldisc and we want to 766 /* At this point we have a closed ldisc and we want to
801 reopen it. We could defer this to the next open but 767 reopen it. We could defer this to the next open but
@@ -860,14 +826,6 @@ void tty_ldisc_release(struct tty_struct *tty, struct tty_struct *o_tty)
860 tty_ldisc_halt(tty); 826 tty_ldisc_halt(tty);
861 flush_scheduled_work(); 827 flush_scheduled_work();
862 828
863 /*
864 * Wait for any short term users (we know they are just driver
865 * side waiters as the file is closing so user count on the file
866 * side is zero.
867 */
868
869 tty_ldisc_wait_idle(tty);
870
871 mutex_lock(&tty->ldisc_mutex); 829 mutex_lock(&tty->ldisc_mutex);
872 /* 830 /*
873 * Now kill off the ldisc 831 * Now kill off the ldisc
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c
index 2964f5f4a7ef..6b3e0c2f33e2 100644
--- a/drivers/clocksource/sh_cmt.c
+++ b/drivers/clocksource/sh_cmt.c
@@ -40,6 +40,7 @@ struct sh_cmt_priv {
40 struct platform_device *pdev; 40 struct platform_device *pdev;
41 41
42 unsigned long flags; 42 unsigned long flags;
43 unsigned long flags_suspend;
43 unsigned long match_value; 44 unsigned long match_value;
44 unsigned long next_match_value; 45 unsigned long next_match_value;
45 unsigned long max_match_value; 46 unsigned long max_match_value;
@@ -667,11 +668,38 @@ static int __devexit sh_cmt_remove(struct platform_device *pdev)
667 return -EBUSY; /* cannot unregister clockevent and clocksource */ 668 return -EBUSY; /* cannot unregister clockevent and clocksource */
668} 669}
669 670
671static int sh_cmt_suspend(struct device *dev)
672{
673 struct platform_device *pdev = to_platform_device(dev);
674 struct sh_cmt_priv *p = platform_get_drvdata(pdev);
675
676 /* save flag state and stop CMT channel */
677 p->flags_suspend = p->flags;
678 sh_cmt_stop(p, p->flags);
679 return 0;
680}
681
682static int sh_cmt_resume(struct device *dev)
683{
684 struct platform_device *pdev = to_platform_device(dev);
685 struct sh_cmt_priv *p = platform_get_drvdata(pdev);
686
687 /* start CMT channel from saved state */
688 sh_cmt_start(p, p->flags_suspend);
689 return 0;
690}
691
692static struct dev_pm_ops sh_cmt_dev_pm_ops = {
693 .suspend = sh_cmt_suspend,
694 .resume = sh_cmt_resume,
695};
696
670static struct platform_driver sh_cmt_device_driver = { 697static struct platform_driver sh_cmt_device_driver = {
671 .probe = sh_cmt_probe, 698 .probe = sh_cmt_probe,
672 .remove = __devexit_p(sh_cmt_remove), 699 .remove = __devexit_p(sh_cmt_remove),
673 .driver = { 700 .driver = {
674 .name = "sh_cmt", 701 .name = "sh_cmt",
702 .pm = &sh_cmt_dev_pm_ops,
675 } 703 }
676}; 704};
677 705
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index b90eda8b3440..fd69086d08d5 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -858,6 +858,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
858 858
859 /* Check for existing affected CPUs. 859 /* Check for existing affected CPUs.
860 * They may not be aware of it due to CPU Hotplug. 860 * They may not be aware of it due to CPU Hotplug.
861 * cpufreq_cpu_put is called when the device is removed
862 * in __cpufreq_remove_dev()
861 */ 863 */
862 managed_policy = cpufreq_cpu_get(j); 864 managed_policy = cpufreq_cpu_get(j);
863 if (unlikely(managed_policy)) { 865 if (unlikely(managed_policy)) {
@@ -884,7 +886,7 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
884 ret = sysfs_create_link(&sys_dev->kobj, 886 ret = sysfs_create_link(&sys_dev->kobj,
885 &managed_policy->kobj, 887 &managed_policy->kobj,
886 "cpufreq"); 888 "cpufreq");
887 if (!ret) 889 if (ret)
888 cpufreq_cpu_put(managed_policy); 890 cpufreq_cpu_put(managed_policy);
889 /* 891 /*
890 * Success. We only needed to be added to the mask. 892 * Success. We only needed to be added to the mask.
@@ -924,6 +926,8 @@ static int cpufreq_add_dev(struct sys_device *sys_dev)
924 926
925 spin_lock_irqsave(&cpufreq_driver_lock, flags); 927 spin_lock_irqsave(&cpufreq_driver_lock, flags);
926 for_each_cpu(j, policy->cpus) { 928 for_each_cpu(j, policy->cpus) {
929 if (!cpu_online(j))
930 continue;
927 per_cpu(cpufreq_cpu_data, j) = policy; 931 per_cpu(cpufreq_cpu_data, j) = policy;
928 per_cpu(policy_cpu, j) = policy->cpu; 932 per_cpu(policy_cpu, j) = policy->cpu;
929 } 933 }
@@ -1244,13 +1248,22 @@ EXPORT_SYMBOL(cpufreq_get);
1244 1248
1245static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg) 1249static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg)
1246{ 1250{
1247 int cpu = sysdev->id;
1248 int ret = 0; 1251 int ret = 0;
1252
1253#ifdef __powerpc__
1254 int cpu = sysdev->id;
1249 unsigned int cur_freq = 0; 1255 unsigned int cur_freq = 0;
1250 struct cpufreq_policy *cpu_policy; 1256 struct cpufreq_policy *cpu_policy;
1251 1257
1252 dprintk("suspending cpu %u\n", cpu); 1258 dprintk("suspending cpu %u\n", cpu);
1253 1259
1260 /*
1261 * This whole bogosity is here because Powerbooks are made of fail.
1262 * No sane platform should need any of the code below to be run.
1263 * (it's entirely the wrong thing to do, as driver->get may
1264 * reenable interrupts on some architectures).
1265 */
1266
1254 if (!cpu_online(cpu)) 1267 if (!cpu_online(cpu))
1255 return 0; 1268 return 0;
1256 1269
@@ -1309,6 +1322,7 @@ static int cpufreq_suspend(struct sys_device *sysdev, pm_message_t pmsg)
1309 1322
1310out: 1323out:
1311 cpufreq_cpu_put(cpu_policy); 1324 cpufreq_cpu_put(cpu_policy);
1325#endif /* __powerpc__ */
1312 return ret; 1326 return ret;
1313} 1327}
1314 1328
@@ -1322,12 +1336,18 @@ out:
1322 */ 1336 */
1323static int cpufreq_resume(struct sys_device *sysdev) 1337static int cpufreq_resume(struct sys_device *sysdev)
1324{ 1338{
1325 int cpu = sysdev->id;
1326 int ret = 0; 1339 int ret = 0;
1340
1341#ifdef __powerpc__
1342 int cpu = sysdev->id;
1327 struct cpufreq_policy *cpu_policy; 1343 struct cpufreq_policy *cpu_policy;
1328 1344
1329 dprintk("resuming cpu %u\n", cpu); 1345 dprintk("resuming cpu %u\n", cpu);
1330 1346
1347 /* As with the ->suspend method, all the code below is
1348 * only necessary because Powerbooks suck.
1349 * See commit 42d4dc3f4e1e for jokes. */
1350
1331 if (!cpu_online(cpu)) 1351 if (!cpu_online(cpu))
1332 return 0; 1352 return 0;
1333 1353
@@ -1391,6 +1411,7 @@ out:
1391 schedule_work(&cpu_policy->update); 1411 schedule_work(&cpu_policy->update);
1392fail: 1412fail:
1393 cpufreq_cpu_put(cpu_policy); 1413 cpufreq_cpu_put(cpu_policy);
1414#endif /* __powerpc__ */
1394 return ret; 1415 return ret;
1395} 1416}
1396 1417
diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c
index 57490502b21c..bdea7e2f94ba 100644
--- a/drivers/cpufreq/cpufreq_conservative.c
+++ b/drivers/cpufreq/cpufreq_conservative.c
@@ -63,6 +63,7 @@ struct cpu_dbs_info_s {
63 unsigned int down_skip; 63 unsigned int down_skip;
64 unsigned int requested_freq; 64 unsigned int requested_freq;
65 int cpu; 65 int cpu;
66 unsigned int enable:1;
66 /* 67 /*
67 * percpu mutex that serializes governor limit change with 68 * percpu mutex that serializes governor limit change with
68 * do_dbs_timer invocation. We do not want do_dbs_timer to run 69 * do_dbs_timer invocation. We do not want do_dbs_timer to run
@@ -141,6 +142,9 @@ dbs_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
141 142
142 struct cpufreq_policy *policy; 143 struct cpufreq_policy *policy;
143 144
145 if (!this_dbs_info->enable)
146 return 0;
147
144 policy = this_dbs_info->cur_policy; 148 policy = this_dbs_info->cur_policy;
145 149
146 /* 150 /*
@@ -497,6 +501,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
497 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate); 501 int delay = usecs_to_jiffies(dbs_tuners_ins.sampling_rate);
498 delay -= jiffies % delay; 502 delay -= jiffies % delay;
499 503
504 dbs_info->enable = 1;
500 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer); 505 INIT_DELAYED_WORK_DEFERRABLE(&dbs_info->work, do_dbs_timer);
501 queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work, 506 queue_delayed_work_on(dbs_info->cpu, kconservative_wq, &dbs_info->work,
502 delay); 507 delay);
@@ -504,6 +509,7 @@ static inline void dbs_timer_init(struct cpu_dbs_info_s *dbs_info)
504 509
505static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info) 510static inline void dbs_timer_exit(struct cpu_dbs_info_s *dbs_info)
506{ 511{
512 dbs_info->enable = 0;
507 cancel_delayed_work_sync(&dbs_info->work); 513 cancel_delayed_work_sync(&dbs_info->work);
508} 514}
509 515
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
index 24964c1d0af9..e2a10bcba7a1 100644
--- a/drivers/edac/amd64_edac.c
+++ b/drivers/edac/amd64_edac.c
@@ -868,6 +868,8 @@ static void amd64_read_dbam_reg(struct amd64_pvt *pvt)
868 goto err_reg; 868 goto err_reg;
869 } 869 }
870 870
871 return;
872
871err_reg: 873err_reg:
872 debugf0("Error reading F2x%03x.\n", reg); 874 debugf0("Error reading F2x%03x.\n", reg);
873} 875}
@@ -2634,6 +2636,8 @@ static void amd64_read_mc_registers(struct amd64_pvt *pvt)
2634 2636
2635 amd64_dump_misc_regs(pvt); 2637 amd64_dump_misc_regs(pvt);
2636 2638
2639 return;
2640
2637err_reg: 2641err_reg:
2638 debugf0("Reading an MC register failed\n"); 2642 debugf0("Reading an MC register failed\n");
2639 2643
@@ -2977,6 +2981,9 @@ static int amd64_check_ecc_enabled(struct amd64_pvt *pvt)
2977 "ECC is enabled by BIOS, Proceeding " 2981 "ECC is enabled by BIOS, Proceeding "
2978 "with EDAC module initialization\n"); 2982 "with EDAC module initialization\n");
2979 2983
2984 /* Signal good ECC status */
2985 ret = 0;
2986
2980 /* CLEAR the override, since BIOS controlled it */ 2987 /* CLEAR the override, since BIOS controlled it */
2981 ecc_enable_override = 0; 2988 ecc_enable_override = 0;
2982 } 2989 }
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index 8fab7890a363..2f631c75f704 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -258,31 +258,6 @@ void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type)
258EXPORT_SYMBOL(drm_mode_object_find); 258EXPORT_SYMBOL(drm_mode_object_find);
259 259
260/** 260/**
261 * drm_crtc_from_fb - find the CRTC structure associated with an fb
262 * @dev: DRM device
263 * @fb: framebuffer in question
264 *
265 * LOCKING:
266 * Caller must hold mode_config lock.
267 *
268 * Find CRTC in the mode_config structure that matches @fb.
269 *
270 * RETURNS:
271 * Pointer to the CRTC or NULL if it wasn't found.
272 */
273struct drm_crtc *drm_crtc_from_fb(struct drm_device *dev,
274 struct drm_framebuffer *fb)
275{
276 struct drm_crtc *crtc;
277
278 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
279 if (crtc->fb == fb)
280 return crtc;
281 }
282 return NULL;
283}
284
285/**
286 * drm_framebuffer_init - initialize a framebuffer 261 * drm_framebuffer_init - initialize a framebuffer
287 * @dev: DRM device 262 * @dev: DRM device
288 * 263 *
@@ -328,11 +303,20 @@ void drm_framebuffer_cleanup(struct drm_framebuffer *fb)
328{ 303{
329 struct drm_device *dev = fb->dev; 304 struct drm_device *dev = fb->dev;
330 struct drm_crtc *crtc; 305 struct drm_crtc *crtc;
306 struct drm_mode_set set;
307 int ret;
331 308
332 /* remove from any CRTC */ 309 /* remove from any CRTC */
333 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { 310 list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
334 if (crtc->fb == fb) 311 if (crtc->fb == fb) {
335 crtc->fb = NULL; 312 /* should turn off the crtc */
313 memset(&set, 0, sizeof(struct drm_mode_set));
314 set.crtc = crtc;
315 set.fb = NULL;
316 ret = crtc->funcs->set_config(&set);
317 if (ret)
318 DRM_ERROR("failed to reset crtc %p when fb was deleted\n", crtc);
319 }
336 } 320 }
337 321
338 drm_mode_object_put(dev, &fb->base); 322 drm_mode_object_put(dev, &fb->base);
@@ -1461,7 +1445,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
1461 goto out; 1445 goto out;
1462 } 1446 }
1463 1447
1464 if (crtc_req->count_connectors > 0 && !mode && !fb) { 1448 if (crtc_req->count_connectors > 0 && (!mode || !fb)) {
1465 DRM_DEBUG("Count connectors is %d but no mode or fb set\n", 1449 DRM_DEBUG("Count connectors is %d but no mode or fb set\n",
1466 crtc_req->count_connectors); 1450 crtc_req->count_connectors);
1467 ret = -EINVAL; 1451 ret = -EINVAL;
@@ -1511,7 +1495,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
1511 set.mode = mode; 1495 set.mode = mode;
1512 set.connectors = connector_set; 1496 set.connectors = connector_set;
1513 set.num_connectors = crtc_req->count_connectors; 1497 set.num_connectors = crtc_req->count_connectors;
1514 set.fb =fb; 1498 set.fb = fb;
1515 ret = crtc->funcs->set_config(&set); 1499 ret = crtc->funcs->set_config(&set);
1516 1500
1517out: 1501out:
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 3da9cfa31848..6aaa2cb23365 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -706,8 +706,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
706 struct drm_encoder **save_encoders, *new_encoder; 706 struct drm_encoder **save_encoders, *new_encoder;
707 struct drm_framebuffer *old_fb = NULL; 707 struct drm_framebuffer *old_fb = NULL;
708 bool save_enabled; 708 bool save_enabled;
709 bool mode_changed = false; 709 bool mode_changed = false; /* if true do a full mode set */
710 bool fb_changed = false; 710 bool fb_changed = false; /* if true and !mode_changed just do a flip */
711 struct drm_connector *connector; 711 struct drm_connector *connector;
712 int count = 0, ro, fail = 0; 712 int count = 0, ro, fail = 0;
713 struct drm_crtc_helper_funcs *crtc_funcs; 713 struct drm_crtc_helper_funcs *crtc_funcs;
@@ -758,6 +758,8 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
758 if (set->crtc->fb == NULL) { 758 if (set->crtc->fb == NULL) {
759 DRM_DEBUG("crtc has no fb, full mode set\n"); 759 DRM_DEBUG("crtc has no fb, full mode set\n");
760 mode_changed = true; 760 mode_changed = true;
761 } else if (set->fb == NULL) {
762 mode_changed = true;
761 } else if ((set->fb->bits_per_pixel != 763 } else if ((set->fb->bits_per_pixel !=
762 set->crtc->fb->bits_per_pixel) || 764 set->crtc->fb->bits_per_pixel) ||
763 set->fb->depth != set->crtc->fb->depth) 765 set->fb->depth != set->crtc->fb->depth)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 80cc6d06d61b..7f2728bbc16c 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -502,12 +502,40 @@ static int add_detailed_info(struct drm_connector *connector,
502 struct detailed_non_pixel *data = &timing->data.other_data; 502 struct detailed_non_pixel *data = &timing->data.other_data;
503 struct drm_display_mode *newmode; 503 struct drm_display_mode *newmode;
504 504
505 /* EDID up to and including 1.2 may put monitor info here */ 505 /* X server check is version 1.1 or higher */
506 if (edid->version == 1 && edid->revision < 3) 506 if (edid->version == 1 && edid->revision >= 1 &&
507 continue; 507 !timing->pixel_clock) {
508 508 /* Other timing or info */
509 /* Detailed mode timing */ 509 switch (data->type) {
510 if (timing->pixel_clock) { 510 case EDID_DETAIL_MONITOR_SERIAL:
511 break;
512 case EDID_DETAIL_MONITOR_STRING:
513 break;
514 case EDID_DETAIL_MONITOR_RANGE:
515 /* Get monitor range data */
516 break;
517 case EDID_DETAIL_MONITOR_NAME:
518 break;
519 case EDID_DETAIL_MONITOR_CPDATA:
520 break;
521 case EDID_DETAIL_STD_MODES:
522 /* Five modes per detailed section */
523 for (j = 0; j < 5; i++) {
524 struct std_timing *std;
525 struct drm_display_mode *newmode;
526
527 std = &data->data.timings[j];
528 newmode = drm_mode_std(dev, std);
529 if (newmode) {
530 drm_mode_probed_add(connector, newmode);
531 modes++;
532 }
533 }
534 break;
535 default:
536 break;
537 }
538 } else {
511 newmode = drm_mode_detailed(dev, edid, timing, quirks); 539 newmode = drm_mode_detailed(dev, edid, timing, quirks);
512 if (!newmode) 540 if (!newmode)
513 continue; 541 continue;
@@ -518,38 +546,6 @@ static int add_detailed_info(struct drm_connector *connector,
518 drm_mode_probed_add(connector, newmode); 546 drm_mode_probed_add(connector, newmode);
519 547
520 modes++; 548 modes++;
521 continue;
522 }
523
524 /* Other timing or info */
525 switch (data->type) {
526 case EDID_DETAIL_MONITOR_SERIAL:
527 break;
528 case EDID_DETAIL_MONITOR_STRING:
529 break;
530 case EDID_DETAIL_MONITOR_RANGE:
531 /* Get monitor range data */
532 break;
533 case EDID_DETAIL_MONITOR_NAME:
534 break;
535 case EDID_DETAIL_MONITOR_CPDATA:
536 break;
537 case EDID_DETAIL_STD_MODES:
538 /* Five modes per detailed section */
539 for (j = 0; j < 5; i++) {
540 struct std_timing *std;
541 struct drm_display_mode *newmode;
542
543 std = &data->data.timings[j];
544 newmode = drm_mode_std(dev, std);
545 if (newmode) {
546 drm_mode_probed_add(connector, newmode);
547 modes++;
548 }
549 }
550 break;
551 default:
552 break;
553 } 549 }
554 } 550 }
555 551
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index b4a3dbcebe9b..f85aaf21e783 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -566,7 +566,7 @@ int drm_wait_vblank(struct drm_device *dev, void *data,
566 566
567 ret = drm_vblank_get(dev, crtc); 567 ret = drm_vblank_get(dev, crtc);
568 if (ret) { 568 if (ret) {
569 DRM_ERROR("failed to acquire vblank counter, %d\n", ret); 569 DRM_DEBUG("failed to acquire vblank counter, %d\n", ret);
570 return ret; 570 return ret;
571 } 571 }
572 seq = drm_vblank_count(dev, crtc); 572 seq = drm_vblank_count(dev, crtc);
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 54f492a488a9..7914097b09c6 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -566,6 +566,8 @@ void drm_mode_connector_list_update(struct drm_connector *connector)
566 found_it = 1; 566 found_it = 1;
567 /* if equal delete the probed mode */ 567 /* if equal delete the probed mode */
568 mode->status = pmode->status; 568 mode->status = pmode->status;
569 /* Merge type bits together */
570 mode->type |= pmode->type;
569 list_del(&pmode->head); 571 list_del(&pmode->head);
570 drm_mode_destroy(connector->dev, pmode); 572 drm_mode_destroy(connector->dev, pmode);
571 break; 573 break;
diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
index 85ec31b3ff00..f7a615b80c70 100644
--- a/drivers/gpu/drm/drm_sysfs.c
+++ b/drivers/gpu/drm/drm_sysfs.c
@@ -22,44 +22,50 @@
22#define to_drm_minor(d) container_of(d, struct drm_minor, kdev) 22#define to_drm_minor(d) container_of(d, struct drm_minor, kdev)
23#define to_drm_connector(d) container_of(d, struct drm_connector, kdev) 23#define to_drm_connector(d) container_of(d, struct drm_connector, kdev)
24 24
25static struct device_type drm_sysfs_device_minor = {
26 .name = "drm_minor"
27};
28
25/** 29/**
26 * drm_sysfs_suspend - DRM class suspend hook 30 * drm_class_suspend - DRM class suspend hook
27 * @dev: Linux device to suspend 31 * @dev: Linux device to suspend
28 * @state: power state to enter 32 * @state: power state to enter
29 * 33 *
30 * Just figures out what the actual struct drm_device associated with 34 * Just figures out what the actual struct drm_device associated with
31 * @dev is and calls its suspend hook, if present. 35 * @dev is and calls its suspend hook, if present.
32 */ 36 */
33static int drm_sysfs_suspend(struct device *dev, pm_message_t state) 37static int drm_class_suspend(struct device *dev, pm_message_t state)
34{ 38{
35 struct drm_minor *drm_minor = to_drm_minor(dev); 39 if (dev->type == &drm_sysfs_device_minor) {
36 struct drm_device *drm_dev = drm_minor->dev; 40 struct drm_minor *drm_minor = to_drm_minor(dev);
37 41 struct drm_device *drm_dev = drm_minor->dev;
38 if (drm_minor->type == DRM_MINOR_LEGACY && 42
39 !drm_core_check_feature(drm_dev, DRIVER_MODESET) && 43 if (drm_minor->type == DRM_MINOR_LEGACY &&
40 drm_dev->driver->suspend) 44 !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
41 return drm_dev->driver->suspend(drm_dev, state); 45 drm_dev->driver->suspend)
42 46 return drm_dev->driver->suspend(drm_dev, state);
47 }
43 return 0; 48 return 0;
44} 49}
45 50
46/** 51/**
47 * drm_sysfs_resume - DRM class resume hook 52 * drm_class_resume - DRM class resume hook
48 * @dev: Linux device to resume 53 * @dev: Linux device to resume
49 * 54 *
50 * Just figures out what the actual struct drm_device associated with 55 * Just figures out what the actual struct drm_device associated with
51 * @dev is and calls its resume hook, if present. 56 * @dev is and calls its resume hook, if present.
52 */ 57 */
53static int drm_sysfs_resume(struct device *dev) 58static int drm_class_resume(struct device *dev)
54{ 59{
55 struct drm_minor *drm_minor = to_drm_minor(dev); 60 if (dev->type == &drm_sysfs_device_minor) {
56 struct drm_device *drm_dev = drm_minor->dev; 61 struct drm_minor *drm_minor = to_drm_minor(dev);
57 62 struct drm_device *drm_dev = drm_minor->dev;
58 if (drm_minor->type == DRM_MINOR_LEGACY && 63
59 !drm_core_check_feature(drm_dev, DRIVER_MODESET) && 64 if (drm_minor->type == DRM_MINOR_LEGACY &&
60 drm_dev->driver->resume) 65 !drm_core_check_feature(drm_dev, DRIVER_MODESET) &&
61 return drm_dev->driver->resume(drm_dev); 66 drm_dev->driver->resume)
62 67 return drm_dev->driver->resume(drm_dev);
68 }
63 return 0; 69 return 0;
64} 70}
65 71
@@ -99,8 +105,8 @@ struct class *drm_sysfs_create(struct module *owner, char *name)
99 goto err_out; 105 goto err_out;
100 } 106 }
101 107
102 class->suspend = drm_sysfs_suspend; 108 class->suspend = drm_class_suspend;
103 class->resume = drm_sysfs_resume; 109 class->resume = drm_class_resume;
104 110
105 err = class_create_file(class, &class_attr_version); 111 err = class_create_file(class, &class_attr_version);
106 if (err) 112 if (err)
@@ -480,6 +486,7 @@ int drm_sysfs_device_add(struct drm_minor *minor)
480 minor->kdev.class = drm_class; 486 minor->kdev.class = drm_class;
481 minor->kdev.release = drm_sysfs_device_release; 487 minor->kdev.release = drm_sysfs_device_release;
482 minor->kdev.devt = minor->device; 488 minor->kdev.devt = minor->device;
489 minor->kdev.type = &drm_sysfs_device_minor;
483 if (minor->type == DRM_MINOR_CONTROL) 490 if (minor->type == DRM_MINOR_CONTROL)
484 minor_str = "controlD%d"; 491 minor_str = "controlD%d";
485 else if (minor->type == DRM_MINOR_RENDER) 492 else if (minor->type == DRM_MINOR_RENDER)
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
index 8c4783180bf6..50d1f782768c 100644
--- a/drivers/gpu/drm/i915/i915_dma.c
+++ b/drivers/gpu/drm/i915/i915_dma.c
@@ -1186,6 +1186,13 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1186 if (ret) 1186 if (ret)
1187 goto out_iomapfree; 1187 goto out_iomapfree;
1188 1188
1189 dev_priv->wq = create_workqueue("i915");
1190 if (dev_priv->wq == NULL) {
1191 DRM_ERROR("Failed to create our workqueue.\n");
1192 ret = -ENOMEM;
1193 goto out_iomapfree;
1194 }
1195
1189 /* enable GEM by default */ 1196 /* enable GEM by default */
1190 dev_priv->has_gem = 1; 1197 dev_priv->has_gem = 1;
1191 1198
@@ -1211,7 +1218,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1211 if (!I915_NEED_GFX_HWS(dev)) { 1218 if (!I915_NEED_GFX_HWS(dev)) {
1212 ret = i915_init_phys_hws(dev); 1219 ret = i915_init_phys_hws(dev);
1213 if (ret != 0) 1220 if (ret != 0)
1214 goto out_iomapfree; 1221 goto out_workqueue_free;
1215 } 1222 }
1216 1223
1217 i915_get_mem_freq(dev); 1224 i915_get_mem_freq(dev);
@@ -1245,7 +1252,7 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1245 ret = i915_load_modeset_init(dev, prealloc_size, agp_size); 1252 ret = i915_load_modeset_init(dev, prealloc_size, agp_size);
1246 if (ret < 0) { 1253 if (ret < 0) {
1247 DRM_ERROR("failed to init modeset\n"); 1254 DRM_ERROR("failed to init modeset\n");
1248 goto out_rmmap; 1255 goto out_workqueue_free;
1249 } 1256 }
1250 } 1257 }
1251 1258
@@ -1256,6 +1263,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
1256 1263
1257 return 0; 1264 return 0;
1258 1265
1266out_workqueue_free:
1267 destroy_workqueue(dev_priv->wq);
1259out_iomapfree: 1268out_iomapfree:
1260 io_mapping_free(dev_priv->mm.gtt_mapping); 1269 io_mapping_free(dev_priv->mm.gtt_mapping);
1261out_rmmap: 1270out_rmmap:
@@ -1269,6 +1278,8 @@ int i915_driver_unload(struct drm_device *dev)
1269{ 1278{
1270 struct drm_i915_private *dev_priv = dev->dev_private; 1279 struct drm_i915_private *dev_priv = dev->dev_private;
1271 1280
1281 destroy_workqueue(dev_priv->wq);
1282
1272 io_mapping_free(dev_priv->mm.gtt_mapping); 1283 io_mapping_free(dev_priv->mm.gtt_mapping);
1273 if (dev_priv->mm.gtt_mtrr >= 0) { 1284 if (dev_priv->mm.gtt_mtrr >= 0) {
1274 mtrr_del(dev_priv->mm.gtt_mtrr, dev->agp->base, 1285 mtrr_del(dev_priv->mm.gtt_mtrr, dev->agp->base,
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d08752875885..5b4f87e55621 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -219,8 +219,10 @@ typedef struct drm_i915_private {
219 unsigned int lvds_vbt:1; 219 unsigned int lvds_vbt:1;
220 unsigned int int_crt_support:1; 220 unsigned int int_crt_support:1;
221 unsigned int lvds_use_ssc:1; 221 unsigned int lvds_use_ssc:1;
222 unsigned int edp_support:1;
222 int lvds_ssc_freq; 223 int lvds_ssc_freq;
223 224
225 int crt_ddc_bus; /* -1 = unknown, else GPIO to use for CRT DDC */
224 struct drm_i915_fence_reg fence_regs[16]; /* assume 965 */ 226 struct drm_i915_fence_reg fence_regs[16]; /* assume 965 */
225 int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */ 227 int fence_reg_start; /* 4 if userland hasn't ioctl'd us yet */
226 int num_fence_regs; /* 8 on pre-965, 16 otherwise */ 228 int num_fence_regs; /* 8 on pre-965, 16 otherwise */
@@ -229,6 +231,8 @@ typedef struct drm_i915_private {
229 231
230 spinlock_t error_lock; 232 spinlock_t error_lock;
231 struct drm_i915_error_state *first_error; 233 struct drm_i915_error_state *first_error;
234 struct work_struct error_work;
235 struct workqueue_struct *wq;
232 236
233 /* Register state */ 237 /* Register state */
234 u8 saveLBB; 238 u8 saveLBB;
@@ -381,6 +385,9 @@ typedef struct drm_i915_private {
381 */ 385 */
382 struct list_head inactive_list; 386 struct list_head inactive_list;
383 387
388 /** LRU list of objects with fence regs on them. */
389 struct list_head fence_list;
390
384 /** 391 /**
385 * List of breadcrumbs associated with GPU requests currently 392 * List of breadcrumbs associated with GPU requests currently
386 * outstanding. 393 * outstanding.
@@ -448,6 +455,9 @@ struct drm_i915_gem_object {
448 /** This object's place on the active/flushing/inactive lists */ 455 /** This object's place on the active/flushing/inactive lists */
449 struct list_head list; 456 struct list_head list;
450 457
458 /** This object's place on the fenced object LRU */
459 struct list_head fence_list;
460
451 /** 461 /**
452 * This is set if the object is on the active or flushing lists 462 * This is set if the object is on the active or flushing lists
453 * (has pending rendering), and is not set if it's on inactive (ready 463 * (has pending rendering), and is not set if it's on inactive (ready
@@ -888,6 +898,7 @@ extern int i915_wait_ring(struct drm_device * dev, int n, const char *caller);
888 IS_I915GM(dev))) 898 IS_I915GM(dev)))
889#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev) || IS_IGDNG(dev)) 899#define SUPPORTS_INTEGRATED_HDMI(dev) (IS_G4X(dev) || IS_IGDNG(dev))
890#define SUPPORTS_INTEGRATED_DP(dev) (IS_G4X(dev) || IS_IGDNG(dev)) 900#define SUPPORTS_INTEGRATED_DP(dev) (IS_G4X(dev) || IS_IGDNG(dev))
901#define SUPPORTS_EDP(dev) (IS_IGDNG_M(dev))
891#define I915_HAS_HOTPLUG(dev) (IS_I945G(dev) || IS_I945GM(dev) || IS_I965G(dev)) 902#define I915_HAS_HOTPLUG(dev) (IS_I945G(dev) || IS_I945GM(dev) || IS_I965G(dev))
892/* dsparb controlled by hw only */ 903/* dsparb controlled by hw only */
893#define DSPARB_HWCONTROL(dev) (IS_G4X(dev) || IS_IGDNG(dev)) 904#define DSPARB_HWCONTROL(dev) (IS_G4X(dev) || IS_IGDNG(dev))
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 5bf420378b6d..0c07a755b3a3 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -978,6 +978,7 @@ int
978i915_gem_set_domain_ioctl(struct drm_device *dev, void *data, 978i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
979 struct drm_file *file_priv) 979 struct drm_file *file_priv)
980{ 980{
981 struct drm_i915_private *dev_priv = dev->dev_private;
981 struct drm_i915_gem_set_domain *args = data; 982 struct drm_i915_gem_set_domain *args = data;
982 struct drm_gem_object *obj; 983 struct drm_gem_object *obj;
983 uint32_t read_domains = args->read_domains; 984 uint32_t read_domains = args->read_domains;
@@ -1010,8 +1011,18 @@ i915_gem_set_domain_ioctl(struct drm_device *dev, void *data,
1010 obj, obj->size, read_domains, write_domain); 1011 obj, obj->size, read_domains, write_domain);
1011#endif 1012#endif
1012 if (read_domains & I915_GEM_DOMAIN_GTT) { 1013 if (read_domains & I915_GEM_DOMAIN_GTT) {
1014 struct drm_i915_gem_object *obj_priv = obj->driver_private;
1015
1013 ret = i915_gem_object_set_to_gtt_domain(obj, write_domain != 0); 1016 ret = i915_gem_object_set_to_gtt_domain(obj, write_domain != 0);
1014 1017
1018 /* Update the LRU on the fence for the CPU access that's
1019 * about to occur.
1020 */
1021 if (obj_priv->fence_reg != I915_FENCE_REG_NONE) {
1022 list_move_tail(&obj_priv->fence_list,
1023 &dev_priv->mm.fence_list);
1024 }
1025
1015 /* Silently promote "you're not bound, there was nothing to do" 1026 /* Silently promote "you're not bound, there was nothing to do"
1016 * to success, since the client was just asking us to 1027 * to success, since the client was just asking us to
1017 * make sure everything was done. 1028 * make sure everything was done.
@@ -1155,8 +1166,7 @@ int i915_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1155 } 1166 }
1156 1167
1157 /* Need a new fence register? */ 1168 /* Need a new fence register? */
1158 if (obj_priv->fence_reg == I915_FENCE_REG_NONE && 1169 if (obj_priv->tiling_mode != I915_TILING_NONE) {
1159 obj_priv->tiling_mode != I915_TILING_NONE) {
1160 ret = i915_gem_object_get_fence_reg(obj); 1170 ret = i915_gem_object_get_fence_reg(obj);
1161 if (ret) { 1171 if (ret) {
1162 mutex_unlock(&dev->struct_mutex); 1172 mutex_unlock(&dev->struct_mutex);
@@ -1570,7 +1580,7 @@ i915_add_request(struct drm_device *dev, struct drm_file *file_priv,
1570 } 1580 }
1571 1581
1572 if (was_empty && !dev_priv->mm.suspended) 1582 if (was_empty && !dev_priv->mm.suspended)
1573 schedule_delayed_work(&dev_priv->mm.retire_work, HZ); 1583 queue_delayed_work(dev_priv->wq, &dev_priv->mm.retire_work, HZ);
1574 return seqno; 1584 return seqno;
1575} 1585}
1576 1586
@@ -1719,7 +1729,7 @@ i915_gem_retire_work_handler(struct work_struct *work)
1719 i915_gem_retire_requests(dev); 1729 i915_gem_retire_requests(dev);
1720 if (!dev_priv->mm.suspended && 1730 if (!dev_priv->mm.suspended &&
1721 !list_empty(&dev_priv->mm.request_list)) 1731 !list_empty(&dev_priv->mm.request_list))
1722 schedule_delayed_work(&dev_priv->mm.retire_work, HZ); 1732 queue_delayed_work(dev_priv->wq, &dev_priv->mm.retire_work, HZ);
1723 mutex_unlock(&dev->struct_mutex); 1733 mutex_unlock(&dev->struct_mutex);
1724} 1734}
1725 1735
@@ -2208,6 +2218,12 @@ i915_gem_object_get_fence_reg(struct drm_gem_object *obj)
2208 struct drm_i915_gem_object *old_obj_priv = NULL; 2218 struct drm_i915_gem_object *old_obj_priv = NULL;
2209 int i, ret, avail; 2219 int i, ret, avail;
2210 2220
2221 /* Just update our place in the LRU if our fence is getting used. */
2222 if (obj_priv->fence_reg != I915_FENCE_REG_NONE) {
2223 list_move_tail(&obj_priv->fence_list, &dev_priv->mm.fence_list);
2224 return 0;
2225 }
2226
2211 switch (obj_priv->tiling_mode) { 2227 switch (obj_priv->tiling_mode) {
2212 case I915_TILING_NONE: 2228 case I915_TILING_NONE:
2213 WARN(1, "allocating a fence for non-tiled object?\n"); 2229 WARN(1, "allocating a fence for non-tiled object?\n");
@@ -2229,7 +2245,6 @@ i915_gem_object_get_fence_reg(struct drm_gem_object *obj)
2229 } 2245 }
2230 2246
2231 /* First try to find a free reg */ 2247 /* First try to find a free reg */
2232try_again:
2233 avail = 0; 2248 avail = 0;
2234 for (i = dev_priv->fence_reg_start; i < dev_priv->num_fence_regs; i++) { 2249 for (i = dev_priv->fence_reg_start; i < dev_priv->num_fence_regs; i++) {
2235 reg = &dev_priv->fence_regs[i]; 2250 reg = &dev_priv->fence_regs[i];
@@ -2243,52 +2258,41 @@ try_again:
2243 2258
2244 /* None available, try to steal one or wait for a user to finish */ 2259 /* None available, try to steal one or wait for a user to finish */
2245 if (i == dev_priv->num_fence_regs) { 2260 if (i == dev_priv->num_fence_regs) {
2246 uint32_t seqno = dev_priv->mm.next_gem_seqno; 2261 struct drm_gem_object *old_obj = NULL;
2247 2262
2248 if (avail == 0) 2263 if (avail == 0)
2249 return -ENOSPC; 2264 return -ENOSPC;
2250 2265
2251 for (i = dev_priv->fence_reg_start; 2266 list_for_each_entry(old_obj_priv, &dev_priv->mm.fence_list,
2252 i < dev_priv->num_fence_regs; i++) { 2267 fence_list) {
2253 uint32_t this_seqno; 2268 old_obj = old_obj_priv->obj;
2254 2269
2255 reg = &dev_priv->fence_regs[i]; 2270 reg = &dev_priv->fence_regs[old_obj_priv->fence_reg];
2256 old_obj_priv = reg->obj->driver_private;
2257 2271
2258 if (old_obj_priv->pin_count) 2272 if (old_obj_priv->pin_count)
2259 continue; 2273 continue;
2260 2274
2275 /* Take a reference, as otherwise the wait_rendering
2276 * below may cause the object to get freed out from
2277 * under us.
2278 */
2279 drm_gem_object_reference(old_obj);
2280
2261 /* i915 uses fences for GPU access to tiled buffers */ 2281 /* i915 uses fences for GPU access to tiled buffers */
2262 if (IS_I965G(dev) || !old_obj_priv->active) 2282 if (IS_I965G(dev) || !old_obj_priv->active)
2263 break; 2283 break;
2264 2284
2265 /* find the seqno of the first available fence */ 2285 /* This brings the object to the head of the LRU if it
2266 this_seqno = old_obj_priv->last_rendering_seqno; 2286 * had been written to. The only way this should
2267 if (this_seqno != 0 && 2287 * result in us waiting longer than the expected
2268 reg->obj->write_domain == 0 && 2288 * optimal amount of time is if there was a
2269 i915_seqno_passed(seqno, this_seqno)) 2289 * fence-using buffer later that was read-only.
2270 seqno = this_seqno; 2290 */
2271 } 2291 i915_gem_object_flush_gpu_write_domain(old_obj);
2272 2292 ret = i915_gem_object_wait_rendering(old_obj);
2273 /* 2293 if (ret != 0)
2274 * Now things get ugly... we have to wait for one of the
2275 * objects to finish before trying again.
2276 */
2277 if (i == dev_priv->num_fence_regs) {
2278 if (seqno == dev_priv->mm.next_gem_seqno) {
2279 i915_gem_flush(dev,
2280 I915_GEM_GPU_DOMAINS,
2281 I915_GEM_GPU_DOMAINS);
2282 seqno = i915_add_request(dev, NULL,
2283 I915_GEM_GPU_DOMAINS);
2284 if (seqno == 0)
2285 return -ENOMEM;
2286 }
2287
2288 ret = i915_wait_request(dev, seqno);
2289 if (ret)
2290 return ret; 2294 return ret;
2291 goto try_again; 2295 break;
2292 } 2296 }
2293 2297
2294 /* 2298 /*
@@ -2296,10 +2300,15 @@ try_again:
2296 * for this object next time we need it. 2300 * for this object next time we need it.
2297 */ 2301 */
2298 i915_gem_release_mmap(reg->obj); 2302 i915_gem_release_mmap(reg->obj);
2303 i = old_obj_priv->fence_reg;
2299 old_obj_priv->fence_reg = I915_FENCE_REG_NONE; 2304 old_obj_priv->fence_reg = I915_FENCE_REG_NONE;
2305 list_del_init(&old_obj_priv->fence_list);
2306 drm_gem_object_unreference(old_obj);
2300 } 2307 }
2301 2308
2302 obj_priv->fence_reg = i; 2309 obj_priv->fence_reg = i;
2310 list_add_tail(&obj_priv->fence_list, &dev_priv->mm.fence_list);
2311
2303 reg->obj = obj; 2312 reg->obj = obj;
2304 2313
2305 if (IS_I965G(dev)) 2314 if (IS_I965G(dev))
@@ -2342,6 +2351,7 @@ i915_gem_clear_fence_reg(struct drm_gem_object *obj)
2342 2351
2343 dev_priv->fence_regs[obj_priv->fence_reg].obj = NULL; 2352 dev_priv->fence_regs[obj_priv->fence_reg].obj = NULL;
2344 obj_priv->fence_reg = I915_FENCE_REG_NONE; 2353 obj_priv->fence_reg = I915_FENCE_REG_NONE;
2354 list_del_init(&obj_priv->fence_list);
2345} 2355}
2346 2356
2347/** 2357/**
@@ -3595,9 +3605,7 @@ i915_gem_object_pin(struct drm_gem_object *obj, uint32_t alignment)
3595 * Pre-965 chips need a fence register set up in order to 3605 * Pre-965 chips need a fence register set up in order to
3596 * properly handle tiled surfaces. 3606 * properly handle tiled surfaces.
3597 */ 3607 */
3598 if (!IS_I965G(dev) && 3608 if (!IS_I965G(dev) && obj_priv->tiling_mode != I915_TILING_NONE) {
3599 obj_priv->fence_reg == I915_FENCE_REG_NONE &&
3600 obj_priv->tiling_mode != I915_TILING_NONE) {
3601 ret = i915_gem_object_get_fence_reg(obj); 3609 ret = i915_gem_object_get_fence_reg(obj);
3602 if (ret != 0) { 3610 if (ret != 0) {
3603 if (ret != -EBUSY && ret != -ERESTARTSYS) 3611 if (ret != -EBUSY && ret != -ERESTARTSYS)
@@ -3806,6 +3814,7 @@ int i915_gem_init_object(struct drm_gem_object *obj)
3806 obj_priv->obj = obj; 3814 obj_priv->obj = obj;
3807 obj_priv->fence_reg = I915_FENCE_REG_NONE; 3815 obj_priv->fence_reg = I915_FENCE_REG_NONE;
3808 INIT_LIST_HEAD(&obj_priv->list); 3816 INIT_LIST_HEAD(&obj_priv->list);
3817 INIT_LIST_HEAD(&obj_priv->fence_list);
3809 3818
3810 return 0; 3819 return 0;
3811} 3820}
@@ -4253,6 +4262,7 @@ i915_gem_load(struct drm_device *dev)
4253 INIT_LIST_HEAD(&dev_priv->mm.flushing_list); 4262 INIT_LIST_HEAD(&dev_priv->mm.flushing_list);
4254 INIT_LIST_HEAD(&dev_priv->mm.inactive_list); 4263 INIT_LIST_HEAD(&dev_priv->mm.inactive_list);
4255 INIT_LIST_HEAD(&dev_priv->mm.request_list); 4264 INIT_LIST_HEAD(&dev_priv->mm.request_list);
4265 INIT_LIST_HEAD(&dev_priv->mm.fence_list);
4256 INIT_DELAYED_WORK(&dev_priv->mm.retire_work, 4266 INIT_DELAYED_WORK(&dev_priv->mm.retire_work,
4257 i915_gem_retire_work_handler); 4267 i915_gem_retire_work_handler);
4258 dev_priv->mm.next_gem_seqno = 1; 4268 dev_priv->mm.next_gem_seqno = 1;
diff --git a/drivers/gpu/drm/i915/i915_gem_debugfs.c b/drivers/gpu/drm/i915/i915_gem_debugfs.c
index 9a44bfcb8139..cb3b97405fbf 100644
--- a/drivers/gpu/drm/i915/i915_gem_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_gem_debugfs.c
@@ -343,6 +343,8 @@ static int i915_error_state(struct seq_file *m, void *unused)
343 343
344 error = dev_priv->first_error; 344 error = dev_priv->first_error;
345 345
346 seq_printf(m, "Time: %ld s %ld us\n", error->time.tv_sec,
347 error->time.tv_usec);
346 seq_printf(m, "EIR: 0x%08x\n", error->eir); 348 seq_printf(m, "EIR: 0x%08x\n", error->eir);
347 seq_printf(m, " PGTBL_ER: 0x%08x\n", error->pgtbl_er); 349 seq_printf(m, " PGTBL_ER: 0x%08x\n", error->pgtbl_er);
348 seq_printf(m, " INSTPM: 0x%08x\n", error->instpm); 350 seq_printf(m, " INSTPM: 0x%08x\n", error->instpm);
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index 7ba23a69a0c0..7ebc84c2881e 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -190,7 +190,7 @@ u32 i915_get_vblank_counter(struct drm_device *dev, int pipe)
190 low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL; 190 low_frame = pipe ? PIPEBFRAMEPIXEL : PIPEAFRAMEPIXEL;
191 191
192 if (!i915_pipe_enabled(dev, pipe)) { 192 if (!i915_pipe_enabled(dev, pipe)) {
193 DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe); 193 DRM_DEBUG("trying to get vblank count for disabled pipe %d\n", pipe);
194 return 0; 194 return 0;
195 } 195 }
196 196
@@ -219,7 +219,7 @@ u32 gm45_get_vblank_counter(struct drm_device *dev, int pipe)
219 int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45; 219 int reg = pipe ? PIPEB_FRMCOUNT_GM45 : PIPEA_FRMCOUNT_GM45;
220 220
221 if (!i915_pipe_enabled(dev, pipe)) { 221 if (!i915_pipe_enabled(dev, pipe)) {
222 DRM_ERROR("trying to get vblank count for disabled pipe %d\n", pipe); 222 DRM_DEBUG("trying to get vblank count for disabled pipe %d\n", pipe);
223 return 0; 223 return 0;
224 } 224 }
225 225
@@ -290,6 +290,35 @@ irqreturn_t igdng_irq_handler(struct drm_device *dev)
290 return ret; 290 return ret;
291} 291}
292 292
293/**
294 * i915_error_work_func - do process context error handling work
295 * @work: work struct
296 *
297 * Fire an error uevent so userspace can see that a hang or error
298 * was detected.
299 */
300static void i915_error_work_func(struct work_struct *work)
301{
302 drm_i915_private_t *dev_priv = container_of(work, drm_i915_private_t,
303 error_work);
304 struct drm_device *dev = dev_priv->dev;
305 char *event_string = "ERROR=1";
306 char *envp[] = { event_string, NULL };
307
308 DRM_DEBUG("generating error event\n");
309
310 kobject_uevent_env(&dev->primary->kdev.kobj, KOBJ_CHANGE, envp);
311}
312
313/**
314 * i915_capture_error_state - capture an error record for later analysis
315 * @dev: drm device
316 *
317 * Should be called when an error is detected (either a hang or an error
318 * interrupt) to capture error state from the time of the error. Fills
319 * out a structure which becomes available in debugfs for user level tools
320 * to pick up.
321 */
293static void i915_capture_error_state(struct drm_device *dev) 322static void i915_capture_error_state(struct drm_device *dev)
294{ 323{
295 struct drm_i915_private *dev_priv = dev->dev_private; 324 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -325,12 +354,137 @@ static void i915_capture_error_state(struct drm_device *dev)
325 error->acthd = I915_READ(ACTHD_I965); 354 error->acthd = I915_READ(ACTHD_I965);
326 } 355 }
327 356
357 do_gettimeofday(&error->time);
358
328 dev_priv->first_error = error; 359 dev_priv->first_error = error;
329 360
330out: 361out:
331 spin_unlock_irqrestore(&dev_priv->error_lock, flags); 362 spin_unlock_irqrestore(&dev_priv->error_lock, flags);
332} 363}
333 364
365/**
366 * i915_handle_error - handle an error interrupt
367 * @dev: drm device
368 *
369 * Do some basic checking of regsiter state at error interrupt time and
370 * dump it to the syslog. Also call i915_capture_error_state() to make
371 * sure we get a record and make it available in debugfs. Fire a uevent
372 * so userspace knows something bad happened (should trigger collection
373 * of a ring dump etc.).
374 */
375static void i915_handle_error(struct drm_device *dev)
376{
377 struct drm_i915_private *dev_priv = dev->dev_private;
378 u32 eir = I915_READ(EIR);
379 u32 pipea_stats = I915_READ(PIPEASTAT);
380 u32 pipeb_stats = I915_READ(PIPEBSTAT);
381
382 i915_capture_error_state(dev);
383
384 printk(KERN_ERR "render error detected, EIR: 0x%08x\n",
385 eir);
386
387 if (IS_G4X(dev)) {
388 if (eir & (GM45_ERROR_MEM_PRIV | GM45_ERROR_CP_PRIV)) {
389 u32 ipeir = I915_READ(IPEIR_I965);
390
391 printk(KERN_ERR " IPEIR: 0x%08x\n",
392 I915_READ(IPEIR_I965));
393 printk(KERN_ERR " IPEHR: 0x%08x\n",
394 I915_READ(IPEHR_I965));
395 printk(KERN_ERR " INSTDONE: 0x%08x\n",
396 I915_READ(INSTDONE_I965));
397 printk(KERN_ERR " INSTPS: 0x%08x\n",
398 I915_READ(INSTPS));
399 printk(KERN_ERR " INSTDONE1: 0x%08x\n",
400 I915_READ(INSTDONE1));
401 printk(KERN_ERR " ACTHD: 0x%08x\n",
402 I915_READ(ACTHD_I965));
403 I915_WRITE(IPEIR_I965, ipeir);
404 (void)I915_READ(IPEIR_I965);
405 }
406 if (eir & GM45_ERROR_PAGE_TABLE) {
407 u32 pgtbl_err = I915_READ(PGTBL_ER);
408 printk(KERN_ERR "page table error\n");
409 printk(KERN_ERR " PGTBL_ER: 0x%08x\n",
410 pgtbl_err);
411 I915_WRITE(PGTBL_ER, pgtbl_err);
412 (void)I915_READ(PGTBL_ER);
413 }
414 }
415
416 if (IS_I9XX(dev)) {
417 if (eir & I915_ERROR_PAGE_TABLE) {
418 u32 pgtbl_err = I915_READ(PGTBL_ER);
419 printk(KERN_ERR "page table error\n");
420 printk(KERN_ERR " PGTBL_ER: 0x%08x\n",
421 pgtbl_err);
422 I915_WRITE(PGTBL_ER, pgtbl_err);
423 (void)I915_READ(PGTBL_ER);
424 }
425 }
426
427 if (eir & I915_ERROR_MEMORY_REFRESH) {
428 printk(KERN_ERR "memory refresh error\n");
429 printk(KERN_ERR "PIPEASTAT: 0x%08x\n",
430 pipea_stats);
431 printk(KERN_ERR "PIPEBSTAT: 0x%08x\n",
432 pipeb_stats);
433 /* pipestat has already been acked */
434 }
435 if (eir & I915_ERROR_INSTRUCTION) {
436 printk(KERN_ERR "instruction error\n");
437 printk(KERN_ERR " INSTPM: 0x%08x\n",
438 I915_READ(INSTPM));
439 if (!IS_I965G(dev)) {
440 u32 ipeir = I915_READ(IPEIR);
441
442 printk(KERN_ERR " IPEIR: 0x%08x\n",
443 I915_READ(IPEIR));
444 printk(KERN_ERR " IPEHR: 0x%08x\n",
445 I915_READ(IPEHR));
446 printk(KERN_ERR " INSTDONE: 0x%08x\n",
447 I915_READ(INSTDONE));
448 printk(KERN_ERR " ACTHD: 0x%08x\n",
449 I915_READ(ACTHD));
450 I915_WRITE(IPEIR, ipeir);
451 (void)I915_READ(IPEIR);
452 } else {
453 u32 ipeir = I915_READ(IPEIR_I965);
454
455 printk(KERN_ERR " IPEIR: 0x%08x\n",
456 I915_READ(IPEIR_I965));
457 printk(KERN_ERR " IPEHR: 0x%08x\n",
458 I915_READ(IPEHR_I965));
459 printk(KERN_ERR " INSTDONE: 0x%08x\n",
460 I915_READ(INSTDONE_I965));
461 printk(KERN_ERR " INSTPS: 0x%08x\n",
462 I915_READ(INSTPS));
463 printk(KERN_ERR " INSTDONE1: 0x%08x\n",
464 I915_READ(INSTDONE1));
465 printk(KERN_ERR " ACTHD: 0x%08x\n",
466 I915_READ(ACTHD_I965));
467 I915_WRITE(IPEIR_I965, ipeir);
468 (void)I915_READ(IPEIR_I965);
469 }
470 }
471
472 I915_WRITE(EIR, eir);
473 (void)I915_READ(EIR);
474 eir = I915_READ(EIR);
475 if (eir) {
476 /*
477 * some errors might have become stuck,
478 * mask them.
479 */
480 DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir);
481 I915_WRITE(EMR, I915_READ(EMR) | eir);
482 I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
483 }
484
485 queue_work(dev_priv->wq, &dev_priv->error_work);
486}
487
334irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS) 488irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
335{ 489{
336 struct drm_device *dev = (struct drm_device *) arg; 490 struct drm_device *dev = (struct drm_device *) arg;
@@ -372,6 +526,9 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
372 pipea_stats = I915_READ(PIPEASTAT); 526 pipea_stats = I915_READ(PIPEASTAT);
373 pipeb_stats = I915_READ(PIPEBSTAT); 527 pipeb_stats = I915_READ(PIPEBSTAT);
374 528
529 if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)
530 i915_handle_error(dev);
531
375 /* 532 /*
376 * Clear the PIPE(A|B)STAT regs before the IIR 533 * Clear the PIPE(A|B)STAT regs before the IIR
377 */ 534 */
@@ -403,86 +560,13 @@ irqreturn_t i915_driver_irq_handler(DRM_IRQ_ARGS)
403 DRM_DEBUG("hotplug event received, stat 0x%08x\n", 560 DRM_DEBUG("hotplug event received, stat 0x%08x\n",
404 hotplug_status); 561 hotplug_status);
405 if (hotplug_status & dev_priv->hotplug_supported_mask) 562 if (hotplug_status & dev_priv->hotplug_supported_mask)
406 schedule_work(&dev_priv->hotplug_work); 563 queue_work(dev_priv->wq,
564 &dev_priv->hotplug_work);
407 565
408 I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status); 566 I915_WRITE(PORT_HOTPLUG_STAT, hotplug_status);
409 I915_READ(PORT_HOTPLUG_STAT); 567 I915_READ(PORT_HOTPLUG_STAT);
410 } 568 }
411 569
412 if (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT) {
413 u32 eir = I915_READ(EIR);
414
415 i915_capture_error_state(dev);
416
417 printk(KERN_ERR "render error detected, EIR: 0x%08x\n",
418 eir);
419 if (eir & I915_ERROR_PAGE_TABLE) {
420 u32 pgtbl_err = I915_READ(PGTBL_ER);
421 printk(KERN_ERR "page table error\n");
422 printk(KERN_ERR " PGTBL_ER: 0x%08x\n",
423 pgtbl_err);
424 I915_WRITE(PGTBL_ER, pgtbl_err);
425 (void)I915_READ(PGTBL_ER);
426 }
427 if (eir & I915_ERROR_MEMORY_REFRESH) {
428 printk(KERN_ERR "memory refresh error\n");
429 printk(KERN_ERR "PIPEASTAT: 0x%08x\n",
430 pipea_stats);
431 printk(KERN_ERR "PIPEBSTAT: 0x%08x\n",
432 pipeb_stats);
433 /* pipestat has already been acked */
434 }
435 if (eir & I915_ERROR_INSTRUCTION) {
436 printk(KERN_ERR "instruction error\n");
437 printk(KERN_ERR " INSTPM: 0x%08x\n",
438 I915_READ(INSTPM));
439 if (!IS_I965G(dev)) {
440 u32 ipeir = I915_READ(IPEIR);
441
442 printk(KERN_ERR " IPEIR: 0x%08x\n",
443 I915_READ(IPEIR));
444 printk(KERN_ERR " IPEHR: 0x%08x\n",
445 I915_READ(IPEHR));
446 printk(KERN_ERR " INSTDONE: 0x%08x\n",
447 I915_READ(INSTDONE));
448 printk(KERN_ERR " ACTHD: 0x%08x\n",
449 I915_READ(ACTHD));
450 I915_WRITE(IPEIR, ipeir);
451 (void)I915_READ(IPEIR);
452 } else {
453 u32 ipeir = I915_READ(IPEIR_I965);
454
455 printk(KERN_ERR " IPEIR: 0x%08x\n",
456 I915_READ(IPEIR_I965));
457 printk(KERN_ERR " IPEHR: 0x%08x\n",
458 I915_READ(IPEHR_I965));
459 printk(KERN_ERR " INSTDONE: 0x%08x\n",
460 I915_READ(INSTDONE_I965));
461 printk(KERN_ERR " INSTPS: 0x%08x\n",
462 I915_READ(INSTPS));
463 printk(KERN_ERR " INSTDONE1: 0x%08x\n",
464 I915_READ(INSTDONE1));
465 printk(KERN_ERR " ACTHD: 0x%08x\n",
466 I915_READ(ACTHD_I965));
467 I915_WRITE(IPEIR_I965, ipeir);
468 (void)I915_READ(IPEIR_I965);
469 }
470 }
471
472 I915_WRITE(EIR, eir);
473 (void)I915_READ(EIR);
474 eir = I915_READ(EIR);
475 if (eir) {
476 /*
477 * some errors might have become stuck,
478 * mask them.
479 */
480 DRM_ERROR("EIR stuck: 0x%08x, masking\n", eir);
481 I915_WRITE(EMR, I915_READ(EMR) | eir);
482 I915_WRITE(IIR, I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT);
483 }
484 }
485
486 I915_WRITE(IIR, iir); 570 I915_WRITE(IIR, iir);
487 new_iir = I915_READ(IIR); /* Flush posted writes */ 571 new_iir = I915_READ(IIR); /* Flush posted writes */
488 572
@@ -830,6 +914,7 @@ void i915_driver_irq_preinstall(struct drm_device * dev)
830 atomic_set(&dev_priv->irq_received, 0); 914 atomic_set(&dev_priv->irq_received, 0);
831 915
832 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func); 916 INIT_WORK(&dev_priv->hotplug_work, i915_hotplug_work_func);
917 INIT_WORK(&dev_priv->error_work, i915_error_work_func);
833 918
834 if (IS_IGDNG(dev)) { 919 if (IS_IGDNG(dev)) {
835 igdng_irq_preinstall(dev); 920 igdng_irq_preinstall(dev);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 6c0858484094..2955083aa471 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -1395,6 +1395,7 @@
1395#define TV_V_CHROMA_42 0x684a8 1395#define TV_V_CHROMA_42 0x684a8
1396 1396
1397/* Display Port */ 1397/* Display Port */
1398#define DP_A 0x64000 /* eDP */
1398#define DP_B 0x64100 1399#define DP_B 0x64100
1399#define DP_C 0x64200 1400#define DP_C 0x64200
1400#define DP_D 0x64300 1401#define DP_D 0x64300
@@ -1437,13 +1438,22 @@
1437/* Mystic DPCD version 1.1 special mode */ 1438/* Mystic DPCD version 1.1 special mode */
1438#define DP_ENHANCED_FRAMING (1 << 18) 1439#define DP_ENHANCED_FRAMING (1 << 18)
1439 1440
1441/* eDP */
1442#define DP_PLL_FREQ_270MHZ (0 << 16)
1443#define DP_PLL_FREQ_160MHZ (1 << 16)
1444#define DP_PLL_FREQ_MASK (3 << 16)
1445
1440/** locked once port is enabled */ 1446/** locked once port is enabled */
1441#define DP_PORT_REVERSAL (1 << 15) 1447#define DP_PORT_REVERSAL (1 << 15)
1442 1448
1449/* eDP */
1450#define DP_PLL_ENABLE (1 << 14)
1451
1443/** sends the clock on lane 15 of the PEG for debug */ 1452/** sends the clock on lane 15 of the PEG for debug */
1444#define DP_CLOCK_OUTPUT_ENABLE (1 << 13) 1453#define DP_CLOCK_OUTPUT_ENABLE (1 << 13)
1445 1454
1446#define DP_SCRAMBLING_DISABLE (1 << 12) 1455#define DP_SCRAMBLING_DISABLE (1 << 12)
1456#define DP_SCRAMBLING_DISABLE_IGDNG (1 << 7)
1447 1457
1448/** limit RGB values to avoid confusing TVs */ 1458/** limit RGB values to avoid confusing TVs */
1449#define DP_COLOR_RANGE_16_235 (1 << 8) 1459#define DP_COLOR_RANGE_16_235 (1 << 8)
@@ -1463,6 +1473,13 @@
1463 * is 20 bytes in each direction, hence the 5 fixed 1473 * is 20 bytes in each direction, hence the 5 fixed
1464 * data registers 1474 * data registers
1465 */ 1475 */
1476#define DPA_AUX_CH_CTL 0x64010
1477#define DPA_AUX_CH_DATA1 0x64014
1478#define DPA_AUX_CH_DATA2 0x64018
1479#define DPA_AUX_CH_DATA3 0x6401c
1480#define DPA_AUX_CH_DATA4 0x64020
1481#define DPA_AUX_CH_DATA5 0x64024
1482
1466#define DPB_AUX_CH_CTL 0x64110 1483#define DPB_AUX_CH_CTL 0x64110
1467#define DPB_AUX_CH_DATA1 0x64114 1484#define DPB_AUX_CH_DATA1 0x64114
1468#define DPB_AUX_CH_DATA2 0x64118 1485#define DPB_AUX_CH_DATA2 0x64118
@@ -1618,7 +1635,7 @@
1618#define I830_FIFO_LINE_SIZE 32 1635#define I830_FIFO_LINE_SIZE 32
1619#define I945_FIFO_SIZE 127 /* 945 & 965 */ 1636#define I945_FIFO_SIZE 127 /* 945 & 965 */
1620#define I915_FIFO_SIZE 95 1637#define I915_FIFO_SIZE 95
1621#define I855GM_FIFO_SIZE 255 1638#define I855GM_FIFO_SIZE 127 /* In cachelines */
1622#define I830_FIFO_SIZE 95 1639#define I830_FIFO_SIZE 95
1623#define I915_MAX_WM 0x3f 1640#define I915_MAX_WM 0x3f
1624 1641
@@ -1848,6 +1865,8 @@
1848#define PFA_CTL_1 0x68080 1865#define PFA_CTL_1 0x68080
1849#define PFB_CTL_1 0x68880 1866#define PFB_CTL_1 0x68880
1850#define PF_ENABLE (1<<31) 1867#define PF_ENABLE (1<<31)
1868#define PFA_WIN_SZ 0x68074
1869#define PFB_WIN_SZ 0x68874
1851 1870
1852/* legacy palette */ 1871/* legacy palette */
1853#define LGC_PALETTE_A 0x4a000 1872#define LGC_PALETTE_A 0x4a000
@@ -2208,4 +2227,28 @@
2208#define PCH_PP_OFF_DELAYS 0xc720c 2227#define PCH_PP_OFF_DELAYS 0xc720c
2209#define PCH_PP_DIVISOR 0xc7210 2228#define PCH_PP_DIVISOR 0xc7210
2210 2229
2230#define PCH_DP_B 0xe4100
2231#define PCH_DPB_AUX_CH_CTL 0xe4110
2232#define PCH_DPB_AUX_CH_DATA1 0xe4114
2233#define PCH_DPB_AUX_CH_DATA2 0xe4118
2234#define PCH_DPB_AUX_CH_DATA3 0xe411c
2235#define PCH_DPB_AUX_CH_DATA4 0xe4120
2236#define PCH_DPB_AUX_CH_DATA5 0xe4124
2237
2238#define PCH_DP_C 0xe4200
2239#define PCH_DPC_AUX_CH_CTL 0xe4210
2240#define PCH_DPC_AUX_CH_DATA1 0xe4214
2241#define PCH_DPC_AUX_CH_DATA2 0xe4218
2242#define PCH_DPC_AUX_CH_DATA3 0xe421c
2243#define PCH_DPC_AUX_CH_DATA4 0xe4220
2244#define PCH_DPC_AUX_CH_DATA5 0xe4224
2245
2246#define PCH_DP_D 0xe4300
2247#define PCH_DPD_AUX_CH_CTL 0xe4310
2248#define PCH_DPD_AUX_CH_DATA1 0xe4314
2249#define PCH_DPD_AUX_CH_DATA2 0xe4318
2250#define PCH_DPD_AUX_CH_DATA3 0xe431c
2251#define PCH_DPD_AUX_CH_DATA4 0xe4320
2252#define PCH_DPD_AUX_CH_DATA5 0xe4324
2253
2211#endif /* _I915_REG_H_ */ 2254#endif /* _I915_REG_H_ */
diff --git a/drivers/gpu/drm/i915/i915_suspend.c b/drivers/gpu/drm/i915/i915_suspend.c
index 9e1d16e5c3ea..1d04e1904ac6 100644
--- a/drivers/gpu/drm/i915/i915_suspend.c
+++ b/drivers/gpu/drm/i915/i915_suspend.c
@@ -598,7 +598,7 @@ int i915_restore_state(struct drm_device *dev)
598 598
599 for (i = 0; i < 16; i++) { 599 for (i = 0; i < 16; i++) {
600 I915_WRITE(SWF00 + (i << 2), dev_priv->saveSWF0[i]); 600 I915_WRITE(SWF00 + (i << 2), dev_priv->saveSWF0[i]);
601 I915_WRITE(SWF10 + (i << 2), dev_priv->saveSWF1[i+7]); 601 I915_WRITE(SWF10 + (i << 2), dev_priv->saveSWF1[i]);
602 } 602 }
603 for (i = 0; i < 3; i++) 603 for (i = 0; i < 3; i++)
604 I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]); 604 I915_WRITE(SWF30 + (i << 2), dev_priv->saveSWF2[i]);
diff --git a/drivers/gpu/drm/i915/intel_bios.c b/drivers/gpu/drm/i915/intel_bios.c
index 7cc447191028..f806fcc54e09 100644
--- a/drivers/gpu/drm/i915/intel_bios.c
+++ b/drivers/gpu/drm/i915/intel_bios.c
@@ -59,6 +59,16 @@ find_section(struct bdb_header *bdb, int section_id)
59 return NULL; 59 return NULL;
60} 60}
61 61
62static u16
63get_blocksize(void *p)
64{
65 u16 *block_ptr, block_size;
66
67 block_ptr = (u16 *)((char *)p - 2);
68 block_size = *block_ptr;
69 return block_size;
70}
71
62static void 72static void
63fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode, 73fill_detail_timing_data(struct drm_display_mode *panel_fixed_mode,
64 struct lvds_dvo_timing *dvo_timing) 74 struct lvds_dvo_timing *dvo_timing)
@@ -97,14 +107,13 @@ static void
97parse_lfp_panel_data(struct drm_i915_private *dev_priv, 107parse_lfp_panel_data(struct drm_i915_private *dev_priv,
98 struct bdb_header *bdb) 108 struct bdb_header *bdb)
99{ 109{
100 struct drm_device *dev = dev_priv->dev;
101 struct bdb_lvds_options *lvds_options; 110 struct bdb_lvds_options *lvds_options;
102 struct bdb_lvds_lfp_data *lvds_lfp_data; 111 struct bdb_lvds_lfp_data *lvds_lfp_data;
103 struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs; 112 struct bdb_lvds_lfp_data_ptrs *lvds_lfp_data_ptrs;
104 struct bdb_lvds_lfp_data_entry *entry; 113 struct bdb_lvds_lfp_data_entry *entry;
105 struct lvds_dvo_timing *dvo_timing; 114 struct lvds_dvo_timing *dvo_timing;
106 struct drm_display_mode *panel_fixed_mode; 115 struct drm_display_mode *panel_fixed_mode;
107 int lfp_data_size; 116 int lfp_data_size, dvo_timing_offset;
108 117
109 /* Defaults if we can't find VBT info */ 118 /* Defaults if we can't find VBT info */
110 dev_priv->lvds_dither = 0; 119 dev_priv->lvds_dither = 0;
@@ -133,14 +142,16 @@ parse_lfp_panel_data(struct drm_i915_private *dev_priv,
133 entry = (struct bdb_lvds_lfp_data_entry *) 142 entry = (struct bdb_lvds_lfp_data_entry *)
134 ((uint8_t *)lvds_lfp_data->data + (lfp_data_size * 143 ((uint8_t *)lvds_lfp_data->data + (lfp_data_size *
135 lvds_options->panel_type)); 144 lvds_options->panel_type));
145 dvo_timing_offset = lvds_lfp_data_ptrs->ptr[0].dvo_timing_offset -
146 lvds_lfp_data_ptrs->ptr[0].fp_timing_offset;
136 147
137 /* On IGDNG mobile, LVDS data block removes panel fitting registers. 148 /*
138 So dec 2 dword from dvo_timing offset */ 149 * the size of fp_timing varies on the different platform.
139 if (IS_IGDNG(dev)) 150 * So calculate the DVO timing relative offset in LVDS data
140 dvo_timing = (struct lvds_dvo_timing *) 151 * entry to get the DVO timing entry
141 ((u8 *)&entry->dvo_timing - 8); 152 */
142 else 153 dvo_timing = (struct lvds_dvo_timing *)
143 dvo_timing = &entry->dvo_timing; 154 ((unsigned char *)entry + dvo_timing_offset);
144 155
145 panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL); 156 panel_fixed_mode = kzalloc(sizeof(*panel_fixed_mode), GFP_KERNEL);
146 157
@@ -214,6 +225,41 @@ parse_general_features(struct drm_i915_private *dev_priv,
214} 225}
215 226
216static void 227static void
228parse_general_definitions(struct drm_i915_private *dev_priv,
229 struct bdb_header *bdb)
230{
231 struct bdb_general_definitions *general;
232 const int crt_bus_map_table[] = {
233 GPIOB,
234 GPIOA,
235 GPIOC,
236 GPIOD,
237 GPIOE,
238 GPIOF,
239 };
240
241 /* Set sensible defaults in case we can't find the general block
242 or it is the wrong chipset */
243 dev_priv->crt_ddc_bus = -1;
244
245 general = find_section(bdb, BDB_GENERAL_DEFINITIONS);
246 if (general) {
247 u16 block_size = get_blocksize(general);
248 if (block_size >= sizeof(*general)) {
249 int bus_pin = general->crt_ddc_gmbus_pin;
250 DRM_DEBUG("crt_ddc_bus_pin: %d\n", bus_pin);
251 if ((bus_pin >= 1) && (bus_pin <= 6)) {
252 dev_priv->crt_ddc_bus =
253 crt_bus_map_table[bus_pin-1];
254 }
255 } else {
256 DRM_DEBUG("BDB_GD too small (%d). Invalid.\n",
257 block_size);
258 }
259 }
260}
261
262static void
217parse_sdvo_device_mapping(struct drm_i915_private *dev_priv, 263parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
218 struct bdb_header *bdb) 264 struct bdb_header *bdb)
219{ 265{
@@ -221,7 +267,7 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
221 struct bdb_general_definitions *p_defs; 267 struct bdb_general_definitions *p_defs;
222 struct child_device_config *p_child; 268 struct child_device_config *p_child;
223 int i, child_device_num, count; 269 int i, child_device_num, count;
224 u16 block_size, *block_ptr; 270 u16 block_size;
225 271
226 p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS); 272 p_defs = find_section(bdb, BDB_GENERAL_DEFINITIONS);
227 if (!p_defs) { 273 if (!p_defs) {
@@ -239,8 +285,7 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
239 return; 285 return;
240 } 286 }
241 /* get the block size of general definitions */ 287 /* get the block size of general definitions */
242 block_ptr = (u16 *)((char *)p_defs - 2); 288 block_size = get_blocksize(p_defs);
243 block_size = *block_ptr;
244 /* get the number of child device */ 289 /* get the number of child device */
245 child_device_num = (block_size - sizeof(*p_defs)) / 290 child_device_num = (block_size - sizeof(*p_defs)) /
246 sizeof(*p_child); 291 sizeof(*p_child);
@@ -295,6 +340,25 @@ parse_sdvo_device_mapping(struct drm_i915_private *dev_priv,
295 } 340 }
296 return; 341 return;
297} 342}
343
344static void
345parse_driver_features(struct drm_i915_private *dev_priv,
346 struct bdb_header *bdb)
347{
348 struct drm_device *dev = dev_priv->dev;
349 struct bdb_driver_features *driver;
350
351 /* set default for chips without eDP */
352 if (!SUPPORTS_EDP(dev)) {
353 dev_priv->edp_support = 0;
354 return;
355 }
356
357 driver = find_section(bdb, BDB_DRIVER_FEATURES);
358 if (driver && driver->lvds_config == BDB_DRIVER_FEATURE_EDP)
359 dev_priv->edp_support = 1;
360}
361
298/** 362/**
299 * intel_init_bios - initialize VBIOS settings & find VBT 363 * intel_init_bios - initialize VBIOS settings & find VBT
300 * @dev: DRM device 364 * @dev: DRM device
@@ -342,9 +406,12 @@ intel_init_bios(struct drm_device *dev)
342 406
343 /* Grab useful general definitions */ 407 /* Grab useful general definitions */
344 parse_general_features(dev_priv, bdb); 408 parse_general_features(dev_priv, bdb);
409 parse_general_definitions(dev_priv, bdb);
345 parse_lfp_panel_data(dev_priv, bdb); 410 parse_lfp_panel_data(dev_priv, bdb);
346 parse_sdvo_panel_data(dev_priv, bdb); 411 parse_sdvo_panel_data(dev_priv, bdb);
347 parse_sdvo_device_mapping(dev_priv, bdb); 412 parse_sdvo_device_mapping(dev_priv, bdb);
413 parse_driver_features(dev_priv, bdb);
414
348 pci_unmap_rom(pdev, bios); 415 pci_unmap_rom(pdev, bios);
349 416
350 return 0; 417 return 0;
diff --git a/drivers/gpu/drm/i915/intel_bios.h b/drivers/gpu/drm/i915/intel_bios.h
index fe72e1c225d8..0f8e5f69ac7a 100644
--- a/drivers/gpu/drm/i915/intel_bios.h
+++ b/drivers/gpu/drm/i915/intel_bios.h
@@ -381,6 +381,51 @@ struct bdb_sdvo_lvds_options {
381} __attribute__((packed)); 381} __attribute__((packed));
382 382
383 383
384#define BDB_DRIVER_FEATURE_NO_LVDS 0
385#define BDB_DRIVER_FEATURE_INT_LVDS 1
386#define BDB_DRIVER_FEATURE_SDVO_LVDS 2
387#define BDB_DRIVER_FEATURE_EDP 3
388
389struct bdb_driver_features {
390 u8 boot_dev_algorithm:1;
391 u8 block_display_switch:1;
392 u8 allow_display_switch:1;
393 u8 hotplug_dvo:1;
394 u8 dual_view_zoom:1;
395 u8 int15h_hook:1;
396 u8 sprite_in_clone:1;
397 u8 primary_lfp_id:1;
398
399 u16 boot_mode_x;
400 u16 boot_mode_y;
401 u8 boot_mode_bpp;
402 u8 boot_mode_refresh;
403
404 u16 enable_lfp_primary:1;
405 u16 selective_mode_pruning:1;
406 u16 dual_frequency:1;
407 u16 render_clock_freq:1; /* 0: high freq; 1: low freq */
408 u16 nt_clone_support:1;
409 u16 power_scheme_ui:1; /* 0: CUI; 1: 3rd party */
410 u16 sprite_display_assign:1; /* 0: secondary; 1: primary */
411 u16 cui_aspect_scaling:1;
412 u16 preserve_aspect_ratio:1;
413 u16 sdvo_device_power_down:1;
414 u16 crt_hotplug:1;
415 u16 lvds_config:2;
416 u16 tv_hotplug:1;
417 u16 hdmi_config:2;
418
419 u8 static_display:1;
420 u8 reserved2:7;
421 u16 legacy_crt_max_x;
422 u16 legacy_crt_max_y;
423 u8 legacy_crt_max_refresh;
424
425 u8 hdmi_termination;
426 u8 custom_vbt_version;
427} __attribute__((packed));
428
384bool intel_init_bios(struct drm_device *dev); 429bool intel_init_bios(struct drm_device *dev);
385 430
386/* 431/*
diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index d6a1a6e5539a..590f81c8f594 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -156,6 +156,9 @@ static bool intel_igdng_crt_detect_hotplug(struct drm_connector *connector)
156 156
157 temp = adpa = I915_READ(PCH_ADPA); 157 temp = adpa = I915_READ(PCH_ADPA);
158 158
159 adpa &= ~ADPA_DAC_ENABLE;
160 I915_WRITE(PCH_ADPA, adpa);
161
159 adpa &= ~ADPA_CRT_HOTPLUG_MASK; 162 adpa &= ~ADPA_CRT_HOTPLUG_MASK;
160 163
161 adpa |= (ADPA_CRT_HOTPLUG_PERIOD_128 | 164 adpa |= (ADPA_CRT_HOTPLUG_PERIOD_128 |
@@ -169,13 +172,14 @@ static bool intel_igdng_crt_detect_hotplug(struct drm_connector *connector)
169 DRM_DEBUG("pch crt adpa 0x%x", adpa); 172 DRM_DEBUG("pch crt adpa 0x%x", adpa);
170 I915_WRITE(PCH_ADPA, adpa); 173 I915_WRITE(PCH_ADPA, adpa);
171 174
172 /* This might not be needed as not specified in spec...*/ 175 while ((I915_READ(PCH_ADPA) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) != 0)
173 udelay(1000); 176 ;
174 177
175 /* Check the status to see if both blue and green are on now */ 178 /* Check the status to see if both blue and green are on now */
176 adpa = I915_READ(PCH_ADPA); 179 adpa = I915_READ(PCH_ADPA);
177 if ((adpa & ADPA_CRT_HOTPLUG_MONITOR_MASK) == 180 adpa &= ADPA_CRT_HOTPLUG_MONITOR_MASK;
178 ADPA_CRT_HOTPLUG_MONITOR_COLOR) 181 if ((adpa == ADPA_CRT_HOTPLUG_MONITOR_COLOR) ||
182 (adpa == ADPA_CRT_HOTPLUG_MONITOR_MONO))
179 ret = true; 183 ret = true;
180 else 184 else
181 ret = false; 185 ret = false;
@@ -504,6 +508,7 @@ void intel_crt_init(struct drm_device *dev)
504{ 508{
505 struct drm_connector *connector; 509 struct drm_connector *connector;
506 struct intel_output *intel_output; 510 struct intel_output *intel_output;
511 struct drm_i915_private *dev_priv = dev->dev_private;
507 u32 i2c_reg; 512 u32 i2c_reg;
508 513
509 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL); 514 intel_output = kzalloc(sizeof(struct intel_output), GFP_KERNEL);
@@ -523,8 +528,12 @@ void intel_crt_init(struct drm_device *dev)
523 /* Set up the DDC bus. */ 528 /* Set up the DDC bus. */
524 if (IS_IGDNG(dev)) 529 if (IS_IGDNG(dev))
525 i2c_reg = PCH_GPIOA; 530 i2c_reg = PCH_GPIOA;
526 else 531 else {
527 i2c_reg = GPIOA; 532 i2c_reg = GPIOA;
533 /* Use VBT information for CRT DDC if available */
534 if (dev_priv->crt_ddc_bus != -1)
535 i2c_reg = dev_priv->crt_ddc_bus;
536 }
528 intel_output->ddc_bus = intel_i2c_create(dev, i2c_reg, "CRTDDC_A"); 537 intel_output->ddc_bus = intel_i2c_create(dev, i2c_reg, "CRTDDC_A");
529 if (!intel_output->ddc_bus) { 538 if (!intel_output->ddc_bus) {
530 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration " 539 dev_printk(KERN_ERR, &dev->pdev->dev, "DDC bus registration "
@@ -533,6 +542,10 @@ void intel_crt_init(struct drm_device *dev)
533 } 542 }
534 543
535 intel_output->type = INTEL_OUTPUT_ANALOG; 544 intel_output->type = INTEL_OUTPUT_ANALOG;
545 intel_output->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
546 (1 << INTEL_ANALOG_CLONE_BIT) |
547 (1 << INTEL_SDVO_LVDS_CLONE_BIT);
548 intel_output->crtc_mask = (1 << 0) | (1 << 1);
536 connector->interlace_allowed = 0; 549 connector->interlace_allowed = 0;
537 connector->doublescan_allowed = 0; 550 connector->doublescan_allowed = 0;
538 551
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 508838ee31e0..3fadb5358858 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -34,6 +34,8 @@
34 34
35#include "drm_crtc_helper.h" 35#include "drm_crtc_helper.h"
36 36
37#define HAS_eDP (intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))
38
37bool intel_pipe_has_type (struct drm_crtc *crtc, int type); 39bool intel_pipe_has_type (struct drm_crtc *crtc, int type);
38static void intel_update_watermarks(struct drm_device *dev); 40static void intel_update_watermarks(struct drm_device *dev);
39 41
@@ -88,7 +90,7 @@ struct intel_limit {
88#define I8XX_P2_SLOW 4 90#define I8XX_P2_SLOW 4
89#define I8XX_P2_FAST 2 91#define I8XX_P2_FAST 2
90#define I8XX_P2_LVDS_SLOW 14 92#define I8XX_P2_LVDS_SLOW 14
91#define I8XX_P2_LVDS_FAST 14 /* No fast option */ 93#define I8XX_P2_LVDS_FAST 7
92#define I8XX_P2_SLOW_LIMIT 165000 94#define I8XX_P2_SLOW_LIMIT 165000
93 95
94#define I9XX_DOT_MIN 20000 96#define I9XX_DOT_MIN 20000
@@ -268,6 +270,9 @@ intel_igdng_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
268static bool 270static bool
269intel_find_pll_g4x_dp(const intel_limit_t *, struct drm_crtc *crtc, 271intel_find_pll_g4x_dp(const intel_limit_t *, struct drm_crtc *crtc,
270 int target, int refclk, intel_clock_t *best_clock); 272 int target, int refclk, intel_clock_t *best_clock);
273static bool
274intel_find_pll_igdng_dp(const intel_limit_t *, struct drm_crtc *crtc,
275 int target, int refclk, intel_clock_t *best_clock);
271 276
272static const intel_limit_t intel_limits_i8xx_dvo = { 277static const intel_limit_t intel_limits_i8xx_dvo = {
273 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX }, 278 .dot = { .min = I8XX_DOT_MIN, .max = I8XX_DOT_MAX },
@@ -598,6 +603,23 @@ bool intel_pipe_has_type (struct drm_crtc *crtc, int type)
598 return false; 603 return false;
599} 604}
600 605
606struct drm_connector *
607intel_pipe_get_output (struct drm_crtc *crtc)
608{
609 struct drm_device *dev = crtc->dev;
610 struct drm_mode_config *mode_config = &dev->mode_config;
611 struct drm_connector *l_entry, *ret = NULL;
612
613 list_for_each_entry(l_entry, &mode_config->connector_list, head) {
614 if (l_entry->encoder &&
615 l_entry->encoder->crtc == crtc) {
616 ret = l_entry;
617 break;
618 }
619 }
620 return ret;
621}
622
601#define INTELPllInvalid(s) do { /* DRM_DEBUG(s); */ return false; } while (0) 623#define INTELPllInvalid(s) do { /* DRM_DEBUG(s); */ return false; } while (0)
602/** 624/**
603 * Returns whether the given set of divisors are valid for a given refclk with 625 * Returns whether the given set of divisors are valid for a given refclk with
@@ -644,8 +666,8 @@ intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
644 intel_clock_t clock; 666 intel_clock_t clock;
645 int err = target; 667 int err = target;
646 668
647 if (IS_I9XX(dev) && intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) && 669 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) &&
648 (I915_READ(LVDS) & LVDS_PORT_EN) != 0) { 670 (I915_READ(LVDS)) != 0) {
649 /* 671 /*
650 * For LVDS, if the panel is on, just rely on its current 672 * For LVDS, if the panel is on, just rely on its current
651 * settings for dual-channel. We haven't figured out how to 673 * settings for dual-channel. We haven't figured out how to
@@ -752,6 +774,30 @@ intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
752} 774}
753 775
754static bool 776static bool
777intel_find_pll_igdng_dp(const intel_limit_t *limit, struct drm_crtc *crtc,
778 int target, int refclk, intel_clock_t *best_clock)
779{
780 struct drm_device *dev = crtc->dev;
781 intel_clock_t clock;
782 if (target < 200000) {
783 clock.n = 1;
784 clock.p1 = 2;
785 clock.p2 = 10;
786 clock.m1 = 12;
787 clock.m2 = 9;
788 } else {
789 clock.n = 2;
790 clock.p1 = 1;
791 clock.p2 = 10;
792 clock.m1 = 14;
793 clock.m2 = 8;
794 }
795 intel_clock(dev, refclk, &clock);
796 memcpy(best_clock, &clock, sizeof(intel_clock_t));
797 return true;
798}
799
800static bool
755intel_igdng_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc, 801intel_igdng_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
756 int target, int refclk, intel_clock_t *best_clock) 802 int target, int refclk, intel_clock_t *best_clock)
757{ 803{
@@ -763,6 +809,14 @@ intel_igdng_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
763 int err_most = 47; 809 int err_most = 47;
764 found = false; 810 found = false;
765 811
812 /* eDP has only 2 clock choice, no n/m/p setting */
813 if (HAS_eDP)
814 return true;
815
816 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT))
817 return intel_find_pll_igdng_dp(limit, crtc, target,
818 refclk, best_clock);
819
766 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { 820 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
767 if ((I915_READ(LVDS) & LVDS_CLKB_POWER_MASK) == 821 if ((I915_READ(LVDS) & LVDS_CLKB_POWER_MASK) ==
768 LVDS_CLKB_POWER_UP) 822 LVDS_CLKB_POWER_UP)
@@ -998,6 +1052,90 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
998 return 0; 1052 return 0;
999} 1053}
1000 1054
1055/* Disable the VGA plane that we never use */
1056static void i915_disable_vga (struct drm_device *dev)
1057{
1058 struct drm_i915_private *dev_priv = dev->dev_private;
1059 u8 sr1;
1060 u32 vga_reg;
1061
1062 if (IS_IGDNG(dev))
1063 vga_reg = CPU_VGACNTRL;
1064 else
1065 vga_reg = VGACNTRL;
1066
1067 if (I915_READ(vga_reg) & VGA_DISP_DISABLE)
1068 return;
1069
1070 I915_WRITE8(VGA_SR_INDEX, 1);
1071 sr1 = I915_READ8(VGA_SR_DATA);
1072 I915_WRITE8(VGA_SR_DATA, sr1 | (1 << 5));
1073 udelay(100);
1074
1075 I915_WRITE(vga_reg, VGA_DISP_DISABLE);
1076}
1077
1078static void igdng_disable_pll_edp (struct drm_crtc *crtc)
1079{
1080 struct drm_device *dev = crtc->dev;
1081 struct drm_i915_private *dev_priv = dev->dev_private;
1082 u32 dpa_ctl;
1083
1084 DRM_DEBUG("\n");
1085 dpa_ctl = I915_READ(DP_A);
1086 dpa_ctl &= ~DP_PLL_ENABLE;
1087 I915_WRITE(DP_A, dpa_ctl);
1088}
1089
1090static void igdng_enable_pll_edp (struct drm_crtc *crtc)
1091{
1092 struct drm_device *dev = crtc->dev;
1093 struct drm_i915_private *dev_priv = dev->dev_private;
1094 u32 dpa_ctl;
1095
1096 dpa_ctl = I915_READ(DP_A);
1097 dpa_ctl |= DP_PLL_ENABLE;
1098 I915_WRITE(DP_A, dpa_ctl);
1099 udelay(200);
1100}
1101
1102
1103static void igdng_set_pll_edp (struct drm_crtc *crtc, int clock)
1104{
1105 struct drm_device *dev = crtc->dev;
1106 struct drm_i915_private *dev_priv = dev->dev_private;
1107 u32 dpa_ctl;
1108
1109 DRM_DEBUG("eDP PLL enable for clock %d\n", clock);
1110 dpa_ctl = I915_READ(DP_A);
1111 dpa_ctl &= ~DP_PLL_FREQ_MASK;
1112
1113 if (clock < 200000) {
1114 u32 temp;
1115 dpa_ctl |= DP_PLL_FREQ_160MHZ;
1116 /* workaround for 160Mhz:
1117 1) program 0x4600c bits 15:0 = 0x8124
1118 2) program 0x46010 bit 0 = 1
1119 3) program 0x46034 bit 24 = 1
1120 4) program 0x64000 bit 14 = 1
1121 */
1122 temp = I915_READ(0x4600c);
1123 temp &= 0xffff0000;
1124 I915_WRITE(0x4600c, temp | 0x8124);
1125
1126 temp = I915_READ(0x46010);
1127 I915_WRITE(0x46010, temp | 1);
1128
1129 temp = I915_READ(0x46034);
1130 I915_WRITE(0x46034, temp | (1 << 24));
1131 } else {
1132 dpa_ctl |= DP_PLL_FREQ_270MHZ;
1133 }
1134 I915_WRITE(DP_A, dpa_ctl);
1135
1136 udelay(500);
1137}
1138
1001static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode) 1139static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1002{ 1140{
1003 struct drm_device *dev = crtc->dev; 1141 struct drm_device *dev = crtc->dev;
@@ -1015,6 +1153,7 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1015 int fdi_rx_imr_reg = (pipe == 0) ? FDI_RXA_IMR : FDI_RXB_IMR; 1153 int fdi_rx_imr_reg = (pipe == 0) ? FDI_RXA_IMR : FDI_RXB_IMR;
1016 int transconf_reg = (pipe == 0) ? TRANSACONF : TRANSBCONF; 1154 int transconf_reg = (pipe == 0) ? TRANSACONF : TRANSBCONF;
1017 int pf_ctl_reg = (pipe == 0) ? PFA_CTL_1 : PFB_CTL_1; 1155 int pf_ctl_reg = (pipe == 0) ? PFA_CTL_1 : PFB_CTL_1;
1156 int pf_win_size = (pipe == 0) ? PFA_WIN_SZ : PFB_WIN_SZ;
1018 int cpu_htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B; 1157 int cpu_htot_reg = (pipe == 0) ? HTOTAL_A : HTOTAL_B;
1019 int cpu_hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B; 1158 int cpu_hblank_reg = (pipe == 0) ? HBLANK_A : HBLANK_B;
1020 int cpu_hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B; 1159 int cpu_hsync_reg = (pipe == 0) ? HSYNC_A : HSYNC_B;
@@ -1028,7 +1167,7 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1028 int trans_vblank_reg = (pipe == 0) ? TRANS_VBLANK_A : TRANS_VBLANK_B; 1167 int trans_vblank_reg = (pipe == 0) ? TRANS_VBLANK_A : TRANS_VBLANK_B;
1029 int trans_vsync_reg = (pipe == 0) ? TRANS_VSYNC_A : TRANS_VSYNC_B; 1168 int trans_vsync_reg = (pipe == 0) ? TRANS_VSYNC_A : TRANS_VSYNC_B;
1030 u32 temp; 1169 u32 temp;
1031 int tries = 5, j; 1170 int tries = 5, j, n;
1032 1171
1033 /* XXX: When our outputs are all unaware of DPMS modes other than off 1172 /* XXX: When our outputs are all unaware of DPMS modes other than off
1034 * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC. 1173 * and on, we should map those modes to DRM_MODE_DPMS_OFF in the CRTC.
@@ -1038,27 +1177,32 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1038 case DRM_MODE_DPMS_STANDBY: 1177 case DRM_MODE_DPMS_STANDBY:
1039 case DRM_MODE_DPMS_SUSPEND: 1178 case DRM_MODE_DPMS_SUSPEND:
1040 DRM_DEBUG("crtc %d dpms on\n", pipe); 1179 DRM_DEBUG("crtc %d dpms on\n", pipe);
1041 /* enable PCH DPLL */ 1180 if (HAS_eDP) {
1042 temp = I915_READ(pch_dpll_reg); 1181 /* enable eDP PLL */
1043 if ((temp & DPLL_VCO_ENABLE) == 0) { 1182 igdng_enable_pll_edp(crtc);
1044 I915_WRITE(pch_dpll_reg, temp | DPLL_VCO_ENABLE); 1183 } else {
1045 I915_READ(pch_dpll_reg); 1184 /* enable PCH DPLL */
1046 } 1185 temp = I915_READ(pch_dpll_reg);
1047 1186 if ((temp & DPLL_VCO_ENABLE) == 0) {
1048 /* enable PCH FDI RX PLL, wait warmup plus DMI latency */ 1187 I915_WRITE(pch_dpll_reg, temp | DPLL_VCO_ENABLE);
1049 temp = I915_READ(fdi_rx_reg); 1188 I915_READ(pch_dpll_reg);
1050 I915_WRITE(fdi_rx_reg, temp | FDI_RX_PLL_ENABLE | 1189 }
1051 FDI_SEL_PCDCLK |
1052 FDI_DP_PORT_WIDTH_X4); /* default 4 lanes */
1053 I915_READ(fdi_rx_reg);
1054 udelay(200);
1055 1190
1056 /* Enable CPU FDI TX PLL, always on for IGDNG */ 1191 /* enable PCH FDI RX PLL, wait warmup plus DMI latency */
1057 temp = I915_READ(fdi_tx_reg); 1192 temp = I915_READ(fdi_rx_reg);
1058 if ((temp & FDI_TX_PLL_ENABLE) == 0) { 1193 I915_WRITE(fdi_rx_reg, temp | FDI_RX_PLL_ENABLE |
1059 I915_WRITE(fdi_tx_reg, temp | FDI_TX_PLL_ENABLE); 1194 FDI_SEL_PCDCLK |
1060 I915_READ(fdi_tx_reg); 1195 FDI_DP_PORT_WIDTH_X4); /* default 4 lanes */
1061 udelay(100); 1196 I915_READ(fdi_rx_reg);
1197 udelay(200);
1198
1199 /* Enable CPU FDI TX PLL, always on for IGDNG */
1200 temp = I915_READ(fdi_tx_reg);
1201 if ((temp & FDI_TX_PLL_ENABLE) == 0) {
1202 I915_WRITE(fdi_tx_reg, temp | FDI_TX_PLL_ENABLE);
1203 I915_READ(fdi_tx_reg);
1204 udelay(100);
1205 }
1062 } 1206 }
1063 1207
1064 /* Enable CPU pipe */ 1208 /* Enable CPU pipe */
@@ -1077,122 +1221,126 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1077 I915_WRITE(dspbase_reg, I915_READ(dspbase_reg)); 1221 I915_WRITE(dspbase_reg, I915_READ(dspbase_reg));
1078 } 1222 }
1079 1223
1080 /* enable CPU FDI TX and PCH FDI RX */ 1224 if (!HAS_eDP) {
1081 temp = I915_READ(fdi_tx_reg); 1225 /* enable CPU FDI TX and PCH FDI RX */
1082 temp |= FDI_TX_ENABLE; 1226 temp = I915_READ(fdi_tx_reg);
1083 temp |= FDI_DP_PORT_WIDTH_X4; /* default */ 1227 temp |= FDI_TX_ENABLE;
1084 temp &= ~FDI_LINK_TRAIN_NONE; 1228 temp |= FDI_DP_PORT_WIDTH_X4; /* default */
1085 temp |= FDI_LINK_TRAIN_PATTERN_1; 1229 temp &= ~FDI_LINK_TRAIN_NONE;
1086 I915_WRITE(fdi_tx_reg, temp); 1230 temp |= FDI_LINK_TRAIN_PATTERN_1;
1087 I915_READ(fdi_tx_reg); 1231 I915_WRITE(fdi_tx_reg, temp);
1232 I915_READ(fdi_tx_reg);
1088 1233
1089 temp = I915_READ(fdi_rx_reg); 1234 temp = I915_READ(fdi_rx_reg);
1090 temp &= ~FDI_LINK_TRAIN_NONE; 1235 temp &= ~FDI_LINK_TRAIN_NONE;
1091 temp |= FDI_LINK_TRAIN_PATTERN_1; 1236 temp |= FDI_LINK_TRAIN_PATTERN_1;
1092 I915_WRITE(fdi_rx_reg, temp | FDI_RX_ENABLE); 1237 I915_WRITE(fdi_rx_reg, temp | FDI_RX_ENABLE);
1093 I915_READ(fdi_rx_reg); 1238 I915_READ(fdi_rx_reg);
1094 1239
1095 udelay(150); 1240 udelay(150);
1096 1241
1097 /* Train FDI. */ 1242 /* Train FDI. */
1098 /* umask FDI RX Interrupt symbol_lock and bit_lock bit 1243 /* umask FDI RX Interrupt symbol_lock and bit_lock bit
1099 for train result */ 1244 for train result */
1100 temp = I915_READ(fdi_rx_imr_reg); 1245 temp = I915_READ(fdi_rx_imr_reg);
1101 temp &= ~FDI_RX_SYMBOL_LOCK; 1246 temp &= ~FDI_RX_SYMBOL_LOCK;
1102 temp &= ~FDI_RX_BIT_LOCK; 1247 temp &= ~FDI_RX_BIT_LOCK;
1103 I915_WRITE(fdi_rx_imr_reg, temp); 1248 I915_WRITE(fdi_rx_imr_reg, temp);
1104 I915_READ(fdi_rx_imr_reg); 1249 I915_READ(fdi_rx_imr_reg);
1105 udelay(150); 1250 udelay(150);
1106 1251
1107 temp = I915_READ(fdi_rx_iir_reg); 1252 temp = I915_READ(fdi_rx_iir_reg);
1108 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp); 1253 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp);
1109 1254
1110 if ((temp & FDI_RX_BIT_LOCK) == 0) { 1255 if ((temp & FDI_RX_BIT_LOCK) == 0) {
1111 for (j = 0; j < tries; j++) { 1256 for (j = 0; j < tries; j++) {
1112 temp = I915_READ(fdi_rx_iir_reg); 1257 temp = I915_READ(fdi_rx_iir_reg);
1113 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp); 1258 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp);
1114 if (temp & FDI_RX_BIT_LOCK) 1259 if (temp & FDI_RX_BIT_LOCK)
1115 break; 1260 break;
1116 udelay(200); 1261 udelay(200);
1117 } 1262 }
1118 if (j != tries) 1263 if (j != tries)
1264 I915_WRITE(fdi_rx_iir_reg,
1265 temp | FDI_RX_BIT_LOCK);
1266 else
1267 DRM_DEBUG("train 1 fail\n");
1268 } else {
1119 I915_WRITE(fdi_rx_iir_reg, 1269 I915_WRITE(fdi_rx_iir_reg,
1120 temp | FDI_RX_BIT_LOCK); 1270 temp | FDI_RX_BIT_LOCK);
1121 else 1271 DRM_DEBUG("train 1 ok 2!\n");
1122 DRM_DEBUG("train 1 fail\n"); 1272 }
1123 } else { 1273 temp = I915_READ(fdi_tx_reg);
1124 I915_WRITE(fdi_rx_iir_reg, 1274 temp &= ~FDI_LINK_TRAIN_NONE;
1125 temp | FDI_RX_BIT_LOCK); 1275 temp |= FDI_LINK_TRAIN_PATTERN_2;
1126 DRM_DEBUG("train 1 ok 2!\n"); 1276 I915_WRITE(fdi_tx_reg, temp);
1127 } 1277
1128 temp = I915_READ(fdi_tx_reg); 1278 temp = I915_READ(fdi_rx_reg);
1129 temp &= ~FDI_LINK_TRAIN_NONE; 1279 temp &= ~FDI_LINK_TRAIN_NONE;
1130 temp |= FDI_LINK_TRAIN_PATTERN_2; 1280 temp |= FDI_LINK_TRAIN_PATTERN_2;
1131 I915_WRITE(fdi_tx_reg, temp); 1281 I915_WRITE(fdi_rx_reg, temp);
1132
1133 temp = I915_READ(fdi_rx_reg);
1134 temp &= ~FDI_LINK_TRAIN_NONE;
1135 temp |= FDI_LINK_TRAIN_PATTERN_2;
1136 I915_WRITE(fdi_rx_reg, temp);
1137 1282
1138 udelay(150); 1283 udelay(150);
1139 1284
1140 temp = I915_READ(fdi_rx_iir_reg); 1285 temp = I915_READ(fdi_rx_iir_reg);
1141 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp); 1286 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp);
1142 1287
1143 if ((temp & FDI_RX_SYMBOL_LOCK) == 0) { 1288 if ((temp & FDI_RX_SYMBOL_LOCK) == 0) {
1144 for (j = 0; j < tries; j++) { 1289 for (j = 0; j < tries; j++) {
1145 temp = I915_READ(fdi_rx_iir_reg); 1290 temp = I915_READ(fdi_rx_iir_reg);
1146 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp); 1291 DRM_DEBUG("FDI_RX_IIR 0x%x\n", temp);
1147 if (temp & FDI_RX_SYMBOL_LOCK) 1292 if (temp & FDI_RX_SYMBOL_LOCK)
1148 break; 1293 break;
1149 udelay(200); 1294 udelay(200);
1150 } 1295 }
1151 if (j != tries) { 1296 if (j != tries) {
1297 I915_WRITE(fdi_rx_iir_reg,
1298 temp | FDI_RX_SYMBOL_LOCK);
1299 DRM_DEBUG("train 2 ok 1!\n");
1300 } else
1301 DRM_DEBUG("train 2 fail\n");
1302 } else {
1152 I915_WRITE(fdi_rx_iir_reg, 1303 I915_WRITE(fdi_rx_iir_reg,
1153 temp | FDI_RX_SYMBOL_LOCK); 1304 temp | FDI_RX_SYMBOL_LOCK);
1154 DRM_DEBUG("train 2 ok 1!\n"); 1305 DRM_DEBUG("train 2 ok 2!\n");
1155 } else 1306 }
1156 DRM_DEBUG("train 2 fail\n"); 1307 DRM_DEBUG("train done\n");
1157 } else {
1158 I915_WRITE(fdi_rx_iir_reg, temp | FDI_RX_SYMBOL_LOCK);
1159 DRM_DEBUG("train 2 ok 2!\n");
1160 }
1161 DRM_DEBUG("train done\n");
1162 1308
1163 /* set transcoder timing */ 1309 /* set transcoder timing */
1164 I915_WRITE(trans_htot_reg, I915_READ(cpu_htot_reg)); 1310 I915_WRITE(trans_htot_reg, I915_READ(cpu_htot_reg));
1165 I915_WRITE(trans_hblank_reg, I915_READ(cpu_hblank_reg)); 1311 I915_WRITE(trans_hblank_reg, I915_READ(cpu_hblank_reg));
1166 I915_WRITE(trans_hsync_reg, I915_READ(cpu_hsync_reg)); 1312 I915_WRITE(trans_hsync_reg, I915_READ(cpu_hsync_reg));
1167 1313
1168 I915_WRITE(trans_vtot_reg, I915_READ(cpu_vtot_reg)); 1314 I915_WRITE(trans_vtot_reg, I915_READ(cpu_vtot_reg));
1169 I915_WRITE(trans_vblank_reg, I915_READ(cpu_vblank_reg)); 1315 I915_WRITE(trans_vblank_reg, I915_READ(cpu_vblank_reg));
1170 I915_WRITE(trans_vsync_reg, I915_READ(cpu_vsync_reg)); 1316 I915_WRITE(trans_vsync_reg, I915_READ(cpu_vsync_reg));
1171 1317
1172 /* enable PCH transcoder */ 1318 /* enable PCH transcoder */
1173 temp = I915_READ(transconf_reg); 1319 temp = I915_READ(transconf_reg);
1174 I915_WRITE(transconf_reg, temp | TRANS_ENABLE); 1320 I915_WRITE(transconf_reg, temp | TRANS_ENABLE);
1175 I915_READ(transconf_reg); 1321 I915_READ(transconf_reg);
1176 1322
1177 while ((I915_READ(transconf_reg) & TRANS_STATE_ENABLE) == 0) 1323 while ((I915_READ(transconf_reg) & TRANS_STATE_ENABLE) == 0)
1178 ; 1324 ;
1179 1325
1180 /* enable normal */ 1326 /* enable normal */
1181 1327
1182 temp = I915_READ(fdi_tx_reg); 1328 temp = I915_READ(fdi_tx_reg);
1183 temp &= ~FDI_LINK_TRAIN_NONE; 1329 temp &= ~FDI_LINK_TRAIN_NONE;
1184 I915_WRITE(fdi_tx_reg, temp | FDI_LINK_TRAIN_NONE | 1330 I915_WRITE(fdi_tx_reg, temp | FDI_LINK_TRAIN_NONE |
1185 FDI_TX_ENHANCE_FRAME_ENABLE); 1331 FDI_TX_ENHANCE_FRAME_ENABLE);
1186 I915_READ(fdi_tx_reg); 1332 I915_READ(fdi_tx_reg);
1187 1333
1188 temp = I915_READ(fdi_rx_reg); 1334 temp = I915_READ(fdi_rx_reg);
1189 temp &= ~FDI_LINK_TRAIN_NONE; 1335 temp &= ~FDI_LINK_TRAIN_NONE;
1190 I915_WRITE(fdi_rx_reg, temp | FDI_LINK_TRAIN_NONE | 1336 I915_WRITE(fdi_rx_reg, temp | FDI_LINK_TRAIN_NONE |
1191 FDI_RX_ENHANCE_FRAME_ENABLE); 1337 FDI_RX_ENHANCE_FRAME_ENABLE);
1192 I915_READ(fdi_rx_reg); 1338 I915_READ(fdi_rx_reg);
1193 1339
1194 /* wait one idle pattern time */ 1340 /* wait one idle pattern time */
1195 udelay(100); 1341 udelay(100);
1342
1343 }
1196 1344
1197 intel_crtc_load_lut(crtc); 1345 intel_crtc_load_lut(crtc);
1198 1346
@@ -1200,8 +1348,7 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1200 case DRM_MODE_DPMS_OFF: 1348 case DRM_MODE_DPMS_OFF:
1201 DRM_DEBUG("crtc %d dpms off\n", pipe); 1349 DRM_DEBUG("crtc %d dpms off\n", pipe);
1202 1350
1203 /* Disable the VGA plane that we never use */ 1351 i915_disable_vga(dev);
1204 I915_WRITE(CPU_VGACNTRL, VGA_DISP_DISABLE);
1205 1352
1206 /* Disable display plane */ 1353 /* Disable display plane */
1207 temp = I915_READ(dspcntr_reg); 1354 temp = I915_READ(dspcntr_reg);
@@ -1217,17 +1364,23 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1217 if ((temp & PIPEACONF_ENABLE) != 0) { 1364 if ((temp & PIPEACONF_ENABLE) != 0) {
1218 I915_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE); 1365 I915_WRITE(pipeconf_reg, temp & ~PIPEACONF_ENABLE);
1219 I915_READ(pipeconf_reg); 1366 I915_READ(pipeconf_reg);
1367 n = 0;
1220 /* wait for cpu pipe off, pipe state */ 1368 /* wait for cpu pipe off, pipe state */
1221 while ((I915_READ(pipeconf_reg) & I965_PIPECONF_ACTIVE) != 0) 1369 while ((I915_READ(pipeconf_reg) & I965_PIPECONF_ACTIVE) != 0) {
1222 ; 1370 n++;
1371 if (n < 60) {
1372 udelay(500);
1373 continue;
1374 } else {
1375 DRM_DEBUG("pipe %d off delay\n", pipe);
1376 break;
1377 }
1378 }
1223 } else 1379 } else
1224 DRM_DEBUG("crtc %d is disabled\n", pipe); 1380 DRM_DEBUG("crtc %d is disabled\n", pipe);
1225 1381
1226 /* IGDNG-A : disable cpu panel fitter ? */ 1382 if (HAS_eDP) {
1227 temp = I915_READ(pf_ctl_reg); 1383 igdng_disable_pll_edp(crtc);
1228 if ((temp & PF_ENABLE) != 0) {
1229 I915_WRITE(pf_ctl_reg, temp & ~PF_ENABLE);
1230 I915_READ(pf_ctl_reg);
1231 } 1384 }
1232 1385
1233 /* disable CPU FDI tx and PCH FDI rx */ 1386 /* disable CPU FDI tx and PCH FDI rx */
@@ -1239,6 +1392,8 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1239 I915_WRITE(fdi_rx_reg, temp & ~FDI_RX_ENABLE); 1392 I915_WRITE(fdi_rx_reg, temp & ~FDI_RX_ENABLE);
1240 I915_READ(fdi_rx_reg); 1393 I915_READ(fdi_rx_reg);
1241 1394
1395 udelay(100);
1396
1242 /* still set train pattern 1 */ 1397 /* still set train pattern 1 */
1243 temp = I915_READ(fdi_tx_reg); 1398 temp = I915_READ(fdi_tx_reg);
1244 temp &= ~FDI_LINK_TRAIN_NONE; 1399 temp &= ~FDI_LINK_TRAIN_NONE;
@@ -1250,14 +1405,25 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1250 temp |= FDI_LINK_TRAIN_PATTERN_1; 1405 temp |= FDI_LINK_TRAIN_PATTERN_1;
1251 I915_WRITE(fdi_rx_reg, temp); 1406 I915_WRITE(fdi_rx_reg, temp);
1252 1407
1408 udelay(100);
1409
1253 /* disable PCH transcoder */ 1410 /* disable PCH transcoder */
1254 temp = I915_READ(transconf_reg); 1411 temp = I915_READ(transconf_reg);
1255 if ((temp & TRANS_ENABLE) != 0) { 1412 if ((temp & TRANS_ENABLE) != 0) {
1256 I915_WRITE(transconf_reg, temp & ~TRANS_ENABLE); 1413 I915_WRITE(transconf_reg, temp & ~TRANS_ENABLE);
1257 I915_READ(transconf_reg); 1414 I915_READ(transconf_reg);
1415 n = 0;
1258 /* wait for PCH transcoder off, transcoder state */ 1416 /* wait for PCH transcoder off, transcoder state */
1259 while ((I915_READ(transconf_reg) & TRANS_STATE_ENABLE) != 0) 1417 while ((I915_READ(transconf_reg) & TRANS_STATE_ENABLE) != 0) {
1260 ; 1418 n++;
1419 if (n < 60) {
1420 udelay(500);
1421 continue;
1422 } else {
1423 DRM_DEBUG("transcoder %d off delay\n", pipe);
1424 break;
1425 }
1426 }
1261 } 1427 }
1262 1428
1263 /* disable PCH DPLL */ 1429 /* disable PCH DPLL */
@@ -1275,6 +1441,22 @@ static void igdng_crtc_dpms(struct drm_crtc *crtc, int mode)
1275 I915_READ(fdi_rx_reg); 1441 I915_READ(fdi_rx_reg);
1276 } 1442 }
1277 1443
1444 /* Disable CPU FDI TX PLL */
1445 temp = I915_READ(fdi_tx_reg);
1446 if ((temp & FDI_TX_PLL_ENABLE) != 0) {
1447 I915_WRITE(fdi_tx_reg, temp & ~FDI_TX_PLL_ENABLE);
1448 I915_READ(fdi_tx_reg);
1449 udelay(100);
1450 }
1451
1452 /* Disable PF */
1453 temp = I915_READ(pf_ctl_reg);
1454 if ((temp & PF_ENABLE) != 0) {
1455 I915_WRITE(pf_ctl_reg, temp & ~PF_ENABLE);
1456 I915_READ(pf_ctl_reg);
1457 }
1458 I915_WRITE(pf_win_size, 0);
1459
1278 /* Wait for the clocks to turn off. */ 1460 /* Wait for the clocks to turn off. */
1279 udelay(150); 1461 udelay(150);
1280 break; 1462 break;
@@ -1342,7 +1524,7 @@ static void i9xx_crtc_dpms(struct drm_crtc *crtc, int mode)
1342 //intel_crtc_dpms_video(crtc, FALSE); TODO 1524 //intel_crtc_dpms_video(crtc, FALSE); TODO
1343 1525
1344 /* Disable the VGA plane that we never use */ 1526 /* Disable the VGA plane that we never use */
1345 I915_WRITE(VGACNTRL, VGA_DISP_DISABLE); 1527 i915_disable_vga(dev);
1346 1528
1347 /* Disable display plane */ 1529 /* Disable display plane */
1348 temp = I915_READ(dspcntr_reg); 1530 temp = I915_READ(dspcntr_reg);
@@ -1623,48 +1805,72 @@ static struct intel_watermark_params igd_cursor_hplloff_wm = {
1623 IGD_FIFO_LINE_SIZE 1805 IGD_FIFO_LINE_SIZE
1624}; 1806};
1625static struct intel_watermark_params i945_wm_info = { 1807static struct intel_watermark_params i945_wm_info = {
1626 I915_FIFO_LINE_SIZE, 1808 I945_FIFO_SIZE,
1627 I915_MAX_WM, 1809 I915_MAX_WM,
1628 1, 1810 1,
1629 0, 1811 2,
1630 IGD_FIFO_LINE_SIZE 1812 I915_FIFO_LINE_SIZE
1631}; 1813};
1632static struct intel_watermark_params i915_wm_info = { 1814static struct intel_watermark_params i915_wm_info = {
1633 I945_FIFO_SIZE, 1815 I915_FIFO_SIZE,
1634 I915_MAX_WM, 1816 I915_MAX_WM,
1635 1, 1817 1,
1636 0, 1818 2,
1637 I915_FIFO_LINE_SIZE 1819 I915_FIFO_LINE_SIZE
1638}; 1820};
1639static struct intel_watermark_params i855_wm_info = { 1821static struct intel_watermark_params i855_wm_info = {
1640 I855GM_FIFO_SIZE, 1822 I855GM_FIFO_SIZE,
1641 I915_MAX_WM, 1823 I915_MAX_WM,
1642 1, 1824 1,
1643 0, 1825 2,
1644 I830_FIFO_LINE_SIZE 1826 I830_FIFO_LINE_SIZE
1645}; 1827};
1646static struct intel_watermark_params i830_wm_info = { 1828static struct intel_watermark_params i830_wm_info = {
1647 I830_FIFO_SIZE, 1829 I830_FIFO_SIZE,
1648 I915_MAX_WM, 1830 I915_MAX_WM,
1649 1, 1831 1,
1650 0, 1832 2,
1651 I830_FIFO_LINE_SIZE 1833 I830_FIFO_LINE_SIZE
1652}; 1834};
1653 1835
1836/**
1837 * intel_calculate_wm - calculate watermark level
1838 * @clock_in_khz: pixel clock
1839 * @wm: chip FIFO params
1840 * @pixel_size: display pixel size
1841 * @latency_ns: memory latency for the platform
1842 *
1843 * Calculate the watermark level (the level at which the display plane will
1844 * start fetching from memory again). Each chip has a different display
1845 * FIFO size and allocation, so the caller needs to figure that out and pass
1846 * in the correct intel_watermark_params structure.
1847 *
1848 * As the pixel clock runs, the FIFO will be drained at a rate that depends
1849 * on the pixel size. When it reaches the watermark level, it'll start
1850 * fetching FIFO line sized based chunks from memory until the FIFO fills
1851 * past the watermark point. If the FIFO drains completely, a FIFO underrun
1852 * will occur, and a display engine hang could result.
1853 */
1654static unsigned long intel_calculate_wm(unsigned long clock_in_khz, 1854static unsigned long intel_calculate_wm(unsigned long clock_in_khz,
1655 struct intel_watermark_params *wm, 1855 struct intel_watermark_params *wm,
1656 int pixel_size, 1856 int pixel_size,
1657 unsigned long latency_ns) 1857 unsigned long latency_ns)
1658{ 1858{
1659 unsigned long bytes_required, wm_size; 1859 long entries_required, wm_size;
1660 1860
1661 bytes_required = (clock_in_khz * pixel_size * latency_ns) / 1000000; 1861 entries_required = (clock_in_khz * pixel_size * latency_ns) / 1000000;
1662 bytes_required /= wm->cacheline_size; 1862 entries_required /= wm->cacheline_size;
1663 wm_size = wm->fifo_size - bytes_required - wm->guard_size;
1664 1863
1665 if (wm_size > wm->max_wm) 1864 DRM_DEBUG("FIFO entries required for mode: %d\n", entries_required);
1865
1866 wm_size = wm->fifo_size - (entries_required + wm->guard_size);
1867
1868 DRM_DEBUG("FIFO watermark level: %d\n", wm_size);
1869
1870 /* Don't promote wm_size to unsigned... */
1871 if (wm_size > (long)wm->max_wm)
1666 wm_size = wm->max_wm; 1872 wm_size = wm->max_wm;
1667 if (wm_size == 0) 1873 if (wm_size <= 0)
1668 wm_size = wm->default_wm; 1874 wm_size = wm->default_wm;
1669 return wm_size; 1875 return wm_size;
1670} 1876}
@@ -1799,8 +2005,40 @@ static void igd_enable_cxsr(struct drm_device *dev, unsigned long clock,
1799 return; 2005 return;
1800} 2006}
1801 2007
1802const static int latency_ns = 5000; /* default for non-igd platforms */ 2008const static int latency_ns = 3000; /* default for non-igd platforms */
1803 2009
2010static int intel_get_fifo_size(struct drm_device *dev, int plane)
2011{
2012 struct drm_i915_private *dev_priv = dev->dev_private;
2013 uint32_t dsparb = I915_READ(DSPARB);
2014 int size;
2015
2016 if (IS_I9XX(dev)) {
2017 if (plane == 0)
2018 size = dsparb & 0x7f;
2019 else
2020 size = ((dsparb >> DSPARB_CSTART_SHIFT) & 0x7f) -
2021 (dsparb & 0x7f);
2022 } else if (IS_I85X(dev)) {
2023 if (plane == 0)
2024 size = dsparb & 0x1ff;
2025 else
2026 size = ((dsparb >> DSPARB_BEND_SHIFT) & 0x1ff) -
2027 (dsparb & 0x1ff);
2028 size >>= 1; /* Convert to cachelines */
2029 } else if (IS_845G(dev)) {
2030 size = dsparb & 0x7f;
2031 size >>= 2; /* Convert to cachelines */
2032 } else {
2033 size = dsparb & 0x7f;
2034 size >>= 1; /* Convert to cachelines */
2035 }
2036
2037 DRM_DEBUG("FIFO size - (0x%08x) %s: %d\n", dsparb, plane ? "B" : "A",
2038 size);
2039
2040 return size;
2041}
1804 2042
1805static void i965_update_wm(struct drm_device *dev) 2043static void i965_update_wm(struct drm_device *dev)
1806{ 2044{
@@ -1817,101 +2055,89 @@ static void i9xx_update_wm(struct drm_device *dev, int planea_clock,
1817 int planeb_clock, int sr_hdisplay, int pixel_size) 2055 int planeb_clock, int sr_hdisplay, int pixel_size)
1818{ 2056{
1819 struct drm_i915_private *dev_priv = dev->dev_private; 2057 struct drm_i915_private *dev_priv = dev->dev_private;
1820 uint32_t fwater_lo = I915_READ(FW_BLC) & MM_FIFO_WATERMARK; 2058 uint32_t fwater_lo;
1821 uint32_t fwater_hi = I915_READ(FW_BLC2) & LM_FIFO_WATERMARK; 2059 uint32_t fwater_hi;
1822 int bsize, asize, cwm, bwm = 1, awm = 1, srwm = 1; 2060 int total_size, cacheline_size, cwm, srwm = 1;
1823 uint32_t dsparb = I915_READ(DSPARB); 2061 int planea_wm, planeb_wm;
1824 int planea_entries, planeb_entries; 2062 struct intel_watermark_params planea_params, planeb_params;
1825 struct intel_watermark_params *wm_params;
1826 unsigned long line_time_us; 2063 unsigned long line_time_us;
1827 int sr_clock, sr_entries = 0; 2064 int sr_clock, sr_entries = 0;
1828 2065
2066 /* Create copies of the base settings for each pipe */
1829 if (IS_I965GM(dev) || IS_I945GM(dev)) 2067 if (IS_I965GM(dev) || IS_I945GM(dev))
1830 wm_params = &i945_wm_info; 2068 planea_params = planeb_params = i945_wm_info;
1831 else if (IS_I9XX(dev)) 2069 else if (IS_I9XX(dev))
1832 wm_params = &i915_wm_info; 2070 planea_params = planeb_params = i915_wm_info;
1833 else 2071 else
1834 wm_params = &i855_wm_info; 2072 planea_params = planeb_params = i855_wm_info;
1835 2073
1836 planea_entries = intel_calculate_wm(planea_clock, wm_params, 2074 /* Grab a couple of global values before we overwrite them */
1837 pixel_size, latency_ns); 2075 total_size = planea_params.fifo_size;
1838 planeb_entries = intel_calculate_wm(planeb_clock, wm_params, 2076 cacheline_size = planea_params.cacheline_size;
1839 pixel_size, latency_ns);
1840 2077
1841 DRM_DEBUG("FIFO entries - A: %d, B: %d\n", planea_entries, 2078 /* Update per-plane FIFO sizes */
1842 planeb_entries); 2079 planea_params.fifo_size = intel_get_fifo_size(dev, 0);
2080 planeb_params.fifo_size = intel_get_fifo_size(dev, 1);
1843 2081
1844 if (IS_I9XX(dev)) { 2082 planea_wm = intel_calculate_wm(planea_clock, &planea_params,
1845 asize = dsparb & 0x7f; 2083 pixel_size, latency_ns);
1846 bsize = (dsparb >> DSPARB_CSTART_SHIFT) & 0x7f; 2084 planeb_wm = intel_calculate_wm(planeb_clock, &planeb_params,
1847 } else { 2085 pixel_size, latency_ns);
1848 asize = dsparb & 0x1ff; 2086 DRM_DEBUG("FIFO watermarks - A: %d, B: %d\n", planea_wm, planeb_wm);
1849 bsize = (dsparb >> DSPARB_BEND_SHIFT) & 0x1ff;
1850 }
1851 DRM_DEBUG("FIFO size - A: %d, B: %d\n", asize, bsize);
1852
1853 /* Two extra entries for padding */
1854 awm = asize - (planea_entries + 2);
1855 bwm = bsize - (planeb_entries + 2);
1856
1857 /* Sanity check against potentially bad FIFO allocations */
1858 if (awm <= 0) {
1859 /* pipe is on but has too few FIFO entries */
1860 if (planea_entries != 0)
1861 DRM_DEBUG("plane A needs more FIFO entries\n");
1862 awm = 1;
1863 }
1864 if (bwm <= 0) {
1865 if (planeb_entries != 0)
1866 DRM_DEBUG("plane B needs more FIFO entries\n");
1867 bwm = 1;
1868 }
1869 2087
1870 /* 2088 /*
1871 * Overlay gets an aggressive default since video jitter is bad. 2089 * Overlay gets an aggressive default since video jitter is bad.
1872 */ 2090 */
1873 cwm = 2; 2091 cwm = 2;
1874 2092
1875 /* Calc sr entries for one pipe configs */ 2093 /* Calc sr entries for one plane configs */
1876 if (!planea_clock || !planeb_clock) { 2094 if (sr_hdisplay && (!planea_clock || !planeb_clock)) {
2095 /* self-refresh has much higher latency */
2096 const static int sr_latency_ns = 6000;
2097
1877 sr_clock = planea_clock ? planea_clock : planeb_clock; 2098 sr_clock = planea_clock ? planea_clock : planeb_clock;
1878 line_time_us = (sr_hdisplay * 1000) / sr_clock; 2099 line_time_us = ((sr_hdisplay * 1000) / sr_clock);
1879 sr_entries = (((latency_ns / line_time_us) + 1) * pixel_size * 2100
1880 sr_hdisplay) / 1000; 2101 /* Use ns/us then divide to preserve precision */
1881 sr_entries = roundup(sr_entries / wm_params->cacheline_size, 1); 2102 sr_entries = (((sr_latency_ns / line_time_us) + 1) *
1882 if (sr_entries < wm_params->fifo_size) 2103 pixel_size * sr_hdisplay) / 1000;
1883 srwm = wm_params->fifo_size - sr_entries; 2104 sr_entries = roundup(sr_entries / cacheline_size, 1);
2105 DRM_DEBUG("self-refresh entries: %d\n", sr_entries);
2106 srwm = total_size - sr_entries;
2107 if (srwm < 0)
2108 srwm = 1;
2109 if (IS_I9XX(dev))
2110 I915_WRITE(FW_BLC_SELF, (srwm & 0x3f));
1884 } 2111 }
1885 2112
1886 DRM_DEBUG("Setting FIFO watermarks - A: %d, B: %d, C: %d, SR %d\n", 2113 DRM_DEBUG("Setting FIFO watermarks - A: %d, B: %d, C: %d, SR %d\n",
1887 awm, bwm, cwm, srwm); 2114 planea_wm, planeb_wm, cwm, srwm);
1888 2115
1889 fwater_lo = fwater_lo | ((bwm & 0x3f) << 16) | (awm & 0x3f); 2116 fwater_lo = ((planeb_wm & 0x3f) << 16) | (planea_wm & 0x3f);
1890 fwater_hi = fwater_hi | (cwm & 0x1f); 2117 fwater_hi = (cwm & 0x1f);
2118
2119 /* Set request length to 8 cachelines per fetch */
2120 fwater_lo = fwater_lo | (1 << 24) | (1 << 8);
2121 fwater_hi = fwater_hi | (1 << 8);
1891 2122
1892 I915_WRITE(FW_BLC, fwater_lo); 2123 I915_WRITE(FW_BLC, fwater_lo);
1893 I915_WRITE(FW_BLC2, fwater_hi); 2124 I915_WRITE(FW_BLC2, fwater_hi);
1894 if (IS_I9XX(dev))
1895 I915_WRITE(FW_BLC_SELF, FW_BLC_SELF_EN | (srwm & 0x3f));
1896} 2125}
1897 2126
1898static void i830_update_wm(struct drm_device *dev, int planea_clock, 2127static void i830_update_wm(struct drm_device *dev, int planea_clock,
1899 int pixel_size) 2128 int pixel_size)
1900{ 2129{
1901 struct drm_i915_private *dev_priv = dev->dev_private; 2130 struct drm_i915_private *dev_priv = dev->dev_private;
1902 uint32_t dsparb = I915_READ(DSPARB); 2131 uint32_t fwater_lo = I915_READ(FW_BLC) & ~0xfff;
1903 uint32_t fwater_lo = I915_READ(FW_BLC) & MM_FIFO_WATERMARK; 2132 int planea_wm;
1904 unsigned int asize, awm;
1905 int planea_entries;
1906
1907 planea_entries = intel_calculate_wm(planea_clock, &i830_wm_info,
1908 pixel_size, latency_ns);
1909 2133
1910 asize = dsparb & 0x7f; 2134 i830_wm_info.fifo_size = intel_get_fifo_size(dev, 0);
1911 2135
1912 awm = asize - planea_entries; 2136 planea_wm = intel_calculate_wm(planea_clock, &i830_wm_info,
2137 pixel_size, latency_ns);
2138 fwater_lo |= (3<<8) | planea_wm;
1913 2139
1914 fwater_lo = fwater_lo | awm; 2140 DRM_DEBUG("Setting FIFO watermarks - A: %d\n", planea_wm);
1915 2141
1916 I915_WRITE(FW_BLC, fwater_lo); 2142 I915_WRITE(FW_BLC, fwater_lo);
1917} 2143}
@@ -1984,7 +2210,7 @@ static void intel_update_watermarks(struct drm_device *dev)
1984 if (enabled <= 0) 2210 if (enabled <= 0)
1985 return; 2211 return;
1986 2212
1987 /* Single pipe configs can enable self refresh */ 2213 /* Single plane configs can enable self refresh */
1988 if (enabled == 1 && IS_IGD(dev)) 2214 if (enabled == 1 && IS_IGD(dev))
1989 igd_enable_cxsr(dev, sr_clock, pixel_size); 2215 igd_enable_cxsr(dev, sr_clock, pixel_size);
1990 else if (IS_IGD(dev)) 2216 else if (IS_IGD(dev))
@@ -2028,6 +2254,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2028 u32 dpll = 0, fp = 0, dspcntr, pipeconf; 2254 u32 dpll = 0, fp = 0, dspcntr, pipeconf;
2029 bool ok, is_sdvo = false, is_dvo = false; 2255 bool ok, is_sdvo = false, is_dvo = false;
2030 bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; 2256 bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false;
2257 bool is_edp = false;
2031 struct drm_mode_config *mode_config = &dev->mode_config; 2258 struct drm_mode_config *mode_config = &dev->mode_config;
2032 struct drm_connector *connector; 2259 struct drm_connector *connector;
2033 const intel_limit_t *limit; 2260 const intel_limit_t *limit;
@@ -2043,6 +2270,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2043 int lvds_reg = LVDS; 2270 int lvds_reg = LVDS;
2044 u32 temp; 2271 u32 temp;
2045 int sdvo_pixel_multiply; 2272 int sdvo_pixel_multiply;
2273 int target_clock;
2046 2274
2047 drm_vblank_pre_modeset(dev, pipe); 2275 drm_vblank_pre_modeset(dev, pipe);
2048 2276
@@ -2074,6 +2302,9 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2074 case INTEL_OUTPUT_DISPLAYPORT: 2302 case INTEL_OUTPUT_DISPLAYPORT:
2075 is_dp = true; 2303 is_dp = true;
2076 break; 2304 break;
2305 case INTEL_OUTPUT_EDP:
2306 is_edp = true;
2307 break;
2077 } 2308 }
2078 2309
2079 num_outputs++; 2310 num_outputs++;
@@ -2125,11 +2356,29 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2125 } 2356 }
2126 2357
2127 /* FDI link */ 2358 /* FDI link */
2128 if (IS_IGDNG(dev)) 2359 if (IS_IGDNG(dev)) {
2129 igdng_compute_m_n(3, 4, /* lane num 4 */ 2360 int lane, link_bw;
2130 adjusted_mode->clock, 2361 /* eDP doesn't require FDI link, so just set DP M/N
2131 270000, /* lane clock */ 2362 according to current link config */
2132 &m_n); 2363 if (is_edp) {
2364 struct drm_connector *edp;
2365 target_clock = mode->clock;
2366 edp = intel_pipe_get_output(crtc);
2367 intel_edp_link_config(to_intel_output(edp),
2368 &lane, &link_bw);
2369 } else {
2370 /* DP over FDI requires target mode clock
2371 instead of link clock */
2372 if (is_dp)
2373 target_clock = mode->clock;
2374 else
2375 target_clock = adjusted_mode->clock;
2376 lane = 4;
2377 link_bw = 270000;
2378 }
2379 igdng_compute_m_n(3, lane, target_clock,
2380 link_bw, &m_n);
2381 }
2133 2382
2134 if (IS_IGD(dev)) 2383 if (IS_IGD(dev))
2135 fp = (1 << clock.n) << 16 | clock.m1 << 8 | clock.m2; 2384 fp = (1 << clock.n) << 16 | clock.m1 << 8 | clock.m2;
@@ -2147,7 +2396,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2147 if (is_sdvo) { 2396 if (is_sdvo) {
2148 dpll |= DPLL_DVO_HIGH_SPEED; 2397 dpll |= DPLL_DVO_HIGH_SPEED;
2149 sdvo_pixel_multiply = adjusted_mode->clock / mode->clock; 2398 sdvo_pixel_multiply = adjusted_mode->clock / mode->clock;
2150 if (IS_I945G(dev) || IS_I945GM(dev)) 2399 if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev))
2151 dpll |= (sdvo_pixel_multiply - 1) << SDVO_MULTIPLIER_SHIFT_HIRES; 2400 dpll |= (sdvo_pixel_multiply - 1) << SDVO_MULTIPLIER_SHIFT_HIRES;
2152 else if (IS_IGDNG(dev)) 2401 else if (IS_IGDNG(dev))
2153 dpll |= (sdvo_pixel_multiply - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; 2402 dpll |= (sdvo_pixel_multiply - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT;
@@ -2250,29 +2499,15 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2250 dpll_reg = pch_dpll_reg; 2499 dpll_reg = pch_dpll_reg;
2251 } 2500 }
2252 2501
2253 if (dpll & DPLL_VCO_ENABLE) { 2502 if (is_edp) {
2503 igdng_disable_pll_edp(crtc);
2504 } else if ((dpll & DPLL_VCO_ENABLE)) {
2254 I915_WRITE(fp_reg, fp); 2505 I915_WRITE(fp_reg, fp);
2255 I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE); 2506 I915_WRITE(dpll_reg, dpll & ~DPLL_VCO_ENABLE);
2256 I915_READ(dpll_reg); 2507 I915_READ(dpll_reg);
2257 udelay(150); 2508 udelay(150);
2258 } 2509 }
2259 2510
2260 if (IS_IGDNG(dev)) {
2261 /* enable PCH clock reference source */
2262 /* XXX need to change the setting for other outputs */
2263 u32 temp;
2264 temp = I915_READ(PCH_DREF_CONTROL);
2265 temp &= ~DREF_NONSPREAD_SOURCE_MASK;
2266 temp |= DREF_NONSPREAD_CK505_ENABLE;
2267 temp &= ~DREF_SSC_SOURCE_MASK;
2268 temp |= DREF_SSC_SOURCE_ENABLE;
2269 temp &= ~DREF_SSC1_ENABLE;
2270 /* if no eDP, disable source output to CPU */
2271 temp &= ~DREF_CPU_SOURCE_OUTPUT_MASK;
2272 temp |= DREF_CPU_SOURCE_OUTPUT_DISABLE;
2273 I915_WRITE(PCH_DREF_CONTROL, temp);
2274 }
2275
2276 /* The LVDS pin pair needs to be on before the DPLLs are enabled. 2511 /* The LVDS pin pair needs to be on before the DPLLs are enabled.
2277 * This is an exception to the general rule that mode_set doesn't turn 2512 * This is an exception to the general rule that mode_set doesn't turn
2278 * things on. 2513 * things on.
@@ -2304,23 +2539,25 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2304 if (is_dp) 2539 if (is_dp)
2305 intel_dp_set_m_n(crtc, mode, adjusted_mode); 2540 intel_dp_set_m_n(crtc, mode, adjusted_mode);
2306 2541
2307 I915_WRITE(fp_reg, fp); 2542 if (!is_edp) {
2308 I915_WRITE(dpll_reg, dpll); 2543 I915_WRITE(fp_reg, fp);
2309 I915_READ(dpll_reg);
2310 /* Wait for the clocks to stabilize. */
2311 udelay(150);
2312
2313 if (IS_I965G(dev) && !IS_IGDNG(dev)) {
2314 sdvo_pixel_multiply = adjusted_mode->clock / mode->clock;
2315 I915_WRITE(dpll_md_reg, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) |
2316 ((sdvo_pixel_multiply - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT));
2317 } else {
2318 /* write it again -- the BIOS does, after all */
2319 I915_WRITE(dpll_reg, dpll); 2544 I915_WRITE(dpll_reg, dpll);
2545 I915_READ(dpll_reg);
2546 /* Wait for the clocks to stabilize. */
2547 udelay(150);
2548
2549 if (IS_I965G(dev) && !IS_IGDNG(dev)) {
2550 sdvo_pixel_multiply = adjusted_mode->clock / mode->clock;
2551 I915_WRITE(dpll_md_reg, (0 << DPLL_MD_UDI_DIVIDER_SHIFT) |
2552 ((sdvo_pixel_multiply - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT));
2553 } else {
2554 /* write it again -- the BIOS does, after all */
2555 I915_WRITE(dpll_reg, dpll);
2556 }
2557 I915_READ(dpll_reg);
2558 /* Wait for the clocks to stabilize. */
2559 udelay(150);
2320 } 2560 }
2321 I915_READ(dpll_reg);
2322 /* Wait for the clocks to stabilize. */
2323 udelay(150);
2324 2561
2325 I915_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) | 2562 I915_WRITE(htot_reg, (adjusted_mode->crtc_hdisplay - 1) |
2326 ((adjusted_mode->crtc_htotal - 1) << 16)); 2563 ((adjusted_mode->crtc_htotal - 1) << 16));
@@ -2350,10 +2587,14 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
2350 I915_WRITE(link_m1_reg, m_n.link_m); 2587 I915_WRITE(link_m1_reg, m_n.link_m);
2351 I915_WRITE(link_n1_reg, m_n.link_n); 2588 I915_WRITE(link_n1_reg, m_n.link_n);
2352 2589
2353 /* enable FDI RX PLL too */ 2590 if (is_edp) {
2354 temp = I915_READ(fdi_rx_reg); 2591 igdng_set_pll_edp(crtc, adjusted_mode->clock);
2355 I915_WRITE(fdi_rx_reg, temp | FDI_RX_PLL_ENABLE); 2592 } else {
2356 udelay(200); 2593 /* enable FDI RX PLL too */
2594 temp = I915_READ(fdi_rx_reg);
2595 I915_WRITE(fdi_rx_reg, temp | FDI_RX_PLL_ENABLE);
2596 udelay(200);
2597 }
2357 } 2598 }
2358 2599
2359 I915_WRITE(pipeconf_reg, pipeconf); 2600 I915_WRITE(pipeconf_reg, pipeconf);
@@ -2929,7 +3170,7 @@ static int intel_connector_clones(struct drm_device *dev, int type_mask)
2929 3170
2930 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 3171 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
2931 struct intel_output *intel_output = to_intel_output(connector); 3172 struct intel_output *intel_output = to_intel_output(connector);
2932 if (type_mask & (1 << intel_output->type)) 3173 if (type_mask & intel_output->clone_mask)
2933 index_mask |= (1 << entry); 3174 index_mask |= (1 << entry);
2934 entry++; 3175 entry++;
2935 } 3176 }
@@ -2951,12 +3192,17 @@ static void intel_setup_outputs(struct drm_device *dev)
2951 if (IS_IGDNG(dev)) { 3192 if (IS_IGDNG(dev)) {
2952 int found; 3193 int found;
2953 3194
3195 if (IS_MOBILE(dev) && (I915_READ(DP_A) & DP_DETECTED))
3196 intel_dp_init(dev, DP_A);
3197
2954 if (I915_READ(HDMIB) & PORT_DETECTED) { 3198 if (I915_READ(HDMIB) & PORT_DETECTED) {
2955 /* check SDVOB */ 3199 /* check SDVOB */
2956 /* found = intel_sdvo_init(dev, HDMIB); */ 3200 /* found = intel_sdvo_init(dev, HDMIB); */
2957 found = 0; 3201 found = 0;
2958 if (!found) 3202 if (!found)
2959 intel_hdmi_init(dev, HDMIB); 3203 intel_hdmi_init(dev, HDMIB);
3204 if (!found && (I915_READ(PCH_DP_B) & DP_DETECTED))
3205 intel_dp_init(dev, PCH_DP_B);
2960 } 3206 }
2961 3207
2962 if (I915_READ(HDMIC) & PORT_DETECTED) 3208 if (I915_READ(HDMIC) & PORT_DETECTED)
@@ -2965,31 +3211,37 @@ static void intel_setup_outputs(struct drm_device *dev)
2965 if (I915_READ(HDMID) & PORT_DETECTED) 3211 if (I915_READ(HDMID) & PORT_DETECTED)
2966 intel_hdmi_init(dev, HDMID); 3212 intel_hdmi_init(dev, HDMID);
2967 3213
3214 if (I915_READ(PCH_DP_C) & DP_DETECTED)
3215 intel_dp_init(dev, PCH_DP_C);
3216
3217 if (I915_READ(PCH_DP_D) & DP_DETECTED)
3218 intel_dp_init(dev, PCH_DP_D);
3219
2968 } else if (IS_I9XX(dev)) { 3220 } else if (IS_I9XX(dev)) {
2969 int found; 3221 bool found = false;
2970 u32 reg;
2971 3222
2972 if (I915_READ(SDVOB) & SDVO_DETECTED) { 3223 if (I915_READ(SDVOB) & SDVO_DETECTED) {
2973 found = intel_sdvo_init(dev, SDVOB); 3224 found = intel_sdvo_init(dev, SDVOB);
2974 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 3225 if (!found && SUPPORTS_INTEGRATED_HDMI(dev))
2975 intel_hdmi_init(dev, SDVOB); 3226 intel_hdmi_init(dev, SDVOB);
3227
2976 if (!found && SUPPORTS_INTEGRATED_DP(dev)) 3228 if (!found && SUPPORTS_INTEGRATED_DP(dev))
2977 intel_dp_init(dev, DP_B); 3229 intel_dp_init(dev, DP_B);
2978 } 3230 }
2979 3231
2980 /* Before G4X SDVOC doesn't have its own detect register */ 3232 /* Before G4X SDVOC doesn't have its own detect register */
2981 if (IS_G4X(dev))
2982 reg = SDVOC;
2983 else
2984 reg = SDVOB;
2985 3233
2986 if (I915_READ(reg) & SDVO_DETECTED) { 3234 if (I915_READ(SDVOB) & SDVO_DETECTED)
2987 found = intel_sdvo_init(dev, SDVOC); 3235 found = intel_sdvo_init(dev, SDVOC);
2988 if (!found && SUPPORTS_INTEGRATED_HDMI(dev)) 3236
3237 if (!found && (I915_READ(SDVOC) & SDVO_DETECTED)) {
3238
3239 if (SUPPORTS_INTEGRATED_HDMI(dev))
2989 intel_hdmi_init(dev, SDVOC); 3240 intel_hdmi_init(dev, SDVOC);
2990 if (!found && SUPPORTS_INTEGRATED_DP(dev)) 3241 if (SUPPORTS_INTEGRATED_DP(dev))
2991 intel_dp_init(dev, DP_C); 3242 intel_dp_init(dev, DP_C);
2992 } 3243 }
3244
2993 if (SUPPORTS_INTEGRATED_DP(dev) && (I915_READ(DP_D) & DP_DETECTED)) 3245 if (SUPPORTS_INTEGRATED_DP(dev) && (I915_READ(DP_D) & DP_DETECTED))
2994 intel_dp_init(dev, DP_D); 3246 intel_dp_init(dev, DP_D);
2995 } else 3247 } else
@@ -3001,47 +3253,10 @@ static void intel_setup_outputs(struct drm_device *dev)
3001 list_for_each_entry(connector, &dev->mode_config.connector_list, head) { 3253 list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
3002 struct intel_output *intel_output = to_intel_output(connector); 3254 struct intel_output *intel_output = to_intel_output(connector);
3003 struct drm_encoder *encoder = &intel_output->enc; 3255 struct drm_encoder *encoder = &intel_output->enc;
3004 int crtc_mask = 0, clone_mask = 0;
3005 3256
3006 /* valid crtcs */ 3257 encoder->possible_crtcs = intel_output->crtc_mask;
3007 switch(intel_output->type) { 3258 encoder->possible_clones = intel_connector_clones(dev,
3008 case INTEL_OUTPUT_HDMI: 3259 intel_output->clone_mask);
3009 crtc_mask = ((1 << 0)|
3010 (1 << 1));
3011 clone_mask = ((1 << INTEL_OUTPUT_HDMI));
3012 break;
3013 case INTEL_OUTPUT_DVO:
3014 case INTEL_OUTPUT_SDVO:
3015 crtc_mask = ((1 << 0)|
3016 (1 << 1));
3017 clone_mask = ((1 << INTEL_OUTPUT_ANALOG) |
3018 (1 << INTEL_OUTPUT_DVO) |
3019 (1 << INTEL_OUTPUT_SDVO));
3020 break;
3021 case INTEL_OUTPUT_ANALOG:
3022 crtc_mask = ((1 << 0)|
3023 (1 << 1));
3024 clone_mask = ((1 << INTEL_OUTPUT_ANALOG) |
3025 (1 << INTEL_OUTPUT_DVO) |
3026 (1 << INTEL_OUTPUT_SDVO));
3027 break;
3028 case INTEL_OUTPUT_LVDS:
3029 crtc_mask = (1 << 1);
3030 clone_mask = (1 << INTEL_OUTPUT_LVDS);
3031 break;
3032 case INTEL_OUTPUT_TVOUT:
3033 crtc_mask = ((1 << 0) |
3034 (1 << 1));
3035 clone_mask = (1 << INTEL_OUTPUT_TVOUT);
3036 break;
3037 case INTEL_OUTPUT_DISPLAYPORT:
3038 crtc_mask = ((1 << 0) |
3039 (1 << 1));
3040 clone_mask = (1 << INTEL_OUTPUT_DISPLAYPORT);
3041 break;
3042 }
3043 encoder->possible_crtcs = crtc_mask;
3044 encoder->possible_clones = intel_connector_clones(dev, clone_mask);
3045 } 3260 }
3046} 3261}
3047 3262
@@ -3148,6 +3363,9 @@ void intel_modeset_init(struct drm_device *dev)
3148 if (IS_I965G(dev)) { 3363 if (IS_I965G(dev)) {
3149 dev->mode_config.max_width = 8192; 3364 dev->mode_config.max_width = 8192;
3150 dev->mode_config.max_height = 8192; 3365 dev->mode_config.max_height = 8192;
3366 } else if (IS_I9XX(dev)) {
3367 dev->mode_config.max_width = 4096;
3368 dev->mode_config.max_height = 4096;
3151 } else { 3369 } else {
3152 dev->mode_config.max_width = 2048; 3370 dev->mode_config.max_width = 2048;
3153 dev->mode_config.max_height = 2048; 3371 dev->mode_config.max_height = 2048;
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 6770ae88370d..f2afc4af4bc9 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -40,6 +40,8 @@
40 40
41#define DP_LINK_CONFIGURATION_SIZE 9 41#define DP_LINK_CONFIGURATION_SIZE 9
42 42
43#define IS_eDP(i) ((i)->type == INTEL_OUTPUT_EDP)
44
43struct intel_dp_priv { 45struct intel_dp_priv {
44 uint32_t output_reg; 46 uint32_t output_reg;
45 uint32_t DP; 47 uint32_t DP;
@@ -63,6 +65,19 @@ intel_dp_link_train(struct intel_output *intel_output, uint32_t DP,
63static void 65static void
64intel_dp_link_down(struct intel_output *intel_output, uint32_t DP); 66intel_dp_link_down(struct intel_output *intel_output, uint32_t DP);
65 67
68void
69intel_edp_link_config (struct intel_output *intel_output,
70 int *lane_num, int *link_bw)
71{
72 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
73
74 *lane_num = dp_priv->lane_count;
75 if (dp_priv->link_bw == DP_LINK_BW_1_62)
76 *link_bw = 162000;
77 else if (dp_priv->link_bw == DP_LINK_BW_2_7)
78 *link_bw = 270000;
79}
80
66static int 81static int
67intel_dp_max_lane_count(struct intel_output *intel_output) 82intel_dp_max_lane_count(struct intel_output *intel_output)
68{ 83{
@@ -206,7 +221,13 @@ intel_dp_aux_ch(struct intel_output *intel_output,
206 * and would like to run at 2MHz. So, take the 221 * and would like to run at 2MHz. So, take the
207 * hrawclk value and divide by 2 and use that 222 * hrawclk value and divide by 2 and use that
208 */ 223 */
209 aux_clock_divider = intel_hrawclk(dev) / 2; 224 if (IS_eDP(intel_output))
225 aux_clock_divider = 225; /* eDP input clock at 450Mhz */
226 else if (IS_IGDNG(dev))
227 aux_clock_divider = 62; /* IGDNG: input clock fixed at 125Mhz */
228 else
229 aux_clock_divider = intel_hrawclk(dev) / 2;
230
210 /* Must try at least 3 times according to DP spec */ 231 /* Must try at least 3 times according to DP spec */
211 for (try = 0; try < 5; try++) { 232 for (try = 0; try < 5; try++) {
212 /* Load the send data into the aux channel data registers */ 233 /* Load the send data into the aux channel data registers */
@@ -236,7 +257,7 @@ intel_dp_aux_ch(struct intel_output *intel_output,
236 } 257 }
237 258
238 /* Clear done status and any errors */ 259 /* Clear done status and any errors */
239 I915_WRITE(ch_ctl, (ctl | 260 I915_WRITE(ch_ctl, (status |
240 DP_AUX_CH_CTL_DONE | 261 DP_AUX_CH_CTL_DONE |
241 DP_AUX_CH_CTL_TIME_OUT_ERROR | 262 DP_AUX_CH_CTL_TIME_OUT_ERROR |
242 DP_AUX_CH_CTL_RECEIVE_ERROR)); 263 DP_AUX_CH_CTL_RECEIVE_ERROR));
@@ -295,7 +316,7 @@ intel_dp_aux_native_write(struct intel_output *intel_output,
295 return -1; 316 return -1;
296 msg[0] = AUX_NATIVE_WRITE << 4; 317 msg[0] = AUX_NATIVE_WRITE << 4;
297 msg[1] = address >> 8; 318 msg[1] = address >> 8;
298 msg[2] = address; 319 msg[2] = address & 0xff;
299 msg[3] = send_bytes - 1; 320 msg[3] = send_bytes - 1;
300 memcpy(&msg[4], send, send_bytes); 321 memcpy(&msg[4], send, send_bytes);
301 msg_bytes = send_bytes + 4; 322 msg_bytes = send_bytes + 4;
@@ -387,8 +408,8 @@ intel_dp_i2c_init(struct intel_output *intel_output, const char *name)
387 memset(&dp_priv->adapter, '\0', sizeof (dp_priv->adapter)); 408 memset(&dp_priv->adapter, '\0', sizeof (dp_priv->adapter));
388 dp_priv->adapter.owner = THIS_MODULE; 409 dp_priv->adapter.owner = THIS_MODULE;
389 dp_priv->adapter.class = I2C_CLASS_DDC; 410 dp_priv->adapter.class = I2C_CLASS_DDC;
390 strncpy (dp_priv->adapter.name, name, sizeof dp_priv->adapter.name - 1); 411 strncpy (dp_priv->adapter.name, name, sizeof(dp_priv->adapter.name) - 1);
391 dp_priv->adapter.name[sizeof dp_priv->adapter.name - 1] = '\0'; 412 dp_priv->adapter.name[sizeof(dp_priv->adapter.name) - 1] = '\0';
392 dp_priv->adapter.algo_data = &dp_priv->algo; 413 dp_priv->adapter.algo_data = &dp_priv->algo;
393 dp_priv->adapter.dev.parent = &intel_output->base.kdev; 414 dp_priv->adapter.dev.parent = &intel_output->base.kdev;
394 415
@@ -493,22 +514,40 @@ intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
493 intel_dp_compute_m_n(3, lane_count, 514 intel_dp_compute_m_n(3, lane_count,
494 mode->clock, adjusted_mode->clock, &m_n); 515 mode->clock, adjusted_mode->clock, &m_n);
495 516
496 if (intel_crtc->pipe == 0) { 517 if (IS_IGDNG(dev)) {
497 I915_WRITE(PIPEA_GMCH_DATA_M, 518 if (intel_crtc->pipe == 0) {
498 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) | 519 I915_WRITE(TRANSA_DATA_M1,
499 m_n.gmch_m); 520 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
500 I915_WRITE(PIPEA_GMCH_DATA_N, 521 m_n.gmch_m);
501 m_n.gmch_n); 522 I915_WRITE(TRANSA_DATA_N1, m_n.gmch_n);
502 I915_WRITE(PIPEA_DP_LINK_M, m_n.link_m); 523 I915_WRITE(TRANSA_DP_LINK_M1, m_n.link_m);
503 I915_WRITE(PIPEA_DP_LINK_N, m_n.link_n); 524 I915_WRITE(TRANSA_DP_LINK_N1, m_n.link_n);
525 } else {
526 I915_WRITE(TRANSB_DATA_M1,
527 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
528 m_n.gmch_m);
529 I915_WRITE(TRANSB_DATA_N1, m_n.gmch_n);
530 I915_WRITE(TRANSB_DP_LINK_M1, m_n.link_m);
531 I915_WRITE(TRANSB_DP_LINK_N1, m_n.link_n);
532 }
504 } else { 533 } else {
505 I915_WRITE(PIPEB_GMCH_DATA_M, 534 if (intel_crtc->pipe == 0) {
506 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) | 535 I915_WRITE(PIPEA_GMCH_DATA_M,
507 m_n.gmch_m); 536 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
508 I915_WRITE(PIPEB_GMCH_DATA_N, 537 m_n.gmch_m);
509 m_n.gmch_n); 538 I915_WRITE(PIPEA_GMCH_DATA_N,
510 I915_WRITE(PIPEB_DP_LINK_M, m_n.link_m); 539 m_n.gmch_n);
511 I915_WRITE(PIPEB_DP_LINK_N, m_n.link_n); 540 I915_WRITE(PIPEA_DP_LINK_M, m_n.link_m);
541 I915_WRITE(PIPEA_DP_LINK_N, m_n.link_n);
542 } else {
543 I915_WRITE(PIPEB_GMCH_DATA_M,
544 ((m_n.tu - 1) << PIPE_GMCH_DATA_M_TU_SIZE_SHIFT) |
545 m_n.gmch_m);
546 I915_WRITE(PIPEB_GMCH_DATA_N,
547 m_n.gmch_n);
548 I915_WRITE(PIPEB_DP_LINK_M, m_n.link_m);
549 I915_WRITE(PIPEB_DP_LINK_N, m_n.link_n);
550 }
512 } 551 }
513} 552}
514 553
@@ -556,8 +595,38 @@ intel_dp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
556 595
557 if (intel_crtc->pipe == 1) 596 if (intel_crtc->pipe == 1)
558 dp_priv->DP |= DP_PIPEB_SELECT; 597 dp_priv->DP |= DP_PIPEB_SELECT;
598
599 if (IS_eDP(intel_output)) {
600 /* don't miss out required setting for eDP */
601 dp_priv->DP |= DP_PLL_ENABLE;
602 if (adjusted_mode->clock < 200000)
603 dp_priv->DP |= DP_PLL_FREQ_160MHZ;
604 else
605 dp_priv->DP |= DP_PLL_FREQ_270MHZ;
606 }
559} 607}
560 608
609static void igdng_edp_backlight_on (struct drm_device *dev)
610{
611 struct drm_i915_private *dev_priv = dev->dev_private;
612 u32 pp;
613
614 DRM_DEBUG("\n");
615 pp = I915_READ(PCH_PP_CONTROL);
616 pp |= EDP_BLC_ENABLE;
617 I915_WRITE(PCH_PP_CONTROL, pp);
618}
619
620static void igdng_edp_backlight_off (struct drm_device *dev)
621{
622 struct drm_i915_private *dev_priv = dev->dev_private;
623 u32 pp;
624
625 DRM_DEBUG("\n");
626 pp = I915_READ(PCH_PP_CONTROL);
627 pp &= ~EDP_BLC_ENABLE;
628 I915_WRITE(PCH_PP_CONTROL, pp);
629}
561 630
562static void 631static void
563intel_dp_dpms(struct drm_encoder *encoder, int mode) 632intel_dp_dpms(struct drm_encoder *encoder, int mode)
@@ -569,11 +638,17 @@ intel_dp_dpms(struct drm_encoder *encoder, int mode)
569 uint32_t dp_reg = I915_READ(dp_priv->output_reg); 638 uint32_t dp_reg = I915_READ(dp_priv->output_reg);
570 639
571 if (mode != DRM_MODE_DPMS_ON) { 640 if (mode != DRM_MODE_DPMS_ON) {
572 if (dp_reg & DP_PORT_EN) 641 if (dp_reg & DP_PORT_EN) {
573 intel_dp_link_down(intel_output, dp_priv->DP); 642 intel_dp_link_down(intel_output, dp_priv->DP);
643 if (IS_eDP(intel_output))
644 igdng_edp_backlight_off(dev);
645 }
574 } else { 646 } else {
575 if (!(dp_reg & DP_PORT_EN)) 647 if (!(dp_reg & DP_PORT_EN)) {
576 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration); 648 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration);
649 if (IS_eDP(intel_output))
650 igdng_edp_backlight_on(dev);
651 }
577 } 652 }
578 dp_priv->dpms_mode = mode; 653 dp_priv->dpms_mode = mode;
579} 654}
@@ -935,6 +1010,23 @@ intel_dp_link_down(struct intel_output *intel_output, uint32_t DP)
935 struct drm_i915_private *dev_priv = dev->dev_private; 1010 struct drm_i915_private *dev_priv = dev->dev_private;
936 struct intel_dp_priv *dp_priv = intel_output->dev_priv; 1011 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
937 1012
1013 DRM_DEBUG("\n");
1014
1015 if (IS_eDP(intel_output)) {
1016 DP &= ~DP_PLL_ENABLE;
1017 I915_WRITE(dp_priv->output_reg, DP);
1018 POSTING_READ(dp_priv->output_reg);
1019 udelay(100);
1020 }
1021
1022 DP &= ~DP_LINK_TRAIN_MASK;
1023 I915_WRITE(dp_priv->output_reg, DP | DP_LINK_TRAIN_PAT_IDLE);
1024 POSTING_READ(dp_priv->output_reg);
1025
1026 udelay(17000);
1027
1028 if (IS_eDP(intel_output))
1029 DP |= DP_LINK_TRAIN_OFF;
938 I915_WRITE(dp_priv->output_reg, DP & ~DP_PORT_EN); 1030 I915_WRITE(dp_priv->output_reg, DP & ~DP_PORT_EN);
939 POSTING_READ(dp_priv->output_reg); 1031 POSTING_READ(dp_priv->output_reg);
940} 1032}
@@ -978,6 +1070,24 @@ intel_dp_check_link_status(struct intel_output *intel_output)
978 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration); 1070 intel_dp_link_train(intel_output, dp_priv->DP, dp_priv->link_configuration);
979} 1071}
980 1072
1073static enum drm_connector_status
1074igdng_dp_detect(struct drm_connector *connector)
1075{
1076 struct intel_output *intel_output = to_intel_output(connector);
1077 struct intel_dp_priv *dp_priv = intel_output->dev_priv;
1078 enum drm_connector_status status;
1079
1080 status = connector_status_disconnected;
1081 if (intel_dp_aux_native_read(intel_output,
1082 0x000, dp_priv->dpcd,
1083 sizeof (dp_priv->dpcd)) == sizeof (dp_priv->dpcd))
1084 {
1085 if (dp_priv->dpcd[0] != 0)
1086 status = connector_status_connected;
1087 }
1088 return status;
1089}
1090
981/** 1091/**
982 * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect DP connection. 1092 * Uses CRT_HOTPLUG_EN and CRT_HOTPLUG_STAT to detect DP connection.
983 * 1093 *
@@ -996,6 +1106,9 @@ intel_dp_detect(struct drm_connector *connector)
996 1106
997 dp_priv->has_audio = false; 1107 dp_priv->has_audio = false;
998 1108
1109 if (IS_IGDNG(dev))
1110 return igdng_dp_detect(connector);
1111
999 temp = I915_READ(PORT_HOTPLUG_EN); 1112 temp = I915_READ(PORT_HOTPLUG_EN);
1000 1113
1001 I915_WRITE(PORT_HOTPLUG_EN, 1114 I915_WRITE(PORT_HOTPLUG_EN,
@@ -1039,11 +1152,27 @@ intel_dp_detect(struct drm_connector *connector)
1039static int intel_dp_get_modes(struct drm_connector *connector) 1152static int intel_dp_get_modes(struct drm_connector *connector)
1040{ 1153{
1041 struct intel_output *intel_output = to_intel_output(connector); 1154 struct intel_output *intel_output = to_intel_output(connector);
1155 struct drm_device *dev = intel_output->base.dev;
1156 struct drm_i915_private *dev_priv = dev->dev_private;
1157 int ret;
1042 1158
1043 /* We should parse the EDID data and find out if it has an audio sink 1159 /* We should parse the EDID data and find out if it has an audio sink
1044 */ 1160 */
1045 1161
1046 return intel_ddc_get_modes(intel_output); 1162 ret = intel_ddc_get_modes(intel_output);
1163 if (ret)
1164 return ret;
1165
1166 /* if eDP has no EDID, try to use fixed panel mode from VBT */
1167 if (IS_eDP(intel_output)) {
1168 if (dev_priv->panel_fixed_mode != NULL) {
1169 struct drm_display_mode *mode;
1170 mode = drm_mode_duplicate(dev, dev_priv->panel_fixed_mode);
1171 drm_mode_probed_add(connector, mode);
1172 return 1;
1173 }
1174 }
1175 return 0;
1047} 1176}
1048 1177
1049static void 1178static void
@@ -1106,6 +1235,7 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1106 struct drm_connector *connector; 1235 struct drm_connector *connector;
1107 struct intel_output *intel_output; 1236 struct intel_output *intel_output;
1108 struct intel_dp_priv *dp_priv; 1237 struct intel_dp_priv *dp_priv;
1238 const char *name = NULL;
1109 1239
1110 intel_output = kcalloc(sizeof(struct intel_output) + 1240 intel_output = kcalloc(sizeof(struct intel_output) +
1111 sizeof(struct intel_dp_priv), 1, GFP_KERNEL); 1241 sizeof(struct intel_dp_priv), 1, GFP_KERNEL);
@@ -1119,8 +1249,23 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1119 DRM_MODE_CONNECTOR_DisplayPort); 1249 DRM_MODE_CONNECTOR_DisplayPort);
1120 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs); 1250 drm_connector_helper_add(connector, &intel_dp_connector_helper_funcs);
1121 1251
1122 intel_output->type = INTEL_OUTPUT_DISPLAYPORT; 1252 if (output_reg == DP_A)
1123 1253 intel_output->type = INTEL_OUTPUT_EDP;
1254 else
1255 intel_output->type = INTEL_OUTPUT_DISPLAYPORT;
1256
1257 if (output_reg == DP_B)
1258 intel_output->clone_mask = (1 << INTEL_DP_B_CLONE_BIT);
1259 else if (output_reg == DP_C)
1260 intel_output->clone_mask = (1 << INTEL_DP_C_CLONE_BIT);
1261 else if (output_reg == DP_D)
1262 intel_output->clone_mask = (1 << INTEL_DP_D_CLONE_BIT);
1263
1264 if (IS_eDP(intel_output)) {
1265 intel_output->crtc_mask = (1 << 1);
1266 intel_output->clone_mask = (1 << INTEL_OUTPUT_EDP);
1267 } else
1268 intel_output->crtc_mask = (1 << 0) | (1 << 1);
1124 connector->interlace_allowed = true; 1269 connector->interlace_allowed = true;
1125 connector->doublescan_allowed = 0; 1270 connector->doublescan_allowed = 0;
1126 1271
@@ -1139,12 +1284,41 @@ intel_dp_init(struct drm_device *dev, int output_reg)
1139 drm_sysfs_connector_add(connector); 1284 drm_sysfs_connector_add(connector);
1140 1285
1141 /* Set up the DDC bus. */ 1286 /* Set up the DDC bus. */
1142 intel_dp_i2c_init(intel_output, 1287 switch (output_reg) {
1143 (output_reg == DP_B) ? "DPDDC-B" : 1288 case DP_A:
1144 (output_reg == DP_C) ? "DPDDC-C" : "DPDDC-D"); 1289 name = "DPDDC-A";
1290 break;
1291 case DP_B:
1292 case PCH_DP_B:
1293 name = "DPDDC-B";
1294 break;
1295 case DP_C:
1296 case PCH_DP_C:
1297 name = "DPDDC-C";
1298 break;
1299 case DP_D:
1300 case PCH_DP_D:
1301 name = "DPDDC-D";
1302 break;
1303 }
1304
1305 intel_dp_i2c_init(intel_output, name);
1306
1145 intel_output->ddc_bus = &dp_priv->adapter; 1307 intel_output->ddc_bus = &dp_priv->adapter;
1146 intel_output->hot_plug = intel_dp_hot_plug; 1308 intel_output->hot_plug = intel_dp_hot_plug;
1147 1309
1310 if (output_reg == DP_A) {
1311 /* initialize panel mode from VBT if available for eDP */
1312 if (dev_priv->lfp_lvds_vbt_mode) {
1313 dev_priv->panel_fixed_mode =
1314 drm_mode_duplicate(dev, dev_priv->lfp_lvds_vbt_mode);
1315 if (dev_priv->panel_fixed_mode) {
1316 dev_priv->panel_fixed_mode->type |=
1317 DRM_MODE_TYPE_PREFERRED;
1318 }
1319 }
1320 }
1321
1148 /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written 1322 /* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written
1149 * 0xd. Failure to do so will result in spurious interrupts being 1323 * 0xd. Failure to do so will result in spurious interrupts being
1150 * generated on the port when a cable is not attached. 1324 * generated on the port when a cable is not attached.
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 004541c935a8..25aa6facc12d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -55,6 +55,25 @@
55#define INTEL_OUTPUT_TVOUT 5 55#define INTEL_OUTPUT_TVOUT 5
56#define INTEL_OUTPUT_HDMI 6 56#define INTEL_OUTPUT_HDMI 6
57#define INTEL_OUTPUT_DISPLAYPORT 7 57#define INTEL_OUTPUT_DISPLAYPORT 7
58#define INTEL_OUTPUT_EDP 8
59
60/* Intel Pipe Clone Bit */
61#define INTEL_HDMIB_CLONE_BIT 1
62#define INTEL_HDMIC_CLONE_BIT 2
63#define INTEL_HDMID_CLONE_BIT 3
64#define INTEL_HDMIE_CLONE_BIT 4
65#define INTEL_HDMIF_CLONE_BIT 5
66#define INTEL_SDVO_NON_TV_CLONE_BIT 6
67#define INTEL_SDVO_TV_CLONE_BIT 7
68#define INTEL_SDVO_LVDS_CLONE_BIT 8
69#define INTEL_ANALOG_CLONE_BIT 9
70#define INTEL_TV_CLONE_BIT 10
71#define INTEL_DP_B_CLONE_BIT 11
72#define INTEL_DP_C_CLONE_BIT 12
73#define INTEL_DP_D_CLONE_BIT 13
74#define INTEL_LVDS_CLONE_BIT 14
75#define INTEL_DVO_TMDS_CLONE_BIT 15
76#define INTEL_DVO_LVDS_CLONE_BIT 16
58 77
59#define INTEL_DVO_CHIP_NONE 0 78#define INTEL_DVO_CHIP_NONE 0
60#define INTEL_DVO_CHIP_LVDS 1 79#define INTEL_DVO_CHIP_LVDS 1
@@ -85,6 +104,8 @@ struct intel_output {
85 bool needs_tv_clock; 104 bool needs_tv_clock;
86 void *dev_priv; 105 void *dev_priv;
87 void (*hot_plug)(struct intel_output *); 106 void (*hot_plug)(struct intel_output *);
107 int crtc_mask;
108 int clone_mask;
88}; 109};
89 110
90struct intel_crtc { 111struct intel_crtc {
@@ -121,6 +142,8 @@ extern void intel_dp_init(struct drm_device *dev, int dp_reg);
121void 142void
122intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode, 143intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
123 struct drm_display_mode *adjusted_mode); 144 struct drm_display_mode *adjusted_mode);
145extern void intel_edp_link_config (struct intel_output *, int *, int *);
146
124 147
125extern void intel_crtc_load_lut(struct drm_crtc *crtc); 148extern void intel_crtc_load_lut(struct drm_crtc *crtc);
126extern void intel_encoder_prepare (struct drm_encoder *encoder); 149extern void intel_encoder_prepare (struct drm_encoder *encoder);
diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c
index 13bff20930e8..a4d2606de778 100644
--- a/drivers/gpu/drm/i915/intel_dvo.c
+++ b/drivers/gpu/drm/i915/intel_dvo.c
@@ -435,14 +435,20 @@ void intel_dvo_init(struct drm_device *dev)
435 continue; 435 continue;
436 436
437 intel_output->type = INTEL_OUTPUT_DVO; 437 intel_output->type = INTEL_OUTPUT_DVO;
438 intel_output->crtc_mask = (1 << 0) | (1 << 1);
438 switch (dvo->type) { 439 switch (dvo->type) {
439 case INTEL_DVO_CHIP_TMDS: 440 case INTEL_DVO_CHIP_TMDS:
441 intel_output->clone_mask =
442 (1 << INTEL_DVO_TMDS_CLONE_BIT) |
443 (1 << INTEL_ANALOG_CLONE_BIT);
440 drm_connector_init(dev, connector, 444 drm_connector_init(dev, connector,
441 &intel_dvo_connector_funcs, 445 &intel_dvo_connector_funcs,
442 DRM_MODE_CONNECTOR_DVII); 446 DRM_MODE_CONNECTOR_DVII);
443 encoder_type = DRM_MODE_ENCODER_TMDS; 447 encoder_type = DRM_MODE_ENCODER_TMDS;
444 break; 448 break;
445 case INTEL_DVO_CHIP_LVDS: 449 case INTEL_DVO_CHIP_LVDS:
450 intel_output->clone_mask =
451 (1 << INTEL_DVO_LVDS_CLONE_BIT);
446 drm_connector_init(dev, connector, 452 drm_connector_init(dev, connector,
447 &intel_dvo_connector_funcs, 453 &intel_dvo_connector_funcs,
448 DRM_MODE_CONNECTOR_LVDS); 454 DRM_MODE_CONNECTOR_LVDS);
diff --git a/drivers/gpu/drm/i915/intel_hdmi.c b/drivers/gpu/drm/i915/intel_hdmi.c
index 9e30daae37dc..fa304e136010 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -130,16 +130,17 @@ static bool intel_hdmi_mode_fixup(struct drm_encoder *encoder,
130} 130}
131 131
132static enum drm_connector_status 132static enum drm_connector_status
133intel_hdmi_edid_detect(struct drm_connector *connector) 133intel_hdmi_detect(struct drm_connector *connector)
134{ 134{
135 struct intel_output *intel_output = to_intel_output(connector); 135 struct intel_output *intel_output = to_intel_output(connector);
136 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv; 136 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv;
137 struct edid *edid = NULL; 137 struct edid *edid = NULL;
138 enum drm_connector_status status = connector_status_disconnected; 138 enum drm_connector_status status = connector_status_disconnected;
139 139
140 hdmi_priv->has_hdmi_sink = false;
140 edid = drm_get_edid(&intel_output->base, 141 edid = drm_get_edid(&intel_output->base,
141 intel_output->ddc_bus); 142 intel_output->ddc_bus);
142 hdmi_priv->has_hdmi_sink = false; 143
143 if (edid) { 144 if (edid) {
144 if (edid->input & DRM_EDID_INPUT_DIGITAL) { 145 if (edid->input & DRM_EDID_INPUT_DIGITAL) {
145 status = connector_status_connected; 146 status = connector_status_connected;
@@ -148,65 +149,8 @@ intel_hdmi_edid_detect(struct drm_connector *connector)
148 intel_output->base.display_info.raw_edid = NULL; 149 intel_output->base.display_info.raw_edid = NULL;
149 kfree(edid); 150 kfree(edid);
150 } 151 }
151 return status;
152}
153
154static enum drm_connector_status
155igdng_hdmi_detect(struct drm_connector *connector)
156{
157 struct intel_output *intel_output = to_intel_output(connector);
158 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv;
159
160 /* FIXME hotplug detect */
161 152
162 hdmi_priv->has_hdmi_sink = false; 153 return status;
163 return intel_hdmi_edid_detect(connector);
164}
165
166static enum drm_connector_status
167intel_hdmi_detect(struct drm_connector *connector)
168{
169 struct drm_device *dev = connector->dev;
170 struct drm_i915_private *dev_priv = dev->dev_private;
171 struct intel_output *intel_output = to_intel_output(connector);
172 struct intel_hdmi_priv *hdmi_priv = intel_output->dev_priv;
173 u32 temp, bit;
174
175 if (IS_IGDNG(dev))
176 return igdng_hdmi_detect(connector);
177
178 temp = I915_READ(PORT_HOTPLUG_EN);
179
180 switch (hdmi_priv->sdvox_reg) {
181 case SDVOB:
182 temp |= HDMIB_HOTPLUG_INT_EN;
183 break;
184 case SDVOC:
185 temp |= HDMIC_HOTPLUG_INT_EN;
186 break;
187 default:
188 return connector_status_unknown;
189 }
190
191 I915_WRITE(PORT_HOTPLUG_EN, temp);
192
193 POSTING_READ(PORT_HOTPLUG_EN);
194
195 switch (hdmi_priv->sdvox_reg) {
196 case SDVOB:
197 bit = HDMIB_HOTPLUG_INT_STATUS;
198 break;
199 case SDVOC:
200 bit = HDMIC_HOTPLUG_INT_STATUS;
201 break;
202 default:
203 return connector_status_unknown;
204 }
205
206 if ((I915_READ(PORT_HOTPLUG_STAT) & bit) != 0)
207 return intel_hdmi_edid_detect(connector);
208 else
209 return connector_status_disconnected;
210} 154}
211 155
212static int intel_hdmi_get_modes(struct drm_connector *connector) 156static int intel_hdmi_get_modes(struct drm_connector *connector)
@@ -286,22 +230,28 @@ void intel_hdmi_init(struct drm_device *dev, int sdvox_reg)
286 230
287 connector->interlace_allowed = 0; 231 connector->interlace_allowed = 0;
288 connector->doublescan_allowed = 0; 232 connector->doublescan_allowed = 0;
233 intel_output->crtc_mask = (1 << 0) | (1 << 1);
289 234
290 /* Set up the DDC bus. */ 235 /* Set up the DDC bus. */
291 if (sdvox_reg == SDVOB) 236 if (sdvox_reg == SDVOB) {
237 intel_output->clone_mask = (1 << INTEL_HDMIB_CLONE_BIT);
292 intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "HDMIB"); 238 intel_output->ddc_bus = intel_i2c_create(dev, GPIOE, "HDMIB");
293 else if (sdvox_reg == SDVOC) 239 } else if (sdvox_reg == SDVOC) {
240 intel_output->clone_mask = (1 << INTEL_HDMIC_CLONE_BIT);
294 intel_output->ddc_bus = intel_i2c_create(dev, GPIOD, "HDMIC"); 241 intel_output->ddc_bus = intel_i2c_create(dev, GPIOD, "HDMIC");
295 else if (sdvox_reg == HDMIB) 242 } else if (sdvox_reg == HDMIB) {
243 intel_output->clone_mask = (1 << INTEL_HDMID_CLONE_BIT);
296 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOE, 244 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOE,
297 "HDMIB"); 245 "HDMIB");
298 else if (sdvox_reg == HDMIC) 246 } else if (sdvox_reg == HDMIC) {
247 intel_output->clone_mask = (1 << INTEL_HDMIE_CLONE_BIT);
299 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOD, 248 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOD,
300 "HDMIC"); 249 "HDMIC");
301 else if (sdvox_reg == HDMID) 250 } else if (sdvox_reg == HDMID) {
251 intel_output->clone_mask = (1 << INTEL_HDMIF_CLONE_BIT);
302 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOF, 252 intel_output->ddc_bus = intel_i2c_create(dev, PCH_GPIOF,
303 "HDMID"); 253 "HDMID");
304 254 }
305 if (!intel_output->ddc_bus) 255 if (!intel_output->ddc_bus)
306 goto err_connector; 256 goto err_connector;
307 257
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c
index 9ab38efffecf..8df02ef89261 100644
--- a/drivers/gpu/drm/i915/intel_lvds.c
+++ b/drivers/gpu/drm/i915/intel_lvds.c
@@ -780,6 +780,14 @@ static const struct dmi_system_id intel_no_lvds[] = {
780 }, 780 },
781 { 781 {
782 .callback = intel_no_lvds_dmi_callback, 782 .callback = intel_no_lvds_dmi_callback,
783 .ident = "AOpen Mini PC MP915",
784 .matches = {
785 DMI_MATCH(DMI_BOARD_VENDOR, "AOpen"),
786 DMI_MATCH(DMI_BOARD_NAME, "i915GMx-F"),
787 },
788 },
789 {
790 .callback = intel_no_lvds_dmi_callback,
783 .ident = "Aopen i945GTt-VFA", 791 .ident = "Aopen i945GTt-VFA",
784 .matches = { 792 .matches = {
785 DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"), 793 DMI_MATCH(DMI_PRODUCT_VERSION, "AO00001JW"),
@@ -884,6 +892,10 @@ void intel_lvds_init(struct drm_device *dev)
884 if (IS_IGDNG(dev)) { 892 if (IS_IGDNG(dev)) {
885 if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0) 893 if ((I915_READ(PCH_LVDS) & LVDS_DETECTED) == 0)
886 return; 894 return;
895 if (dev_priv->edp_support) {
896 DRM_DEBUG("disable LVDS for eDP support\n");
897 return;
898 }
887 gpio = PCH_GPIOC; 899 gpio = PCH_GPIOC;
888 } 900 }
889 901
@@ -904,6 +916,8 @@ void intel_lvds_init(struct drm_device *dev)
904 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 916 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc);
905 intel_output->type = INTEL_OUTPUT_LVDS; 917 intel_output->type = INTEL_OUTPUT_LVDS;
906 918
919 intel_output->clone_mask = (1 << INTEL_LVDS_CLONE_BIT);
920 intel_output->crtc_mask = (1 << 1);
907 drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs); 921 drm_encoder_helper_add(encoder, &intel_lvds_helper_funcs);
908 drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs); 922 drm_connector_helper_add(connector, &intel_lvds_connector_helper_funcs);
909 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 923 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
diff --git a/drivers/gpu/drm/i915/intel_sdvo.c b/drivers/gpu/drm/i915/intel_sdvo.c
index 4f0c30948bc4..d3b74ba62b4a 100644
--- a/drivers/gpu/drm/i915/intel_sdvo.c
+++ b/drivers/gpu/drm/i915/intel_sdvo.c
@@ -31,6 +31,7 @@
31#include "drm.h" 31#include "drm.h"
32#include "drm_crtc.h" 32#include "drm_crtc.h"
33#include "intel_drv.h" 33#include "intel_drv.h"
34#include "drm_edid.h"
34#include "i915_drm.h" 35#include "i915_drm.h"
35#include "i915_drv.h" 36#include "i915_drv.h"
36#include "intel_sdvo_regs.h" 37#include "intel_sdvo_regs.h"
@@ -55,6 +56,12 @@ struct intel_sdvo_priv {
55 /* Pixel clock limitations reported by the SDVO device, in kHz */ 56 /* Pixel clock limitations reported by the SDVO device, in kHz */
56 int pixel_clock_min, pixel_clock_max; 57 int pixel_clock_min, pixel_clock_max;
57 58
59 /*
60 * For multiple function SDVO device,
61 * this is for current attached outputs.
62 */
63 uint16_t attached_output;
64
58 /** 65 /**
59 * This is set if we're going to treat the device as TV-out. 66 * This is set if we're going to treat the device as TV-out.
60 * 67 *
@@ -114,6 +121,9 @@ struct intel_sdvo_priv {
114 u32 save_SDVOX; 121 u32 save_SDVOX;
115}; 122};
116 123
124static bool
125intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags);
126
117/** 127/**
118 * Writes the SDVOB or SDVOC with the given value, but always writes both 128 * Writes the SDVOB or SDVOC with the given value, but always writes both
119 * SDVOB and SDVOC to work around apparent hardware issues (according to 129 * SDVOB and SDVOC to work around apparent hardware issues (according to
@@ -1435,41 +1445,96 @@ void intel_sdvo_set_hotplug(struct drm_connector *connector, int on)
1435 intel_sdvo_read_response(intel_output, &response, 2); 1445 intel_sdvo_read_response(intel_output, &response, 2);
1436} 1446}
1437 1447
1438static void 1448static bool
1439intel_sdvo_hdmi_sink_detect(struct drm_connector *connector) 1449intel_sdvo_multifunc_encoder(struct intel_output *intel_output)
1450{
1451 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1452 int caps = 0;
1453
1454 if (sdvo_priv->caps.output_flags &
1455 (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1))
1456 caps++;
1457 if (sdvo_priv->caps.output_flags &
1458 (SDVO_OUTPUT_RGB0 | SDVO_OUTPUT_RGB1))
1459 caps++;
1460 if (sdvo_priv->caps.output_flags &
1461 (SDVO_OUTPUT_SVID0 | SDVO_OUTPUT_SVID1))
1462 caps++;
1463 if (sdvo_priv->caps.output_flags &
1464 (SDVO_OUTPUT_CVBS0 | SDVO_OUTPUT_CVBS1))
1465 caps++;
1466 if (sdvo_priv->caps.output_flags &
1467 (SDVO_OUTPUT_YPRPB0 | SDVO_OUTPUT_YPRPB1))
1468 caps++;
1469
1470 if (sdvo_priv->caps.output_flags &
1471 (SDVO_OUTPUT_SCART0 | SDVO_OUTPUT_SCART1))
1472 caps++;
1473
1474 if (sdvo_priv->caps.output_flags &
1475 (SDVO_OUTPUT_LVDS0 | SDVO_OUTPUT_LVDS1))
1476 caps++;
1477
1478 return (caps > 1);
1479}
1480
1481enum drm_connector_status
1482intel_sdvo_hdmi_sink_detect(struct drm_connector *connector, u16 response)
1440{ 1483{
1441 struct intel_output *intel_output = to_intel_output(connector); 1484 struct intel_output *intel_output = to_intel_output(connector);
1442 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv; 1485 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1486 enum drm_connector_status status = connector_status_connected;
1443 struct edid *edid = NULL; 1487 struct edid *edid = NULL;
1444 1488
1445 edid = drm_get_edid(&intel_output->base, 1489 edid = drm_get_edid(&intel_output->base,
1446 intel_output->ddc_bus); 1490 intel_output->ddc_bus);
1447 if (edid != NULL) { 1491 if (edid != NULL) {
1448 sdvo_priv->is_hdmi = drm_detect_hdmi_monitor(edid); 1492 /* Don't report the output as connected if it's a DVI-I
1493 * connector with a non-digital EDID coming out.
1494 */
1495 if (response & (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) {
1496 if (edid->input & DRM_EDID_INPUT_DIGITAL)
1497 sdvo_priv->is_hdmi =
1498 drm_detect_hdmi_monitor(edid);
1499 else
1500 status = connector_status_disconnected;
1501 }
1502
1449 kfree(edid); 1503 kfree(edid);
1450 intel_output->base.display_info.raw_edid = NULL; 1504 intel_output->base.display_info.raw_edid = NULL;
1451 } 1505
1506 } else if (response & (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1))
1507 status = connector_status_disconnected;
1508
1509 return status;
1452} 1510}
1453 1511
1454static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector) 1512static enum drm_connector_status intel_sdvo_detect(struct drm_connector *connector)
1455{ 1513{
1456 u8 response[2]; 1514 uint16_t response;
1457 u8 status; 1515 u8 status;
1458 struct intel_output *intel_output = to_intel_output(connector); 1516 struct intel_output *intel_output = to_intel_output(connector);
1517 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1459 1518
1460 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0); 1519 intel_sdvo_write_cmd(intel_output, SDVO_CMD_GET_ATTACHED_DISPLAYS, NULL, 0);
1461 status = intel_sdvo_read_response(intel_output, &response, 2); 1520 status = intel_sdvo_read_response(intel_output, &response, 2);
1462 1521
1463 DRM_DEBUG("SDVO response %d %d\n", response[0], response[1]); 1522 DRM_DEBUG("SDVO response %d %d\n", response & 0xff, response >> 8);
1464 1523
1465 if (status != SDVO_CMD_STATUS_SUCCESS) 1524 if (status != SDVO_CMD_STATUS_SUCCESS)
1466 return connector_status_unknown; 1525 return connector_status_unknown;
1467 1526
1468 if ((response[0] != 0) || (response[1] != 0)) { 1527 if (response == 0)
1469 intel_sdvo_hdmi_sink_detect(connector);
1470 return connector_status_connected;
1471 } else
1472 return connector_status_disconnected; 1528 return connector_status_disconnected;
1529
1530 if (intel_sdvo_multifunc_encoder(intel_output) &&
1531 sdvo_priv->attached_output != response) {
1532 if (sdvo_priv->controlled_output != response &&
1533 intel_sdvo_output_setup(intel_output, response) != true)
1534 return connector_status_unknown;
1535 sdvo_priv->attached_output = response;
1536 }
1537 return intel_sdvo_hdmi_sink_detect(connector, response);
1473} 1538}
1474 1539
1475static void intel_sdvo_get_ddc_modes(struct drm_connector *connector) 1540static void intel_sdvo_get_ddc_modes(struct drm_connector *connector)
@@ -1866,16 +1931,112 @@ intel_sdvo_get_slave_addr(struct drm_device *dev, int output_device)
1866 return 0x72; 1931 return 0x72;
1867} 1932}
1868 1933
1934static bool
1935intel_sdvo_output_setup(struct intel_output *intel_output, uint16_t flags)
1936{
1937 struct drm_connector *connector = &intel_output->base;
1938 struct drm_encoder *encoder = &intel_output->enc;
1939 struct intel_sdvo_priv *sdvo_priv = intel_output->dev_priv;
1940 bool ret = true, registered = false;
1941
1942 sdvo_priv->is_tv = false;
1943 intel_output->needs_tv_clock = false;
1944 sdvo_priv->is_lvds = false;
1945
1946 if (device_is_registered(&connector->kdev)) {
1947 drm_sysfs_connector_remove(connector);
1948 registered = true;
1949 }
1950
1951 if (flags &
1952 (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) {
1953 if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0)
1954 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS0;
1955 else
1956 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1;
1957
1958 encoder->encoder_type = DRM_MODE_ENCODER_TMDS;
1959 connector->connector_type = DRM_MODE_CONNECTOR_DVID;
1960
1961 if (intel_sdvo_get_supp_encode(intel_output,
1962 &sdvo_priv->encode) &&
1963 intel_sdvo_get_digital_encoding_mode(intel_output) &&
1964 sdvo_priv->is_hdmi) {
1965 /* enable hdmi encoding mode if supported */
1966 intel_sdvo_set_encode(intel_output, SDVO_ENCODE_HDMI);
1967 intel_sdvo_set_colorimetry(intel_output,
1968 SDVO_COLORIMETRY_RGB256);
1969 connector->connector_type = DRM_MODE_CONNECTOR_HDMIA;
1970 intel_output->clone_mask =
1971 (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
1972 (1 << INTEL_ANALOG_CLONE_BIT);
1973 }
1974 } else if (flags & SDVO_OUTPUT_SVID0) {
1975
1976 sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0;
1977 encoder->encoder_type = DRM_MODE_ENCODER_TVDAC;
1978 connector->connector_type = DRM_MODE_CONNECTOR_SVIDEO;
1979 sdvo_priv->is_tv = true;
1980 intel_output->needs_tv_clock = true;
1981 intel_output->clone_mask = 1 << INTEL_SDVO_TV_CLONE_BIT;
1982 } else if (flags & SDVO_OUTPUT_RGB0) {
1983
1984 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0;
1985 encoder->encoder_type = DRM_MODE_ENCODER_DAC;
1986 connector->connector_type = DRM_MODE_CONNECTOR_VGA;
1987 intel_output->clone_mask = (1 << INTEL_SDVO_NON_TV_CLONE_BIT) |
1988 (1 << INTEL_ANALOG_CLONE_BIT);
1989 } else if (flags & SDVO_OUTPUT_RGB1) {
1990
1991 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1;
1992 encoder->encoder_type = DRM_MODE_ENCODER_DAC;
1993 connector->connector_type = DRM_MODE_CONNECTOR_VGA;
1994 } else if (flags & SDVO_OUTPUT_LVDS0) {
1995
1996 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0;
1997 encoder->encoder_type = DRM_MODE_ENCODER_LVDS;
1998 connector->connector_type = DRM_MODE_CONNECTOR_LVDS;
1999 sdvo_priv->is_lvds = true;
2000 intel_output->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) |
2001 (1 << INTEL_SDVO_LVDS_CLONE_BIT);
2002 } else if (flags & SDVO_OUTPUT_LVDS1) {
2003
2004 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1;
2005 encoder->encoder_type = DRM_MODE_ENCODER_LVDS;
2006 connector->connector_type = DRM_MODE_CONNECTOR_LVDS;
2007 sdvo_priv->is_lvds = true;
2008 intel_output->clone_mask = (1 << INTEL_ANALOG_CLONE_BIT) |
2009 (1 << INTEL_SDVO_LVDS_CLONE_BIT);
2010 } else {
2011
2012 unsigned char bytes[2];
2013
2014 sdvo_priv->controlled_output = 0;
2015 memcpy(bytes, &sdvo_priv->caps.output_flags, 2);
2016 DRM_DEBUG_KMS(I915_SDVO,
2017 "%s: Unknown SDVO output type (0x%02x%02x)\n",
2018 SDVO_NAME(sdvo_priv),
2019 bytes[0], bytes[1]);
2020 ret = false;
2021 }
2022 intel_output->crtc_mask = (1 << 0) | (1 << 1);
2023
2024 if (ret && registered)
2025 ret = drm_sysfs_connector_add(connector) == 0 ? true : false;
2026
2027
2028 return ret;
2029
2030}
2031
1869bool intel_sdvo_init(struct drm_device *dev, int output_device) 2032bool intel_sdvo_init(struct drm_device *dev, int output_device)
1870{ 2033{
1871 struct drm_connector *connector; 2034 struct drm_connector *connector;
1872 struct intel_output *intel_output; 2035 struct intel_output *intel_output;
1873 struct intel_sdvo_priv *sdvo_priv; 2036 struct intel_sdvo_priv *sdvo_priv;
1874 2037
1875 int connector_type;
1876 u8 ch[0x40]; 2038 u8 ch[0x40];
1877 int i; 2039 int i;
1878 int encoder_type;
1879 2040
1880 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL); 2041 intel_output = kcalloc(sizeof(struct intel_output)+sizeof(struct intel_sdvo_priv), 1, GFP_KERNEL);
1881 if (!intel_output) { 2042 if (!intel_output) {
@@ -1925,88 +2086,28 @@ bool intel_sdvo_init(struct drm_device *dev, int output_device)
1925 intel_output->ddc_bus->algo = &intel_sdvo_i2c_bit_algo; 2086 intel_output->ddc_bus->algo = &intel_sdvo_i2c_bit_algo;
1926 2087
1927 /* In defaut case sdvo lvds is false */ 2088 /* In defaut case sdvo lvds is false */
1928 sdvo_priv->is_lvds = false;
1929 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps); 2089 intel_sdvo_get_capabilities(intel_output, &sdvo_priv->caps);
1930 2090
1931 if (sdvo_priv->caps.output_flags & 2091 if (intel_sdvo_output_setup(intel_output,
1932 (SDVO_OUTPUT_TMDS0 | SDVO_OUTPUT_TMDS1)) { 2092 sdvo_priv->caps.output_flags) != true) {
1933 if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_TMDS0) 2093 DRM_DEBUG("SDVO output failed to setup on SDVO%c\n",
1934 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS0; 2094 output_device == SDVOB ? 'B' : 'C');
1935 else
1936 sdvo_priv->controlled_output = SDVO_OUTPUT_TMDS1;
1937
1938 encoder_type = DRM_MODE_ENCODER_TMDS;
1939 connector_type = DRM_MODE_CONNECTOR_DVID;
1940
1941 if (intel_sdvo_get_supp_encode(intel_output,
1942 &sdvo_priv->encode) &&
1943 intel_sdvo_get_digital_encoding_mode(intel_output) &&
1944 sdvo_priv->is_hdmi) {
1945 /* enable hdmi encoding mode if supported */
1946 intel_sdvo_set_encode(intel_output, SDVO_ENCODE_HDMI);
1947 intel_sdvo_set_colorimetry(intel_output,
1948 SDVO_COLORIMETRY_RGB256);
1949 connector_type = DRM_MODE_CONNECTOR_HDMIA;
1950 }
1951 }
1952 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_SVID0)
1953 {
1954 sdvo_priv->controlled_output = SDVO_OUTPUT_SVID0;
1955 encoder_type = DRM_MODE_ENCODER_TVDAC;
1956 connector_type = DRM_MODE_CONNECTOR_SVIDEO;
1957 sdvo_priv->is_tv = true;
1958 intel_output->needs_tv_clock = true;
1959 }
1960 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB0)
1961 {
1962 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB0;
1963 encoder_type = DRM_MODE_ENCODER_DAC;
1964 connector_type = DRM_MODE_CONNECTOR_VGA;
1965 }
1966 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_RGB1)
1967 {
1968 sdvo_priv->controlled_output = SDVO_OUTPUT_RGB1;
1969 encoder_type = DRM_MODE_ENCODER_DAC;
1970 connector_type = DRM_MODE_CONNECTOR_VGA;
1971 }
1972 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS0)
1973 {
1974 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS0;
1975 encoder_type = DRM_MODE_ENCODER_LVDS;
1976 connector_type = DRM_MODE_CONNECTOR_LVDS;
1977 sdvo_priv->is_lvds = true;
1978 }
1979 else if (sdvo_priv->caps.output_flags & SDVO_OUTPUT_LVDS1)
1980 {
1981 sdvo_priv->controlled_output = SDVO_OUTPUT_LVDS1;
1982 encoder_type = DRM_MODE_ENCODER_LVDS;
1983 connector_type = DRM_MODE_CONNECTOR_LVDS;
1984 sdvo_priv->is_lvds = true;
1985 }
1986 else
1987 {
1988 unsigned char bytes[2];
1989
1990 sdvo_priv->controlled_output = 0;
1991 memcpy (bytes, &sdvo_priv->caps.output_flags, 2);
1992 DRM_DEBUG_KMS(I915_SDVO,
1993 "%s: Unknown SDVO output type (0x%02x%02x)\n",
1994 SDVO_NAME(sdvo_priv),
1995 bytes[0], bytes[1]);
1996 encoder_type = DRM_MODE_ENCODER_NONE;
1997 connector_type = DRM_MODE_CONNECTOR_Unknown;
1998 goto err_i2c; 2095 goto err_i2c;
1999 } 2096 }
2000 2097
2098
2001 connector = &intel_output->base; 2099 connector = &intel_output->base;
2002 drm_connector_init(dev, connector, &intel_sdvo_connector_funcs, 2100 drm_connector_init(dev, connector, &intel_sdvo_connector_funcs,
2003 connector_type); 2101 connector->connector_type);
2102
2004 drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs); 2103 drm_connector_helper_add(connector, &intel_sdvo_connector_helper_funcs);
2005 connector->interlace_allowed = 0; 2104 connector->interlace_allowed = 0;
2006 connector->doublescan_allowed = 0; 2105 connector->doublescan_allowed = 0;
2007 connector->display_info.subpixel_order = SubPixelHorizontalRGB; 2106 connector->display_info.subpixel_order = SubPixelHorizontalRGB;
2008 2107
2009 drm_encoder_init(dev, &intel_output->enc, &intel_sdvo_enc_funcs, encoder_type); 2108 drm_encoder_init(dev, &intel_output->enc,
2109 &intel_sdvo_enc_funcs, intel_output->enc.encoder_type);
2110
2010 drm_encoder_helper_add(&intel_output->enc, &intel_sdvo_helper_funcs); 2111 drm_encoder_helper_add(&intel_output->enc, &intel_sdvo_helper_funcs);
2011 2112
2012 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 2113 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc);
diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c
index a43c98e3f077..2fbe13a0de81 100644
--- a/drivers/gpu/drm/i915/intel_tv.c
+++ b/drivers/gpu/drm/i915/intel_tv.c
@@ -1490,6 +1490,27 @@ static struct input_res {
1490 {"1920x1080", 1920, 1080}, 1490 {"1920x1080", 1920, 1080},
1491}; 1491};
1492 1492
1493/*
1494 * Chose preferred mode according to line number of TV format
1495 */
1496static void
1497intel_tv_chose_preferred_modes(struct drm_connector *connector,
1498 struct drm_display_mode *mode_ptr)
1499{
1500 struct intel_output *intel_output = to_intel_output(connector);
1501 const struct tv_mode *tv_mode = intel_tv_mode_find(intel_output);
1502
1503 if (tv_mode->nbr_end < 480 && mode_ptr->vdisplay == 480)
1504 mode_ptr->type |= DRM_MODE_TYPE_PREFERRED;
1505 else if (tv_mode->nbr_end > 480) {
1506 if (tv_mode->progressive == true && tv_mode->nbr_end < 720) {
1507 if (mode_ptr->vdisplay == 720)
1508 mode_ptr->type |= DRM_MODE_TYPE_PREFERRED;
1509 } else if (mode_ptr->vdisplay == 1080)
1510 mode_ptr->type |= DRM_MODE_TYPE_PREFERRED;
1511 }
1512}
1513
1493/** 1514/**
1494 * Stub get_modes function. 1515 * Stub get_modes function.
1495 * 1516 *
@@ -1544,6 +1565,7 @@ intel_tv_get_modes(struct drm_connector *connector)
1544 mode_ptr->clock = (int) tmp; 1565 mode_ptr->clock = (int) tmp;
1545 1566
1546 mode_ptr->type = DRM_MODE_TYPE_DRIVER; 1567 mode_ptr->type = DRM_MODE_TYPE_DRIVER;
1568 intel_tv_chose_preferred_modes(connector, mode_ptr);
1547 drm_mode_probed_add(connector, mode_ptr); 1569 drm_mode_probed_add(connector, mode_ptr);
1548 count++; 1570 count++;
1549 } 1571 }
@@ -1696,6 +1718,7 @@ intel_tv_init(struct drm_device *dev)
1696 if (!intel_output) { 1718 if (!intel_output) {
1697 return; 1719 return;
1698 } 1720 }
1721
1699 connector = &intel_output->base; 1722 connector = &intel_output->base;
1700 1723
1701 drm_connector_init(dev, connector, &intel_tv_connector_funcs, 1724 drm_connector_init(dev, connector, &intel_tv_connector_funcs,
@@ -1707,6 +1730,7 @@ intel_tv_init(struct drm_device *dev)
1707 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc); 1730 drm_mode_connector_attach_encoder(&intel_output->base, &intel_output->enc);
1708 tv_priv = (struct intel_tv_priv *)(intel_output + 1); 1731 tv_priv = (struct intel_tv_priv *)(intel_output + 1);
1709 intel_output->type = INTEL_OUTPUT_TVOUT; 1732 intel_output->type = INTEL_OUTPUT_TVOUT;
1733 intel_output->clone_mask = (1 << INTEL_TV_CLONE_BIT);
1710 intel_output->enc.possible_crtcs = ((1 << 0) | (1 << 1)); 1734 intel_output->enc.possible_crtcs = ((1 << 0) | (1 << 1));
1711 intel_output->enc.possible_clones = (1 << INTEL_OUTPUT_TVOUT); 1735 intel_output->enc.possible_clones = (1 << INTEL_OUTPUT_TVOUT);
1712 intel_output->dev_priv = tv_priv; 1736 intel_output->dev_priv = tv_priv;
diff --git a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
index 05a44896dffb..68e728e8be4d 100644
--- a/drivers/gpu/drm/radeon/r100.c
+++ b/drivers/gpu/drm/radeon/r100.c
@@ -254,6 +254,72 @@ void r100_mc_fini(struct radeon_device *rdev)
254 254
255 255
256/* 256/*
257 * Interrupts
258 */
259int r100_irq_set(struct radeon_device *rdev)
260{
261 uint32_t tmp = 0;
262
263 if (rdev->irq.sw_int) {
264 tmp |= RADEON_SW_INT_ENABLE;
265 }
266 if (rdev->irq.crtc_vblank_int[0]) {
267 tmp |= RADEON_CRTC_VBLANK_MASK;
268 }
269 if (rdev->irq.crtc_vblank_int[1]) {
270 tmp |= RADEON_CRTC2_VBLANK_MASK;
271 }
272 WREG32(RADEON_GEN_INT_CNTL, tmp);
273 return 0;
274}
275
276static inline uint32_t r100_irq_ack(struct radeon_device *rdev)
277{
278 uint32_t irqs = RREG32(RADEON_GEN_INT_STATUS);
279 uint32_t irq_mask = RADEON_SW_INT_TEST | RADEON_CRTC_VBLANK_STAT |
280 RADEON_CRTC2_VBLANK_STAT;
281
282 if (irqs) {
283 WREG32(RADEON_GEN_INT_STATUS, irqs);
284 }
285 return irqs & irq_mask;
286}
287
288int r100_irq_process(struct radeon_device *rdev)
289{
290 uint32_t status;
291
292 status = r100_irq_ack(rdev);
293 if (!status) {
294 return IRQ_NONE;
295 }
296 while (status) {
297 /* SW interrupt */
298 if (status & RADEON_SW_INT_TEST) {
299 radeon_fence_process(rdev);
300 }
301 /* Vertical blank interrupts */
302 if (status & RADEON_CRTC_VBLANK_STAT) {
303 drm_handle_vblank(rdev->ddev, 0);
304 }
305 if (status & RADEON_CRTC2_VBLANK_STAT) {
306 drm_handle_vblank(rdev->ddev, 1);
307 }
308 status = r100_irq_ack(rdev);
309 }
310 return IRQ_HANDLED;
311}
312
313u32 r100_get_vblank_counter(struct radeon_device *rdev, int crtc)
314{
315 if (crtc == 0)
316 return RREG32(RADEON_CRTC_CRNT_FRAME);
317 else
318 return RREG32(RADEON_CRTC2_CRNT_FRAME);
319}
320
321
322/*
257 * Fence emission 323 * Fence emission
258 */ 324 */
259void r100_fence_ring_emit(struct radeon_device *rdev, 325void r100_fence_ring_emit(struct radeon_device *rdev,
@@ -722,13 +788,14 @@ int r100_cs_packet_parse(struct radeon_cs_parser *p,
722 unsigned idx) 788 unsigned idx)
723{ 789{
724 struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx]; 790 struct radeon_cs_chunk *ib_chunk = &p->chunks[p->chunk_ib_idx];
725 uint32_t header = ib_chunk->kdata[idx]; 791 uint32_t header;
726 792
727 if (idx >= ib_chunk->length_dw) { 793 if (idx >= ib_chunk->length_dw) {
728 DRM_ERROR("Can not parse packet at %d after CS end %d !\n", 794 DRM_ERROR("Can not parse packet at %d after CS end %d !\n",
729 idx, ib_chunk->length_dw); 795 idx, ib_chunk->length_dw);
730 return -EINVAL; 796 return -EINVAL;
731 } 797 }
798 header = ib_chunk->kdata[idx];
732 pkt->idx = idx; 799 pkt->idx = idx;
733 pkt->type = CP_PACKET_GET_TYPE(header); 800 pkt->type = CP_PACKET_GET_TYPE(header);
734 pkt->count = CP_PACKET_GET_COUNT(header); 801 pkt->count = CP_PACKET_GET_COUNT(header);
@@ -1024,6 +1091,16 @@ static int r100_packet0_check(struct radeon_cs_parser *p,
1024 tmp |= tile_flags; 1091 tmp |= tile_flags;
1025 ib[idx] = tmp; 1092 ib[idx] = tmp;
1026 break; 1093 break;
1094 case RADEON_RB3D_ZPASS_ADDR:
1095 r = r100_cs_packet_next_reloc(p, &reloc);
1096 if (r) {
1097 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
1098 idx, reg);
1099 r100_cs_dump_packet(p, pkt);
1100 return r;
1101 }
1102 ib[idx] = ib_chunk->kdata[idx] + ((u32)reloc->lobj.gpu_offset);
1103 break;
1027 default: 1104 default:
1028 /* FIXME: we don't want to allow anyothers packet */ 1105 /* FIXME: we don't want to allow anyothers packet */
1029 break; 1106 break;
@@ -1555,26 +1632,6 @@ void r100_pll_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
1555 r100_pll_errata_after_data(rdev); 1632 r100_pll_errata_after_data(rdev);
1556} 1633}
1557 1634
1558uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg)
1559{
1560 if (reg < 0x10000)
1561 return readl(((void __iomem *)rdev->rmmio) + reg);
1562 else {
1563 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
1564 return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
1565 }
1566}
1567
1568void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
1569{
1570 if (reg < 0x10000)
1571 writel(v, ((void __iomem *)rdev->rmmio) + reg);
1572 else {
1573 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
1574 writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
1575 }
1576}
1577
1578int r100_init(struct radeon_device *rdev) 1635int r100_init(struct radeon_device *rdev)
1579{ 1636{
1580 return 0; 1637 return 0;
diff --git a/drivers/gpu/drm/radeon/r300.c b/drivers/gpu/drm/radeon/r300.c
index 9c8d41534a5d..053f4ec397f7 100644
--- a/drivers/gpu/drm/radeon/r300.c
+++ b/drivers/gpu/drm/radeon/r300.c
@@ -83,8 +83,8 @@ void rv370_pcie_gart_tlb_flush(struct radeon_device *rdev)
83 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp | RADEON_PCIE_TX_GART_INVALIDATE_TLB); 83 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp | RADEON_PCIE_TX_GART_INVALIDATE_TLB);
84 (void)RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL); 84 (void)RREG32_PCIE(RADEON_PCIE_TX_GART_CNTL);
85 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp); 85 WREG32_PCIE(RADEON_PCIE_TX_GART_CNTL, tmp);
86 mb();
87 } 86 }
87 mb();
88} 88}
89 89
90int rv370_pcie_gart_enable(struct radeon_device *rdev) 90int rv370_pcie_gart_enable(struct radeon_device *rdev)
@@ -448,6 +448,7 @@ void r300_gpu_init(struct radeon_device *rdev)
448 /* rv350,rv370,rv380 */ 448 /* rv350,rv370,rv380 */
449 rdev->num_gb_pipes = 1; 449 rdev->num_gb_pipes = 1;
450 } 450 }
451 rdev->num_z_pipes = 1;
451 gb_tile_config = (R300_ENABLE_TILING | R300_TILE_SIZE_16); 452 gb_tile_config = (R300_ENABLE_TILING | R300_TILE_SIZE_16);
452 switch (rdev->num_gb_pipes) { 453 switch (rdev->num_gb_pipes) {
453 case 2: 454 case 2:
@@ -486,7 +487,8 @@ void r300_gpu_init(struct radeon_device *rdev)
486 printk(KERN_WARNING "Failed to wait MC idle while " 487 printk(KERN_WARNING "Failed to wait MC idle while "
487 "programming pipes. Bad things might happen.\n"); 488 "programming pipes. Bad things might happen.\n");
488 } 489 }
489 DRM_INFO("radeon: %d pipes initialized.\n", rdev->num_gb_pipes); 490 DRM_INFO("radeon: %d quad pipes, %d Z pipes initialized.\n",
491 rdev->num_gb_pipes, rdev->num_z_pipes);
490} 492}
491 493
492int r300_ga_reset(struct radeon_device *rdev) 494int r300_ga_reset(struct radeon_device *rdev)
@@ -593,27 +595,6 @@ void r300_vram_info(struct radeon_device *rdev)
593 595
594 596
595/* 597/*
596 * Indirect registers accessor
597 */
598uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
599{
600 uint32_t r;
601
602 WREG8(RADEON_PCIE_INDEX, ((reg) & 0xff));
603 (void)RREG32(RADEON_PCIE_INDEX);
604 r = RREG32(RADEON_PCIE_DATA);
605 return r;
606}
607
608void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
609{
610 WREG8(RADEON_PCIE_INDEX, ((reg) & 0xff));
611 (void)RREG32(RADEON_PCIE_INDEX);
612 WREG32(RADEON_PCIE_DATA, (v));
613 (void)RREG32(RADEON_PCIE_DATA);
614}
615
616/*
617 * PCIE Lanes 598 * PCIE Lanes
618 */ 599 */
619 600
@@ -1403,6 +1384,21 @@ static int r300_packet0_check(struct radeon_cs_parser *p,
1403 tmp = (ib_chunk->kdata[idx] >> 22) & 0xF; 1384 tmp = (ib_chunk->kdata[idx] >> 22) & 0xF;
1404 track->textures[i].txdepth = tmp; 1385 track->textures[i].txdepth = tmp;
1405 break; 1386 break;
1387 case R300_ZB_ZPASS_ADDR:
1388 r = r100_cs_packet_next_reloc(p, &reloc);
1389 if (r) {
1390 DRM_ERROR("No reloc for ib[%d]=0x%04X\n",
1391 idx, reg);
1392 r100_cs_dump_packet(p, pkt);
1393 return r;
1394 }
1395 ib[idx] = ib_chunk->kdata[idx] + ((u32)reloc->lobj.gpu_offset);
1396 break;
1397 case 0x4be8:
1398 /* valid register only on RV530 */
1399 if (p->rdev->family == CHIP_RV530)
1400 break;
1401 /* fallthrough do not move */
1406 default: 1402 default:
1407 printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n", 1403 printk(KERN_ERR "Forbidden register 0x%04X in cs at %d\n",
1408 reg, idx); 1404 reg, idx);
diff --git a/drivers/gpu/drm/radeon/r420.c b/drivers/gpu/drm/radeon/r420.c
index dea497a979f2..97426a6f370f 100644
--- a/drivers/gpu/drm/radeon/r420.c
+++ b/drivers/gpu/drm/radeon/r420.c
@@ -165,7 +165,18 @@ void r420_pipes_init(struct radeon_device *rdev)
165 printk(KERN_WARNING "Failed to wait GUI idle while " 165 printk(KERN_WARNING "Failed to wait GUI idle while "
166 "programming pipes. Bad things might happen.\n"); 166 "programming pipes. Bad things might happen.\n");
167 } 167 }
168 DRM_INFO("radeon: %d pipes initialized.\n", rdev->num_gb_pipes); 168
169 if (rdev->family == CHIP_RV530) {
170 tmp = RREG32(RV530_GB_PIPE_SELECT2);
171 if ((tmp & 3) == 3)
172 rdev->num_z_pipes = 2;
173 else
174 rdev->num_z_pipes = 1;
175 } else
176 rdev->num_z_pipes = 1;
177
178 DRM_INFO("radeon: %d quad pipes, %d z pipes initialized.\n",
179 rdev->num_gb_pipes, rdev->num_z_pipes);
169} 180}
170 181
171void r420_gpu_init(struct radeon_device *rdev) 182void r420_gpu_init(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/r500_reg.h b/drivers/gpu/drm/radeon/r500_reg.h
index 036691b38cb7..e1d5e0331e19 100644
--- a/drivers/gpu/drm/radeon/r500_reg.h
+++ b/drivers/gpu/drm/radeon/r500_reg.h
@@ -350,6 +350,7 @@
350#define AVIVO_D1CRTC_BLANK_CONTROL 0x6084 350#define AVIVO_D1CRTC_BLANK_CONTROL 0x6084
351#define AVIVO_D1CRTC_INTERLACE_CONTROL 0x6088 351#define AVIVO_D1CRTC_INTERLACE_CONTROL 0x6088
352#define AVIVO_D1CRTC_INTERLACE_STATUS 0x608c 352#define AVIVO_D1CRTC_INTERLACE_STATUS 0x608c
353#define AVIVO_D1CRTC_FRAME_COUNT 0x60a4
353#define AVIVO_D1CRTC_STEREO_CONTROL 0x60c4 354#define AVIVO_D1CRTC_STEREO_CONTROL 0x60c4
354 355
355/* master controls */ 356/* master controls */
@@ -438,14 +439,15 @@
438# define AVIVO_DC_LB_DISP1_END_ADR_SHIFT 4 439# define AVIVO_DC_LB_DISP1_END_ADR_SHIFT 4
439# define AVIVO_DC_LB_DISP1_END_ADR_MASK 0x7ff 440# define AVIVO_DC_LB_DISP1_END_ADR_MASK 0x7ff
440 441
441#define R500_DxMODE_INT_MASK 0x6540
442#define R500_D1MODE_INT_MASK (1<<0)
443#define R500_D2MODE_INT_MASK (1<<8)
444
445#define AVIVO_D1MODE_DATA_FORMAT 0x6528 442#define AVIVO_D1MODE_DATA_FORMAT 0x6528
446# define AVIVO_D1MODE_INTERLEAVE_EN (1 << 0) 443# define AVIVO_D1MODE_INTERLEAVE_EN (1 << 0)
447#define AVIVO_D1MODE_DESKTOP_HEIGHT 0x652C 444#define AVIVO_D1MODE_DESKTOP_HEIGHT 0x652C
445#define AVIVO_D1MODE_VBLANK_STATUS 0x6534
446# define AVIVO_VBLANK_ACK (1 << 4)
448#define AVIVO_D1MODE_VLINE_START_END 0x6538 447#define AVIVO_D1MODE_VLINE_START_END 0x6538
448#define AVIVO_DxMODE_INT_MASK 0x6540
449# define AVIVO_D1MODE_INT_MASK (1 << 0)
450# define AVIVO_D2MODE_INT_MASK (1 << 8)
449#define AVIVO_D1MODE_VIEWPORT_START 0x6580 451#define AVIVO_D1MODE_VIEWPORT_START 0x6580
450#define AVIVO_D1MODE_VIEWPORT_SIZE 0x6584 452#define AVIVO_D1MODE_VIEWPORT_SIZE 0x6584
451#define AVIVO_D1MODE_EXT_OVERSCAN_LEFT_RIGHT 0x6588 453#define AVIVO_D1MODE_EXT_OVERSCAN_LEFT_RIGHT 0x6588
@@ -475,6 +477,7 @@
475#define AVIVO_D2CRTC_BLANK_CONTROL 0x6884 477#define AVIVO_D2CRTC_BLANK_CONTROL 0x6884
476#define AVIVO_D2CRTC_INTERLACE_CONTROL 0x6888 478#define AVIVO_D2CRTC_INTERLACE_CONTROL 0x6888
477#define AVIVO_D2CRTC_INTERLACE_STATUS 0x688c 479#define AVIVO_D2CRTC_INTERLACE_STATUS 0x688c
480#define AVIVO_D2CRTC_FRAME_COUNT 0x68a4
478#define AVIVO_D2CRTC_STEREO_CONTROL 0x68c4 481#define AVIVO_D2CRTC_STEREO_CONTROL 0x68c4
479 482
480#define AVIVO_D2GRPH_ENABLE 0x6900 483#define AVIVO_D2GRPH_ENABLE 0x6900
@@ -497,6 +500,7 @@
497#define AVIVO_D2CUR_SIZE 0x6c10 500#define AVIVO_D2CUR_SIZE 0x6c10
498#define AVIVO_D2CUR_POSITION 0x6c14 501#define AVIVO_D2CUR_POSITION 0x6c14
499 502
503#define AVIVO_D2MODE_VBLANK_STATUS 0x6d34
500#define AVIVO_D2MODE_VLINE_START_END 0x6d38 504#define AVIVO_D2MODE_VLINE_START_END 0x6d38
501#define AVIVO_D2MODE_VIEWPORT_START 0x6d80 505#define AVIVO_D2MODE_VIEWPORT_START 0x6d80
502#define AVIVO_D2MODE_VIEWPORT_SIZE 0x6d84 506#define AVIVO_D2MODE_VIEWPORT_SIZE 0x6d84
@@ -748,4 +752,8 @@
748# define AVIVO_I2C_EN (1 << 0) 752# define AVIVO_I2C_EN (1 << 0)
749# define AVIVO_I2C_RESET (1 << 8) 753# define AVIVO_I2C_RESET (1 << 8)
750 754
755#define AVIVO_DISP_INTERRUPT_STATUS 0x7edc
756# define AVIVO_D1_VBLANK_INTERRUPT (1 << 4)
757# define AVIVO_D2_VBLANK_INTERRUPT (1 << 5)
758
751#endif 759#endif
diff --git a/drivers/gpu/drm/radeon/r520.c b/drivers/gpu/drm/radeon/r520.c
index 09fb0b6ec7dd..ebd6b0f7bdff 100644
--- a/drivers/gpu/drm/radeon/r520.c
+++ b/drivers/gpu/drm/radeon/r520.c
@@ -177,7 +177,6 @@ void r520_gpu_init(struct radeon_device *rdev)
177 */ 177 */
178 /* workaround for RV530 */ 178 /* workaround for RV530 */
179 if (rdev->family == CHIP_RV530) { 179 if (rdev->family == CHIP_RV530) {
180 WREG32(0x4124, 1);
181 WREG32(0x4128, 0xFF); 180 WREG32(0x4128, 0xFF);
182 } 181 }
183 r420_pipes_init(rdev); 182 r420_pipes_init(rdev);
diff --git a/drivers/gpu/drm/radeon/r600_cp.c b/drivers/gpu/drm/radeon/r600_cp.c
index 146f3570af8e..20f17908b036 100644
--- a/drivers/gpu/drm/radeon/r600_cp.c
+++ b/drivers/gpu/drm/radeon/r600_cp.c
@@ -384,8 +384,9 @@ static void r600_cp_load_microcode(drm_radeon_private_t *dev_priv)
384 DRM_INFO("Loading RV670 PFP Microcode\n"); 384 DRM_INFO("Loading RV670 PFP Microcode\n");
385 for (i = 0; i < PFP_UCODE_SIZE; i++) 385 for (i = 0; i < PFP_UCODE_SIZE; i++)
386 RADEON_WRITE(R600_CP_PFP_UCODE_DATA, RV670_pfp_microcode[i]); 386 RADEON_WRITE(R600_CP_PFP_UCODE_DATA, RV670_pfp_microcode[i]);
387 } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) { 387 } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) ||
388 DRM_INFO("Loading RS780 CP Microcode\n"); 388 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880)) {
389 DRM_INFO("Loading RS780/RS880 CP Microcode\n");
389 for (i = 0; i < PM4_UCODE_SIZE; i++) { 390 for (i = 0; i < PM4_UCODE_SIZE; i++) {
390 RADEON_WRITE(R600_CP_ME_RAM_DATA, 391 RADEON_WRITE(R600_CP_ME_RAM_DATA,
391 RS780_cp_microcode[i][0]); 392 RS780_cp_microcode[i][0]);
@@ -396,7 +397,7 @@ static void r600_cp_load_microcode(drm_radeon_private_t *dev_priv)
396 } 397 }
397 398
398 RADEON_WRITE(R600_CP_PFP_UCODE_ADDR, 0); 399 RADEON_WRITE(R600_CP_PFP_UCODE_ADDR, 0);
399 DRM_INFO("Loading RS780 PFP Microcode\n"); 400 DRM_INFO("Loading RS780/RS880 PFP Microcode\n");
400 for (i = 0; i < PFP_UCODE_SIZE; i++) 401 for (i = 0; i < PFP_UCODE_SIZE; i++)
401 RADEON_WRITE(R600_CP_PFP_UCODE_DATA, RS780_pfp_microcode[i]); 402 RADEON_WRITE(R600_CP_PFP_UCODE_DATA, RS780_pfp_microcode[i]);
402 } 403 }
@@ -783,6 +784,7 @@ static void r600_gfx_init(struct drm_device *dev,
783 break; 784 break;
784 case CHIP_RV610: 785 case CHIP_RV610:
785 case CHIP_RS780: 786 case CHIP_RS780:
787 case CHIP_RS880:
786 case CHIP_RV620: 788 case CHIP_RV620:
787 dev_priv->r600_max_pipes = 1; 789 dev_priv->r600_max_pipes = 1;
788 dev_priv->r600_max_tile_pipes = 1; 790 dev_priv->r600_max_tile_pipes = 1;
@@ -917,7 +919,8 @@ static void r600_gfx_init(struct drm_device *dev,
917 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV630) || 919 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV630) ||
918 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || 920 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) ||
919 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || 921 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) ||
920 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) 922 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) ||
923 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880))
921 RADEON_WRITE(R600_DB_DEBUG, R600_PREZ_MUST_WAIT_FOR_POSTZ_DONE); 924 RADEON_WRITE(R600_DB_DEBUG, R600_PREZ_MUST_WAIT_FOR_POSTZ_DONE);
922 else 925 else
923 RADEON_WRITE(R600_DB_DEBUG, 0); 926 RADEON_WRITE(R600_DB_DEBUG, 0);
@@ -935,7 +938,8 @@ static void r600_gfx_init(struct drm_device *dev,
935 sq_ms_fifo_sizes = RADEON_READ(R600_SQ_MS_FIFO_SIZES); 938 sq_ms_fifo_sizes = RADEON_READ(R600_SQ_MS_FIFO_SIZES);
936 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || 939 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) ||
937 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || 940 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) ||
938 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) { 941 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) ||
942 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880)) {
939 sq_ms_fifo_sizes = (R600_CACHE_FIFO_SIZE(0xa) | 943 sq_ms_fifo_sizes = (R600_CACHE_FIFO_SIZE(0xa) |
940 R600_FETCH_FIFO_HIWATER(0xa) | 944 R600_FETCH_FIFO_HIWATER(0xa) |
941 R600_DONE_FIFO_HIWATER(0xe0) | 945 R600_DONE_FIFO_HIWATER(0xe0) |
@@ -978,7 +982,8 @@ static void r600_gfx_init(struct drm_device *dev,
978 R600_NUM_ES_STACK_ENTRIES(0)); 982 R600_NUM_ES_STACK_ENTRIES(0));
979 } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || 983 } else if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) ||
980 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || 984 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) ||
981 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) { 985 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) ||
986 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880)) {
982 /* no vertex cache */ 987 /* no vertex cache */
983 sq_config &= ~R600_VC_ENABLE; 988 sq_config &= ~R600_VC_ENABLE;
984 989
@@ -1035,7 +1040,8 @@ static void r600_gfx_init(struct drm_device *dev,
1035 1040
1036 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) || 1041 if (((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV610) ||
1037 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) || 1042 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV620) ||
1038 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780)) 1043 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS780) ||
1044 ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RS880))
1039 RADEON_WRITE(R600_VGT_CACHE_INVALIDATION, R600_CACHE_INVALIDATION(R600_TC_ONLY)); 1045 RADEON_WRITE(R600_VGT_CACHE_INVALIDATION, R600_CACHE_INVALIDATION(R600_TC_ONLY));
1040 else 1046 else
1041 RADEON_WRITE(R600_VGT_CACHE_INVALIDATION, R600_CACHE_INVALIDATION(R600_VC_AND_TC)); 1047 RADEON_WRITE(R600_VGT_CACHE_INVALIDATION, R600_CACHE_INVALIDATION(R600_VC_AND_TC));
@@ -1078,6 +1084,7 @@ static void r600_gfx_init(struct drm_device *dev,
1078 break; 1084 break;
1079 case CHIP_RV610: 1085 case CHIP_RV610:
1080 case CHIP_RS780: 1086 case CHIP_RS780:
1087 case CHIP_RS880:
1081 case CHIP_RV620: 1088 case CHIP_RV620:
1082 gs_prim_buffer_depth = 32; 1089 gs_prim_buffer_depth = 32;
1083 break; 1090 break;
@@ -1123,6 +1130,7 @@ static void r600_gfx_init(struct drm_device *dev,
1123 switch (dev_priv->flags & RADEON_FAMILY_MASK) { 1130 switch (dev_priv->flags & RADEON_FAMILY_MASK) {
1124 case CHIP_RV610: 1131 case CHIP_RV610:
1125 case CHIP_RS780: 1132 case CHIP_RS780:
1133 case CHIP_RS880:
1126 case CHIP_RV620: 1134 case CHIP_RV620:
1127 tc_cntl = R600_TC_L2_SIZE(8); 1135 tc_cntl = R600_TC_L2_SIZE(8);
1128 break; 1136 break;
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index b1d945b8ed6c..b519fb2fecbb 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -242,6 +242,7 @@ int radeon_object_pin(struct radeon_object *robj, uint32_t domain,
242 uint64_t *gpu_addr); 242 uint64_t *gpu_addr);
243void radeon_object_unpin(struct radeon_object *robj); 243void radeon_object_unpin(struct radeon_object *robj);
244int radeon_object_wait(struct radeon_object *robj); 244int radeon_object_wait(struct radeon_object *robj);
245int radeon_object_busy_domain(struct radeon_object *robj, uint32_t *cur_placement);
245int radeon_object_evict_vram(struct radeon_device *rdev); 246int radeon_object_evict_vram(struct radeon_device *rdev);
246int radeon_object_mmap(struct radeon_object *robj, uint64_t *offset); 247int radeon_object_mmap(struct radeon_object *robj, uint64_t *offset);
247void radeon_object_force_delete(struct radeon_device *rdev); 248void radeon_object_force_delete(struct radeon_device *rdev);
@@ -574,6 +575,7 @@ struct radeon_asic {
574 void (*ring_start)(struct radeon_device *rdev); 575 void (*ring_start)(struct radeon_device *rdev);
575 int (*irq_set)(struct radeon_device *rdev); 576 int (*irq_set)(struct radeon_device *rdev);
576 int (*irq_process)(struct radeon_device *rdev); 577 int (*irq_process)(struct radeon_device *rdev);
578 u32 (*get_vblank_counter)(struct radeon_device *rdev, int crtc);
577 void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence); 579 void (*fence_ring_emit)(struct radeon_device *rdev, struct radeon_fence *fence);
578 int (*cs_parse)(struct radeon_cs_parser *p); 580 int (*cs_parse)(struct radeon_cs_parser *p);
579 int (*copy_blit)(struct radeon_device *rdev, 581 int (*copy_blit)(struct radeon_device *rdev,
@@ -653,6 +655,7 @@ struct radeon_device {
653 int usec_timeout; 655 int usec_timeout;
654 enum radeon_pll_errata pll_errata; 656 enum radeon_pll_errata pll_errata;
655 int num_gb_pipes; 657 int num_gb_pipes;
658 int num_z_pipes;
656 int disp_priority; 659 int disp_priority;
657 /* BIOS */ 660 /* BIOS */
658 uint8_t *bios; 661 uint8_t *bios;
@@ -666,14 +669,11 @@ struct radeon_device {
666 resource_size_t rmmio_base; 669 resource_size_t rmmio_base;
667 resource_size_t rmmio_size; 670 resource_size_t rmmio_size;
668 void *rmmio; 671 void *rmmio;
669 radeon_rreg_t mm_rreg;
670 radeon_wreg_t mm_wreg;
671 radeon_rreg_t mc_rreg; 672 radeon_rreg_t mc_rreg;
672 radeon_wreg_t mc_wreg; 673 radeon_wreg_t mc_wreg;
673 radeon_rreg_t pll_rreg; 674 radeon_rreg_t pll_rreg;
674 radeon_wreg_t pll_wreg; 675 radeon_wreg_t pll_wreg;
675 radeon_rreg_t pcie_rreg; 676 uint32_t pcie_reg_mask;
676 radeon_wreg_t pcie_wreg;
677 radeon_rreg_t pciep_rreg; 677 radeon_rreg_t pciep_rreg;
678 radeon_wreg_t pciep_wreg; 678 radeon_wreg_t pciep_wreg;
679 struct radeon_clock clock; 679 struct radeon_clock clock;
@@ -705,22 +705,42 @@ int radeon_device_init(struct radeon_device *rdev,
705void radeon_device_fini(struct radeon_device *rdev); 705void radeon_device_fini(struct radeon_device *rdev);
706int radeon_gpu_wait_for_idle(struct radeon_device *rdev); 706int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
707 707
708static inline uint32_t r100_mm_rreg(struct radeon_device *rdev, uint32_t reg)
709{
710 if (reg < 0x10000)
711 return readl(((void __iomem *)rdev->rmmio) + reg);
712 else {
713 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
714 return readl(((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
715 }
716}
717
718static inline void r100_mm_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
719{
720 if (reg < 0x10000)
721 writel(v, ((void __iomem *)rdev->rmmio) + reg);
722 else {
723 writel(reg, ((void __iomem *)rdev->rmmio) + RADEON_MM_INDEX);
724 writel(v, ((void __iomem *)rdev->rmmio) + RADEON_MM_DATA);
725 }
726}
727
708 728
709/* 729/*
710 * Registers read & write functions. 730 * Registers read & write functions.
711 */ 731 */
712#define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg)) 732#define RREG8(reg) readb(((void __iomem *)rdev->rmmio) + (reg))
713#define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg)) 733#define WREG8(reg, v) writeb(v, ((void __iomem *)rdev->rmmio) + (reg))
714#define RREG32(reg) rdev->mm_rreg(rdev, (reg)) 734#define RREG32(reg) r100_mm_rreg(rdev, (reg))
715#define WREG32(reg, v) rdev->mm_wreg(rdev, (reg), (v)) 735#define WREG32(reg, v) r100_mm_wreg(rdev, (reg), (v))
716#define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) 736#define REG_SET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
717#define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK) 737#define REG_GET(FIELD, v) (((v) << FIELD##_SHIFT) & FIELD##_MASK)
718#define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg)) 738#define RREG32_PLL(reg) rdev->pll_rreg(rdev, (reg))
719#define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v)) 739#define WREG32_PLL(reg, v) rdev->pll_wreg(rdev, (reg), (v))
720#define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg)) 740#define RREG32_MC(reg) rdev->mc_rreg(rdev, (reg))
721#define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v)) 741#define WREG32_MC(reg, v) rdev->mc_wreg(rdev, (reg), (v))
722#define RREG32_PCIE(reg) rdev->pcie_rreg(rdev, (reg)) 742#define RREG32_PCIE(reg) rv370_pcie_rreg(rdev, (reg))
723#define WREG32_PCIE(reg, v) rdev->pcie_wreg(rdev, (reg), (v)) 743#define WREG32_PCIE(reg, v) rv370_pcie_wreg(rdev, (reg), (v))
724#define WREG32_P(reg, val, mask) \ 744#define WREG32_P(reg, val, mask) \
725 do { \ 745 do { \
726 uint32_t tmp_ = RREG32(reg); \ 746 uint32_t tmp_ = RREG32(reg); \
@@ -736,6 +756,24 @@ int radeon_gpu_wait_for_idle(struct radeon_device *rdev);
736 WREG32_PLL(reg, tmp_); \ 756 WREG32_PLL(reg, tmp_); \
737 } while (0) 757 } while (0)
738 758
759/*
760 * Indirect registers accessor
761 */
762static inline uint32_t rv370_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
763{
764 uint32_t r;
765
766 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
767 r = RREG32(RADEON_PCIE_DATA);
768 return r;
769}
770
771static inline void rv370_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
772{
773 WREG32(RADEON_PCIE_INDEX, ((reg) & rdev->pcie_reg_mask));
774 WREG32(RADEON_PCIE_DATA, (v));
775}
776
739void r100_pll_errata_after_index(struct radeon_device *rdev); 777void r100_pll_errata_after_index(struct radeon_device *rdev);
740 778
741 779
@@ -862,6 +900,7 @@ static inline void radeon_ring_write(struct radeon_device *rdev, uint32_t v)
862#define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev)) 900#define radeon_ring_start(rdev) (rdev)->asic->ring_start((rdev))
863#define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev)) 901#define radeon_irq_set(rdev) (rdev)->asic->irq_set((rdev))
864#define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev)) 902#define radeon_irq_process(rdev) (rdev)->asic->irq_process((rdev))
903#define radeon_get_vblank_counter(rdev, crtc) (rdev)->asic->get_vblank_counter((rdev), (crtc))
865#define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence)) 904#define radeon_fence_ring_emit(rdev, fence) (rdev)->asic->fence_ring_emit((rdev), (fence))
866#define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f)) 905#define radeon_copy_blit(rdev, s, d, np, f) (rdev)->asic->copy_blit((rdev), (s), (d), (np), (f))
867#define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f)) 906#define radeon_copy_dma(rdev, s, d, np, f) (rdev)->asic->copy_dma((rdev), (s), (d), (np), (f))
diff --git a/drivers/gpu/drm/radeon/radeon_asic.h b/drivers/gpu/drm/radeon/radeon_asic.h
index 9a75876e0c3b..7ca6c13569b5 100644
--- a/drivers/gpu/drm/radeon/radeon_asic.h
+++ b/drivers/gpu/drm/radeon/radeon_asic.h
@@ -49,6 +49,7 @@ void r100_vram_info(struct radeon_device *rdev);
49int r100_gpu_reset(struct radeon_device *rdev); 49int r100_gpu_reset(struct radeon_device *rdev);
50int r100_mc_init(struct radeon_device *rdev); 50int r100_mc_init(struct radeon_device *rdev);
51void r100_mc_fini(struct radeon_device *rdev); 51void r100_mc_fini(struct radeon_device *rdev);
52u32 r100_get_vblank_counter(struct radeon_device *rdev, int crtc);
52int r100_wb_init(struct radeon_device *rdev); 53int r100_wb_init(struct radeon_device *rdev);
53void r100_wb_fini(struct radeon_device *rdev); 54void r100_wb_fini(struct radeon_device *rdev);
54int r100_gart_enable(struct radeon_device *rdev); 55int r100_gart_enable(struct radeon_device *rdev);
@@ -96,6 +97,7 @@ static struct radeon_asic r100_asic = {
96 .ring_start = &r100_ring_start, 97 .ring_start = &r100_ring_start,
97 .irq_set = &r100_irq_set, 98 .irq_set = &r100_irq_set,
98 .irq_process = &r100_irq_process, 99 .irq_process = &r100_irq_process,
100 .get_vblank_counter = &r100_get_vblank_counter,
99 .fence_ring_emit = &r100_fence_ring_emit, 101 .fence_ring_emit = &r100_fence_ring_emit,
100 .cs_parse = &r100_cs_parse, 102 .cs_parse = &r100_cs_parse,
101 .copy_blit = &r100_copy_blit, 103 .copy_blit = &r100_copy_blit,
@@ -156,6 +158,7 @@ static struct radeon_asic r300_asic = {
156 .ring_start = &r300_ring_start, 158 .ring_start = &r300_ring_start,
157 .irq_set = &r100_irq_set, 159 .irq_set = &r100_irq_set,
158 .irq_process = &r100_irq_process, 160 .irq_process = &r100_irq_process,
161 .get_vblank_counter = &r100_get_vblank_counter,
159 .fence_ring_emit = &r300_fence_ring_emit, 162 .fence_ring_emit = &r300_fence_ring_emit,
160 .cs_parse = &r300_cs_parse, 163 .cs_parse = &r300_cs_parse,
161 .copy_blit = &r100_copy_blit, 164 .copy_blit = &r100_copy_blit,
@@ -196,6 +199,7 @@ static struct radeon_asic r420_asic = {
196 .ring_start = &r300_ring_start, 199 .ring_start = &r300_ring_start,
197 .irq_set = &r100_irq_set, 200 .irq_set = &r100_irq_set,
198 .irq_process = &r100_irq_process, 201 .irq_process = &r100_irq_process,
202 .get_vblank_counter = &r100_get_vblank_counter,
199 .fence_ring_emit = &r300_fence_ring_emit, 203 .fence_ring_emit = &r300_fence_ring_emit,
200 .cs_parse = &r300_cs_parse, 204 .cs_parse = &r300_cs_parse,
201 .copy_blit = &r100_copy_blit, 205 .copy_blit = &r100_copy_blit,
@@ -243,6 +247,7 @@ static struct radeon_asic rs400_asic = {
243 .ring_start = &r300_ring_start, 247 .ring_start = &r300_ring_start,
244 .irq_set = &r100_irq_set, 248 .irq_set = &r100_irq_set,
245 .irq_process = &r100_irq_process, 249 .irq_process = &r100_irq_process,
250 .get_vblank_counter = &r100_get_vblank_counter,
246 .fence_ring_emit = &r300_fence_ring_emit, 251 .fence_ring_emit = &r300_fence_ring_emit,
247 .cs_parse = &r300_cs_parse, 252 .cs_parse = &r300_cs_parse,
248 .copy_blit = &r100_copy_blit, 253 .copy_blit = &r100_copy_blit,
@@ -266,6 +271,8 @@ void rs600_vram_info(struct radeon_device *rdev);
266int rs600_mc_init(struct radeon_device *rdev); 271int rs600_mc_init(struct radeon_device *rdev);
267void rs600_mc_fini(struct radeon_device *rdev); 272void rs600_mc_fini(struct radeon_device *rdev);
268int rs600_irq_set(struct radeon_device *rdev); 273int rs600_irq_set(struct radeon_device *rdev);
274int rs600_irq_process(struct radeon_device *rdev);
275u32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc);
269int rs600_gart_enable(struct radeon_device *rdev); 276int rs600_gart_enable(struct radeon_device *rdev);
270void rs600_gart_disable(struct radeon_device *rdev); 277void rs600_gart_disable(struct radeon_device *rdev);
271void rs600_gart_tlb_flush(struct radeon_device *rdev); 278void rs600_gart_tlb_flush(struct radeon_device *rdev);
@@ -291,7 +298,8 @@ static struct radeon_asic rs600_asic = {
291 .cp_disable = &r100_cp_disable, 298 .cp_disable = &r100_cp_disable,
292 .ring_start = &r300_ring_start, 299 .ring_start = &r300_ring_start,
293 .irq_set = &rs600_irq_set, 300 .irq_set = &rs600_irq_set,
294 .irq_process = &r100_irq_process, 301 .irq_process = &rs600_irq_process,
302 .get_vblank_counter = &rs600_get_vblank_counter,
295 .fence_ring_emit = &r300_fence_ring_emit, 303 .fence_ring_emit = &r300_fence_ring_emit,
296 .cs_parse = &r300_cs_parse, 304 .cs_parse = &r300_cs_parse,
297 .copy_blit = &r100_copy_blit, 305 .copy_blit = &r100_copy_blit,
@@ -308,6 +316,7 @@ static struct radeon_asic rs600_asic = {
308/* 316/*
309 * rs690,rs740 317 * rs690,rs740
310 */ 318 */
319int rs690_init(struct radeon_device *rdev);
311void rs690_errata(struct radeon_device *rdev); 320void rs690_errata(struct radeon_device *rdev);
312void rs690_vram_info(struct radeon_device *rdev); 321void rs690_vram_info(struct radeon_device *rdev);
313int rs690_mc_init(struct radeon_device *rdev); 322int rs690_mc_init(struct radeon_device *rdev);
@@ -316,7 +325,7 @@ uint32_t rs690_mc_rreg(struct radeon_device *rdev, uint32_t reg);
316void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v); 325void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v);
317void rs690_bandwidth_update(struct radeon_device *rdev); 326void rs690_bandwidth_update(struct radeon_device *rdev);
318static struct radeon_asic rs690_asic = { 327static struct radeon_asic rs690_asic = {
319 .init = &r300_init, 328 .init = &rs690_init,
320 .errata = &rs690_errata, 329 .errata = &rs690_errata,
321 .vram_info = &rs690_vram_info, 330 .vram_info = &rs690_vram_info,
322 .gpu_reset = &r300_gpu_reset, 331 .gpu_reset = &r300_gpu_reset,
@@ -333,7 +342,8 @@ static struct radeon_asic rs690_asic = {
333 .cp_disable = &r100_cp_disable, 342 .cp_disable = &r100_cp_disable,
334 .ring_start = &r300_ring_start, 343 .ring_start = &r300_ring_start,
335 .irq_set = &rs600_irq_set, 344 .irq_set = &rs600_irq_set,
336 .irq_process = &r100_irq_process, 345 .irq_process = &rs600_irq_process,
346 .get_vblank_counter = &rs600_get_vblank_counter,
337 .fence_ring_emit = &r300_fence_ring_emit, 347 .fence_ring_emit = &r300_fence_ring_emit,
338 .cs_parse = &r300_cs_parse, 348 .cs_parse = &r300_cs_parse,
339 .copy_blit = &r100_copy_blit, 349 .copy_blit = &r100_copy_blit,
@@ -381,8 +391,9 @@ static struct radeon_asic rv515_asic = {
381 .cp_fini = &r100_cp_fini, 391 .cp_fini = &r100_cp_fini,
382 .cp_disable = &r100_cp_disable, 392 .cp_disable = &r100_cp_disable,
383 .ring_start = &rv515_ring_start, 393 .ring_start = &rv515_ring_start,
384 .irq_set = &r100_irq_set, 394 .irq_set = &rs600_irq_set,
385 .irq_process = &r100_irq_process, 395 .irq_process = &rs600_irq_process,
396 .get_vblank_counter = &rs600_get_vblank_counter,
386 .fence_ring_emit = &r300_fence_ring_emit, 397 .fence_ring_emit = &r300_fence_ring_emit,
387 .cs_parse = &r300_cs_parse, 398 .cs_parse = &r300_cs_parse,
388 .copy_blit = &r100_copy_blit, 399 .copy_blit = &r100_copy_blit,
@@ -423,8 +434,9 @@ static struct radeon_asic r520_asic = {
423 .cp_fini = &r100_cp_fini, 434 .cp_fini = &r100_cp_fini,
424 .cp_disable = &r100_cp_disable, 435 .cp_disable = &r100_cp_disable,
425 .ring_start = &rv515_ring_start, 436 .ring_start = &rv515_ring_start,
426 .irq_set = &r100_irq_set, 437 .irq_set = &rs600_irq_set,
427 .irq_process = &r100_irq_process, 438 .irq_process = &rs600_irq_process,
439 .get_vblank_counter = &rs600_get_vblank_counter,
428 .fence_ring_emit = &r300_fence_ring_emit, 440 .fence_ring_emit = &r300_fence_ring_emit,
429 .cs_parse = &r300_cs_parse, 441 .cs_parse = &r300_cs_parse,
430 .copy_blit = &r100_copy_blit, 442 .copy_blit = &r100_copy_blit,
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index afc4db280b94..2a027e00762a 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -685,23 +685,15 @@ static const uint32_t default_tvdac_adj[CHIP_LAST] = {
685 0x00780000, /* rs480 */ 685 0x00780000, /* rs480 */
686}; 686};
687 687
688static struct radeon_encoder_tv_dac 688static void radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev,
689 *radeon_legacy_get_tv_dac_info_from_table(struct radeon_device *rdev) 689 struct radeon_encoder_tv_dac *tv_dac)
690{ 690{
691 struct radeon_encoder_tv_dac *tv_dac = NULL;
692
693 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
694
695 if (!tv_dac)
696 return NULL;
697
698 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family]; 691 tv_dac->ps2_tvdac_adj = default_tvdac_adj[rdev->family];
699 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250)) 692 if ((rdev->flags & RADEON_IS_MOBILITY) && (rdev->family == CHIP_RV250))
700 tv_dac->ps2_tvdac_adj = 0x00880000; 693 tv_dac->ps2_tvdac_adj = 0x00880000;
701 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 694 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
702 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 695 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
703 696 return;
704 return tv_dac;
705} 697}
706 698
707struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct 699struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
@@ -713,19 +705,18 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
713 uint16_t dac_info; 705 uint16_t dac_info;
714 uint8_t rev, bg, dac; 706 uint8_t rev, bg, dac;
715 struct radeon_encoder_tv_dac *tv_dac = NULL; 707 struct radeon_encoder_tv_dac *tv_dac = NULL;
708 int found = 0;
709
710 tv_dac = kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
711 if (!tv_dac)
712 return NULL;
716 713
717 if (rdev->bios == NULL) 714 if (rdev->bios == NULL)
718 return radeon_legacy_get_tv_dac_info_from_table(rdev); 715 goto out;
719 716
720 /* first check TV table */ 717 /* first check TV table */
721 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE); 718 dac_info = combios_get_table_offset(dev, COMBIOS_TV_INFO_TABLE);
722 if (dac_info) { 719 if (dac_info) {
723 tv_dac =
724 kzalloc(sizeof(struct radeon_encoder_tv_dac), GFP_KERNEL);
725
726 if (!tv_dac)
727 return NULL;
728
729 rev = RBIOS8(dac_info + 0x3); 720 rev = RBIOS8(dac_info + 0x3);
730 if (rev > 4) { 721 if (rev > 4) {
731 bg = RBIOS8(dac_info + 0xc) & 0xf; 722 bg = RBIOS8(dac_info + 0xc) & 0xf;
@@ -739,6 +730,7 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
739 bg = RBIOS8(dac_info + 0x10) & 0xf; 730 bg = RBIOS8(dac_info + 0x10) & 0xf;
740 dac = RBIOS8(dac_info + 0x11) & 0xf; 731 dac = RBIOS8(dac_info + 0x11) & 0xf;
741 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 732 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
733 found = 1;
742 } else if (rev > 1) { 734 } else if (rev > 1) {
743 bg = RBIOS8(dac_info + 0xc) & 0xf; 735 bg = RBIOS8(dac_info + 0xc) & 0xf;
744 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf; 736 dac = (RBIOS8(dac_info + 0xc) >> 4) & 0xf;
@@ -751,22 +743,15 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
751 bg = RBIOS8(dac_info + 0xe) & 0xf; 743 bg = RBIOS8(dac_info + 0xe) & 0xf;
752 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf; 744 dac = (RBIOS8(dac_info + 0xe) >> 4) & 0xf;
753 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20); 745 tv_dac->ntsc_tvdac_adj = (bg << 16) | (dac << 20);
746 found = 1;
754 } 747 }
755
756 tv_dac->tv_std = radeon_combios_get_tv_info(encoder); 748 tv_dac->tv_std = radeon_combios_get_tv_info(encoder);
757 749 }
758 } else { 750 if (!found) {
759 /* then check CRT table */ 751 /* then check CRT table */
760 dac_info = 752 dac_info =
761 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE); 753 combios_get_table_offset(dev, COMBIOS_CRT_INFO_TABLE);
762 if (dac_info) { 754 if (dac_info) {
763 tv_dac =
764 kzalloc(sizeof(struct radeon_encoder_tv_dac),
765 GFP_KERNEL);
766
767 if (!tv_dac)
768 return NULL;
769
770 rev = RBIOS8(dac_info) & 0x3; 755 rev = RBIOS8(dac_info) & 0x3;
771 if (rev < 2) { 756 if (rev < 2) {
772 bg = RBIOS8(dac_info + 0x3) & 0xf; 757 bg = RBIOS8(dac_info + 0x3) & 0xf;
@@ -775,6 +760,7 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
775 (bg << 16) | (dac << 20); 760 (bg << 16) | (dac << 20);
776 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 761 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
777 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 762 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
763 found = 1;
778 } else { 764 } else {
779 bg = RBIOS8(dac_info + 0x4) & 0xf; 765 bg = RBIOS8(dac_info + 0x4) & 0xf;
780 dac = RBIOS8(dac_info + 0x5) & 0xf; 766 dac = RBIOS8(dac_info + 0x5) & 0xf;
@@ -782,13 +768,17 @@ struct radeon_encoder_tv_dac *radeon_combios_get_tv_dac_info(struct
782 (bg << 16) | (dac << 20); 768 (bg << 16) | (dac << 20);
783 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj; 769 tv_dac->pal_tvdac_adj = tv_dac->ps2_tvdac_adj;
784 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj; 770 tv_dac->ntsc_tvdac_adj = tv_dac->ps2_tvdac_adj;
771 found = 1;
785 } 772 }
786 } else { 773 } else {
787 DRM_INFO("No TV DAC info found in BIOS\n"); 774 DRM_INFO("No TV DAC info found in BIOS\n");
788 return radeon_legacy_get_tv_dac_info_from_table(rdev);
789 } 775 }
790 } 776 }
791 777
778out:
779 if (!found) /* fallback to defaults */
780 radeon_legacy_get_tv_dac_info_from_table(rdev, tv_dac);
781
792 return tv_dac; 782 return tv_dac;
793} 783}
794 784
diff --git a/drivers/gpu/drm/radeon/radeon_cp.c b/drivers/gpu/drm/radeon/radeon_cp.c
index d8356827ef17..7a52c461145c 100644
--- a/drivers/gpu/drm/radeon/radeon_cp.c
+++ b/drivers/gpu/drm/radeon/radeon_cp.c
@@ -406,6 +406,15 @@ static void radeon_init_pipes(drm_radeon_private_t *dev_priv)
406{ 406{
407 uint32_t gb_tile_config, gb_pipe_sel = 0; 407 uint32_t gb_tile_config, gb_pipe_sel = 0;
408 408
409 if ((dev_priv->flags & RADEON_FAMILY_MASK) == CHIP_RV530) {
410 uint32_t z_pipe_sel = RADEON_READ(RV530_GB_PIPE_SELECT2);
411 if ((z_pipe_sel & 3) == 3)
412 dev_priv->num_z_pipes = 2;
413 else
414 dev_priv->num_z_pipes = 1;
415 } else
416 dev_priv->num_z_pipes = 1;
417
409 /* RS4xx/RS6xx/R4xx/R5xx */ 418 /* RS4xx/RS6xx/R4xx/R5xx */
410 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) { 419 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R420) {
411 gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT); 420 gb_pipe_sel = RADEON_READ(R400_GB_PIPE_SELECT);
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index a162ade74b7f..7693f7c67bd3 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -152,7 +152,9 @@ int radeon_mc_setup(struct radeon_device *rdev)
152 } 152 }
153 } else { 153 } else {
154 rdev->mc.vram_location = 0; 154 rdev->mc.vram_location = 0;
155 rdev->mc.gtt_location = rdev->mc.mc_vram_size; 155 tmp = rdev->mc.mc_vram_size;
156 tmp = (tmp + rdev->mc.gtt_size - 1) & ~(rdev->mc.gtt_size - 1);
157 rdev->mc.gtt_location = tmp;
156 } 158 }
157 DRM_INFO("radeon: VRAM %uM\n", rdev->mc.real_vram_size >> 20); 159 DRM_INFO("radeon: VRAM %uM\n", rdev->mc.real_vram_size >> 20);
158 DRM_INFO("radeon: VRAM from 0x%08X to 0x%08X\n", 160 DRM_INFO("radeon: VRAM from 0x%08X to 0x%08X\n",
@@ -223,25 +225,18 @@ void radeon_invalid_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
223 225
224void radeon_register_accessor_init(struct radeon_device *rdev) 226void radeon_register_accessor_init(struct radeon_device *rdev)
225{ 227{
226 rdev->mm_rreg = &r100_mm_rreg;
227 rdev->mm_wreg = &r100_mm_wreg;
228 rdev->mc_rreg = &radeon_invalid_rreg; 228 rdev->mc_rreg = &radeon_invalid_rreg;
229 rdev->mc_wreg = &radeon_invalid_wreg; 229 rdev->mc_wreg = &radeon_invalid_wreg;
230 rdev->pll_rreg = &radeon_invalid_rreg; 230 rdev->pll_rreg = &radeon_invalid_rreg;
231 rdev->pll_wreg = &radeon_invalid_wreg; 231 rdev->pll_wreg = &radeon_invalid_wreg;
232 rdev->pcie_rreg = &radeon_invalid_rreg;
233 rdev->pcie_wreg = &radeon_invalid_wreg;
234 rdev->pciep_rreg = &radeon_invalid_rreg; 232 rdev->pciep_rreg = &radeon_invalid_rreg;
235 rdev->pciep_wreg = &radeon_invalid_wreg; 233 rdev->pciep_wreg = &radeon_invalid_wreg;
236 234
237 /* Don't change order as we are overridding accessor. */ 235 /* Don't change order as we are overridding accessor. */
238 if (rdev->family < CHIP_RV515) { 236 if (rdev->family < CHIP_RV515) {
239 rdev->pcie_rreg = &rv370_pcie_rreg; 237 rdev->pcie_reg_mask = 0xff;
240 rdev->pcie_wreg = &rv370_pcie_wreg; 238 } else {
241 } 239 rdev->pcie_reg_mask = 0x7ff;
242 if (rdev->family >= CHIP_RV515) {
243 rdev->pcie_rreg = &rv515_pcie_rreg;
244 rdev->pcie_wreg = &rv515_pcie_wreg;
245 } 240 }
246 /* FIXME: not sure here */ 241 /* FIXME: not sure here */
247 if (rdev->family <= CHIP_R580) { 242 if (rdev->family <= CHIP_R580) {
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c
index 3cfcee17dc56..0bd5879a4957 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.c
+++ b/drivers/gpu/drm/radeon/radeon_drv.c
@@ -318,6 +318,14 @@ static int __init radeon_init(void)
318 driver = &driver_old; 318 driver = &driver_old;
319 driver->num_ioctls = radeon_max_ioctl; 319 driver->num_ioctls = radeon_max_ioctl;
320#if defined(CONFIG_DRM_RADEON_KMS) 320#if defined(CONFIG_DRM_RADEON_KMS)
321#ifdef CONFIG_VGA_CONSOLE
322 if (vgacon_text_force() && radeon_modeset == -1) {
323 DRM_INFO("VGACON disable radeon kernel modesetting.\n");
324 driver = &driver_old;
325 driver->driver_features &= ~DRIVER_MODESET;
326 radeon_modeset = 0;
327 }
328#endif
321 /* if enabled by default */ 329 /* if enabled by default */
322 if (radeon_modeset == -1) { 330 if (radeon_modeset == -1) {
323 DRM_INFO("radeon default to kernel modesetting.\n"); 331 DRM_INFO("radeon default to kernel modesetting.\n");
@@ -329,17 +337,8 @@ static int __init radeon_init(void)
329 driver->driver_features |= DRIVER_MODESET; 337 driver->driver_features |= DRIVER_MODESET;
330 driver->num_ioctls = radeon_max_kms_ioctl; 338 driver->num_ioctls = radeon_max_kms_ioctl;
331 } 339 }
332
333 /* if the vga console setting is enabled still 340 /* if the vga console setting is enabled still
334 * let modprobe override it */ 341 * let modprobe override it */
335#ifdef CONFIG_VGA_CONSOLE
336 if (vgacon_text_force() && radeon_modeset == -1) {
337 DRM_INFO("VGACON disable radeon kernel modesetting.\n");
338 driver = &driver_old;
339 driver->driver_features &= ~DRIVER_MODESET;
340 radeon_modeset = 0;
341 }
342#endif
343#endif 342#endif
344 return drm_init(driver); 343 return drm_init(driver);
345} 344}
diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
index 127d0456f628..6fa32dac4e97 100644
--- a/drivers/gpu/drm/radeon/radeon_drv.h
+++ b/drivers/gpu/drm/radeon/radeon_drv.h
@@ -100,9 +100,10 @@
100 * 1.28- Add support for VBL on CRTC2 100 * 1.28- Add support for VBL on CRTC2
101 * 1.29- R500 3D cmd buffer support 101 * 1.29- R500 3D cmd buffer support
102 * 1.30- Add support for occlusion queries 102 * 1.30- Add support for occlusion queries
103 * 1.31- Add support for num Z pipes from GET_PARAM
103 */ 104 */
104#define DRIVER_MAJOR 1 105#define DRIVER_MAJOR 1
105#define DRIVER_MINOR 30 106#define DRIVER_MINOR 31
106#define DRIVER_PATCHLEVEL 0 107#define DRIVER_PATCHLEVEL 0
107 108
108/* 109/*
@@ -143,6 +144,7 @@ enum radeon_family {
143 CHIP_RV635, 144 CHIP_RV635,
144 CHIP_RV670, 145 CHIP_RV670,
145 CHIP_RS780, 146 CHIP_RS780,
147 CHIP_RS880,
146 CHIP_RV770, 148 CHIP_RV770,
147 CHIP_RV730, 149 CHIP_RV730,
148 CHIP_RV710, 150 CHIP_RV710,
@@ -328,6 +330,7 @@ typedef struct drm_radeon_private {
328 resource_size_t fb_aper_offset; 330 resource_size_t fb_aper_offset;
329 331
330 int num_gb_pipes; 332 int num_gb_pipes;
333 int num_z_pipes;
331 int track_flush; 334 int track_flush;
332 drm_local_map_t *mmio; 335 drm_local_map_t *mmio;
333 336
@@ -688,6 +691,7 @@ extern void r600_page_table_cleanup(struct drm_device *dev, struct drm_ati_pciga
688 691
689/* pipe config regs */ 692/* pipe config regs */
690#define R400_GB_PIPE_SELECT 0x402c 693#define R400_GB_PIPE_SELECT 0x402c
694#define RV530_GB_PIPE_SELECT2 0x4124
691#define R500_DYN_SCLK_PWMEM_PIPE 0x000d /* PLL */ 695#define R500_DYN_SCLK_PWMEM_PIPE 0x000d /* PLL */
692#define R300_GB_TILE_CONFIG 0x4018 696#define R300_GB_TILE_CONFIG 0x4018
693# define R300_ENABLE_TILING (1 << 0) 697# define R300_ENABLE_TILING (1 << 0)
diff --git a/drivers/gpu/drm/radeon/radeon_fb.c b/drivers/gpu/drm/radeon/radeon_fb.c
index 3206c0ad7b6c..ec383edf5f38 100644
--- a/drivers/gpu/drm/radeon/radeon_fb.c
+++ b/drivers/gpu/drm/radeon/radeon_fb.c
@@ -574,6 +574,8 @@ int radeonfb_create(struct radeon_device *rdev,
574 goto out_unref; 574 goto out_unref;
575 } 575 }
576 576
577 memset_io(fbptr, 0, aligned_size);
578
577 strcpy(info->fix.id, "radeondrmfb"); 579 strcpy(info->fix.id, "radeondrmfb");
578 info->fix.type = FB_TYPE_PACKED_PIXELS; 580 info->fix.type = FB_TYPE_PACKED_PIXELS;
579 info->fix.visual = FB_VISUAL_TRUECOLOR; 581 info->fix.visual = FB_VISUAL_TRUECOLOR;
diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c
index cded5180c752..d880edf254db 100644
--- a/drivers/gpu/drm/radeon/radeon_gem.c
+++ b/drivers/gpu/drm/radeon/radeon_gem.c
@@ -262,8 +262,34 @@ int radeon_gem_mmap_ioctl(struct drm_device *dev, void *data,
262int radeon_gem_busy_ioctl(struct drm_device *dev, void *data, 262int radeon_gem_busy_ioctl(struct drm_device *dev, void *data,
263 struct drm_file *filp) 263 struct drm_file *filp)
264{ 264{
265 /* FIXME: implement */ 265 struct drm_radeon_gem_busy *args = data;
266 return 0; 266 struct drm_gem_object *gobj;
267 struct radeon_object *robj;
268 int r;
269 uint32_t cur_placement;
270
271 gobj = drm_gem_object_lookup(dev, filp, args->handle);
272 if (gobj == NULL) {
273 return -EINVAL;
274 }
275 robj = gobj->driver_private;
276 r = radeon_object_busy_domain(robj, &cur_placement);
277 switch (cur_placement) {
278 case TTM_PL_VRAM:
279 args->domain = RADEON_GEM_DOMAIN_VRAM;
280 break;
281 case TTM_PL_TT:
282 args->domain = RADEON_GEM_DOMAIN_GTT;
283 break;
284 case TTM_PL_SYSTEM:
285 args->domain = RADEON_GEM_DOMAIN_CPU;
286 default:
287 break;
288 }
289 mutex_lock(&dev->struct_mutex);
290 drm_gem_object_unreference(gobj);
291 mutex_unlock(&dev->struct_mutex);
292 return r;
267} 293}
268 294
269int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data, 295int radeon_gem_wait_idle_ioctl(struct drm_device *dev, void *data,
diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index 491d569deb0e..9805e4b6ca1b 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -32,60 +32,6 @@
32#include "radeon.h" 32#include "radeon.h"
33#include "atom.h" 33#include "atom.h"
34 34
35static inline uint32_t r100_irq_ack(struct radeon_device *rdev)
36{
37 uint32_t irqs = RREG32(RADEON_GEN_INT_STATUS);
38 uint32_t irq_mask = RADEON_SW_INT_TEST;
39
40 if (irqs) {
41 WREG32(RADEON_GEN_INT_STATUS, irqs);
42 }
43 return irqs & irq_mask;
44}
45
46int r100_irq_set(struct radeon_device *rdev)
47{
48 uint32_t tmp = 0;
49
50 if (rdev->irq.sw_int) {
51 tmp |= RADEON_SW_INT_ENABLE;
52 }
53 /* Todo go through CRTC and enable vblank int or not */
54 WREG32(RADEON_GEN_INT_CNTL, tmp);
55 return 0;
56}
57
58int r100_irq_process(struct radeon_device *rdev)
59{
60 uint32_t status;
61
62 status = r100_irq_ack(rdev);
63 if (!status) {
64 return IRQ_NONE;
65 }
66 while (status) {
67 /* SW interrupt */
68 if (status & RADEON_SW_INT_TEST) {
69 radeon_fence_process(rdev);
70 }
71 status = r100_irq_ack(rdev);
72 }
73 return IRQ_HANDLED;
74}
75
76int rs600_irq_set(struct radeon_device *rdev)
77{
78 uint32_t tmp = 0;
79
80 if (rdev->irq.sw_int) {
81 tmp |= RADEON_SW_INT_ENABLE;
82 }
83 WREG32(RADEON_GEN_INT_CNTL, tmp);
84 /* Todo go through CRTC and enable vblank int or not */
85 WREG32(R500_DxMODE_INT_MASK, 0);
86 return 0;
87}
88
89irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS) 35irqreturn_t radeon_driver_irq_handler_kms(DRM_IRQ_ARGS)
90{ 36{
91 struct drm_device *dev = (struct drm_device *) arg; 37 struct drm_device *dev = (struct drm_device *) arg;
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c
index 937a2f1cdb46..dce09ada32bc 100644
--- a/drivers/gpu/drm/radeon/radeon_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_kms.c
@@ -58,6 +58,8 @@ int radeon_driver_load_kms(struct drm_device *dev, unsigned long flags)
58 if (r) { 58 if (r) {
59 DRM_ERROR("Failed to initialize radeon, disabling IOCTL\n"); 59 DRM_ERROR("Failed to initialize radeon, disabling IOCTL\n");
60 radeon_device_fini(rdev); 60 radeon_device_fini(rdev);
61 kfree(rdev);
62 dev->dev_private = NULL;
61 return r; 63 return r;
62 } 64 }
63 return 0; 65 return 0;
@@ -93,6 +95,9 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
93 case RADEON_INFO_NUM_GB_PIPES: 95 case RADEON_INFO_NUM_GB_PIPES:
94 value = rdev->num_gb_pipes; 96 value = rdev->num_gb_pipes;
95 break; 97 break;
98 case RADEON_INFO_NUM_Z_PIPES:
99 value = rdev->num_z_pipes;
100 break;
96 default: 101 default:
97 DRM_DEBUG("Invalid request %d\n", info->request); 102 DRM_DEBUG("Invalid request %d\n", info->request);
98 return -EINVAL; 103 return -EINVAL;
@@ -139,19 +144,42 @@ void radeon_driver_preclose_kms(struct drm_device *dev,
139 */ 144 */
140u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc) 145u32 radeon_get_vblank_counter_kms(struct drm_device *dev, int crtc)
141{ 146{
142 /* FIXME: implement */ 147 struct radeon_device *rdev = dev->dev_private;
143 return 0; 148
149 if (crtc < 0 || crtc > 1) {
150 DRM_ERROR("Invalid crtc %d\n", crtc);
151 return -EINVAL;
152 }
153
154 return radeon_get_vblank_counter(rdev, crtc);
144} 155}
145 156
146int radeon_enable_vblank_kms(struct drm_device *dev, int crtc) 157int radeon_enable_vblank_kms(struct drm_device *dev, int crtc)
147{ 158{
148 /* FIXME: implement */ 159 struct radeon_device *rdev = dev->dev_private;
149 return 0; 160
161 if (crtc < 0 || crtc > 1) {
162 DRM_ERROR("Invalid crtc %d\n", crtc);
163 return -EINVAL;
164 }
165
166 rdev->irq.crtc_vblank_int[crtc] = true;
167
168 return radeon_irq_set(rdev);
150} 169}
151 170
152void radeon_disable_vblank_kms(struct drm_device *dev, int crtc) 171void radeon_disable_vblank_kms(struct drm_device *dev, int crtc)
153{ 172{
154 /* FIXME: implement */ 173 struct radeon_device *rdev = dev->dev_private;
174
175 if (crtc < 0 || crtc > 1) {
176 DRM_ERROR("Invalid crtc %d\n", crtc);
177 return;
178 }
179
180 rdev->irq.crtc_vblank_int[crtc] = false;
181
182 radeon_irq_set(rdev);
155} 183}
156 184
157 185
@@ -293,5 +321,6 @@ struct drm_ioctl_desc radeon_ioctls_kms[] = {
293 DRM_IOCTL_DEF(DRM_RADEON_INFO, radeon_info_ioctl, DRM_AUTH), 321 DRM_IOCTL_DEF(DRM_RADEON_INFO, radeon_info_ioctl, DRM_AUTH),
294 DRM_IOCTL_DEF(DRM_RADEON_GEM_SET_TILING, radeon_gem_set_tiling_ioctl, DRM_AUTH), 322 DRM_IOCTL_DEF(DRM_RADEON_GEM_SET_TILING, radeon_gem_set_tiling_ioctl, DRM_AUTH),
295 DRM_IOCTL_DEF(DRM_RADEON_GEM_GET_TILING, radeon_gem_get_tiling_ioctl, DRM_AUTH), 323 DRM_IOCTL_DEF(DRM_RADEON_GEM_GET_TILING, radeon_gem_get_tiling_ioctl, DRM_AUTH),
324 DRM_IOCTL_DEF(DRM_RADEON_GEM_BUSY, radeon_gem_busy_ioctl, DRM_AUTH),
296}; 325};
297int radeon_max_kms_ioctl = DRM_ARRAY_SIZE(radeon_ioctls_kms); 326int radeon_max_kms_ioctl = DRM_ARRAY_SIZE(radeon_ioctls_kms);
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index 7d06dc98a42a..0da72f18fd3a 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -310,10 +310,13 @@ void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
310 RADEON_CRTC_DISP_REQ_EN_B)); 310 RADEON_CRTC_DISP_REQ_EN_B));
311 WREG32_P(RADEON_CRTC_EXT_CNTL, 0, ~mask); 311 WREG32_P(RADEON_CRTC_EXT_CNTL, 0, ~mask);
312 } 312 }
313 drm_vblank_post_modeset(dev, radeon_crtc->crtc_id);
314 radeon_crtc_load_lut(crtc);
313 break; 315 break;
314 case DRM_MODE_DPMS_STANDBY: 316 case DRM_MODE_DPMS_STANDBY:
315 case DRM_MODE_DPMS_SUSPEND: 317 case DRM_MODE_DPMS_SUSPEND:
316 case DRM_MODE_DPMS_OFF: 318 case DRM_MODE_DPMS_OFF:
319 drm_vblank_pre_modeset(dev, radeon_crtc->crtc_id);
317 if (radeon_crtc->crtc_id) 320 if (radeon_crtc->crtc_id)
318 WREG32_P(RADEON_CRTC2_GEN_CNTL, mask, ~mask); 321 WREG32_P(RADEON_CRTC2_GEN_CNTL, mask, ~mask);
319 else { 322 else {
@@ -323,10 +326,6 @@ void radeon_crtc_dpms(struct drm_crtc *crtc, int mode)
323 } 326 }
324 break; 327 break;
325 } 328 }
326
327 if (mode != DRM_MODE_DPMS_OFF) {
328 radeon_crtc_load_lut(crtc);
329 }
330} 329}
331 330
332/* properly set crtc bpp when using atombios */ 331/* properly set crtc bpp when using atombios */
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
index 34d0f58eb944..9322675ef6d0 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_encoders.c
@@ -1066,6 +1066,7 @@ radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_id, uint32_t
1066 1066
1067 switch (radeon_encoder->encoder_id) { 1067 switch (radeon_encoder->encoder_id) {
1068 case ENCODER_OBJECT_ID_INTERNAL_LVDS: 1068 case ENCODER_OBJECT_ID_INTERNAL_LVDS:
1069 encoder->possible_crtcs = 0x1;
1069 drm_encoder_init(dev, encoder, &radeon_legacy_lvds_enc_funcs, DRM_MODE_ENCODER_LVDS); 1070 drm_encoder_init(dev, encoder, &radeon_legacy_lvds_enc_funcs, DRM_MODE_ENCODER_LVDS);
1070 drm_encoder_helper_add(encoder, &radeon_legacy_lvds_helper_funcs); 1071 drm_encoder_helper_add(encoder, &radeon_legacy_lvds_helper_funcs);
1071 if (rdev->is_atom_bios) 1072 if (rdev->is_atom_bios)
diff --git a/drivers/gpu/drm/radeon/radeon_object.c b/drivers/gpu/drm/radeon/radeon_object.c
index dd9ac2fed6d6..b85fb83d7ae8 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -106,7 +106,7 @@ static inline uint32_t radeon_object_flags_from_domain(uint32_t domain)
106 flags |= TTM_PL_FLAG_VRAM | TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED; 106 flags |= TTM_PL_FLAG_VRAM | TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED;
107 } 107 }
108 if (domain & RADEON_GEM_DOMAIN_GTT) { 108 if (domain & RADEON_GEM_DOMAIN_GTT) {
109 flags |= TTM_PL_FLAG_TT | TTM_PL_FLAG_WC | TTM_PL_FLAG_UNCACHED; 109 flags |= TTM_PL_FLAG_TT | TTM_PL_MASK_CACHING;
110 } 110 }
111 if (domain & RADEON_GEM_DOMAIN_CPU) { 111 if (domain & RADEON_GEM_DOMAIN_CPU) {
112 flags |= TTM_PL_FLAG_SYSTEM | TTM_PL_MASK_CACHING; 112 flags |= TTM_PL_FLAG_SYSTEM | TTM_PL_MASK_CACHING;
@@ -316,6 +316,25 @@ int radeon_object_wait(struct radeon_object *robj)
316 return r; 316 return r;
317} 317}
318 318
319int radeon_object_busy_domain(struct radeon_object *robj, uint32_t *cur_placement)
320{
321 int r = 0;
322
323 r = radeon_object_reserve(robj, true);
324 if (unlikely(r != 0)) {
325 DRM_ERROR("radeon: failed to reserve object for waiting.\n");
326 return r;
327 }
328 spin_lock(&robj->tobj.lock);
329 *cur_placement = robj->tobj.mem.mem_type;
330 if (robj->tobj.sync_obj) {
331 r = ttm_bo_wait(&robj->tobj, true, true, true);
332 }
333 spin_unlock(&robj->tobj.lock);
334 radeon_object_unreserve(robj);
335 return r;
336}
337
319int radeon_object_evict_vram(struct radeon_device *rdev) 338int radeon_object_evict_vram(struct radeon_device *rdev)
320{ 339{
321 if (rdev->flags & RADEON_IS_IGP) { 340 if (rdev->flags & RADEON_IS_IGP) {
diff --git a/drivers/gpu/drm/radeon/radeon_reg.h b/drivers/gpu/drm/radeon/radeon_reg.h
index e1b618574461..4df43f62c678 100644
--- a/drivers/gpu/drm/radeon/radeon_reg.h
+++ b/drivers/gpu/drm/radeon/radeon_reg.h
@@ -982,12 +982,15 @@
982# define RS400_TMDS2_PLLRST (1 << 1) 982# define RS400_TMDS2_PLLRST (1 << 1)
983 983
984#define RADEON_GEN_INT_CNTL 0x0040 984#define RADEON_GEN_INT_CNTL 0x0040
985# define RADEON_CRTC_VBLANK_MASK (1 << 0)
986# define RADEON_CRTC2_VBLANK_MASK (1 << 9)
985# define RADEON_SW_INT_ENABLE (1 << 25) 987# define RADEON_SW_INT_ENABLE (1 << 25)
986#define RADEON_GEN_INT_STATUS 0x0044 988#define RADEON_GEN_INT_STATUS 0x0044
987# define RADEON_VSYNC_INT_AK (1 << 2) 989# define AVIVO_DISPLAY_INT_STATUS (1 << 0)
988# define RADEON_VSYNC_INT (1 << 2) 990# define RADEON_CRTC_VBLANK_STAT (1 << 0)
989# define RADEON_VSYNC2_INT_AK (1 << 6) 991# define RADEON_CRTC_VBLANK_STAT_ACK (1 << 0)
990# define RADEON_VSYNC2_INT (1 << 6) 992# define RADEON_CRTC2_VBLANK_STAT (1 << 9)
993# define RADEON_CRTC2_VBLANK_STAT_ACK (1 << 9)
991# define RADEON_SW_INT_FIRE (1 << 26) 994# define RADEON_SW_INT_FIRE (1 << 26)
992# define RADEON_SW_INT_TEST (1 << 25) 995# define RADEON_SW_INT_TEST (1 << 25)
993# define RADEON_SW_INT_TEST_ACK (1 << 25) 996# define RADEON_SW_INT_TEST_ACK (1 << 25)
@@ -2334,6 +2337,9 @@
2334# define RADEON_RE_WIDTH_SHIFT 0 2337# define RADEON_RE_WIDTH_SHIFT 0
2335# define RADEON_RE_HEIGHT_SHIFT 16 2338# define RADEON_RE_HEIGHT_SHIFT 16
2336 2339
2340#define RADEON_RB3D_ZPASS_DATA 0x3290
2341#define RADEON_RB3D_ZPASS_ADDR 0x3294
2342
2337#define RADEON_SE_CNTL 0x1c4c 2343#define RADEON_SE_CNTL 0x1c4c
2338# define RADEON_FFACE_CULL_CW (0 << 0) 2344# define RADEON_FFACE_CULL_CW (0 << 0)
2339# define RADEON_FFACE_CULL_CCW (1 << 0) 2345# define RADEON_FFACE_CULL_CCW (1 << 0)
@@ -3568,4 +3574,6 @@
3568#define RADEON_SCRATCH_REG4 0x15f0 3574#define RADEON_SCRATCH_REG4 0x15f0
3569#define RADEON_SCRATCH_REG5 0x15f4 3575#define RADEON_SCRATCH_REG5 0x15f4
3570 3576
3577#define RV530_GB_PIPE_SELECT2 0x4124
3578
3571#endif 3579#endif
diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
index 46645f3e0328..2882f40d5ec5 100644
--- a/drivers/gpu/drm/radeon/radeon_state.c
+++ b/drivers/gpu/drm/radeon/radeon_state.c
@@ -3081,6 +3081,9 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
3081 case RADEON_PARAM_NUM_GB_PIPES: 3081 case RADEON_PARAM_NUM_GB_PIPES:
3082 value = dev_priv->num_gb_pipes; 3082 value = dev_priv->num_gb_pipes;
3083 break; 3083 break;
3084 case RADEON_PARAM_NUM_Z_PIPES:
3085 value = dev_priv->num_z_pipes;
3086 break;
3084 default: 3087 default:
3085 DRM_DEBUG("Invalid parameter %d\n", param->param); 3088 DRM_DEBUG("Invalid parameter %d\n", param->param);
3086 return -EINVAL; 3089 return -EINVAL;
diff --git a/drivers/gpu/drm/radeon/rs600.c b/drivers/gpu/drm/radeon/rs600.c
index bbea6dee4a94..7e8ce983a908 100644
--- a/drivers/gpu/drm/radeon/rs600.c
+++ b/drivers/gpu/drm/radeon/rs600.c
@@ -240,6 +240,88 @@ void rs600_mc_fini(struct radeon_device *rdev)
240 240
241 241
242/* 242/*
243 * Interrupts
244 */
245int rs600_irq_set(struct radeon_device *rdev)
246{
247 uint32_t tmp = 0;
248 uint32_t mode_int = 0;
249
250 if (rdev->irq.sw_int) {
251 tmp |= RADEON_SW_INT_ENABLE;
252 }
253 if (rdev->irq.crtc_vblank_int[0]) {
254 tmp |= AVIVO_DISPLAY_INT_STATUS;
255 mode_int |= AVIVO_D1MODE_INT_MASK;
256 }
257 if (rdev->irq.crtc_vblank_int[1]) {
258 tmp |= AVIVO_DISPLAY_INT_STATUS;
259 mode_int |= AVIVO_D2MODE_INT_MASK;
260 }
261 WREG32(RADEON_GEN_INT_CNTL, tmp);
262 WREG32(AVIVO_DxMODE_INT_MASK, mode_int);
263 return 0;
264}
265
266static inline uint32_t rs600_irq_ack(struct radeon_device *rdev, u32 *r500_disp_int)
267{
268 uint32_t irqs = RREG32(RADEON_GEN_INT_STATUS);
269 uint32_t irq_mask = RADEON_SW_INT_TEST;
270
271 if (irqs & AVIVO_DISPLAY_INT_STATUS) {
272 *r500_disp_int = RREG32(AVIVO_DISP_INTERRUPT_STATUS);
273 if (*r500_disp_int & AVIVO_D1_VBLANK_INTERRUPT) {
274 WREG32(AVIVO_D1MODE_VBLANK_STATUS, AVIVO_VBLANK_ACK);
275 }
276 if (*r500_disp_int & AVIVO_D2_VBLANK_INTERRUPT) {
277 WREG32(AVIVO_D2MODE_VBLANK_STATUS, AVIVO_VBLANK_ACK);
278 }
279 } else {
280 *r500_disp_int = 0;
281 }
282
283 if (irqs) {
284 WREG32(RADEON_GEN_INT_STATUS, irqs);
285 }
286 return irqs & irq_mask;
287}
288
289int rs600_irq_process(struct radeon_device *rdev)
290{
291 uint32_t status;
292 uint32_t r500_disp_int;
293
294 status = rs600_irq_ack(rdev, &r500_disp_int);
295 if (!status && !r500_disp_int) {
296 return IRQ_NONE;
297 }
298 while (status || r500_disp_int) {
299 /* SW interrupt */
300 if (status & RADEON_SW_INT_TEST) {
301 radeon_fence_process(rdev);
302 }
303 /* Vertical blank interrupts */
304 if (r500_disp_int & AVIVO_D1_VBLANK_INTERRUPT) {
305 drm_handle_vblank(rdev->ddev, 0);
306 }
307 if (r500_disp_int & AVIVO_D2_VBLANK_INTERRUPT) {
308 drm_handle_vblank(rdev->ddev, 1);
309 }
310 status = rs600_irq_ack(rdev, &r500_disp_int);
311 }
312 return IRQ_HANDLED;
313}
314
315u32 rs600_get_vblank_counter(struct radeon_device *rdev, int crtc)
316{
317 if (crtc == 0)
318 return RREG32(AVIVO_D1CRTC_FRAME_COUNT);
319 else
320 return RREG32(AVIVO_D2CRTC_FRAME_COUNT);
321}
322
323
324/*
243 * Global GPU functions 325 * Global GPU functions
244 */ 326 */
245void rs600_disable_vga(struct radeon_device *rdev) 327void rs600_disable_vga(struct radeon_device *rdev)
diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
index 839595b00728..bc6b7c5339bc 100644
--- a/drivers/gpu/drm/radeon/rs690.c
+++ b/drivers/gpu/drm/radeon/rs690.c
@@ -652,3 +652,68 @@ void rs690_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
652 WREG32(RS690_MC_DATA, v); 652 WREG32(RS690_MC_DATA, v);
653 WREG32(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK); 653 WREG32(RS690_MC_INDEX, RS690_MC_INDEX_WR_ACK);
654} 654}
655
656static const unsigned rs690_reg_safe_bm[219] = {
657 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
658 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
659 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
660 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
661 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
662 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
663 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
664 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
665 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
666 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
667 0x17FF1FFF,0xFFFFFFFC,0xFFFFFFFF,0xFF30FFBF,
668 0xFFFFFFF8,0xC3E6FFFF,0xFFFFF6DF,0xFFFFFFFF,
669 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
670 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
671 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFF03F,
672 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
673 0xFFFFFFFF,0xFFFFEFCE,0xF00EBFFF,0x007C0000,
674 0xF0000078,0xFF000009,0xFFFFFFFF,0xFFFFFFFF,
675 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
676 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
677 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
678 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
679 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
680 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
681 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
682 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
683 0xFFFFF7FF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
684 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
685 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
686 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
687 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
688 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
689 0xFFFFFC78,0xFFFFFFFF,0xFFFFFFFE,0xFFFFFFFF,
690 0x38FF8F50,0xFFF88082,0xF000000C,0xFAE009FF,
691 0x0000FFFF,0xFFFFFFFF,0xFFFFFFFF,0x00000000,
692 0x00000000,0x0000C100,0x00000000,0x00000000,
693 0x00000000,0x00000000,0x00000000,0x00000000,
694 0x00000000,0xFFFF0000,0xFFFFFFFF,0xFF80FFFF,
695 0x00000000,0x00000000,0x00000000,0x00000000,
696 0x0003FC01,0xFFFFFFF8,0xFE800B19,0xFFFFFFFF,
697 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
698 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
699 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
700 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
701 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
702 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
703 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
704 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
705 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
706 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
707 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
708 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
709 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
710 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
711 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,
712};
713
714int rs690_init(struct radeon_device *rdev)
715{
716 rdev->config.r300.reg_safe_bm = rs690_reg_safe_bm;
717 rdev->config.r300.reg_safe_bm_size = ARRAY_SIZE(rs690_reg_safe_bm);
718 return 0;
719}
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c
index 551e608702e4..31a7f668ae5a 100644
--- a/drivers/gpu/drm/radeon/rv515.c
+++ b/drivers/gpu/drm/radeon/rv515.c
@@ -370,6 +370,7 @@ void rv515_vram_info(struct radeon_device *rdev)
370 370
371 rv515_vram_get_type(rdev); 371 rv515_vram_get_type(rdev);
372 372
373 r100_vram_init_sizes(rdev);
373 /* FIXME: we should enforce default clock in case GPU is not in 374 /* FIXME: we should enforce default clock in case GPU is not in
374 * default setup 375 * default setup
375 */ 376 */
@@ -399,25 +400,6 @@ void rv515_mc_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
399 WREG32(MC_IND_INDEX, 0); 400 WREG32(MC_IND_INDEX, 0);
400} 401}
401 402
402uint32_t rv515_pcie_rreg(struct radeon_device *rdev, uint32_t reg)
403{
404 uint32_t r;
405
406 WREG32(PCIE_INDEX, ((reg) & 0x7ff));
407 (void)RREG32(PCIE_INDEX);
408 r = RREG32(PCIE_DATA);
409 return r;
410}
411
412void rv515_pcie_wreg(struct radeon_device *rdev, uint32_t reg, uint32_t v)
413{
414 WREG32(PCIE_INDEX, ((reg) & 0x7ff));
415 (void)RREG32(PCIE_INDEX);
416 WREG32(PCIE_DATA, (v));
417 (void)RREG32(PCIE_DATA);
418}
419
420
421/* 403/*
422 * Debugfs info 404 * Debugfs info
423 */ 405 */
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 6538d4236989..c2b0d710d10f 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1182,13 +1182,14 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,
1182 1182
1183int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) 1183int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)
1184{ 1184{
1185 struct ttm_mem_type_manager *man = &bdev->man[mem_type]; 1185 struct ttm_mem_type_manager *man;
1186 int ret = -EINVAL; 1186 int ret = -EINVAL;
1187 1187
1188 if (mem_type >= TTM_NUM_MEM_TYPES) { 1188 if (mem_type >= TTM_NUM_MEM_TYPES) {
1189 printk(KERN_ERR TTM_PFX "Illegal memory type %d\n", mem_type); 1189 printk(KERN_ERR TTM_PFX "Illegal memory type %d\n", mem_type);
1190 return ret; 1190 return ret;
1191 } 1191 }
1192 man = &bdev->man[mem_type];
1192 1193
1193 if (!man->has_type) { 1194 if (!man->has_type) {
1194 printk(KERN_ERR TTM_PFX "Trying to take down uninitialized " 1195 printk(KERN_ERR TTM_PFX "Trying to take down uninitialized "
@@ -1575,6 +1576,10 @@ int ttm_bo_wait(struct ttm_buffer_object *bo,
1575 driver->sync_obj_unref(&sync_obj); 1576 driver->sync_obj_unref(&sync_obj);
1576 driver->sync_obj_unref(&tmp_obj); 1577 driver->sync_obj_unref(&tmp_obj);
1577 spin_lock(&bo->lock); 1578 spin_lock(&bo->lock);
1579 } else {
1580 spin_unlock(&bo->lock);
1581 driver->sync_obj_unref(&sync_obj);
1582 spin_lock(&bo->lock);
1578 } 1583 }
1579 } 1584 }
1580 return 0; 1585 return 0;
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index ce2e6f38ea01..ad4ada07c6cf 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -150,7 +150,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
150#ifdef CONFIG_X86 150#ifdef CONFIG_X86
151 dst = kmap_atomic_prot(d, KM_USER0, prot); 151 dst = kmap_atomic_prot(d, KM_USER0, prot);
152#else 152#else
153 if (prot != PAGE_KERNEL) 153 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
154 dst = vmap(&d, 1, 0, prot); 154 dst = vmap(&d, 1, 0, prot);
155 else 155 else
156 dst = kmap(d); 156 dst = kmap(d);
@@ -163,7 +163,7 @@ static int ttm_copy_io_ttm_page(struct ttm_tt *ttm, void *src,
163#ifdef CONFIG_X86 163#ifdef CONFIG_X86
164 kunmap_atomic(dst, KM_USER0); 164 kunmap_atomic(dst, KM_USER0);
165#else 165#else
166 if (prot != PAGE_KERNEL) 166 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
167 vunmap(dst); 167 vunmap(dst);
168 else 168 else
169 kunmap(d); 169 kunmap(d);
@@ -186,7 +186,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
186#ifdef CONFIG_X86 186#ifdef CONFIG_X86
187 src = kmap_atomic_prot(s, KM_USER0, prot); 187 src = kmap_atomic_prot(s, KM_USER0, prot);
188#else 188#else
189 if (prot != PAGE_KERNEL) 189 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
190 src = vmap(&s, 1, 0, prot); 190 src = vmap(&s, 1, 0, prot);
191 else 191 else
192 src = kmap(s); 192 src = kmap(s);
@@ -199,7 +199,7 @@ static int ttm_copy_ttm_io_page(struct ttm_tt *ttm, void *dst,
199#ifdef CONFIG_X86 199#ifdef CONFIG_X86
200 kunmap_atomic(src, KM_USER0); 200 kunmap_atomic(src, KM_USER0);
201#else 201#else
202 if (prot != PAGE_KERNEL) 202 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL))
203 vunmap(src); 203 vunmap(src);
204 else 204 else
205 kunmap(s); 205 kunmap(s);
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index d258b02aef44..827da0858136 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -674,7 +674,14 @@ omap_i2c_isr(int this_irq, void *dev_id)
674 674
675 err = 0; 675 err = 0;
676complete: 676complete:
677 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); 677 /*
678 * Ack the stat in one go, but [R/X]DR and [R/X]RDY should be
679 * acked after the data operation is complete.
680 * Ref: TRM SWPU114Q Figure 18-31
681 */
682 omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat &
683 ~(OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
684 OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
678 685
679 if (stat & OMAP_I2C_STAT_NACK) { 686 if (stat & OMAP_I2C_STAT_NACK) {
680 err |= OMAP_I2C_STAT_NACK; 687 err |= OMAP_I2C_STAT_NACK;
@@ -687,6 +694,9 @@ complete:
687 } 694 }
688 if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK | 695 if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK |
689 OMAP_I2C_STAT_AL)) { 696 OMAP_I2C_STAT_AL)) {
697 omap_i2c_ack_stat(dev, stat &
698 (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR |
699 OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
690 omap_i2c_complete_cmd(dev, err); 700 omap_i2c_complete_cmd(dev, err);
691 return IRQ_HANDLED; 701 return IRQ_HANDLED;
692 } 702 }
@@ -774,7 +784,7 @@ complete:
774 * memory to the I2C interface. 784 * memory to the I2C interface.
775 */ 785 */
776 786
777 if (cpu_is_omap34xx()) { 787 if (dev->rev <= OMAP_I2C_REV_ON_3430) {
778 while (!(stat & OMAP_I2C_STAT_XUDF)) { 788 while (!(stat & OMAP_I2C_STAT_XUDF)) {
779 if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { 789 if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) {
780 omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)); 790 omap_i2c_ack_stat(dev, stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR));
diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c
index 182e711318ba..d2728a28a8db 100644
--- a/drivers/i2c/busses/i2c-stu300.c
+++ b/drivers/i2c/busses/i2c-stu300.c
@@ -117,7 +117,8 @@ enum stu300_error {
117 STU300_ERROR_NONE = 0, 117 STU300_ERROR_NONE = 0,
118 STU300_ERROR_ACKNOWLEDGE_FAILURE, 118 STU300_ERROR_ACKNOWLEDGE_FAILURE,
119 STU300_ERROR_BUS_ERROR, 119 STU300_ERROR_BUS_ERROR,
120 STU300_ERROR_ARBITRATION_LOST 120 STU300_ERROR_ARBITRATION_LOST,
121 STU300_ERROR_UNKNOWN
121}; 122};
122 123
123/* timeout waiting for the controller to respond */ 124/* timeout waiting for the controller to respond */
@@ -127,7 +128,7 @@ enum stu300_error {
127 * The number of address send athemps tried before giving up. 128 * The number of address send athemps tried before giving up.
128 * If the first one failes it seems like 5 to 8 attempts are required. 129 * If the first one failes it seems like 5 to 8 attempts are required.
129 */ 130 */
130#define NUM_ADDR_RESEND_ATTEMPTS 10 131#define NUM_ADDR_RESEND_ATTEMPTS 12
131 132
132/* I2C clock speed, in Hz 0-400kHz*/ 133/* I2C clock speed, in Hz 0-400kHz*/
133static unsigned int scl_frequency = 100000; 134static unsigned int scl_frequency = 100000;
@@ -149,6 +150,7 @@ module_param(scl_frequency, uint, 0644);
149 * @msg_index: index of current message 150 * @msg_index: index of current message
150 * @msg_len: length of current message 151 * @msg_len: length of current message
151 */ 152 */
153
152struct stu300_dev { 154struct stu300_dev {
153 struct platform_device *pdev; 155 struct platform_device *pdev;
154 struct i2c_adapter adapter; 156 struct i2c_adapter adapter;
@@ -188,6 +190,27 @@ static inline u32 stu300_r8(void __iomem *address)
188 return readl(address) & 0x000000FFU; 190 return readl(address) & 0x000000FFU;
189} 191}
190 192
193static void stu300_irq_enable(struct stu300_dev *dev)
194{
195 u32 val;
196 val = stu300_r8(dev->virtbase + I2C_CR);
197 val |= I2C_CR_INTERRUPT_ENABLE;
198 /* Twice paranoia (possible HW glitch) */
199 stu300_wr8(val, dev->virtbase + I2C_CR);
200 stu300_wr8(val, dev->virtbase + I2C_CR);
201}
202
203static void stu300_irq_disable(struct stu300_dev *dev)
204{
205 u32 val;
206 val = stu300_r8(dev->virtbase + I2C_CR);
207 val &= ~I2C_CR_INTERRUPT_ENABLE;
208 /* Twice paranoia (possible HW glitch) */
209 stu300_wr8(val, dev->virtbase + I2C_CR);
210 stu300_wr8(val, dev->virtbase + I2C_CR);
211}
212
213
191/* 214/*
192 * Tells whether a certain event or events occurred in 215 * Tells whether a certain event or events occurred in
193 * response to a command. The events represent states in 216 * response to a command. The events represent states in
@@ -196,9 +219,10 @@ static inline u32 stu300_r8(void __iomem *address)
196 * documentation and can only be treated as abstract state 219 * documentation and can only be treated as abstract state
197 * machine states. 220 * machine states.
198 * 221 *
199 * @ret 0 = event has not occurred, any other value means 222 * @ret 0 = event has not occurred or unknown error, any
200 * the event occurred. 223 * other value means the correct event occurred or an error.
201 */ 224 */
225
202static int stu300_event_occurred(struct stu300_dev *dev, 226static int stu300_event_occurred(struct stu300_dev *dev,
203 enum stu300_event mr_event) { 227 enum stu300_event mr_event) {
204 u32 status1; 228 u32 status1;
@@ -206,11 +230,28 @@ static int stu300_event_occurred(struct stu300_dev *dev,
206 230
207 /* What event happened? */ 231 /* What event happened? */
208 status1 = stu300_r8(dev->virtbase + I2C_SR1); 232 status1 = stu300_r8(dev->virtbase + I2C_SR1);
233
209 if (!(status1 & I2C_SR1_EVF_IND)) 234 if (!(status1 & I2C_SR1_EVF_IND))
210 /* No event at all */ 235 /* No event at all */
211 return 0; 236 return 0;
237
212 status2 = stu300_r8(dev->virtbase + I2C_SR2); 238 status2 = stu300_r8(dev->virtbase + I2C_SR2);
213 239
240 /* Block any multiple interrupts */
241 stu300_irq_disable(dev);
242
243 /* Check for errors first */
244 if (status2 & I2C_SR2_AF_IND) {
245 dev->cmd_err = STU300_ERROR_ACKNOWLEDGE_FAILURE;
246 return 1;
247 } else if (status2 & I2C_SR2_BERR_IND) {
248 dev->cmd_err = STU300_ERROR_BUS_ERROR;
249 return 1;
250 } else if (status2 & I2C_SR2_ARLO_IND) {
251 dev->cmd_err = STU300_ERROR_ARBITRATION_LOST;
252 return 1;
253 }
254
214 switch (mr_event) { 255 switch (mr_event) {
215 case STU300_EVENT_1: 256 case STU300_EVENT_1:
216 if (status1 & I2C_SR1_ADSL_IND) 257 if (status1 & I2C_SR1_ADSL_IND)
@@ -221,10 +262,6 @@ static int stu300_event_occurred(struct stu300_dev *dev,
221 case STU300_EVENT_7: 262 case STU300_EVENT_7:
222 case STU300_EVENT_8: 263 case STU300_EVENT_8:
223 if (status1 & I2C_SR1_BTF_IND) { 264 if (status1 & I2C_SR1_BTF_IND) {
224 if (status2 & I2C_SR2_AF_IND)
225 dev->cmd_err = STU300_ERROR_ACKNOWLEDGE_FAILURE;
226 else if (status2 & I2C_SR2_BERR_IND)
227 dev->cmd_err = STU300_ERROR_BUS_ERROR;
228 return 1; 265 return 1;
229 } 266 }
230 break; 267 break;
@@ -240,8 +277,6 @@ static int stu300_event_occurred(struct stu300_dev *dev,
240 case STU300_EVENT_6: 277 case STU300_EVENT_6:
241 if (status2 & I2C_SR2_ENDAD_IND) { 278 if (status2 & I2C_SR2_ENDAD_IND) {
242 /* First check for any errors */ 279 /* First check for any errors */
243 if (status2 & I2C_SR2_AF_IND)
244 dev->cmd_err = STU300_ERROR_ACKNOWLEDGE_FAILURE;
245 return 1; 280 return 1;
246 } 281 }
247 break; 282 break;
@@ -252,8 +287,15 @@ static int stu300_event_occurred(struct stu300_dev *dev,
252 default: 287 default:
253 break; 288 break;
254 } 289 }
255 if (status2 & I2C_SR2_ARLO_IND) 290 /* If we get here, we're on thin ice.
256 dev->cmd_err = STU300_ERROR_ARBITRATION_LOST; 291 * Here we are in a status where we have
292 * gotten a response that does not match
293 * what we requested.
294 */
295 dev->cmd_err = STU300_ERROR_UNKNOWN;
296 dev_err(&dev->pdev->dev,
297 "Unhandled interrupt! %d sr1: 0x%x sr2: 0x%x\n",
298 mr_event, status1, status2);
257 return 0; 299 return 0;
258} 300}
259 301
@@ -262,21 +304,20 @@ static irqreturn_t stu300_irh(int irq, void *data)
262 struct stu300_dev *dev = data; 304 struct stu300_dev *dev = data;
263 int res; 305 int res;
264 306
307 /* Just make sure that the block is clocked */
308 clk_enable(dev->clk);
309
265 /* See if this was what we were waiting for */ 310 /* See if this was what we were waiting for */
266 spin_lock(&dev->cmd_issue_lock); 311 spin_lock(&dev->cmd_issue_lock);
267 if (dev->cmd_event != STU300_EVENT_NONE) { 312
268 res = stu300_event_occurred(dev, dev->cmd_event); 313 res = stu300_event_occurred(dev, dev->cmd_event);
269 if (res || dev->cmd_err != STU300_ERROR_NONE) { 314 if (res || dev->cmd_err != STU300_ERROR_NONE)
270 u32 val; 315 complete(&dev->cmd_complete);
271 316
272 complete(&dev->cmd_complete);
273 /* Block any multiple interrupts */
274 val = stu300_r8(dev->virtbase + I2C_CR);
275 val &= ~I2C_CR_INTERRUPT_ENABLE;
276 stu300_wr8(val, dev->virtbase + I2C_CR);
277 }
278 }
279 spin_unlock(&dev->cmd_issue_lock); 317 spin_unlock(&dev->cmd_issue_lock);
318
319 clk_disable(dev->clk);
320
280 return IRQ_HANDLED; 321 return IRQ_HANDLED;
281} 322}
282 323
@@ -308,7 +349,6 @@ static int stu300_start_and_await_event(struct stu300_dev *dev,
308 stu300_wr8(cr_value, dev->virtbase + I2C_CR); 349 stu300_wr8(cr_value, dev->virtbase + I2C_CR);
309 ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, 350 ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
310 STU300_TIMEOUT); 351 STU300_TIMEOUT);
311
312 if (ret < 0) { 352 if (ret < 0) {
313 dev_err(&dev->pdev->dev, 353 dev_err(&dev->pdev->dev,
314 "wait_for_completion_interruptible_timeout() " 354 "wait_for_completion_interruptible_timeout() "
@@ -342,7 +382,6 @@ static int stu300_await_event(struct stu300_dev *dev,
342 enum stu300_event mr_event) 382 enum stu300_event mr_event)
343{ 383{
344 int ret; 384 int ret;
345 u32 val;
346 385
347 if (unlikely(irqs_disabled())) { 386 if (unlikely(irqs_disabled())) {
348 /* TODO: implement polling for this case if need be. */ 387 /* TODO: implement polling for this case if need be. */
@@ -354,36 +393,18 @@ static int stu300_await_event(struct stu300_dev *dev,
354 /* Is it already here? */ 393 /* Is it already here? */
355 spin_lock_irq(&dev->cmd_issue_lock); 394 spin_lock_irq(&dev->cmd_issue_lock);
356 dev->cmd_err = STU300_ERROR_NONE; 395 dev->cmd_err = STU300_ERROR_NONE;
357 if (stu300_event_occurred(dev, mr_event)) {
358 spin_unlock_irq(&dev->cmd_issue_lock);
359 goto exit_await_check_err;
360 }
361 init_completion(&dev->cmd_complete);
362 dev->cmd_err = STU300_ERROR_NONE;
363 dev->cmd_event = mr_event; 396 dev->cmd_event = mr_event;
364 397
365 /* Turn on the I2C interrupt for current operation */ 398 init_completion(&dev->cmd_complete);
366 val = stu300_r8(dev->virtbase + I2C_CR);
367 val |= I2C_CR_INTERRUPT_ENABLE;
368 stu300_wr8(val, dev->virtbase + I2C_CR);
369
370 /* Twice paranoia (possible HW glitch) */
371 stu300_wr8(val, dev->virtbase + I2C_CR);
372 399
373 /* Check again: is it already here? */ 400 /* Turn on the I2C interrupt for current operation */
374 if (unlikely(stu300_event_occurred(dev, mr_event))) { 401 stu300_irq_enable(dev);
375 /* Disable IRQ again. */
376 val &= ~I2C_CR_INTERRUPT_ENABLE;
377 stu300_wr8(val, dev->virtbase + I2C_CR);
378 spin_unlock_irq(&dev->cmd_issue_lock);
379 goto exit_await_check_err;
380 }
381 402
382 /* Unlock the command block and wait for the event to occur */ 403 /* Unlock the command block and wait for the event to occur */
383 spin_unlock_irq(&dev->cmd_issue_lock); 404 spin_unlock_irq(&dev->cmd_issue_lock);
405
384 ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, 406 ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete,
385 STU300_TIMEOUT); 407 STU300_TIMEOUT);
386
387 if (ret < 0) { 408 if (ret < 0) {
388 dev_err(&dev->pdev->dev, 409 dev_err(&dev->pdev->dev,
389 "wait_for_completion_interruptible_timeout()" 410 "wait_for_completion_interruptible_timeout()"
@@ -401,7 +422,6 @@ static int stu300_await_event(struct stu300_dev *dev,
401 return -ETIMEDOUT; 422 return -ETIMEDOUT;
402 } 423 }
403 424
404 exit_await_check_err:
405 if (dev->cmd_err != STU300_ERROR_NONE) { 425 if (dev->cmd_err != STU300_ERROR_NONE) {
406 if (mr_event != STU300_EVENT_6) { 426 if (mr_event != STU300_EVENT_6) {
407 dev_err(&dev->pdev->dev, "controller " 427 dev_err(&dev->pdev->dev, "controller "
@@ -457,18 +477,19 @@ struct stu300_clkset {
457}; 477};
458 478
459static const struct stu300_clkset stu300_clktable[] = { 479static const struct stu300_clkset stu300_clktable[] = {
460 { 0, 0xFFU }, 480 { 0, 0xFFU },
461 { 2500000, I2C_OAR2_FR_25_10MHZ }, 481 { 2500000, I2C_OAR2_FR_25_10MHZ },
462 { 10000000, I2C_OAR2_FR_10_1667MHZ }, 482 { 10000000, I2C_OAR2_FR_10_1667MHZ },
463 { 16670000, I2C_OAR2_FR_1667_2667MHZ }, 483 { 16670000, I2C_OAR2_FR_1667_2667MHZ },
464 { 26670000, I2C_OAR2_FR_2667_40MHZ }, 484 { 26670000, I2C_OAR2_FR_2667_40MHZ },
465 { 40000000, I2C_OAR2_FR_40_5333MHZ }, 485 { 40000000, I2C_OAR2_FR_40_5333MHZ },
466 { 53330000, I2C_OAR2_FR_5333_66MHZ }, 486 { 53330000, I2C_OAR2_FR_5333_66MHZ },
467 { 66000000, I2C_OAR2_FR_66_80MHZ }, 487 { 66000000, I2C_OAR2_FR_66_80MHZ },
468 { 80000000, I2C_OAR2_FR_80_100MHZ }, 488 { 80000000, I2C_OAR2_FR_80_100MHZ },
469 { 100000000, 0xFFU }, 489 { 100000000, 0xFFU },
470}; 490};
471 491
492
472static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate) 493static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate)
473{ 494{
474 495
@@ -494,10 +515,10 @@ static int stu300_set_clk(struct stu300_dev *dev, unsigned long clkrate)
494 515
495 if (dev->speed > 100000) 516 if (dev->speed > 100000)
496 /* Fast Mode I2C */ 517 /* Fast Mode I2C */
497 val = ((clkrate/dev->speed)-9)/3; 518 val = ((clkrate/dev->speed) - 9)/3 + 1;
498 else 519 else
499 /* Standard Mode I2C */ 520 /* Standard Mode I2C */
500 val = ((clkrate/dev->speed)-7)/2; 521 val = ((clkrate/dev->speed) - 7)/2 + 1;
501 522
502 /* According to spec the divider must be > 2 */ 523 /* According to spec the divider must be > 2 */
503 if (val < 0x002) { 524 if (val < 0x002) {
@@ -557,6 +578,7 @@ static int stu300_init_hw(struct stu300_dev *dev)
557 */ 578 */
558 clkrate = clk_get_rate(dev->clk); 579 clkrate = clk_get_rate(dev->clk);
559 ret = stu300_set_clk(dev, clkrate); 580 ret = stu300_set_clk(dev, clkrate);
581
560 if (ret) 582 if (ret)
561 return ret; 583 return ret;
562 /* 584 /*
@@ -641,7 +663,6 @@ static int stu300_xfer_msg(struct i2c_adapter *adap,
641 int attempts = 0; 663 int attempts = 0;
642 struct stu300_dev *dev = i2c_get_adapdata(adap); 664 struct stu300_dev *dev = i2c_get_adapdata(adap);
643 665
644
645 clk_enable(dev->clk); 666 clk_enable(dev->clk);
646 667
647 /* Remove this if (0) to trace each and every message. */ 668 /* Remove this if (0) to trace each and every message. */
@@ -715,14 +736,15 @@ static int stu300_xfer_msg(struct i2c_adapter *adap,
715 736
716 if (attempts < NUM_ADDR_RESEND_ATTEMPTS && attempts > 0) { 737 if (attempts < NUM_ADDR_RESEND_ATTEMPTS && attempts > 0) {
717 dev_dbg(&dev->pdev->dev, "managed to get address " 738 dev_dbg(&dev->pdev->dev, "managed to get address "
718 "through after %d attempts\n", attempts); 739 "through after %d attempts\n", attempts);
719 } else if (attempts == NUM_ADDR_RESEND_ATTEMPTS) { 740 } else if (attempts == NUM_ADDR_RESEND_ATTEMPTS) {
720 dev_dbg(&dev->pdev->dev, "I give up, tried %d times " 741 dev_dbg(&dev->pdev->dev, "I give up, tried %d times "
721 "to resend address.\n", 742 "to resend address.\n",
722 NUM_ADDR_RESEND_ATTEMPTS); 743 NUM_ADDR_RESEND_ATTEMPTS);
723 goto exit_disable; 744 goto exit_disable;
724 } 745 }
725 746
747
726 if (msg->flags & I2C_M_RD) { 748 if (msg->flags & I2C_M_RD) {
727 /* READ: we read the actual bytes one at a time */ 749 /* READ: we read the actual bytes one at a time */
728 for (i = 0; i < msg->len; i++) { 750 for (i = 0; i < msg->len; i++) {
@@ -804,8 +826,10 @@ static int stu300_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
804{ 826{
805 int ret = -1; 827 int ret = -1;
806 int i; 828 int i;
829
807 struct stu300_dev *dev = i2c_get_adapdata(adap); 830 struct stu300_dev *dev = i2c_get_adapdata(adap);
808 dev->msg_len = num; 831 dev->msg_len = num;
832
809 for (i = 0; i < num; i++) { 833 for (i = 0; i < num; i++) {
810 /* 834 /*
811 * Another driver appears to send stop for each message, 835 * Another driver appears to send stop for each message,
@@ -817,6 +841,7 @@ static int stu300_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
817 dev->msg_index = i; 841 dev->msg_index = i;
818 842
819 ret = stu300_xfer_msg(adap, &msgs[i], (i == (num - 1))); 843 ret = stu300_xfer_msg(adap, &msgs[i], (i == (num - 1)));
844
820 if (ret != 0) { 845 if (ret != 0) {
821 num = ret; 846 num = ret;
822 break; 847 break;
@@ -845,6 +870,7 @@ stu300_probe(struct platform_device *pdev)
845 struct resource *res; 870 struct resource *res;
846 int bus_nr; 871 int bus_nr;
847 int ret = 0; 872 int ret = 0;
873 char clk_name[] = "I2C0";
848 874
849 dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL); 875 dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL);
850 if (!dev) { 876 if (!dev) {
@@ -854,7 +880,8 @@ stu300_probe(struct platform_device *pdev)
854 } 880 }
855 881
856 bus_nr = pdev->id; 882 bus_nr = pdev->id;
857 dev->clk = clk_get(&pdev->dev, NULL); 883 clk_name[3] += (char)bus_nr;
884 dev->clk = clk_get(&pdev->dev, clk_name);
858 if (IS_ERR(dev->clk)) { 885 if (IS_ERR(dev->clk)) {
859 ret = PTR_ERR(dev->clk); 886 ret = PTR_ERR(dev->clk);
860 dev_err(&pdev->dev, "could not retrieve i2c bus clock\n"); 887 dev_err(&pdev->dev, "could not retrieve i2c bus clock\n");
diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
index 4cfd084fa897..9a1d55b74d7a 100644
--- a/drivers/input/joydev.c
+++ b/drivers/input/joydev.c
@@ -456,8 +456,11 @@ static int joydev_ioctl_common(struct joydev *joydev,
456 unsigned int cmd, void __user *argp) 456 unsigned int cmd, void __user *argp)
457{ 457{
458 struct input_dev *dev = joydev->handle.dev; 458 struct input_dev *dev = joydev->handle.dev;
459 size_t len;
459 int i, j; 460 int i, j;
461 const char *name;
460 462
463 /* Process fixed-sized commands. */
461 switch (cmd) { 464 switch (cmd) {
462 465
463 case JS_SET_CAL: 466 case JS_SET_CAL:
@@ -499,9 +502,22 @@ static int joydev_ioctl_common(struct joydev *joydev,
499 return copy_to_user(argp, joydev->corr, 502 return copy_to_user(argp, joydev->corr,
500 sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0; 503 sizeof(joydev->corr[0]) * joydev->nabs) ? -EFAULT : 0;
501 504
502 case JSIOCSAXMAP: 505 }
503 if (copy_from_user(joydev->abspam, argp, 506
504 sizeof(__u8) * (ABS_MAX + 1))) 507 /*
508 * Process variable-sized commands (the axis and button map commands
509 * are considered variable-sized to decouple them from the values of
510 * ABS_MAX and KEY_MAX).
511 */
512 switch (cmd & ~IOCSIZE_MASK) {
513
514 case (JSIOCSAXMAP & ~IOCSIZE_MASK):
515 len = min_t(size_t, _IOC_SIZE(cmd), sizeof(joydev->abspam));
516 /*
517 * FIXME: we should not copy into our axis map before
518 * validating the data.
519 */
520 if (copy_from_user(joydev->abspam, argp, len))
505 return -EFAULT; 521 return -EFAULT;
506 522
507 for (i = 0; i < joydev->nabs; i++) { 523 for (i = 0; i < joydev->nabs; i++) {
@@ -511,13 +527,17 @@ static int joydev_ioctl_common(struct joydev *joydev,
511 } 527 }
512 return 0; 528 return 0;
513 529
514 case JSIOCGAXMAP: 530 case (JSIOCGAXMAP & ~IOCSIZE_MASK):
515 return copy_to_user(argp, joydev->abspam, 531 len = min_t(size_t, _IOC_SIZE(cmd), sizeof(joydev->abspam));
516 sizeof(__u8) * (ABS_MAX + 1)) ? -EFAULT : 0; 532 return copy_to_user(argp, joydev->abspam, len) ? -EFAULT : 0;
517 533
518 case JSIOCSBTNMAP: 534 case (JSIOCSBTNMAP & ~IOCSIZE_MASK):
519 if (copy_from_user(joydev->keypam, argp, 535 len = min_t(size_t, _IOC_SIZE(cmd), sizeof(joydev->keypam));
520 sizeof(__u16) * (KEY_MAX - BTN_MISC + 1))) 536 /*
537 * FIXME: we should not copy into our keymap before
538 * validating the data.
539 */
540 if (copy_from_user(joydev->keypam, argp, len))
521 return -EFAULT; 541 return -EFAULT;
522 542
523 for (i = 0; i < joydev->nkey; i++) { 543 for (i = 0; i < joydev->nkey; i++) {
@@ -529,25 +549,19 @@ static int joydev_ioctl_common(struct joydev *joydev,
529 549
530 return 0; 550 return 0;
531 551
532 case JSIOCGBTNMAP: 552 case (JSIOCGBTNMAP & ~IOCSIZE_MASK):
533 return copy_to_user(argp, joydev->keypam, 553 len = min_t(size_t, _IOC_SIZE(cmd), sizeof(joydev->keypam));
534 sizeof(__u16) * (KEY_MAX - BTN_MISC + 1)) ? -EFAULT : 0; 554 return copy_to_user(argp, joydev->keypam, len) ? -EFAULT : 0;
535 555
536 default: 556 case JSIOCGNAME(0):
537 if ((cmd & ~IOCSIZE_MASK) == JSIOCGNAME(0)) { 557 name = dev->name;
538 int len; 558 if (!name)
539 const char *name = dev->name; 559 return 0;
540 560
541 if (!name) 561 len = min_t(size_t, _IOC_SIZE(cmd), strlen(name) + 1);
542 return 0; 562 return copy_to_user(argp, name, len) ? -EFAULT : len;
543 len = strlen(name) + 1;
544 if (len > _IOC_SIZE(cmd))
545 len = _IOC_SIZE(cmd);
546 if (copy_to_user(argp, name, len))
547 return -EFAULT;
548 return len;
549 }
550 } 563 }
564
551 return -EINVAL; 565 return -EINVAL;
552} 566}
553 567
diff --git a/drivers/input/joystick/iforce/iforce-main.c b/drivers/input/joystick/iforce/iforce-main.c
index baabf8302645..f6c688cae334 100644
--- a/drivers/input/joystick/iforce/iforce-main.c
+++ b/drivers/input/joystick/iforce/iforce-main.c
@@ -74,6 +74,7 @@ static struct iforce_device iforce_device[] = {
74 { 0x05ef, 0x8884, "AVB Mag Turbo Force", btn_avb_wheel, abs_wheel, ff_iforce }, 74 { 0x05ef, 0x8884, "AVB Mag Turbo Force", btn_avb_wheel, abs_wheel, ff_iforce },
75 { 0x05ef, 0x8888, "AVB Top Shot Force Feedback Racing Wheel", btn_avb_tw, abs_wheel, ff_iforce }, //? 75 { 0x05ef, 0x8888, "AVB Top Shot Force Feedback Racing Wheel", btn_avb_tw, abs_wheel, ff_iforce }, //?
76 { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //? 76 { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //?
77 { 0x061c, 0xc084, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce },
77 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //? 78 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //?
78 { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //? 79 { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //?
79 { 0x06f8, 0x0004, "Gullemot Jet Leader 3D", btn_joystick, abs_joystick, ff_iforce }, //? 80 { 0x06f8, 0x0004, "Gullemot Jet Leader 3D", btn_joystick, abs_joystick, ff_iforce }, //?
diff --git a/drivers/input/joystick/iforce/iforce-usb.c b/drivers/input/joystick/iforce/iforce-usb.c
index f83185aeb511..9f289d8f52c6 100644
--- a/drivers/input/joystick/iforce/iforce-usb.c
+++ b/drivers/input/joystick/iforce/iforce-usb.c
@@ -223,6 +223,7 @@ static struct usb_device_id iforce_usb_ids [] = {
223 { USB_DEVICE(0x05ef, 0x8884) }, /* AVB Mag Turbo Force */ 223 { USB_DEVICE(0x05ef, 0x8884) }, /* AVB Mag Turbo Force */
224 { USB_DEVICE(0x05ef, 0x8888) }, /* AVB Top Shot FFB Racing Wheel */ 224 { USB_DEVICE(0x05ef, 0x8888) }, /* AVB Top Shot FFB Racing Wheel */
225 { USB_DEVICE(0x061c, 0xc0a4) }, /* ACT LABS Force RS */ 225 { USB_DEVICE(0x061c, 0xc0a4) }, /* ACT LABS Force RS */
226 { USB_DEVICE(0x061c, 0xc084) }, /* ACT LABS Force RS */
226 { USB_DEVICE(0x06f8, 0x0001) }, /* Guillemot Race Leader Force Feedback */ 227 { USB_DEVICE(0x06f8, 0x0001) }, /* Guillemot Race Leader Force Feedback */
227 { USB_DEVICE(0x06f8, 0x0004) }, /* Guillemot Force Feedback Racing Wheel */ 228 { USB_DEVICE(0x06f8, 0x0004) }, /* Guillemot Force Feedback Racing Wheel */
228 { USB_DEVICE(0x06f8, 0xa302) }, /* Guillemot Jet Leader 3D */ 229 { USB_DEVICE(0x06f8, 0xa302) }, /* Guillemot Jet Leader 3D */
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c
index e9b2e7cb05be..541b981ff075 100644
--- a/drivers/input/keyboard/matrix_keypad.c
+++ b/drivers/input/keyboard/matrix_keypad.c
@@ -27,6 +27,7 @@ struct matrix_keypad {
27 const struct matrix_keypad_platform_data *pdata; 27 const struct matrix_keypad_platform_data *pdata;
28 struct input_dev *input_dev; 28 struct input_dev *input_dev;
29 unsigned short *keycodes; 29 unsigned short *keycodes;
30 unsigned int row_shift;
30 31
31 uint32_t last_key_state[MATRIX_MAX_COLS]; 32 uint32_t last_key_state[MATRIX_MAX_COLS];
32 struct delayed_work work; 33 struct delayed_work work;
@@ -136,7 +137,7 @@ static void matrix_keypad_scan(struct work_struct *work)
136 if ((bits_changed & (1 << row)) == 0) 137 if ((bits_changed & (1 << row)) == 0)
137 continue; 138 continue;
138 139
139 code = (row << 4) + col; 140 code = MATRIX_SCAN_CODE(row, col, keypad->row_shift);
140 input_event(input_dev, EV_MSC, MSC_SCAN, code); 141 input_event(input_dev, EV_MSC, MSC_SCAN, code);
141 input_report_key(input_dev, 142 input_report_key(input_dev,
142 keypad->keycodes[code], 143 keypad->keycodes[code],
@@ -317,6 +318,7 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
317 struct matrix_keypad *keypad; 318 struct matrix_keypad *keypad;
318 struct input_dev *input_dev; 319 struct input_dev *input_dev;
319 unsigned short *keycodes; 320 unsigned short *keycodes;
321 unsigned int row_shift;
320 int i; 322 int i;
321 int err; 323 int err;
322 324
@@ -332,14 +334,11 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
332 return -EINVAL; 334 return -EINVAL;
333 } 335 }
334 336
335 if (!keymap_data->max_keymap_size) { 337 row_shift = get_count_order(pdata->num_col_gpios);
336 dev_err(&pdev->dev, "invalid keymap data supplied\n");
337 return -EINVAL;
338 }
339 338
340 keypad = kzalloc(sizeof(struct matrix_keypad), GFP_KERNEL); 339 keypad = kzalloc(sizeof(struct matrix_keypad), GFP_KERNEL);
341 keycodes = kzalloc(keymap_data->max_keymap_size * 340 keycodes = kzalloc((pdata->num_row_gpios << row_shift) *
342 sizeof(keypad->keycodes), 341 sizeof(*keycodes),
343 GFP_KERNEL); 342 GFP_KERNEL);
344 input_dev = input_allocate_device(); 343 input_dev = input_allocate_device();
345 if (!keypad || !keycodes || !input_dev) { 344 if (!keypad || !keycodes || !input_dev) {
@@ -350,6 +349,7 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
350 keypad->input_dev = input_dev; 349 keypad->input_dev = input_dev;
351 keypad->pdata = pdata; 350 keypad->pdata = pdata;
352 keypad->keycodes = keycodes; 351 keypad->keycodes = keycodes;
352 keypad->row_shift = row_shift;
353 keypad->stopped = true; 353 keypad->stopped = true;
354 INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan); 354 INIT_DELAYED_WORK(&keypad->work, matrix_keypad_scan);
355 spin_lock_init(&keypad->lock); 355 spin_lock_init(&keypad->lock);
@@ -363,7 +363,7 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
363 363
364 input_dev->keycode = keycodes; 364 input_dev->keycode = keycodes;
365 input_dev->keycodesize = sizeof(*keycodes); 365 input_dev->keycodesize = sizeof(*keycodes);
366 input_dev->keycodemax = keymap_data->max_keymap_size; 366 input_dev->keycodemax = pdata->num_row_gpios << keypad->row_shift;
367 367
368 for (i = 0; i < keymap_data->keymap_size; i++) { 368 for (i = 0; i < keymap_data->keymap_size; i++) {
369 unsigned int key = keymap_data->keymap[i]; 369 unsigned int key = keymap_data->keymap[i];
@@ -371,7 +371,7 @@ static int __devinit matrix_keypad_probe(struct platform_device *pdev)
371 unsigned int col = KEY_COL(key); 371 unsigned int col = KEY_COL(key);
372 unsigned short code = KEY_VAL(key); 372 unsigned short code = KEY_VAL(key);
373 373
374 keycodes[(row << 4) + col] = code; 374 keycodes[MATRIX_SCAN_CODE(row, col, row_shift)] = code;
375 __set_bit(code, input_dev->keybit); 375 __set_bit(code, input_dev->keybit);
376 } 376 }
377 __clear_bit(KEY_RESERVED, input_dev->keybit); 377 __clear_bit(KEY_RESERVED, input_dev->keybit);
diff --git a/drivers/input/misc/wistron_btns.c b/drivers/input/misc/wistron_btns.c
index 26e17a9a22eb..27ee976eb54c 100644
--- a/drivers/input/misc/wistron_btns.c
+++ b/drivers/input/misc/wistron_btns.c
@@ -611,6 +611,20 @@ static struct key_entry keymap_wistron_generic[] __initdata = {
611 { KE_END, 0 } 611 { KE_END, 0 }
612}; 612};
613 613
614static struct key_entry keymap_prestigio[] __initdata = {
615 { KE_KEY, 0x11, {KEY_PROG1} },
616 { KE_KEY, 0x12, {KEY_PROG2} },
617 { KE_WIFI, 0x30 },
618 { KE_KEY, 0x22, {KEY_REWIND} },
619 { KE_KEY, 0x23, {KEY_FORWARD} },
620 { KE_KEY, 0x24, {KEY_PLAYPAUSE} },
621 { KE_KEY, 0x25, {KEY_STOPCD} },
622 { KE_KEY, 0x31, {KEY_MAIL} },
623 { KE_KEY, 0x36, {KEY_WWW} },
624 { KE_END, 0 }
625};
626
627
614/* 628/*
615 * If your machine is not here (which is currently rather likely), please send 629 * If your machine is not here (which is currently rather likely), please send
616 * a list of buttons and their key codes (reported when loading this module 630 * a list of buttons and their key codes (reported when loading this module
@@ -971,6 +985,8 @@ static int __init select_keymap(void)
971 if (keymap_name != NULL) { 985 if (keymap_name != NULL) {
972 if (strcmp (keymap_name, "1557/MS2141") == 0) 986 if (strcmp (keymap_name, "1557/MS2141") == 0)
973 keymap = keymap_wistron_ms2141; 987 keymap = keymap_wistron_ms2141;
988 else if (strcmp (keymap_name, "prestigio") == 0)
989 keymap = keymap_prestigio;
974 else if (strcmp (keymap_name, "generic") == 0) 990 else if (strcmp (keymap_name, "generic") == 0)
975 keymap = keymap_wistron_generic; 991 keymap = keymap_wistron_generic;
976 else { 992 else {
diff --git a/drivers/input/serio/hp_sdc_mlc.c b/drivers/input/serio/hp_sdc_mlc.c
index b587e2d576ac..820e51673b26 100644
--- a/drivers/input/serio/hp_sdc_mlc.c
+++ b/drivers/input/serio/hp_sdc_mlc.c
@@ -296,7 +296,7 @@ static void hp_sdc_mlc_out(hil_mlc *mlc)
296 priv->tseq[3] = 0; 296 priv->tseq[3] = 0;
297 if (mlc->opacket & HIL_CTRL_APE) { 297 if (mlc->opacket & HIL_CTRL_APE) {
298 priv->tseq[3] |= HP_SDC_LPC_APE_IPF; 298 priv->tseq[3] |= HP_SDC_LPC_APE_IPF;
299 down_trylock(&mlc->csem); 299 BUG_ON(down_trylock(&mlc->csem));
300 } 300 }
301 enqueue: 301 enqueue:
302 hp_sdc_enqueue_transaction(&priv->trans); 302 hp_sdc_enqueue_transaction(&priv->trans);
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h
index 924e8ed7f2cf..ae04d8a494e5 100644
--- a/drivers/input/serio/i8042-x86ia64io.h
+++ b/drivers/input/serio/i8042-x86ia64io.h
@@ -78,6 +78,14 @@ static struct dmi_system_id __initdata i8042_dmi_noloop_table[] = {
78 }, 78 },
79 }, 79 },
80 { 80 {
81 .ident = "ASUS G1S",
82 .matches = {
83 DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK Computer Inc."),
84 DMI_MATCH(DMI_BOARD_NAME, "G1S"),
85 DMI_MATCH(DMI_BOARD_VERSION, "1.0"),
86 },
87 },
88 {
81 /* AUX LOOP command does not raise AUX IRQ */ 89 /* AUX LOOP command does not raise AUX IRQ */
82 .ident = "ASUS P65UP5", 90 .ident = "ASUS P65UP5",
83 .matches = { 91 .matches = {
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index a9d5031b855e..ea30c983a33e 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -388,6 +388,32 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
388 return result; 388 return result;
389} 389}
390 390
391static int wacom_query_tablet_data(struct usb_interface *intf)
392{
393 unsigned char *rep_data;
394 int limit = 0;
395 int error;
396
397 rep_data = kmalloc(2, GFP_KERNEL);
398 if (!rep_data)
399 return -ENOMEM;
400
401 do {
402 rep_data[0] = 2;
403 rep_data[1] = 2;
404 error = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
405 2, rep_data, 2);
406 if (error >= 0)
407 error = usb_get_report(intf,
408 WAC_HID_FEATURE_REPORT, 2,
409 rep_data, 2);
410 } while ((error < 0 || rep_data[1] != 2) && limit++ < 5);
411
412 kfree(rep_data);
413
414 return error < 0 ? error : 0;
415}
416
391static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id) 417static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
392{ 418{
393 struct usb_device *dev = interface_to_usbdev(intf); 419 struct usb_device *dev = interface_to_usbdev(intf);
@@ -398,7 +424,6 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
398 struct wacom_features *features; 424 struct wacom_features *features;
399 struct input_dev *input_dev; 425 struct input_dev *input_dev;
400 int error = -ENOMEM; 426 int error = -ENOMEM;
401 char rep_data[2], limit = 0;
402 struct hid_descriptor *hid_desc; 427 struct hid_descriptor *hid_desc;
403 428
404 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL); 429 wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
@@ -489,20 +514,10 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
489 514
490 /* 515 /*
491 * Ask the tablet to report tablet data if it is not a Tablet PC. 516 * Ask the tablet to report tablet data if it is not a Tablet PC.
492 * Repeat until it succeeds 517 * Note that if query fails it is not a hard failure.
493 */ 518 */
494 if (wacom_wac->features->type != TABLETPC) { 519 if (wacom_wac->features->type != TABLETPC)
495 do { 520 wacom_query_tablet_data(intf);
496 rep_data[0] = 2;
497 rep_data[1] = 2;
498 error = usb_set_report(intf, WAC_HID_FEATURE_REPORT,
499 2, rep_data, 2);
500 if (error >= 0)
501 error = usb_get_report(intf,
502 WAC_HID_FEATURE_REPORT, 2,
503 rep_data, 2);
504 } while ((error < 0 || rep_data[1] != 2) && limit++ < 5);
505 }
506 521
507 usb_set_intfdata(intf, wacom); 522 usb_set_intfdata(intf, wacom);
508 return 0; 523 return 0;
diff --git a/drivers/input/touchscreen/ucb1400_ts.c b/drivers/input/touchscreen/ucb1400_ts.c
index 6954f5500108..3a7a58222f83 100644
--- a/drivers/input/touchscreen/ucb1400_ts.c
+++ b/drivers/input/touchscreen/ucb1400_ts.c
@@ -170,11 +170,11 @@ static void ucb1400_handle_pending_irq(struct ucb1400_ts *ucb)
170 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, isr); 170 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, isr);
171 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0); 171 ucb1400_reg_write(ucb->ac97, UCB_IE_CLEAR, 0);
172 172
173 if (isr & UCB_IE_TSPX) { 173 if (isr & UCB_IE_TSPX)
174 ucb1400_ts_irq_disable(ucb->ac97); 174 ucb1400_ts_irq_disable(ucb->ac97);
175 enable_irq(ucb->irq); 175 else
176 } else 176 dev_dbg(&ucb->ts_idev->dev, "ucb1400: unexpected IE_STATUS = %#x\n", isr);
177 printk(KERN_ERR "ucb1400: unexpected IE_STATUS = %#x\n", isr); 177 enable_irq(ucb->irq);
178} 178}
179 179
180static int ucb1400_ts_thread(void *_ucb) 180static int ucb1400_ts_thread(void *_ucb)
@@ -345,6 +345,7 @@ static int ucb1400_ts_detect_irq(struct ucb1400_ts *ucb)
345static int ucb1400_ts_probe(struct platform_device *dev) 345static int ucb1400_ts_probe(struct platform_device *dev)
346{ 346{
347 int error, x_res, y_res; 347 int error, x_res, y_res;
348 u16 fcsr;
348 struct ucb1400_ts *ucb = dev->dev.platform_data; 349 struct ucb1400_ts *ucb = dev->dev.platform_data;
349 350
350 ucb->ts_idev = input_allocate_device(); 351 ucb->ts_idev = input_allocate_device();
@@ -382,6 +383,14 @@ static int ucb1400_ts_probe(struct platform_device *dev)
382 ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY); 383 ucb->ts_idev->evbit[0] = BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY);
383 ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH); 384 ucb->ts_idev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
384 385
386 /*
387 * Enable ADC filter to prevent horrible jitter on Colibri.
388 * This also further reduces jitter on boards where ADCSYNC
389 * pin is connected.
390 */
391 fcsr = ucb1400_reg_read(ucb->ac97, UCB_FCSR);
392 ucb1400_reg_write(ucb->ac97, UCB_FCSR, fcsr | UCB_FCSR_AVE);
393
385 ucb1400_adc_enable(ucb->ac97); 394 ucb1400_adc_enable(ucb->ac97);
386 x_res = ucb1400_ts_read_xres(ucb); 395 x_res = ucb1400_ts_read_xres(ucb);
387 y_res = ucb1400_ts_read_yres(ucb); 396 y_res = ucb1400_ts_read_yres(ucb);
diff --git a/drivers/isdn/mISDN/l1oip_core.c b/drivers/isdn/mISDN/l1oip_core.c
index c3b661a666cb..7e5f30dbc0a0 100644
--- a/drivers/isdn/mISDN/l1oip_core.c
+++ b/drivers/isdn/mISDN/l1oip_core.c
@@ -1480,7 +1480,7 @@ l1oip_init(void)
1480 return -ENOMEM; 1480 return -ENOMEM;
1481 1481
1482 l1oip_cnt = 0; 1482 l1oip_cnt = 0;
1483 while (type[l1oip_cnt] && l1oip_cnt < MAX_CARDS) { 1483 while (l1oip_cnt < MAX_CARDS && type[l1oip_cnt]) {
1484 switch (type[l1oip_cnt] & 0xff) { 1484 switch (type[l1oip_cnt] & 0xff) {
1485 case 1: 1485 case 1:
1486 pri = 0; 1486 pri = 0;
diff --git a/drivers/leds/ledtrig-gpio.c b/drivers/leds/ledtrig-gpio.c
index a247ae63374f..1bc5db4ece0d 100644
--- a/drivers/leds/ledtrig-gpio.c
+++ b/drivers/leds/ledtrig-gpio.c
@@ -117,6 +117,9 @@ static ssize_t gpio_trig_inverted_store(struct device *dev,
117 117
118 gpio_data->inverted = !!inverted; 118 gpio_data->inverted = !!inverted;
119 119
120 /* After inverting, we need to update the LED. */
121 schedule_work(&gpio_data->work);
122
120 return n; 123 return n;
121} 124}
122static DEVICE_ATTR(inverted, 0644, gpio_trig_inverted_show, 125static DEVICE_ATTR(inverted, 0644, gpio_trig_inverted_show,
@@ -146,20 +149,26 @@ static ssize_t gpio_trig_gpio_store(struct device *dev,
146 return -EINVAL; 149 return -EINVAL;
147 } 150 }
148 151
152 if (gpio_data->gpio == gpio)
153 return n;
154
149 if (!gpio) { 155 if (!gpio) {
150 free_irq(gpio_to_irq(gpio_data->gpio), led); 156 if (gpio_data->gpio != 0)
157 free_irq(gpio_to_irq(gpio_data->gpio), led);
158 gpio_data->gpio = 0;
151 return n; 159 return n;
152 } 160 }
153 161
154 if (gpio_data->gpio > 0 && gpio_data->gpio != gpio)
155 free_irq(gpio_to_irq(gpio_data->gpio), led);
156
157 gpio_data->gpio = gpio;
158 ret = request_irq(gpio_to_irq(gpio), gpio_trig_irq, 162 ret = request_irq(gpio_to_irq(gpio), gpio_trig_irq,
159 IRQF_SHARED | IRQF_TRIGGER_RISING 163 IRQF_SHARED | IRQF_TRIGGER_RISING
160 | IRQF_TRIGGER_FALLING, "ledtrig-gpio", led); 164 | IRQF_TRIGGER_FALLING, "ledtrig-gpio", led);
161 if (ret) 165 if (ret) {
162 dev_err(dev, "request_irq failed with error %d\n", ret); 166 dev_err(dev, "request_irq failed with error %d\n", ret);
167 } else {
168 if (gpio_data->gpio != 0)
169 free_irq(gpio_to_irq(gpio_data->gpio), led);
170 gpio_data->gpio = gpio;
171 }
163 172
164 return ret ? ret : n; 173 return ret ? ret : n;
165} 174}
@@ -211,7 +220,8 @@ static void gpio_trig_deactivate(struct led_classdev *led)
211 device_remove_file(led->dev, &dev_attr_inverted); 220 device_remove_file(led->dev, &dev_attr_inverted);
212 device_remove_file(led->dev, &dev_attr_desired_brightness); 221 device_remove_file(led->dev, &dev_attr_desired_brightness);
213 flush_work(&gpio_data->work); 222 flush_work(&gpio_data->work);
214 free_irq(gpio_to_irq(gpio_data->gpio),led); 223 if (gpio_data->gpio != 0)
224 free_irq(gpio_to_irq(gpio_data->gpio), led);
215 kfree(gpio_data); 225 kfree(gpio_data);
216 } 226 }
217} 227}
diff --git a/drivers/macintosh/via-maciisi.c b/drivers/macintosh/via-maciisi.c
index 4d686c0bdea0..9ab5b0c34f0d 100644
--- a/drivers/macintosh/via-maciisi.c
+++ b/drivers/macintosh/via-maciisi.c
@@ -288,7 +288,7 @@ static void maciisi_sync(struct adb_request *req)
288 } 288 }
289 /* This could be BAD... when the ADB controller doesn't respond 289 /* This could be BAD... when the ADB controller doesn't respond
290 * for this long, it's probably not coming back :-( */ 290 * for this long, it's probably not coming back :-( */
291 if(count >= 50) /* Hopefully shouldn't happen */ 291 if (count > 50) /* Hopefully shouldn't happen */
292 printk(KERN_ERR "maciisi_send_request: poll timed out!\n"); 292 printk(KERN_ERR "maciisi_send_request: poll timed out!\n");
293} 293}
294 294
diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c
index 0ca1ee768a1f..8ce74d95ae4d 100644
--- a/drivers/md/dm-log-userspace-transfer.c
+++ b/drivers/md/dm-log-userspace-transfer.c
@@ -108,7 +108,7 @@ static int fill_pkg(struct cn_msg *msg, struct dm_ulog_request *tfr)
108 *(pkg->data_size) = 0; 108 *(pkg->data_size) = 0;
109 } else if (tfr->data_size > *(pkg->data_size)) { 109 } else if (tfr->data_size > *(pkg->data_size)) {
110 DMERR("Insufficient space to receive package [%u] " 110 DMERR("Insufficient space to receive package [%u] "
111 "(%u vs %lu)", tfr->request_type, 111 "(%u vs %zu)", tfr->request_type,
112 tfr->data_size, *(pkg->data_size)); 112 tfr->data_size, *(pkg->data_size));
113 113
114 *(pkg->data_size) = 0; 114 *(pkg->data_size) = 0;
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 5810fa906af0..5fe39c2a3d2b 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -220,6 +220,7 @@ static int linear_run (mddev_t *mddev)
220 mddev->queue->unplug_fn = linear_unplug; 220 mddev->queue->unplug_fn = linear_unplug;
221 mddev->queue->backing_dev_info.congested_fn = linear_congested; 221 mddev->queue->backing_dev_info.congested_fn = linear_congested;
222 mddev->queue->backing_dev_info.congested_data = mddev; 222 mddev->queue->backing_dev_info.congested_data = mddev;
223 md_integrity_register(mddev);
223 return 0; 224 return 0;
224} 225}
225 226
@@ -256,6 +257,7 @@ static int linear_add(mddev_t *mddev, mdk_rdev_t *rdev)
256 rcu_assign_pointer(mddev->private, newconf); 257 rcu_assign_pointer(mddev->private, newconf);
257 md_set_array_sectors(mddev, linear_size(mddev, 0, 0)); 258 md_set_array_sectors(mddev, linear_size(mddev, 0, 0));
258 set_capacity(mddev->gendisk, mddev->array_sectors); 259 set_capacity(mddev->gendisk, mddev->array_sectors);
260 revalidate_disk(mddev->gendisk);
259 call_rcu(&oldconf->rcu, free_conf); 261 call_rcu(&oldconf->rcu, free_conf);
260 return 0; 262 return 0;
261} 263}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index d4351ff0849f..9dd872000cec 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -359,6 +359,7 @@ static mddev_t * mddev_find(dev_t unit)
359 else 359 else
360 new->md_minor = MINOR(unit) >> MdpMinorShift; 360 new->md_minor = MINOR(unit) >> MdpMinorShift;
361 361
362 mutex_init(&new->open_mutex);
362 mutex_init(&new->reconfig_mutex); 363 mutex_init(&new->reconfig_mutex);
363 INIT_LIST_HEAD(&new->disks); 364 INIT_LIST_HEAD(&new->disks);
364 INIT_LIST_HEAD(&new->all_mddevs); 365 INIT_LIST_HEAD(&new->all_mddevs);
@@ -1308,7 +1309,12 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
1308 } 1309 }
1309 if (mddev->level != LEVEL_MULTIPATH) { 1310 if (mddev->level != LEVEL_MULTIPATH) {
1310 int role; 1311 int role;
1311 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]); 1312 if (rdev->desc_nr < 0 ||
1313 rdev->desc_nr >= le32_to_cpu(sb->max_dev)) {
1314 role = 0xffff;
1315 rdev->desc_nr = -1;
1316 } else
1317 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]);
1312 switch(role) { 1318 switch(role) {
1313 case 0xffff: /* spare */ 1319 case 0xffff: /* spare */
1314 break; 1320 break;
@@ -1394,8 +1400,14 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1394 if (rdev2->desc_nr+1 > max_dev) 1400 if (rdev2->desc_nr+1 > max_dev)
1395 max_dev = rdev2->desc_nr+1; 1401 max_dev = rdev2->desc_nr+1;
1396 1402
1397 if (max_dev > le32_to_cpu(sb->max_dev)) 1403 if (max_dev > le32_to_cpu(sb->max_dev)) {
1404 int bmask;
1398 sb->max_dev = cpu_to_le32(max_dev); 1405 sb->max_dev = cpu_to_le32(max_dev);
1406 rdev->sb_size = max_dev * 2 + 256;
1407 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
1408 if (rdev->sb_size & bmask)
1409 rdev->sb_size = (rdev->sb_size | bmask) + 1;
1410 }
1399 for (i=0; i<max_dev;i++) 1411 for (i=0; i<max_dev;i++)
1400 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1412 sb->dev_roles[i] = cpu_to_le16(0xfffe);
1401 1413
@@ -1487,37 +1499,76 @@ static int match_mddev_units(mddev_t *mddev1, mddev_t *mddev2)
1487 1499
1488static LIST_HEAD(pending_raid_disks); 1500static LIST_HEAD(pending_raid_disks);
1489 1501
1490static void md_integrity_check(mdk_rdev_t *rdev, mddev_t *mddev) 1502/*
1503 * Try to register data integrity profile for an mddev
1504 *
1505 * This is called when an array is started and after a disk has been kicked
1506 * from the array. It only succeeds if all working and active component devices
1507 * are integrity capable with matching profiles.
1508 */
1509int md_integrity_register(mddev_t *mddev)
1510{
1511 mdk_rdev_t *rdev, *reference = NULL;
1512
1513 if (list_empty(&mddev->disks))
1514 return 0; /* nothing to do */
1515 if (blk_get_integrity(mddev->gendisk))
1516 return 0; /* already registered */
1517 list_for_each_entry(rdev, &mddev->disks, same_set) {
1518 /* skip spares and non-functional disks */
1519 if (test_bit(Faulty, &rdev->flags))
1520 continue;
1521 if (rdev->raid_disk < 0)
1522 continue;
1523 /*
1524 * If at least one rdev is not integrity capable, we can not
1525 * enable data integrity for the md device.
1526 */
1527 if (!bdev_get_integrity(rdev->bdev))
1528 return -EINVAL;
1529 if (!reference) {
1530 /* Use the first rdev as the reference */
1531 reference = rdev;
1532 continue;
1533 }
1534 /* does this rdev's profile match the reference profile? */
1535 if (blk_integrity_compare(reference->bdev->bd_disk,
1536 rdev->bdev->bd_disk) < 0)
1537 return -EINVAL;
1538 }
1539 /*
1540 * All component devices are integrity capable and have matching
1541 * profiles, register the common profile for the md device.
1542 */
1543 if (blk_integrity_register(mddev->gendisk,
1544 bdev_get_integrity(reference->bdev)) != 0) {
1545 printk(KERN_ERR "md: failed to register integrity for %s\n",
1546 mdname(mddev));
1547 return -EINVAL;
1548 }
1549 printk(KERN_NOTICE "md: data integrity on %s enabled\n",
1550 mdname(mddev));
1551 return 0;
1552}
1553EXPORT_SYMBOL(md_integrity_register);
1554
1555/* Disable data integrity if non-capable/non-matching disk is being added */
1556void md_integrity_add_rdev(mdk_rdev_t *rdev, mddev_t *mddev)
1491{ 1557{
1492 struct mdk_personality *pers = mddev->pers;
1493 struct gendisk *disk = mddev->gendisk;
1494 struct blk_integrity *bi_rdev = bdev_get_integrity(rdev->bdev); 1558 struct blk_integrity *bi_rdev = bdev_get_integrity(rdev->bdev);
1495 struct blk_integrity *bi_mddev = blk_get_integrity(disk); 1559 struct blk_integrity *bi_mddev = blk_get_integrity(mddev->gendisk);
1496 1560
1497 /* Data integrity passthrough not supported on RAID 4, 5 and 6 */ 1561 if (!bi_mddev) /* nothing to do */
1498 if (pers && pers->level >= 4 && pers->level <= 6)
1499 return; 1562 return;
1500 1563 if (rdev->raid_disk < 0) /* skip spares */
1501 /* If rdev is integrity capable, register profile for mddev */
1502 if (!bi_mddev && bi_rdev) {
1503 if (blk_integrity_register(disk, bi_rdev))
1504 printk(KERN_ERR "%s: %s Could not register integrity!\n",
1505 __func__, disk->disk_name);
1506 else
1507 printk(KERN_NOTICE "Enabling data integrity on %s\n",
1508 disk->disk_name);
1509 return; 1564 return;
1510 } 1565 if (bi_rdev && blk_integrity_compare(mddev->gendisk,
1511 1566 rdev->bdev->bd_disk) >= 0)
1512 /* Check that mddev and rdev have matching profiles */ 1567 return;
1513 if (blk_integrity_compare(disk, rdev->bdev->bd_disk) < 0) { 1568 printk(KERN_NOTICE "disabling data integrity on %s\n", mdname(mddev));
1514 printk(KERN_ERR "%s: %s/%s integrity mismatch!\n", __func__, 1569 blk_integrity_unregister(mddev->gendisk);
1515 disk->disk_name, rdev->bdev->bd_disk->disk_name);
1516 printk(KERN_NOTICE "Disabling data integrity on %s\n",
1517 disk->disk_name);
1518 blk_integrity_unregister(disk);
1519 }
1520} 1570}
1571EXPORT_SYMBOL(md_integrity_add_rdev);
1521 1572
1522static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev) 1573static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1523{ 1574{
@@ -1591,7 +1642,6 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
1591 /* May as well allow recovery to be retried once */ 1642 /* May as well allow recovery to be retried once */
1592 mddev->recovery_disabled = 0; 1643 mddev->recovery_disabled = 0;
1593 1644
1594 md_integrity_check(rdev, mddev);
1595 return 0; 1645 return 0;
1596 1646
1597 fail: 1647 fail:
@@ -1925,17 +1975,14 @@ repeat:
1925 /* otherwise we have to go forward and ... */ 1975 /* otherwise we have to go forward and ... */
1926 mddev->events ++; 1976 mddev->events ++;
1927 if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */ 1977 if (!mddev->in_sync || mddev->recovery_cp != MaxSector) { /* not clean */
1928 /* .. if the array isn't clean, insist on an odd 'events' */ 1978 /* .. if the array isn't clean, an 'even' event must also go
1929 if ((mddev->events&1)==0) { 1979 * to spares. */
1930 mddev->events++; 1980 if ((mddev->events&1)==0)
1931 nospares = 0; 1981 nospares = 0;
1932 }
1933 } else { 1982 } else {
1934 /* otherwise insist on an even 'events' (for clean states) */ 1983 /* otherwise an 'odd' event must go to spares */
1935 if ((mddev->events&1)) { 1984 if ((mddev->events&1))
1936 mddev->events++;
1937 nospares = 0; 1985 nospares = 0;
1938 }
1939 } 1986 }
1940 } 1987 }
1941 1988
@@ -2657,6 +2704,7 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
2657 ssize_t rv = len; 2704 ssize_t rv = len;
2658 struct mdk_personality *pers; 2705 struct mdk_personality *pers;
2659 void *priv; 2706 void *priv;
2707 mdk_rdev_t *rdev;
2660 2708
2661 if (mddev->pers == NULL) { 2709 if (mddev->pers == NULL) {
2662 if (len == 0) 2710 if (len == 0)
@@ -2736,6 +2784,12 @@ level_store(mddev_t *mddev, const char *buf, size_t len)
2736 mddev_suspend(mddev); 2784 mddev_suspend(mddev);
2737 mddev->pers->stop(mddev); 2785 mddev->pers->stop(mddev);
2738 module_put(mddev->pers->owner); 2786 module_put(mddev->pers->owner);
2787 /* Invalidate devices that are now superfluous */
2788 list_for_each_entry(rdev, &mddev->disks, same_set)
2789 if (rdev->raid_disk >= mddev->raid_disks) {
2790 rdev->raid_disk = -1;
2791 clear_bit(In_sync, &rdev->flags);
2792 }
2739 mddev->pers = pers; 2793 mddev->pers = pers;
2740 mddev->private = priv; 2794 mddev->private = priv;
2741 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); 2795 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
@@ -3545,6 +3599,7 @@ max_sync_store(mddev_t *mddev, const char *buf, size_t len)
3545 if (max < mddev->resync_min) 3599 if (max < mddev->resync_min)
3546 return -EINVAL; 3600 return -EINVAL;
3547 if (max < mddev->resync_max && 3601 if (max < mddev->resync_max &&
3602 mddev->ro == 0 &&
3548 test_bit(MD_RECOVERY_RUNNING, &mddev->recovery)) 3603 test_bit(MD_RECOVERY_RUNNING, &mddev->recovery))
3549 return -EBUSY; 3604 return -EBUSY;
3550 3605
@@ -3685,17 +3740,8 @@ array_size_store(mddev_t *mddev, const char *buf, size_t len)
3685 3740
3686 mddev->array_sectors = sectors; 3741 mddev->array_sectors = sectors;
3687 set_capacity(mddev->gendisk, mddev->array_sectors); 3742 set_capacity(mddev->gendisk, mddev->array_sectors);
3688 if (mddev->pers) { 3743 if (mddev->pers)
3689 struct block_device *bdev = bdget_disk(mddev->gendisk, 0); 3744 revalidate_disk(mddev->gendisk);
3690
3691 if (bdev) {
3692 mutex_lock(&bdev->bd_inode->i_mutex);
3693 i_size_write(bdev->bd_inode,
3694 (loff_t)mddev->array_sectors << 9);
3695 mutex_unlock(&bdev->bd_inode->i_mutex);
3696 bdput(bdev);
3697 }
3698 }
3699 3745
3700 return len; 3746 return len;
3701} 3747}
@@ -4048,10 +4094,6 @@ static int do_md_run(mddev_t * mddev)
4048 } 4094 }
4049 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel)); 4095 strlcpy(mddev->clevel, pers->name, sizeof(mddev->clevel));
4050 4096
4051 if (pers->level >= 4 && pers->level <= 6)
4052 /* Cannot support integrity (yet) */
4053 blk_integrity_unregister(mddev->gendisk);
4054
4055 if (mddev->reshape_position != MaxSector && 4097 if (mddev->reshape_position != MaxSector &&
4056 pers->start_reshape == NULL) { 4098 pers->start_reshape == NULL) {
4057 /* This personality cannot handle reshaping... */ 4099 /* This personality cannot handle reshaping... */
@@ -4189,6 +4231,7 @@ static int do_md_run(mddev_t * mddev)
4189 md_wakeup_thread(mddev->thread); 4231 md_wakeup_thread(mddev->thread);
4190 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */ 4232 md_wakeup_thread(mddev->sync_thread); /* possibly kick off a reshape */
4191 4233
4234 revalidate_disk(mddev->gendisk);
4192 mddev->changed = 1; 4235 mddev->changed = 1;
4193 md_new_event(mddev); 4236 md_new_event(mddev);
4194 sysfs_notify_dirent(mddev->sysfs_state); 4237 sysfs_notify_dirent(mddev->sysfs_state);
@@ -4260,12 +4303,11 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4260 struct gendisk *disk = mddev->gendisk; 4303 struct gendisk *disk = mddev->gendisk;
4261 mdk_rdev_t *rdev; 4304 mdk_rdev_t *rdev;
4262 4305
4306 mutex_lock(&mddev->open_mutex);
4263 if (atomic_read(&mddev->openers) > is_open) { 4307 if (atomic_read(&mddev->openers) > is_open) {
4264 printk("md: %s still in use.\n",mdname(mddev)); 4308 printk("md: %s still in use.\n",mdname(mddev));
4265 return -EBUSY; 4309 err = -EBUSY;
4266 } 4310 } else if (mddev->pers) {
4267
4268 if (mddev->pers) {
4269 4311
4270 if (mddev->sync_thread) { 4312 if (mddev->sync_thread) {
4271 set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 4313 set_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
@@ -4322,8 +4364,12 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4322 if (mode == 1) 4364 if (mode == 1)
4323 set_disk_ro(disk, 1); 4365 set_disk_ro(disk, 1);
4324 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); 4366 clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery);
4367 err = 0;
4325 } 4368 }
4326 4369out:
4370 mutex_unlock(&mddev->open_mutex);
4371 if (err)
4372 return err;
4327 /* 4373 /*
4328 * Free resources if final stop 4374 * Free resources if final stop
4329 */ 4375 */
@@ -4389,7 +4435,6 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
4389 blk_integrity_unregister(disk); 4435 blk_integrity_unregister(disk);
4390 md_new_event(mddev); 4436 md_new_event(mddev);
4391 sysfs_notify_dirent(mddev->sysfs_state); 4437 sysfs_notify_dirent(mddev->sysfs_state);
4392out:
4393 return err; 4438 return err;
4394} 4439}
4395 4440
@@ -5087,18 +5132,8 @@ static int update_size(mddev_t *mddev, sector_t num_sectors)
5087 return -ENOSPC; 5132 return -ENOSPC;
5088 } 5133 }
5089 rv = mddev->pers->resize(mddev, num_sectors); 5134 rv = mddev->pers->resize(mddev, num_sectors);
5090 if (!rv) { 5135 if (!rv)
5091 struct block_device *bdev; 5136 revalidate_disk(mddev->gendisk);
5092
5093 bdev = bdget_disk(mddev->gendisk, 0);
5094 if (bdev) {
5095 mutex_lock(&bdev->bd_inode->i_mutex);
5096 i_size_write(bdev->bd_inode,
5097 (loff_t)mddev->array_sectors << 9);
5098 mutex_unlock(&bdev->bd_inode->i_mutex);
5099 bdput(bdev);
5100 }
5101 }
5102 return rv; 5137 return rv;
5103} 5138}
5104 5139
@@ -5484,12 +5519,12 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5484 } 5519 }
5485 BUG_ON(mddev != bdev->bd_disk->private_data); 5520 BUG_ON(mddev != bdev->bd_disk->private_data);
5486 5521
5487 if ((err = mutex_lock_interruptible_nested(&mddev->reconfig_mutex, 1))) 5522 if ((err = mutex_lock_interruptible(&mddev->open_mutex)))
5488 goto out; 5523 goto out;
5489 5524
5490 err = 0; 5525 err = 0;
5491 atomic_inc(&mddev->openers); 5526 atomic_inc(&mddev->openers);
5492 mddev_unlock(mddev); 5527 mutex_unlock(&mddev->open_mutex);
5493 5528
5494 check_disk_change(bdev); 5529 check_disk_change(bdev);
5495 out: 5530 out:
diff --git a/drivers/md/md.h b/drivers/md/md.h
index 9430a110db93..f8fc188bc762 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -223,6 +223,16 @@ struct mddev_s
223 * so we don't loop trying */ 223 * so we don't loop trying */
224 224
225 int in_sync; /* know to not need resync */ 225 int in_sync; /* know to not need resync */
226 /* 'open_mutex' avoids races between 'md_open' and 'do_md_stop', so
227 * that we are never stopping an array while it is open.
228 * 'reconfig_mutex' protects all other reconfiguration.
229 * These locks are separate due to conflicting interactions
230 * with bdev->bd_mutex.
231 * Lock ordering is:
232 * reconfig_mutex -> bd_mutex : e.g. do_md_run -> revalidate_disk
233 * bd_mutex -> open_mutex: e.g. __blkdev_get -> md_open
234 */
235 struct mutex open_mutex;
226 struct mutex reconfig_mutex; 236 struct mutex reconfig_mutex;
227 atomic_t active; /* general refcount */ 237 atomic_t active; /* general refcount */
228 atomic_t openers; /* number of active opens */ 238 atomic_t openers; /* number of active opens */
@@ -431,5 +441,7 @@ extern int md_allow_write(mddev_t *mddev);
431extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev); 441extern void md_wait_for_blocked_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
432extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors); 442extern void md_set_array_sectors(mddev_t *mddev, sector_t array_sectors);
433extern int md_check_no_bitmap(mddev_t *mddev); 443extern int md_check_no_bitmap(mddev_t *mddev);
444extern int md_integrity_register(mddev_t *mddev);
445void md_integrity_add_rdev(mdk_rdev_t *rdev, mddev_t *mddev);
434 446
435#endif /* _MD_MD_H */ 447#endif /* _MD_MD_H */
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 237fe3fd235c..7140909f6662 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -313,6 +313,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
313 set_bit(In_sync, &rdev->flags); 313 set_bit(In_sync, &rdev->flags);
314 rcu_assign_pointer(p->rdev, rdev); 314 rcu_assign_pointer(p->rdev, rdev);
315 err = 0; 315 err = 0;
316 md_integrity_add_rdev(rdev, mddev);
316 break; 317 break;
317 } 318 }
318 319
@@ -345,7 +346,9 @@ static int multipath_remove_disk(mddev_t *mddev, int number)
345 /* lost the race, try later */ 346 /* lost the race, try later */
346 err = -EBUSY; 347 err = -EBUSY;
347 p->rdev = rdev; 348 p->rdev = rdev;
349 goto abort;
348 } 350 }
351 md_integrity_register(mddev);
349 } 352 }
350abort: 353abort:
351 354
@@ -519,7 +522,7 @@ static int multipath_run (mddev_t *mddev)
519 mddev->queue->unplug_fn = multipath_unplug; 522 mddev->queue->unplug_fn = multipath_unplug;
520 mddev->queue->backing_dev_info.congested_fn = multipath_congested; 523 mddev->queue->backing_dev_info.congested_fn = multipath_congested;
521 mddev->queue->backing_dev_info.congested_data = mddev; 524 mddev->queue->backing_dev_info.congested_data = mddev;
522 525 md_integrity_register(mddev);
523 return 0; 526 return 0;
524 527
525out_free_conf: 528out_free_conf:
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index 335f490dcad6..898e2bdfee47 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -351,6 +351,7 @@ static int raid0_run(mddev_t *mddev)
351 351
352 blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec); 352 blk_queue_merge_bvec(mddev->queue, raid0_mergeable_bvec);
353 dump_zones(mddev); 353 dump_zones(mddev);
354 md_integrity_register(mddev);
354 return 0; 355 return 0;
355} 356}
356 357
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 0569efba0c02..8726fd7ebce5 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1144,7 +1144,7 @@ static int raid1_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1144 rcu_assign_pointer(p->rdev, rdev); 1144 rcu_assign_pointer(p->rdev, rdev);
1145 break; 1145 break;
1146 } 1146 }
1147 1147 md_integrity_add_rdev(rdev, mddev);
1148 print_conf(conf); 1148 print_conf(conf);
1149 return err; 1149 return err;
1150} 1150}
@@ -1178,7 +1178,9 @@ static int raid1_remove_disk(mddev_t *mddev, int number)
1178 /* lost the race, try later */ 1178 /* lost the race, try later */
1179 err = -EBUSY; 1179 err = -EBUSY;
1180 p->rdev = rdev; 1180 p->rdev = rdev;
1181 goto abort;
1181 } 1182 }
1183 md_integrity_register(mddev);
1182 } 1184 }
1183abort: 1185abort:
1184 1186
@@ -2067,7 +2069,7 @@ static int run(mddev_t *mddev)
2067 mddev->queue->unplug_fn = raid1_unplug; 2069 mddev->queue->unplug_fn = raid1_unplug;
2068 mddev->queue->backing_dev_info.congested_fn = raid1_congested; 2070 mddev->queue->backing_dev_info.congested_fn = raid1_congested;
2069 mddev->queue->backing_dev_info.congested_data = mddev; 2071 mddev->queue->backing_dev_info.congested_data = mddev;
2070 2072 md_integrity_register(mddev);
2071 return 0; 2073 return 0;
2072 2074
2073out_no_mem: 2075out_no_mem:
@@ -2132,6 +2134,7 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors)
2132 return -EINVAL; 2134 return -EINVAL;
2133 set_capacity(mddev->gendisk, mddev->array_sectors); 2135 set_capacity(mddev->gendisk, mddev->array_sectors);
2134 mddev->changed = 1; 2136 mddev->changed = 1;
2137 revalidate_disk(mddev->gendisk);
2135 if (sectors > mddev->dev_sectors && 2138 if (sectors > mddev->dev_sectors &&
2136 mddev->recovery_cp == MaxSector) { 2139 mddev->recovery_cp == MaxSector) {
2137 mddev->recovery_cp = mddev->dev_sectors; 2140 mddev->recovery_cp = mddev->dev_sectors;
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 7298a5e5a183..3d9020cf6f6e 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1170,6 +1170,7 @@ static int raid10_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
1170 break; 1170 break;
1171 } 1171 }
1172 1172
1173 md_integrity_add_rdev(rdev, mddev);
1173 print_conf(conf); 1174 print_conf(conf);
1174 return err; 1175 return err;
1175} 1176}
@@ -1203,7 +1204,9 @@ static int raid10_remove_disk(mddev_t *mddev, int number)
1203 /* lost the race, try later */ 1204 /* lost the race, try later */
1204 err = -EBUSY; 1205 err = -EBUSY;
1205 p->rdev = rdev; 1206 p->rdev = rdev;
1207 goto abort;
1206 } 1208 }
1209 md_integrity_register(mddev);
1207 } 1210 }
1208abort: 1211abort:
1209 1212
@@ -2225,6 +2228,7 @@ static int run(mddev_t *mddev)
2225 2228
2226 if (conf->near_copies < mddev->raid_disks) 2229 if (conf->near_copies < mddev->raid_disks)
2227 blk_queue_merge_bvec(mddev->queue, raid10_mergeable_bvec); 2230 blk_queue_merge_bvec(mddev->queue, raid10_mergeable_bvec);
2231 md_integrity_register(mddev);
2228 return 0; 2232 return 0;
2229 2233
2230out_free_conf: 2234out_free_conf:
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 37835538b58e..b8a2c5dc67ba 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3785,7 +3785,7 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
3785 conf->reshape_progress < raid5_size(mddev, 0, 0)) { 3785 conf->reshape_progress < raid5_size(mddev, 0, 0)) {
3786 sector_nr = raid5_size(mddev, 0, 0) 3786 sector_nr = raid5_size(mddev, 0, 0)
3787 - conf->reshape_progress; 3787 - conf->reshape_progress;
3788 } else if (mddev->delta_disks > 0 && 3788 } else if (mddev->delta_disks >= 0 &&
3789 conf->reshape_progress > 0) 3789 conf->reshape_progress > 0)
3790 sector_nr = conf->reshape_progress; 3790 sector_nr = conf->reshape_progress;
3791 sector_div(sector_nr, new_data_disks); 3791 sector_div(sector_nr, new_data_disks);
@@ -3999,6 +3999,9 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski
3999 return 0; 3999 return 0;
4000 } 4000 }
4001 4001
4002 /* Allow raid5_quiesce to complete */
4003 wait_event(conf->wait_for_overlap, conf->quiesce != 2);
4004
4002 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery)) 4005 if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
4003 return reshape_request(mddev, sector_nr, skipped); 4006 return reshape_request(mddev, sector_nr, skipped);
4004 4007
@@ -4316,6 +4319,15 @@ raid5_size(mddev_t *mddev, sector_t sectors, int raid_disks)
4316 return sectors * (raid_disks - conf->max_degraded); 4319 return sectors * (raid_disks - conf->max_degraded);
4317} 4320}
4318 4321
4322static void free_conf(raid5_conf_t *conf)
4323{
4324 shrink_stripes(conf);
4325 safe_put_page(conf->spare_page);
4326 kfree(conf->disks);
4327 kfree(conf->stripe_hashtbl);
4328 kfree(conf);
4329}
4330
4319static raid5_conf_t *setup_conf(mddev_t *mddev) 4331static raid5_conf_t *setup_conf(mddev_t *mddev)
4320{ 4332{
4321 raid5_conf_t *conf; 4333 raid5_conf_t *conf;
@@ -4447,11 +4459,7 @@ static raid5_conf_t *setup_conf(mddev_t *mddev)
4447 4459
4448 abort: 4460 abort:
4449 if (conf) { 4461 if (conf) {
4450 shrink_stripes(conf); 4462 free_conf(conf);
4451 safe_put_page(conf->spare_page);
4452 kfree(conf->disks);
4453 kfree(conf->stripe_hashtbl);
4454 kfree(conf);
4455 return ERR_PTR(-EIO); 4463 return ERR_PTR(-EIO);
4456 } else 4464 } else
4457 return ERR_PTR(-ENOMEM); 4465 return ERR_PTR(-ENOMEM);
@@ -4501,7 +4509,26 @@ static int run(mddev_t *mddev)
4501 (old_disks-max_degraded)); 4509 (old_disks-max_degraded));
4502 /* here_old is the first stripe that we might need to read 4510 /* here_old is the first stripe that we might need to read
4503 * from */ 4511 * from */
4504 if (here_new >= here_old) { 4512 if (mddev->delta_disks == 0) {
4513 /* We cannot be sure it is safe to start an in-place
4514 * reshape. It is only safe if user-space if monitoring
4515 * and taking constant backups.
4516 * mdadm always starts a situation like this in
4517 * readonly mode so it can take control before
4518 * allowing any writes. So just check for that.
4519 */
4520 if ((here_new * mddev->new_chunk_sectors !=
4521 here_old * mddev->chunk_sectors) ||
4522 mddev->ro == 0) {
4523 printk(KERN_ERR "raid5: in-place reshape must be started"
4524 " in read-only mode - aborting\n");
4525 return -EINVAL;
4526 }
4527 } else if (mddev->delta_disks < 0
4528 ? (here_new * mddev->new_chunk_sectors <=
4529 here_old * mddev->chunk_sectors)
4530 : (here_new * mddev->new_chunk_sectors >=
4531 here_old * mddev->chunk_sectors)) {
4505 /* Reading from the same stripe as writing to - bad */ 4532 /* Reading from the same stripe as writing to - bad */
4506 printk(KERN_ERR "raid5: reshape_position too early for " 4533 printk(KERN_ERR "raid5: reshape_position too early for "
4507 "auto-recovery - aborting.\n"); 4534 "auto-recovery - aborting.\n");
@@ -4629,12 +4656,8 @@ abort:
4629 md_unregister_thread(mddev->thread); 4656 md_unregister_thread(mddev->thread);
4630 mddev->thread = NULL; 4657 mddev->thread = NULL;
4631 if (conf) { 4658 if (conf) {
4632 shrink_stripes(conf);
4633 print_raid5_conf(conf); 4659 print_raid5_conf(conf);
4634 safe_put_page(conf->spare_page); 4660 free_conf(conf);
4635 kfree(conf->disks);
4636 kfree(conf->stripe_hashtbl);
4637 kfree(conf);
4638 } 4661 }
4639 mddev->private = NULL; 4662 mddev->private = NULL;
4640 printk(KERN_ALERT "raid5: failed to run raid set %s\n", mdname(mddev)); 4663 printk(KERN_ALERT "raid5: failed to run raid set %s\n", mdname(mddev));
@@ -4649,13 +4672,10 @@ static int stop(mddev_t *mddev)
4649 4672
4650 md_unregister_thread(mddev->thread); 4673 md_unregister_thread(mddev->thread);
4651 mddev->thread = NULL; 4674 mddev->thread = NULL;
4652 shrink_stripes(conf);
4653 kfree(conf->stripe_hashtbl);
4654 mddev->queue->backing_dev_info.congested_fn = NULL; 4675 mddev->queue->backing_dev_info.congested_fn = NULL;
4655 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/ 4676 blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
4656 sysfs_remove_group(&mddev->kobj, &raid5_attrs_group); 4677 sysfs_remove_group(&mddev->kobj, &raid5_attrs_group);
4657 kfree(conf->disks); 4678 free_conf(conf);
4658 kfree(conf);
4659 mddev->private = NULL; 4679 mddev->private = NULL;
4660 return 0; 4680 return 0;
4661} 4681}
@@ -4857,6 +4877,7 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors)
4857 return -EINVAL; 4877 return -EINVAL;
4858 set_capacity(mddev->gendisk, mddev->array_sectors); 4878 set_capacity(mddev->gendisk, mddev->array_sectors);
4859 mddev->changed = 1; 4879 mddev->changed = 1;
4880 revalidate_disk(mddev->gendisk);
4860 if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) { 4881 if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) {
4861 mddev->recovery_cp = mddev->dev_sectors; 4882 mddev->recovery_cp = mddev->dev_sectors;
4862 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); 4883 set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
@@ -5002,7 +5023,7 @@ static int raid5_start_reshape(mddev_t *mddev)
5002 spin_unlock_irqrestore(&conf->device_lock, flags); 5023 spin_unlock_irqrestore(&conf->device_lock, flags);
5003 } 5024 }
5004 mddev->raid_disks = conf->raid_disks; 5025 mddev->raid_disks = conf->raid_disks;
5005 mddev->reshape_position = 0; 5026 mddev->reshape_position = conf->reshape_progress;
5006 set_bit(MD_CHANGE_DEVS, &mddev->flags); 5027 set_bit(MD_CHANGE_DEVS, &mddev->flags);
5007 5028
5008 clear_bit(MD_RECOVERY_SYNC, &mddev->recovery); 5029 clear_bit(MD_RECOVERY_SYNC, &mddev->recovery);
@@ -5057,7 +5078,6 @@ static void end_reshape(raid5_conf_t *conf)
5057 */ 5078 */
5058static void raid5_finish_reshape(mddev_t *mddev) 5079static void raid5_finish_reshape(mddev_t *mddev)
5059{ 5080{
5060 struct block_device *bdev;
5061 raid5_conf_t *conf = mddev->private; 5081 raid5_conf_t *conf = mddev->private;
5062 5082
5063 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) { 5083 if (!test_bit(MD_RECOVERY_INTR, &mddev->recovery)) {
@@ -5066,15 +5086,7 @@ static void raid5_finish_reshape(mddev_t *mddev)
5066 md_set_array_sectors(mddev, raid5_size(mddev, 0, 0)); 5086 md_set_array_sectors(mddev, raid5_size(mddev, 0, 0));
5067 set_capacity(mddev->gendisk, mddev->array_sectors); 5087 set_capacity(mddev->gendisk, mddev->array_sectors);
5068 mddev->changed = 1; 5088 mddev->changed = 1;
5069 5089 revalidate_disk(mddev->gendisk);
5070 bdev = bdget_disk(mddev->gendisk, 0);
5071 if (bdev) {
5072 mutex_lock(&bdev->bd_inode->i_mutex);
5073 i_size_write(bdev->bd_inode,
5074 (loff_t)mddev->array_sectors << 9);
5075 mutex_unlock(&bdev->bd_inode->i_mutex);
5076 bdput(bdev);
5077 }
5078 } else { 5090 } else {
5079 int d; 5091 int d;
5080 mddev->degraded = conf->raid_disks; 5092 mddev->degraded = conf->raid_disks;
@@ -5085,8 +5097,15 @@ static void raid5_finish_reshape(mddev_t *mddev)
5085 mddev->degraded--; 5097 mddev->degraded--;
5086 for (d = conf->raid_disks ; 5098 for (d = conf->raid_disks ;
5087 d < conf->raid_disks - mddev->delta_disks; 5099 d < conf->raid_disks - mddev->delta_disks;
5088 d++) 5100 d++) {
5089 raid5_remove_disk(mddev, d); 5101 mdk_rdev_t *rdev = conf->disks[d].rdev;
5102 if (rdev && raid5_remove_disk(mddev, d) == 0) {
5103 char nm[20];
5104 sprintf(nm, "rd%d", rdev->raid_disk);
5105 sysfs_remove_link(&mddev->kobj, nm);
5106 rdev->raid_disk = -1;
5107 }
5108 }
5090 } 5109 }
5091 mddev->layout = conf->algorithm; 5110 mddev->layout = conf->algorithm;
5092 mddev->chunk_sectors = conf->chunk_sectors; 5111 mddev->chunk_sectors = conf->chunk_sectors;
@@ -5106,12 +5125,18 @@ static void raid5_quiesce(mddev_t *mddev, int state)
5106 5125
5107 case 1: /* stop all writes */ 5126 case 1: /* stop all writes */
5108 spin_lock_irq(&conf->device_lock); 5127 spin_lock_irq(&conf->device_lock);
5109 conf->quiesce = 1; 5128 /* '2' tells resync/reshape to pause so that all
5129 * active stripes can drain
5130 */
5131 conf->quiesce = 2;
5110 wait_event_lock_irq(conf->wait_for_stripe, 5132 wait_event_lock_irq(conf->wait_for_stripe,
5111 atomic_read(&conf->active_stripes) == 0 && 5133 atomic_read(&conf->active_stripes) == 0 &&
5112 atomic_read(&conf->active_aligned_reads) == 0, 5134 atomic_read(&conf->active_aligned_reads) == 0,
5113 conf->device_lock, /* nothing */); 5135 conf->device_lock, /* nothing */);
5136 conf->quiesce = 1;
5114 spin_unlock_irq(&conf->device_lock); 5137 spin_unlock_irq(&conf->device_lock);
5138 /* allow reshape to continue */
5139 wake_up(&conf->wait_for_overlap);
5115 break; 5140 break;
5116 5141
5117 case 0: /* re-enable writes */ 5142 case 0: /* re-enable writes */
diff --git a/drivers/media/common/tuners/qt1010.c b/drivers/media/common/tuners/qt1010.c
index 825aa1412e6f..9f5dba244cb8 100644
--- a/drivers/media/common/tuners/qt1010.c
+++ b/drivers/media/common/tuners/qt1010.c
@@ -64,24 +64,22 @@ static int qt1010_writereg(struct qt1010_priv *priv, u8 reg, u8 val)
64/* dump all registers */ 64/* dump all registers */
65static void qt1010_dump_regs(struct qt1010_priv *priv) 65static void qt1010_dump_regs(struct qt1010_priv *priv)
66{ 66{
67 char buf[52], buf2[4];
68 u8 reg, val; 67 u8 reg, val;
69 68
70 for (reg = 0; ; reg++) { 69 for (reg = 0; ; reg++) {
71 if (reg % 16 == 0) { 70 if (reg % 16 == 0) {
72 if (reg) 71 if (reg)
73 printk("%s\n", buf); 72 printk(KERN_CONT "\n");
74 sprintf(buf, "%02x: ", reg); 73 printk(KERN_DEBUG "%02x:", reg);
75 } 74 }
76 if (qt1010_readreg(priv, reg, &val) == 0) 75 if (qt1010_readreg(priv, reg, &val) == 0)
77 sprintf(buf2, "%02x ", val); 76 printk(KERN_CONT " %02x", val);
78 else 77 else
79 strcpy(buf2, "-- "); 78 printk(KERN_CONT " --");
80 strcat(buf, buf2);
81 if (reg == 0x2f) 79 if (reg == 0x2f)
82 break; 80 break;
83 } 81 }
84 printk("%s\n", buf); 82 printk(KERN_CONT "\n");
85} 83}
86 84
87static int qt1010_set_params(struct dvb_frontend *fe, 85static int qt1010_set_params(struct dvb_frontend *fe,
diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
index aa20ce8cc668..f270e605da83 100644
--- a/drivers/media/common/tuners/tuner-xc2028.c
+++ b/drivers/media/common/tuners/tuner-xc2028.c
@@ -1119,8 +1119,8 @@ static int xc2028_sleep(struct dvb_frontend *fe)
1119 struct xc2028_data *priv = fe->tuner_priv; 1119 struct xc2028_data *priv = fe->tuner_priv;
1120 int rc = 0; 1120 int rc = 0;
1121 1121
1122 /* Avoid firmware reload on slow devices */ 1122 /* Avoid firmware reload on slow devices or if PM disabled */
1123 if (no_poweroff) 1123 if (no_poweroff || priv->ctrl.disable_power_mgmt)
1124 return 0; 1124 return 0;
1125 1125
1126 tuner_dbg("Putting xc2028/3028 into poweroff mode.\n"); 1126 tuner_dbg("Putting xc2028/3028 into poweroff mode.\n");
diff --git a/drivers/media/common/tuners/tuner-xc2028.h b/drivers/media/common/tuners/tuner-xc2028.h
index 19de7928a74e..a90c35d50add 100644
--- a/drivers/media/common/tuners/tuner-xc2028.h
+++ b/drivers/media/common/tuners/tuner-xc2028.h
@@ -38,6 +38,7 @@ struct xc2028_ctrl {
38 unsigned int input1:1; 38 unsigned int input1:1;
39 unsigned int vhfbw7:1; 39 unsigned int vhfbw7:1;
40 unsigned int uhfbw8:1; 40 unsigned int uhfbw8:1;
41 unsigned int disable_power_mgmt:1;
41 unsigned int demod; 42 unsigned int demod;
42 enum firmware_type type:2; 43 enum firmware_type type:2;
43}; 44};
diff --git a/drivers/media/dvb/dvb-usb/af9015.c b/drivers/media/dvb/dvb-usb/af9015.c
index 4cb31e7c13c2..26690dfb3260 100644
--- a/drivers/media/dvb/dvb-usb/af9015.c
+++ b/drivers/media/dvb/dvb-usb/af9015.c
@@ -81,7 +81,6 @@ static int af9015_rw_udev(struct usb_device *udev, struct req_t *req)
81 81
82 switch (req->cmd) { 82 switch (req->cmd) {
83 case GET_CONFIG: 83 case GET_CONFIG:
84 case BOOT:
85 case READ_MEMORY: 84 case READ_MEMORY:
86 case RECONNECT_USB: 85 case RECONNECT_USB:
87 case GET_IR_CODE: 86 case GET_IR_CODE:
@@ -100,6 +99,7 @@ static int af9015_rw_udev(struct usb_device *udev, struct req_t *req)
100 case WRITE_VIRTUAL_MEMORY: 99 case WRITE_VIRTUAL_MEMORY:
101 case COPY_FIRMWARE: 100 case COPY_FIRMWARE:
102 case DOWNLOAD_FIRMWARE: 101 case DOWNLOAD_FIRMWARE:
102 case BOOT:
103 break; 103 break;
104 default: 104 default:
105 err("unknown command:%d", req->cmd); 105 err("unknown command:%d", req->cmd);
diff --git a/drivers/media/dvb/frontends/cx22700.c b/drivers/media/dvb/frontends/cx22700.c
index ace5cb17165d..fbd838eca268 100644
--- a/drivers/media/dvb/frontends/cx22700.c
+++ b/drivers/media/dvb/frontends/cx22700.c
@@ -380,7 +380,7 @@ struct dvb_frontend* cx22700_attach(const struct cx22700_config* config,
380 struct cx22700_state* state = NULL; 380 struct cx22700_state* state = NULL;
381 381
382 /* allocate memory for the internal state */ 382 /* allocate memory for the internal state */
383 state = kmalloc(sizeof(struct cx22700_state), GFP_KERNEL); 383 state = kzalloc(sizeof(struct cx22700_state), GFP_KERNEL);
384 if (state == NULL) goto error; 384 if (state == NULL) goto error;
385 385
386 /* setup the state */ 386 /* setup the state */
diff --git a/drivers/media/dvb/frontends/cx22702.c b/drivers/media/dvb/frontends/cx22702.c
index 5d1abe34bddb..00b5c7e91d5d 100644
--- a/drivers/media/dvb/frontends/cx22702.c
+++ b/drivers/media/dvb/frontends/cx22702.c
@@ -580,7 +580,7 @@ struct dvb_frontend *cx22702_attach(const struct cx22702_config *config,
580 struct cx22702_state *state = NULL; 580 struct cx22702_state *state = NULL;
581 581
582 /* allocate memory for the internal state */ 582 /* allocate memory for the internal state */
583 state = kmalloc(sizeof(struct cx22702_state), GFP_KERNEL); 583 state = kzalloc(sizeof(struct cx22702_state), GFP_KERNEL);
584 if (state == NULL) 584 if (state == NULL)
585 goto error; 585 goto error;
586 586
diff --git a/drivers/media/dvb/frontends/cx24110.c b/drivers/media/dvb/frontends/cx24110.c
index 87ae29db024f..ffbcfabd83f0 100644
--- a/drivers/media/dvb/frontends/cx24110.c
+++ b/drivers/media/dvb/frontends/cx24110.c
@@ -598,7 +598,7 @@ struct dvb_frontend* cx24110_attach(const struct cx24110_config* config,
598 int ret; 598 int ret;
599 599
600 /* allocate memory for the internal state */ 600 /* allocate memory for the internal state */
601 state = kmalloc(sizeof(struct cx24110_state), GFP_KERNEL); 601 state = kzalloc(sizeof(struct cx24110_state), GFP_KERNEL);
602 if (state == NULL) goto error; 602 if (state == NULL) goto error;
603 603
604 /* setup the state */ 604 /* setup the state */
diff --git a/drivers/media/dvb/frontends/dvb_dummy_fe.c b/drivers/media/dvb/frontends/dvb_dummy_fe.c
index db8a937cc630..a7fc7e53a551 100644
--- a/drivers/media/dvb/frontends/dvb_dummy_fe.c
+++ b/drivers/media/dvb/frontends/dvb_dummy_fe.c
@@ -117,7 +117,7 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
117 struct dvb_dummy_fe_state* state = NULL; 117 struct dvb_dummy_fe_state* state = NULL;
118 118
119 /* allocate memory for the internal state */ 119 /* allocate memory for the internal state */
120 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 120 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
121 if (state == NULL) goto error; 121 if (state == NULL) goto error;
122 122
123 /* create dvb_frontend */ 123 /* create dvb_frontend */
@@ -137,7 +137,7 @@ struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
137 struct dvb_dummy_fe_state* state = NULL; 137 struct dvb_dummy_fe_state* state = NULL;
138 138
139 /* allocate memory for the internal state */ 139 /* allocate memory for the internal state */
140 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 140 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
141 if (state == NULL) goto error; 141 if (state == NULL) goto error;
142 142
143 /* create dvb_frontend */ 143 /* create dvb_frontend */
@@ -157,7 +157,7 @@ struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
157 struct dvb_dummy_fe_state* state = NULL; 157 struct dvb_dummy_fe_state* state = NULL;
158 158
159 /* allocate memory for the internal state */ 159 /* allocate memory for the internal state */
160 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL); 160 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
161 if (state == NULL) goto error; 161 if (state == NULL) goto error;
162 162
163 /* create dvb_frontend */ 163 /* create dvb_frontend */
diff --git a/drivers/media/dvb/frontends/l64781.c b/drivers/media/dvb/frontends/l64781.c
index e1e70e9e0cb9..3051b64aa17c 100644
--- a/drivers/media/dvb/frontends/l64781.c
+++ b/drivers/media/dvb/frontends/l64781.c
@@ -501,7 +501,7 @@ struct dvb_frontend* l64781_attach(const struct l64781_config* config,
501 { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } }; 501 { .addr = config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
502 502
503 /* allocate memory for the internal state */ 503 /* allocate memory for the internal state */
504 state = kmalloc(sizeof(struct l64781_state), GFP_KERNEL); 504 state = kzalloc(sizeof(struct l64781_state), GFP_KERNEL);
505 if (state == NULL) goto error; 505 if (state == NULL) goto error;
506 506
507 /* setup the state */ 507 /* setup the state */
diff --git a/drivers/media/dvb/frontends/lgs8gl5.c b/drivers/media/dvb/frontends/lgs8gl5.c
index 855852fddf22..bb37ed289a05 100644
--- a/drivers/media/dvb/frontends/lgs8gl5.c
+++ b/drivers/media/dvb/frontends/lgs8gl5.c
@@ -387,7 +387,7 @@ lgs8gl5_attach(const struct lgs8gl5_config *config, struct i2c_adapter *i2c)
387 dprintk("%s\n", __func__); 387 dprintk("%s\n", __func__);
388 388
389 /* Allocate memory for the internal state */ 389 /* Allocate memory for the internal state */
390 state = kmalloc(sizeof(struct lgs8gl5_state), GFP_KERNEL); 390 state = kzalloc(sizeof(struct lgs8gl5_state), GFP_KERNEL);
391 if (state == NULL) 391 if (state == NULL)
392 goto error; 392 goto error;
393 393
diff --git a/drivers/media/dvb/frontends/mt312.c b/drivers/media/dvb/frontends/mt312.c
index a621f727935f..f69daaac78c9 100644
--- a/drivers/media/dvb/frontends/mt312.c
+++ b/drivers/media/dvb/frontends/mt312.c
@@ -782,7 +782,7 @@ struct dvb_frontend *mt312_attach(const struct mt312_config *config,
782 struct mt312_state *state = NULL; 782 struct mt312_state *state = NULL;
783 783
784 /* allocate memory for the internal state */ 784 /* allocate memory for the internal state */
785 state = kmalloc(sizeof(struct mt312_state), GFP_KERNEL); 785 state = kzalloc(sizeof(struct mt312_state), GFP_KERNEL);
786 if (state == NULL) 786 if (state == NULL)
787 goto error; 787 goto error;
788 788
diff --git a/drivers/media/dvb/frontends/nxt6000.c b/drivers/media/dvb/frontends/nxt6000.c
index 0eef22dbf8a0..a763ec756f7f 100644
--- a/drivers/media/dvb/frontends/nxt6000.c
+++ b/drivers/media/dvb/frontends/nxt6000.c
@@ -545,7 +545,7 @@ struct dvb_frontend* nxt6000_attach(const struct nxt6000_config* config,
545 struct nxt6000_state* state = NULL; 545 struct nxt6000_state* state = NULL;
546 546
547 /* allocate memory for the internal state */ 547 /* allocate memory for the internal state */
548 state = kmalloc(sizeof(struct nxt6000_state), GFP_KERNEL); 548 state = kzalloc(sizeof(struct nxt6000_state), GFP_KERNEL);
549 if (state == NULL) goto error; 549 if (state == NULL) goto error;
550 550
551 /* setup the state */ 551 /* setup the state */
diff --git a/drivers/media/dvb/frontends/or51132.c b/drivers/media/dvb/frontends/or51132.c
index 8133ea3cddd7..38e67accb8c3 100644
--- a/drivers/media/dvb/frontends/or51132.c
+++ b/drivers/media/dvb/frontends/or51132.c
@@ -562,7 +562,7 @@ struct dvb_frontend* or51132_attach(const struct or51132_config* config,
562 struct or51132_state* state = NULL; 562 struct or51132_state* state = NULL;
563 563
564 /* Allocate memory for the internal state */ 564 /* Allocate memory for the internal state */
565 state = kmalloc(sizeof(struct or51132_state), GFP_KERNEL); 565 state = kzalloc(sizeof(struct or51132_state), GFP_KERNEL);
566 if (state == NULL) 566 if (state == NULL)
567 return NULL; 567 return NULL;
568 568
diff --git a/drivers/media/dvb/frontends/or51211.c b/drivers/media/dvb/frontends/or51211.c
index 16cf2fdd5d7d..c709ce6771c8 100644
--- a/drivers/media/dvb/frontends/or51211.c
+++ b/drivers/media/dvb/frontends/or51211.c
@@ -527,7 +527,7 @@ struct dvb_frontend* or51211_attach(const struct or51211_config* config,
527 struct or51211_state* state = NULL; 527 struct or51211_state* state = NULL;
528 528
529 /* Allocate memory for the internal state */ 529 /* Allocate memory for the internal state */
530 state = kmalloc(sizeof(struct or51211_state), GFP_KERNEL); 530 state = kzalloc(sizeof(struct or51211_state), GFP_KERNEL);
531 if (state == NULL) 531 if (state == NULL)
532 return NULL; 532 return NULL;
533 533
diff --git a/drivers/media/dvb/frontends/s5h1409.c b/drivers/media/dvb/frontends/s5h1409.c
index 3e08d985d6e5..fb3011518427 100644
--- a/drivers/media/dvb/frontends/s5h1409.c
+++ b/drivers/media/dvb/frontends/s5h1409.c
@@ -796,7 +796,7 @@ struct dvb_frontend *s5h1409_attach(const struct s5h1409_config *config,
796 u16 reg; 796 u16 reg;
797 797
798 /* allocate memory for the internal state */ 798 /* allocate memory for the internal state */
799 state = kmalloc(sizeof(struct s5h1409_state), GFP_KERNEL); 799 state = kzalloc(sizeof(struct s5h1409_state), GFP_KERNEL);
800 if (state == NULL) 800 if (state == NULL)
801 goto error; 801 goto error;
802 802
diff --git a/drivers/media/dvb/frontends/s5h1411.c b/drivers/media/dvb/frontends/s5h1411.c
index 66e2dd6d6fe4..d8adf1e32019 100644
--- a/drivers/media/dvb/frontends/s5h1411.c
+++ b/drivers/media/dvb/frontends/s5h1411.c
@@ -844,7 +844,7 @@ struct dvb_frontend *s5h1411_attach(const struct s5h1411_config *config,
844 u16 reg; 844 u16 reg;
845 845
846 /* allocate memory for the internal state */ 846 /* allocate memory for the internal state */
847 state = kmalloc(sizeof(struct s5h1411_state), GFP_KERNEL); 847 state = kzalloc(sizeof(struct s5h1411_state), GFP_KERNEL);
848 if (state == NULL) 848 if (state == NULL)
849 goto error; 849 goto error;
850 850
diff --git a/drivers/media/dvb/frontends/si21xx.c b/drivers/media/dvb/frontends/si21xx.c
index 0bd16af8a6cd..9552a22ccffb 100644
--- a/drivers/media/dvb/frontends/si21xx.c
+++ b/drivers/media/dvb/frontends/si21xx.c
@@ -928,7 +928,7 @@ struct dvb_frontend *si21xx_attach(const struct si21xx_config *config,
928 dprintk("%s\n", __func__); 928 dprintk("%s\n", __func__);
929 929
930 /* allocate memory for the internal state */ 930 /* allocate memory for the internal state */
931 state = kmalloc(sizeof(struct si21xx_state), GFP_KERNEL); 931 state = kzalloc(sizeof(struct si21xx_state), GFP_KERNEL);
932 if (state == NULL) 932 if (state == NULL)
933 goto error; 933 goto error;
934 934
diff --git a/drivers/media/dvb/frontends/sp8870.c b/drivers/media/dvb/frontends/sp8870.c
index 1c9a9b4051b9..b85eb60a893e 100644
--- a/drivers/media/dvb/frontends/sp8870.c
+++ b/drivers/media/dvb/frontends/sp8870.c
@@ -557,7 +557,7 @@ struct dvb_frontend* sp8870_attach(const struct sp8870_config* config,
557 struct sp8870_state* state = NULL; 557 struct sp8870_state* state = NULL;
558 558
559 /* allocate memory for the internal state */ 559 /* allocate memory for the internal state */
560 state = kmalloc(sizeof(struct sp8870_state), GFP_KERNEL); 560 state = kzalloc(sizeof(struct sp8870_state), GFP_KERNEL);
561 if (state == NULL) goto error; 561 if (state == NULL) goto error;
562 562
563 /* setup the state */ 563 /* setup the state */
diff --git a/drivers/media/dvb/frontends/sp887x.c b/drivers/media/dvb/frontends/sp887x.c
index 559509ab4dab..4a7c3d842608 100644
--- a/drivers/media/dvb/frontends/sp887x.c
+++ b/drivers/media/dvb/frontends/sp887x.c
@@ -557,7 +557,7 @@ struct dvb_frontend* sp887x_attach(const struct sp887x_config* config,
557 struct sp887x_state* state = NULL; 557 struct sp887x_state* state = NULL;
558 558
559 /* allocate memory for the internal state */ 559 /* allocate memory for the internal state */
560 state = kmalloc(sizeof(struct sp887x_state), GFP_KERNEL); 560 state = kzalloc(sizeof(struct sp887x_state), GFP_KERNEL);
561 if (state == NULL) goto error; 561 if (state == NULL) goto error;
562 562
563 /* setup the state */ 563 /* setup the state */
diff --git a/drivers/media/dvb/frontends/stv0288.c b/drivers/media/dvb/frontends/stv0288.c
index ff1194de34c0..2930a5d6768a 100644
--- a/drivers/media/dvb/frontends/stv0288.c
+++ b/drivers/media/dvb/frontends/stv0288.c
@@ -570,7 +570,7 @@ struct dvb_frontend *stv0288_attach(const struct stv0288_config *config,
570 int id; 570 int id;
571 571
572 /* allocate memory for the internal state */ 572 /* allocate memory for the internal state */
573 state = kmalloc(sizeof(struct stv0288_state), GFP_KERNEL); 573 state = kzalloc(sizeof(struct stv0288_state), GFP_KERNEL);
574 if (state == NULL) 574 if (state == NULL)
575 goto error; 575 goto error;
576 576
diff --git a/drivers/media/dvb/frontends/stv0297.c b/drivers/media/dvb/frontends/stv0297.c
index 62caf802ed99..4fd7479bb62b 100644
--- a/drivers/media/dvb/frontends/stv0297.c
+++ b/drivers/media/dvb/frontends/stv0297.c
@@ -663,7 +663,7 @@ struct dvb_frontend *stv0297_attach(const struct stv0297_config *config,
663 struct stv0297_state *state = NULL; 663 struct stv0297_state *state = NULL;
664 664
665 /* allocate memory for the internal state */ 665 /* allocate memory for the internal state */
666 state = kmalloc(sizeof(struct stv0297_state), GFP_KERNEL); 666 state = kzalloc(sizeof(struct stv0297_state), GFP_KERNEL);
667 if (state == NULL) 667 if (state == NULL)
668 goto error; 668 goto error;
669 669
diff --git a/drivers/media/dvb/frontends/stv0299.c b/drivers/media/dvb/frontends/stv0299.c
index 6c1cb1973c6e..968874469726 100644
--- a/drivers/media/dvb/frontends/stv0299.c
+++ b/drivers/media/dvb/frontends/stv0299.c
@@ -667,7 +667,7 @@ struct dvb_frontend* stv0299_attach(const struct stv0299_config* config,
667 int id; 667 int id;
668 668
669 /* allocate memory for the internal state */ 669 /* allocate memory for the internal state */
670 state = kmalloc(sizeof(struct stv0299_state), GFP_KERNEL); 670 state = kzalloc(sizeof(struct stv0299_state), GFP_KERNEL);
671 if (state == NULL) goto error; 671 if (state == NULL) goto error;
672 672
673 /* setup the state */ 673 /* setup the state */
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c
index f648fdb64bb7..f5d7b3277a2f 100644
--- a/drivers/media/dvb/frontends/tda10021.c
+++ b/drivers/media/dvb/frontends/tda10021.c
@@ -413,7 +413,7 @@ struct dvb_frontend* tda10021_attach(const struct tda1002x_config* config,
413 u8 id; 413 u8 id;
414 414
415 /* allocate memory for the internal state */ 415 /* allocate memory for the internal state */
416 state = kmalloc(sizeof(struct tda10021_state), GFP_KERNEL); 416 state = kzalloc(sizeof(struct tda10021_state), GFP_KERNEL);
417 if (state == NULL) goto error; 417 if (state == NULL) goto error;
418 418
419 /* setup the state */ 419 /* setup the state */
diff --git a/drivers/media/dvb/frontends/tda10048.c b/drivers/media/dvb/frontends/tda10048.c
index cc8862ce4aae..4e2a7c8b2f62 100644
--- a/drivers/media/dvb/frontends/tda10048.c
+++ b/drivers/media/dvb/frontends/tda10048.c
@@ -1095,7 +1095,7 @@ struct dvb_frontend *tda10048_attach(const struct tda10048_config *config,
1095 dprintk(1, "%s()\n", __func__); 1095 dprintk(1, "%s()\n", __func__);
1096 1096
1097 /* allocate memory for the internal state */ 1097 /* allocate memory for the internal state */
1098 state = kmalloc(sizeof(struct tda10048_state), GFP_KERNEL); 1098 state = kzalloc(sizeof(struct tda10048_state), GFP_KERNEL);
1099 if (state == NULL) 1099 if (state == NULL)
1100 goto error; 1100 goto error;
1101 1101
diff --git a/drivers/media/dvb/frontends/tda1004x.c b/drivers/media/dvb/frontends/tda1004x.c
index 4981cef8b444..f2a8abe0a243 100644
--- a/drivers/media/dvb/frontends/tda1004x.c
+++ b/drivers/media/dvb/frontends/tda1004x.c
@@ -1269,7 +1269,7 @@ struct dvb_frontend* tda10045_attach(const struct tda1004x_config* config,
1269 int id; 1269 int id;
1270 1270
1271 /* allocate memory for the internal state */ 1271 /* allocate memory for the internal state */
1272 state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); 1272 state = kzalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
1273 if (!state) { 1273 if (!state) {
1274 printk(KERN_ERR "Can't alocate memory for tda10045 state\n"); 1274 printk(KERN_ERR "Can't alocate memory for tda10045 state\n");
1275 return NULL; 1275 return NULL;
@@ -1339,7 +1339,7 @@ struct dvb_frontend* tda10046_attach(const struct tda1004x_config* config,
1339 int id; 1339 int id;
1340 1340
1341 /* allocate memory for the internal state */ 1341 /* allocate memory for the internal state */
1342 state = kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL); 1342 state = kzalloc(sizeof(struct tda1004x_state), GFP_KERNEL);
1343 if (!state) { 1343 if (!state) {
1344 printk(KERN_ERR "Can't alocate memory for tda10046 state\n"); 1344 printk(KERN_ERR "Can't alocate memory for tda10046 state\n");
1345 return NULL; 1345 return NULL;
diff --git a/drivers/media/dvb/frontends/tda10086.c b/drivers/media/dvb/frontends/tda10086.c
index a17ce3c4ad86..f2c8faac6f36 100644
--- a/drivers/media/dvb/frontends/tda10086.c
+++ b/drivers/media/dvb/frontends/tda10086.c
@@ -745,7 +745,7 @@ struct dvb_frontend* tda10086_attach(const struct tda10086_config* config,
745 dprintk ("%s\n", __func__); 745 dprintk ("%s\n", __func__);
746 746
747 /* allocate memory for the internal state */ 747 /* allocate memory for the internal state */
748 state = kmalloc(sizeof(struct tda10086_state), GFP_KERNEL); 748 state = kzalloc(sizeof(struct tda10086_state), GFP_KERNEL);
749 if (!state) 749 if (!state)
750 return NULL; 750 return NULL;
751 751
diff --git a/drivers/media/dvb/frontends/tda8083.c b/drivers/media/dvb/frontends/tda8083.c
index 5b843b2e67e8..9369f7442f27 100644
--- a/drivers/media/dvb/frontends/tda8083.c
+++ b/drivers/media/dvb/frontends/tda8083.c
@@ -417,7 +417,7 @@ struct dvb_frontend* tda8083_attach(const struct tda8083_config* config,
417 struct tda8083_state* state = NULL; 417 struct tda8083_state* state = NULL;
418 418
419 /* allocate memory for the internal state */ 419 /* allocate memory for the internal state */
420 state = kmalloc(sizeof(struct tda8083_state), GFP_KERNEL); 420 state = kzalloc(sizeof(struct tda8083_state), GFP_KERNEL);
421 if (state == NULL) goto error; 421 if (state == NULL) goto error;
422 422
423 /* setup the state */ 423 /* setup the state */
diff --git a/drivers/media/dvb/frontends/ves1820.c b/drivers/media/dvb/frontends/ves1820.c
index a184597f1d9b..6e78e4865515 100644
--- a/drivers/media/dvb/frontends/ves1820.c
+++ b/drivers/media/dvb/frontends/ves1820.c
@@ -374,7 +374,7 @@ struct dvb_frontend* ves1820_attach(const struct ves1820_config* config,
374 struct ves1820_state* state = NULL; 374 struct ves1820_state* state = NULL;
375 375
376 /* allocate memory for the internal state */ 376 /* allocate memory for the internal state */
377 state = kmalloc(sizeof(struct ves1820_state), GFP_KERNEL); 377 state = kzalloc(sizeof(struct ves1820_state), GFP_KERNEL);
378 if (state == NULL) 378 if (state == NULL)
379 goto error; 379 goto error;
380 380
diff --git a/drivers/media/dvb/frontends/ves1x93.c b/drivers/media/dvb/frontends/ves1x93.c
index bd558960bd87..8d7854c2fb0c 100644
--- a/drivers/media/dvb/frontends/ves1x93.c
+++ b/drivers/media/dvb/frontends/ves1x93.c
@@ -456,7 +456,7 @@ struct dvb_frontend* ves1x93_attach(const struct ves1x93_config* config,
456 u8 identity; 456 u8 identity;
457 457
458 /* allocate memory for the internal state */ 458 /* allocate memory for the internal state */
459 state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL); 459 state = kzalloc(sizeof(struct ves1x93_state), GFP_KERNEL);
460 if (state == NULL) goto error; 460 if (state == NULL) goto error;
461 461
462 /* setup the state */ 462 /* setup the state */
diff --git a/drivers/media/dvb/frontends/zl10353.c b/drivers/media/dvb/frontends/zl10353.c
index 148b6f7f6cb2..66f5c1fb3074 100644
--- a/drivers/media/dvb/frontends/zl10353.c
+++ b/drivers/media/dvb/frontends/zl10353.c
@@ -98,7 +98,6 @@ static int zl10353_read_register(struct zl10353_state *state, u8 reg)
98static void zl10353_dump_regs(struct dvb_frontend *fe) 98static void zl10353_dump_regs(struct dvb_frontend *fe)
99{ 99{
100 struct zl10353_state *state = fe->demodulator_priv; 100 struct zl10353_state *state = fe->demodulator_priv;
101 char buf[52], buf2[4];
102 int ret; 101 int ret;
103 u8 reg; 102 u8 reg;
104 103
@@ -106,19 +105,18 @@ static void zl10353_dump_regs(struct dvb_frontend *fe)
106 for (reg = 0; ; reg++) { 105 for (reg = 0; ; reg++) {
107 if (reg % 16 == 0) { 106 if (reg % 16 == 0) {
108 if (reg) 107 if (reg)
109 printk(KERN_DEBUG "%s\n", buf); 108 printk(KERN_CONT "\n");
110 sprintf(buf, "%02x: ", reg); 109 printk(KERN_DEBUG "%02x:", reg);
111 } 110 }
112 ret = zl10353_read_register(state, reg); 111 ret = zl10353_read_register(state, reg);
113 if (ret >= 0) 112 if (ret >= 0)
114 sprintf(buf2, "%02x ", (u8)ret); 113 printk(KERN_CONT " %02x", (u8)ret);
115 else 114 else
116 strcpy(buf2, "-- "); 115 printk(KERN_CONT " --");
117 strcat(buf, buf2);
118 if (reg == 0xff) 116 if (reg == 0xff)
119 break; 117 break;
120 } 118 }
121 printk(KERN_DEBUG "%s\n", buf); 119 printk(KERN_CONT "\n");
122} 120}
123 121
124static void zl10353_calc_nominal_rate(struct dvb_frontend *fe, 122static void zl10353_calc_nominal_rate(struct dvb_frontend *fe,
diff --git a/drivers/media/dvb/siano/Kconfig b/drivers/media/dvb/siano/Kconfig
index dd863f261672..8c1aed77ea30 100644
--- a/drivers/media/dvb/siano/Kconfig
+++ b/drivers/media/dvb/siano/Kconfig
@@ -2,25 +2,33 @@
2# Siano Mobile Silicon Digital TV device configuration 2# Siano Mobile Silicon Digital TV device configuration
3# 3#
4 4
5config DVB_SIANO_SMS1XXX 5config SMS_SIANO_MDTV
6 tristate "Siano SMS1XXX USB dongle support" 6 tristate "Siano SMS1xxx based MDTV receiver"
7 depends on DVB_CORE && USB 7 depends on DVB_CORE && INPUT
8 ---help--- 8 ---help---
9 Choose Y here if you have a USB dongle with a SMS1XXX chipset. 9 Choose Y or M here if you have MDTV receiver with a Siano chipset.
10 10
11 To compile this driver as a module, choose M here: the 11 To compile this driver as a module, choose M here
12 module will be called sms1xxx. 12 (The module will be called smsmdtv).
13 13
14config DVB_SIANO_SMS1XXX_SMS_IDS 14 Further documentation on this driver can be found on the WWW
15 bool "Enable support for Siano Mobile Silicon default USB IDs" 15 at http://www.siano-ms.com/
16 depends on DVB_SIANO_SMS1XXX 16
17 default y 17if SMS_SIANO_MDTV
18 ---help--- 18menu "Siano module components"
19 Choose Y here if you have a USB dongle with a SMS1XXX chipset
20 that uses Siano Mobile Silicon's default usb vid:pid.
21 19
22 Choose N here if you would prefer to use Siano's external driver. 20# Hardware interfaces support
23 21
24 Further documentation on this driver can be found on the WWW at 22config SMS_USB_DRV
25 <http://www.siano-ms.com/>. 23 tristate "USB interface support"
24 depends on DVB_CORE && USB
25 ---help---
26 Choose if you would like to have Siano's support for USB interface
26 27
28config SMS_SDIO_DRV
29 tristate "SDIO interface support"
30 depends on DVB_CORE && MMC
31 ---help---
32 Choose if you would like to have Siano's support for SDIO interface
33endmenu
34endif # SMS_SIANO_MDTV
diff --git a/drivers/media/dvb/siano/Makefile b/drivers/media/dvb/siano/Makefile
index c6644d909433..c54140b5ab5a 100644
--- a/drivers/media/dvb/siano/Makefile
+++ b/drivers/media/dvb/siano/Makefile
@@ -1,8 +1,9 @@
1sms1xxx-objs := smscoreapi.o sms-cards.o smsendian.o smsir.o
2 1
3obj-$(CONFIG_DVB_SIANO_SMS1XXX) += sms1xxx.o 2smsmdtv-objs := smscoreapi.o sms-cards.o smsendian.o smsir.o
4obj-$(CONFIG_DVB_SIANO_SMS1XXX) += smsusb.o 3
5obj-$(CONFIG_DVB_SIANO_SMS1XXX) += smsdvb.o 4obj-$(CONFIG_SMS_SIANO_MDTV) += smsmdtv.o smsdvb.o
5obj-$(CONFIG_SMS_USB_DRV) += smsusb.o
6obj-$(CONFIG_SMS_SDIO_DRV) += smssdio.o
6 7
7EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core 8EXTRA_CFLAGS += -Idrivers/media/dvb/dvb-core
8 9
diff --git a/drivers/media/dvb/siano/sms-cards.c b/drivers/media/dvb/siano/sms-cards.c
index d8b15d583bde..0420e2885e75 100644
--- a/drivers/media/dvb/siano/sms-cards.c
+++ b/drivers/media/dvb/siano/sms-cards.c
@@ -116,99 +116,21 @@ static inline void sms_gpio_assign_11xx_default_led_config(
116 116
117int sms_board_event(struct smscore_device_t *coredev, 117int sms_board_event(struct smscore_device_t *coredev,
118 enum SMS_BOARD_EVENTS gevent) { 118 enum SMS_BOARD_EVENTS gevent) {
119 int board_id = smscore_get_board_id(coredev);
120 struct sms_board *board = sms_get_board(board_id);
121 struct smscore_gpio_config MyGpioConfig; 119 struct smscore_gpio_config MyGpioConfig;
122 120
123 sms_gpio_assign_11xx_default_led_config(&MyGpioConfig); 121 sms_gpio_assign_11xx_default_led_config(&MyGpioConfig);
124 122
125 switch (gevent) { 123 switch (gevent) {
126 case BOARD_EVENT_POWER_INIT: /* including hotplug */ 124 case BOARD_EVENT_POWER_INIT: /* including hotplug */
127 switch (board_id) {
128 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
129 /* set I/O and turn off all LEDs */
130 smscore_gpio_configure(coredev,
131 board->board_cfg.leds_power,
132 &MyGpioConfig);
133 smscore_gpio_set_level(coredev,
134 board->board_cfg.leds_power, 0);
135 smscore_gpio_configure(coredev, board->board_cfg.led0,
136 &MyGpioConfig);
137 smscore_gpio_set_level(coredev,
138 board->board_cfg.led0, 0);
139 smscore_gpio_configure(coredev, board->board_cfg.led1,
140 &MyGpioConfig);
141 smscore_gpio_set_level(coredev,
142 board->board_cfg.led1, 0);
143 break;
144 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
145 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
146 /* set I/O and turn off LNA */
147 smscore_gpio_configure(coredev,
148 board->board_cfg.foreign_lna0_ctrl,
149 &MyGpioConfig);
150 smscore_gpio_set_level(coredev,
151 board->board_cfg.foreign_lna0_ctrl,
152 0);
153 break;
154 }
155 break; /* BOARD_EVENT_BIND */ 125 break; /* BOARD_EVENT_BIND */
156 126
157 case BOARD_EVENT_POWER_SUSPEND: 127 case BOARD_EVENT_POWER_SUSPEND:
158 switch (board_id) {
159 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
160 smscore_gpio_set_level(coredev,
161 board->board_cfg.leds_power, 0);
162 smscore_gpio_set_level(coredev,
163 board->board_cfg.led0, 0);
164 smscore_gpio_set_level(coredev,
165 board->board_cfg.led1, 0);
166 break;
167 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
168 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
169 smscore_gpio_set_level(coredev,
170 board->board_cfg.foreign_lna0_ctrl,
171 0);
172 break;
173 }
174 break; /* BOARD_EVENT_POWER_SUSPEND */ 128 break; /* BOARD_EVENT_POWER_SUSPEND */
175 129
176 case BOARD_EVENT_POWER_RESUME: 130 case BOARD_EVENT_POWER_RESUME:
177 switch (board_id) {
178 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
179 smscore_gpio_set_level(coredev,
180 board->board_cfg.leds_power, 1);
181 smscore_gpio_set_level(coredev,
182 board->board_cfg.led0, 1);
183 smscore_gpio_set_level(coredev,
184 board->board_cfg.led1, 0);
185 break;
186 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
187 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
188 smscore_gpio_set_level(coredev,
189 board->board_cfg.foreign_lna0_ctrl,
190 1);
191 break;
192 }
193 break; /* BOARD_EVENT_POWER_RESUME */ 131 break; /* BOARD_EVENT_POWER_RESUME */
194 132
195 case BOARD_EVENT_BIND: 133 case BOARD_EVENT_BIND:
196 switch (board_id) {
197 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
198 smscore_gpio_set_level(coredev,
199 board->board_cfg.leds_power, 1);
200 smscore_gpio_set_level(coredev,
201 board->board_cfg.led0, 1);
202 smscore_gpio_set_level(coredev,
203 board->board_cfg.led1, 0);
204 break;
205 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD_R2:
206 case SMS1XXX_BOARD_HAUPPAUGE_TIGER_MINICARD:
207 smscore_gpio_set_level(coredev,
208 board->board_cfg.foreign_lna0_ctrl,
209 1);
210 break;
211 }
212 break; /* BOARD_EVENT_BIND */ 134 break; /* BOARD_EVENT_BIND */
213 135
214 case BOARD_EVENT_SCAN_PROG: 136 case BOARD_EVENT_SCAN_PROG:
@@ -218,20 +140,8 @@ int sms_board_event(struct smscore_device_t *coredev,
218 case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL: 140 case BOARD_EVENT_EMERGENCY_WARNING_SIGNAL:
219 break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */ 141 break; /* BOARD_EVENT_EMERGENCY_WARNING_SIGNAL */
220 case BOARD_EVENT_FE_LOCK: 142 case BOARD_EVENT_FE_LOCK:
221 switch (board_id) {
222 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
223 smscore_gpio_set_level(coredev,
224 board->board_cfg.led1, 1);
225 break;
226 }
227 break; /* BOARD_EVENT_FE_LOCK */ 143 break; /* BOARD_EVENT_FE_LOCK */
228 case BOARD_EVENT_FE_UNLOCK: 144 case BOARD_EVENT_FE_UNLOCK:
229 switch (board_id) {
230 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
231 smscore_gpio_set_level(coredev,
232 board->board_cfg.led1, 0);
233 break;
234 }
235 break; /* BOARD_EVENT_FE_UNLOCK */ 145 break; /* BOARD_EVENT_FE_UNLOCK */
236 case BOARD_EVENT_DEMOD_LOCK: 146 case BOARD_EVENT_DEMOD_LOCK:
237 break; /* BOARD_EVENT_DEMOD_LOCK */ 147 break; /* BOARD_EVENT_DEMOD_LOCK */
@@ -248,20 +158,8 @@ int sms_board_event(struct smscore_device_t *coredev,
248 case BOARD_EVENT_RECEPTION_LOST_0: 158 case BOARD_EVENT_RECEPTION_LOST_0:
249 break; /* BOARD_EVENT_RECEPTION_LOST_0 */ 159 break; /* BOARD_EVENT_RECEPTION_LOST_0 */
250 case BOARD_EVENT_MULTIPLEX_OK: 160 case BOARD_EVENT_MULTIPLEX_OK:
251 switch (board_id) {
252 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
253 smscore_gpio_set_level(coredev,
254 board->board_cfg.led1, 1);
255 break;
256 }
257 break; /* BOARD_EVENT_MULTIPLEX_OK */ 161 break; /* BOARD_EVENT_MULTIPLEX_OK */
258 case BOARD_EVENT_MULTIPLEX_ERRORS: 162 case BOARD_EVENT_MULTIPLEX_ERRORS:
259 switch (board_id) {
260 case SMS1XXX_BOARD_HAUPPAUGE_WINDHAM:
261 smscore_gpio_set_level(coredev,
262 board->board_cfg.led1, 0);
263 break;
264 }
265 break; /* BOARD_EVENT_MULTIPLEX_ERRORS */ 163 break; /* BOARD_EVENT_MULTIPLEX_ERRORS */
266 164
267 default: 165 default:
diff --git a/drivers/media/dvb/siano/smscoreapi.c b/drivers/media/dvb/siano/smscoreapi.c
index a246903c3341..bd9ab9d0d12a 100644
--- a/drivers/media/dvb/siano/smscoreapi.c
+++ b/drivers/media/dvb/siano/smscoreapi.c
@@ -816,7 +816,7 @@ int smscore_set_device_mode(struct smscore_device_t *coredev, int mode)
816 816
817 sms_debug("set device mode to %d", mode); 817 sms_debug("set device mode to %d", mode);
818 if (coredev->device_flags & SMS_DEVICE_FAMILY2) { 818 if (coredev->device_flags & SMS_DEVICE_FAMILY2) {
819 if (mode < DEVICE_MODE_DVBT || mode > DEVICE_MODE_RAW_TUNER) { 819 if (mode < DEVICE_MODE_DVBT || mode >= DEVICE_MODE_RAW_TUNER) {
820 sms_err("invalid mode specified %d", mode); 820 sms_err("invalid mode specified %d", mode);
821 return -EINVAL; 821 return -EINVAL;
822 } 822 }
diff --git a/drivers/media/dvb/siano/smsdvb.c b/drivers/media/dvb/siano/smsdvb.c
index 3ee1c3902c56..266033ae2784 100644
--- a/drivers/media/dvb/siano/smsdvb.c
+++ b/drivers/media/dvb/siano/smsdvb.c
@@ -325,6 +325,16 @@ static int smsdvb_sendrequest_and_wait(struct smsdvb_client_t *client,
325 0 : -ETIME; 325 0 : -ETIME;
326} 326}
327 327
328static inline int led_feedback(struct smsdvb_client_t *client)
329{
330 if (client->fe_status & FE_HAS_LOCK)
331 return sms_board_led_feedback(client->coredev,
332 (client->sms_stat_dvb.ReceptionData.BER
333 == 0) ? SMS_LED_HI : SMS_LED_LO);
334 else
335 return sms_board_led_feedback(client->coredev, SMS_LED_OFF);
336}
337
328static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat) 338static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
329{ 339{
330 struct smsdvb_client_t *client; 340 struct smsdvb_client_t *client;
@@ -332,6 +342,8 @@ static int smsdvb_read_status(struct dvb_frontend *fe, fe_status_t *stat)
332 342
333 *stat = client->fe_status; 343 *stat = client->fe_status;
334 344
345 led_feedback(client);
346
335 return 0; 347 return 0;
336} 348}
337 349
@@ -342,6 +354,8 @@ static int smsdvb_read_ber(struct dvb_frontend *fe, u32 *ber)
342 354
343 *ber = client->sms_stat_dvb.ReceptionData.BER; 355 *ber = client->sms_stat_dvb.ReceptionData.BER;
344 356
357 led_feedback(client);
358
345 return 0; 359 return 0;
346} 360}
347 361
@@ -359,6 +373,8 @@ static int smsdvb_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
359 (client->sms_stat_dvb.ReceptionData.InBandPwr 373 (client->sms_stat_dvb.ReceptionData.InBandPwr
360 + 95) * 3 / 2; 374 + 95) * 3 / 2;
361 375
376 led_feedback(client);
377
362 return 0; 378 return 0;
363} 379}
364 380
@@ -369,6 +385,8 @@ static int smsdvb_read_snr(struct dvb_frontend *fe, u16 *snr)
369 385
370 *snr = client->sms_stat_dvb.ReceptionData.SNR; 386 *snr = client->sms_stat_dvb.ReceptionData.SNR;
371 387
388 led_feedback(client);
389
372 return 0; 390 return 0;
373} 391}
374 392
@@ -379,6 +397,8 @@ static int smsdvb_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
379 397
380 *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets; 398 *ucblocks = client->sms_stat_dvb.ReceptionData.ErrorTSPackets;
381 399
400 led_feedback(client);
401
382 return 0; 402 return 0;
383} 403}
384 404
@@ -404,6 +424,8 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe,
404 u32 Data[3]; 424 u32 Data[3];
405 } Msg; 425 } Msg;
406 426
427 int ret;
428
407 client->fe_status = FE_HAS_SIGNAL; 429 client->fe_status = FE_HAS_SIGNAL;
408 client->event_fe_state = -1; 430 client->event_fe_state = -1;
409 client->event_unc_state = -1; 431 client->event_unc_state = -1;
@@ -426,6 +448,23 @@ static int smsdvb_set_frontend(struct dvb_frontend *fe,
426 case BANDWIDTH_AUTO: return -EOPNOTSUPP; 448 case BANDWIDTH_AUTO: return -EOPNOTSUPP;
427 default: return -EINVAL; 449 default: return -EINVAL;
428 } 450 }
451 /* Disable LNA, if any. An error is returned if no LNA is present */
452 ret = sms_board_lna_control(client->coredev, 0);
453 if (ret == 0) {
454 fe_status_t status;
455
456 /* tune with LNA off at first */
457 ret = smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
458 &client->tune_done);
459
460 smsdvb_read_status(fe, &status);
461
462 if (status & FE_HAS_LOCK)
463 return ret;
464
465 /* previous tune didnt lock - enable LNA and tune again */
466 sms_board_lna_control(client->coredev, 1);
467 }
429 468
430 return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg), 469 return smsdvb_sendrequest_and_wait(client, &Msg, sizeof(Msg),
431 &client->tune_done); 470 &client->tune_done);
@@ -451,6 +490,8 @@ static int smsdvb_init(struct dvb_frontend *fe)
451 struct smsdvb_client_t *client = 490 struct smsdvb_client_t *client =
452 container_of(fe, struct smsdvb_client_t, frontend); 491 container_of(fe, struct smsdvb_client_t, frontend);
453 492
493 sms_board_power(client->coredev, 1);
494
454 sms_board_dvb3_event(client, DVB3_EVENT_INIT); 495 sms_board_dvb3_event(client, DVB3_EVENT_INIT);
455 return 0; 496 return 0;
456} 497}
@@ -460,6 +501,9 @@ static int smsdvb_sleep(struct dvb_frontend *fe)
460 struct smsdvb_client_t *client = 501 struct smsdvb_client_t *client =
461 container_of(fe, struct smsdvb_client_t, frontend); 502 container_of(fe, struct smsdvb_client_t, frontend);
462 503
504 sms_board_led_feedback(client->coredev, SMS_LED_OFF);
505 sms_board_power(client->coredev, 0);
506
463 sms_board_dvb3_event(client, DVB3_EVENT_SLEEP); 507 sms_board_dvb3_event(client, DVB3_EVENT_SLEEP);
464 508
465 return 0; 509 return 0;
diff --git a/drivers/media/dvb/siano/smssdio.c b/drivers/media/dvb/siano/smssdio.c
index dfaa49a53f32..d1d652e7f890 100644
--- a/drivers/media/dvb/siano/smssdio.c
+++ b/drivers/media/dvb/siano/smssdio.c
@@ -46,6 +46,7 @@
46 46
47#define SMSSDIO_DATA 0x00 47#define SMSSDIO_DATA 0x00
48#define SMSSDIO_INT 0x04 48#define SMSSDIO_INT 0x04
49#define SMSSDIO_BLOCK_SIZE 128
49 50
50static const struct sdio_device_id smssdio_ids[] = { 51static const struct sdio_device_id smssdio_ids[] = {
51 {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_STELLAR), 52 {SDIO_DEVICE(SDIO_VENDOR_ID_SIANO, SDIO_DEVICE_ID_SIANO_STELLAR),
@@ -85,7 +86,8 @@ static int smssdio_sendrequest(void *context, void *buffer, size_t size)
85 sdio_claim_host(smsdev->func); 86 sdio_claim_host(smsdev->func);
86 87
87 while (size >= smsdev->func->cur_blksize) { 88 while (size >= smsdev->func->cur_blksize) {
88 ret = sdio_write_blocks(smsdev->func, SMSSDIO_DATA, buffer, 1); 89 ret = sdio_memcpy_toio(smsdev->func, SMSSDIO_DATA,
90 buffer, smsdev->func->cur_blksize);
89 if (ret) 91 if (ret)
90 goto out; 92 goto out;
91 93
@@ -94,8 +96,8 @@ static int smssdio_sendrequest(void *context, void *buffer, size_t size)
94 } 96 }
95 97
96 if (size) { 98 if (size) {
97 ret = sdio_write_bytes(smsdev->func, SMSSDIO_DATA, 99 ret = sdio_memcpy_toio(smsdev->func, SMSSDIO_DATA,
98 buffer, size); 100 buffer, size);
99 } 101 }
100 102
101out: 103out:
@@ -125,23 +127,23 @@ static void smssdio_interrupt(struct sdio_func *func)
125 */ 127 */
126 isr = sdio_readb(func, SMSSDIO_INT, &ret); 128 isr = sdio_readb(func, SMSSDIO_INT, &ret);
127 if (ret) { 129 if (ret) {
128 dev_err(&smsdev->func->dev, 130 sms_err("Unable to read interrupt register!\n");
129 "Unable to read interrupt register!\n");
130 return; 131 return;
131 } 132 }
132 133
133 if (smsdev->split_cb == NULL) { 134 if (smsdev->split_cb == NULL) {
134 cb = smscore_getbuffer(smsdev->coredev); 135 cb = smscore_getbuffer(smsdev->coredev);
135 if (!cb) { 136 if (!cb) {
136 dev_err(&smsdev->func->dev, 137 sms_err("Unable to allocate data buffer!\n");
137 "Unable to allocate data buffer!\n");
138 return; 138 return;
139 } 139 }
140 140
141 ret = sdio_read_blocks(smsdev->func, cb->p, SMSSDIO_DATA, 1); 141 ret = sdio_memcpy_fromio(smsdev->func,
142 cb->p,
143 SMSSDIO_DATA,
144 SMSSDIO_BLOCK_SIZE);
142 if (ret) { 145 if (ret) {
143 dev_err(&smsdev->func->dev, 146 sms_err("Error %d reading initial block!\n", ret);
144 "Error %d reading initial block!\n", ret);
145 return; 147 return;
146 } 148 }
147 149
@@ -152,7 +154,10 @@ static void smssdio_interrupt(struct sdio_func *func)
152 return; 154 return;
153 } 155 }
154 156
155 size = hdr->msgLength - smsdev->func->cur_blksize; 157 if (hdr->msgLength > smsdev->func->cur_blksize)
158 size = hdr->msgLength - smsdev->func->cur_blksize;
159 else
160 size = 0;
156 } else { 161 } else {
157 cb = smsdev->split_cb; 162 cb = smsdev->split_cb;
158 hdr = cb->p; 163 hdr = cb->p;
@@ -162,23 +167,24 @@ static void smssdio_interrupt(struct sdio_func *func)
162 smsdev->split_cb = NULL; 167 smsdev->split_cb = NULL;
163 } 168 }
164 169
165 if (hdr->msgLength > smsdev->func->cur_blksize) { 170 if (size) {
166 void *buffer; 171 void *buffer;
167 172
168 size = ALIGN(size, 128); 173 buffer = cb->p + (hdr->msgLength - size);
169 buffer = cb->p + hdr->msgLength; 174 size = ALIGN(size, SMSSDIO_BLOCK_SIZE);
170 175
171 BUG_ON(smsdev->func->cur_blksize != 128); 176 BUG_ON(smsdev->func->cur_blksize != SMSSDIO_BLOCK_SIZE);
172 177
173 /* 178 /*
174 * First attempt to transfer all of it in one go... 179 * First attempt to transfer all of it in one go...
175 */ 180 */
176 ret = sdio_read_blocks(smsdev->func, buffer, 181 ret = sdio_memcpy_fromio(smsdev->func,
177 SMSSDIO_DATA, size / 128); 182 buffer,
183 SMSSDIO_DATA,
184 size);
178 if (ret && ret != -EINVAL) { 185 if (ret && ret != -EINVAL) {
179 smscore_putbuffer(smsdev->coredev, cb); 186 smscore_putbuffer(smsdev->coredev, cb);
180 dev_err(&smsdev->func->dev, 187 sms_err("Error %d reading data from card!\n", ret);
181 "Error %d reading data from card!\n", ret);
182 return; 188 return;
183 } 189 }
184 190
@@ -191,12 +197,12 @@ static void smssdio_interrupt(struct sdio_func *func)
191 */ 197 */
192 if (ret == -EINVAL) { 198 if (ret == -EINVAL) {
193 while (size) { 199 while (size) {
194 ret = sdio_read_blocks(smsdev->func, 200 ret = sdio_memcpy_fromio(smsdev->func,
195 buffer, SMSSDIO_DATA, 1); 201 buffer, SMSSDIO_DATA,
202 smsdev->func->cur_blksize);
196 if (ret) { 203 if (ret) {
197 smscore_putbuffer(smsdev->coredev, cb); 204 smscore_putbuffer(smsdev->coredev, cb);
198 dev_err(&smsdev->func->dev, 205 sms_err("Error %d reading "
199 "Error %d reading "
200 "data from card!\n", ret); 206 "data from card!\n", ret);
201 return; 207 return;
202 } 208 }
@@ -269,7 +275,7 @@ static int smssdio_probe(struct sdio_func *func,
269 if (ret) 275 if (ret)
270 goto release; 276 goto release;
271 277
272 ret = sdio_set_block_size(func, 128); 278 ret = sdio_set_block_size(func, SMSSDIO_BLOCK_SIZE);
273 if (ret) 279 if (ret)
274 goto disable; 280 goto disable;
275 281
diff --git a/drivers/media/video/Kconfig b/drivers/media/video/Kconfig
index 84b6fc15519d..dcf9fa9264bb 100644
--- a/drivers/media/video/Kconfig
+++ b/drivers/media/video/Kconfig
@@ -920,6 +920,8 @@ source "drivers/media/video/pwc/Kconfig"
920config USB_ZR364XX 920config USB_ZR364XX
921 tristate "USB ZR364XX Camera support" 921 tristate "USB ZR364XX Camera support"
922 depends on VIDEO_V4L2 922 depends on VIDEO_V4L2
923 select VIDEOBUF_GEN
924 select VIDEOBUF_VMALLOC
923 ---help--- 925 ---help---
924 Say Y here if you want to connect this type of camera to your 926 Say Y here if you want to connect this type of camera to your
925 computer's USB port. 927 computer's USB port.
diff --git a/drivers/media/video/bw-qcam.c b/drivers/media/video/bw-qcam.c
index 10dbd4a11b30..9e39bc5f7b00 100644
--- a/drivers/media/video/bw-qcam.c
+++ b/drivers/media/video/bw-qcam.c
@@ -992,7 +992,7 @@ static int accept_bwqcam(struct parport *port)
992 992
993 if (parport[0] && strncmp(parport[0], "auto", 4) != 0) { 993 if (parport[0] && strncmp(parport[0], "auto", 4) != 0) {
994 /* user gave parport parameters */ 994 /* user gave parport parameters */
995 for(n=0; parport[n] && n<MAX_CAMS; n++){ 995 for (n = 0; n < MAX_CAMS && parport[n]; n++) {
996 char *ep; 996 char *ep;
997 unsigned long r; 997 unsigned long r;
998 r = simple_strtoul(parport[n], &ep, 0); 998 r = simple_strtoul(parport[n], &ep, 0);
diff --git a/drivers/media/video/cx18/cx18-controls.c b/drivers/media/video/cx18/cx18-controls.c
index 5136df198338..93f0dae01350 100644
--- a/drivers/media/video/cx18/cx18-controls.c
+++ b/drivers/media/video/cx18/cx18-controls.c
@@ -20,6 +20,7 @@
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 * 02111-1307 USA 21 * 02111-1307 USA
22 */ 22 */
23#include <linux/kernel.h>
23 24
24#include "cx18-driver.h" 25#include "cx18-driver.h"
25#include "cx18-cards.h" 26#include "cx18-cards.h"
@@ -317,7 +318,7 @@ int cx18_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
317 idx = p.audio_properties & 0x03; 318 idx = p.audio_properties & 0x03;
318 /* The audio clock of the digitizer must match the codec sample 319 /* The audio clock of the digitizer must match the codec sample
319 rate otherwise you get some very strange effects. */ 320 rate otherwise you get some very strange effects. */
320 if (idx < sizeof(freqs)) 321 if (idx < ARRAY_SIZE(freqs))
321 cx18_call_all(cx, audio, s_clock_freq, freqs[idx]); 322 cx18_call_all(cx, audio, s_clock_freq, freqs[idx]);
322 return err; 323 return err;
323 } 324 }
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index e0cf21e0b1bf..1a1048b18f70 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -1715,6 +1715,8 @@ static struct video_device cx23885_mpeg_template = {
1715 .fops = &mpeg_fops, 1715 .fops = &mpeg_fops,
1716 .ioctl_ops = &mpeg_ioctl_ops, 1716 .ioctl_ops = &mpeg_ioctl_ops,
1717 .minor = -1, 1717 .minor = -1,
1718 .tvnorms = CX23885_NORMS,
1719 .current_norm = V4L2_STD_NTSC_M,
1718}; 1720};
1719 1721
1720void cx23885_417_unregister(struct cx23885_dev *dev) 1722void cx23885_417_unregister(struct cx23885_dev *dev)
diff --git a/drivers/media/video/cx88/cx88-cards.c b/drivers/media/video/cx88/cx88-cards.c
index a5cc1c1fc2d6..39465301ec94 100644
--- a/drivers/media/video/cx88/cx88-cards.c
+++ b/drivers/media/video/cx88/cx88-cards.c
@@ -3003,6 +3003,14 @@ void cx88_setup_xc3028(struct cx88_core *core, struct xc2028_ctrl *ctl)
3003 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO: 3003 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
3004 ctl->demod = XC3028_FE_OREN538; 3004 ctl->demod = XC3028_FE_OREN538;
3005 break; 3005 break;
3006 case CX88_BOARD_GENIATECH_X8000_MT:
3007 /* FIXME: For this board, the xc3028 never recovers after being
3008 powered down (the reset GPIO probably is not set properly).
3009 We don't have access to the hardware so we cannot determine
3010 which GPIO is used for xc3028, so just disable power xc3028
3011 power management for now */
3012 ctl->disable_power_mgmt = 1;
3013 break;
3006 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL: 3014 case CX88_BOARD_WINFAST_TV2000_XP_GLOBAL:
3007 case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME: 3015 case CX88_BOARD_PROLINK_PV_GLOBAL_XTREME:
3008 case CX88_BOARD_PROLINK_PV_8000GT: 3016 case CX88_BOARD_PROLINK_PV_8000GT:
diff --git a/drivers/media/video/cx88/cx88-dvb.c b/drivers/media/video/cx88/cx88-dvb.c
index c44e87600219..e237b507659b 100644
--- a/drivers/media/video/cx88/cx88-dvb.c
+++ b/drivers/media/video/cx88/cx88-dvb.c
@@ -501,6 +501,7 @@ static struct zl10353_config cx88_pinnacle_hybrid_pctv = {
501static struct zl10353_config cx88_geniatech_x8000_mt = { 501static struct zl10353_config cx88_geniatech_x8000_mt = {
502 .demod_address = (0x1e >> 1), 502 .demod_address = (0x1e >> 1),
503 .no_tuner = 1, 503 .no_tuner = 1,
504 .disable_i2c_gate_ctrl = 1,
504}; 505};
505 506
506static struct s5h1411_config dvico_fusionhdtv7_config = { 507static struct s5h1411_config dvico_fusionhdtv7_config = {
diff --git a/drivers/media/video/cx88/cx88-mpeg.c b/drivers/media/video/cx88/cx88-mpeg.c
index da4e3912cd37..7172dcf2a4fa 100644
--- a/drivers/media/video/cx88/cx88-mpeg.c
+++ b/drivers/media/video/cx88/cx88-mpeg.c
@@ -116,6 +116,10 @@ static int cx8802_start_dma(struct cx8802_dev *dev,
116 udelay(100); 116 udelay(100);
117 break; 117 break;
118 case CX88_BOARD_HAUPPAUGE_HVR1300: 118 case CX88_BOARD_HAUPPAUGE_HVR1300:
119 /* Enable MPEG parallel IO and video signal pins */
120 cx_write(MO_PINMUX_IO, 0x88);
121 cx_write(TS_SOP_STAT, 0);
122 cx_write(TS_VALERR_CNTRL, 0);
119 break; 123 break;
120 case CX88_BOARD_PINNACLE_PCTV_HD_800i: 124 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
121 /* Enable MPEG parallel IO and video signal pins */ 125 /* Enable MPEG parallel IO and video signal pins */
diff --git a/drivers/media/video/em28xx/em28xx-cards.c b/drivers/media/video/em28xx/em28xx-cards.c
index 320f1f60276e..1c2e544eda73 100644
--- a/drivers/media/video/em28xx/em28xx-cards.c
+++ b/drivers/media/video/em28xx/em28xx-cards.c
@@ -218,7 +218,7 @@ static struct em28xx_reg_seq silvercrest_reg_seq[] = {
218struct em28xx_board em28xx_boards[] = { 218struct em28xx_board em28xx_boards[] = {
219 [EM2750_BOARD_UNKNOWN] = { 219 [EM2750_BOARD_UNKNOWN] = {
220 .name = "EM2710/EM2750/EM2751 webcam grabber", 220 .name = "EM2710/EM2750/EM2751 webcam grabber",
221 .xclk = EM28XX_XCLK_FREQUENCY_48MHZ, 221 .xclk = EM28XX_XCLK_FREQUENCY_20MHZ,
222 .tuner_type = TUNER_ABSENT, 222 .tuner_type = TUNER_ABSENT,
223 .is_webcam = 1, 223 .is_webcam = 1,
224 .input = { { 224 .input = { {
@@ -622,22 +622,27 @@ struct em28xx_board em28xx_boards[] = {
622 }, 622 },
623 [EM2861_BOARD_PLEXTOR_PX_TV100U] = { 623 [EM2861_BOARD_PLEXTOR_PX_TV100U] = {
624 .name = "Plextor ConvertX PX-TV100U", 624 .name = "Plextor ConvertX PX-TV100U",
625 .valid = EM28XX_BOARD_NOT_VALIDATED,
626 .tuner_type = TUNER_TNF_5335MF, 625 .tuner_type = TUNER_TNF_5335MF,
626 .xclk = EM28XX_XCLK_I2S_MSB_TIMING |
627 EM28XX_XCLK_FREQUENCY_12MHZ,
627 .tda9887_conf = TDA9887_PRESENT, 628 .tda9887_conf = TDA9887_PRESENT,
628 .decoder = EM28XX_TVP5150, 629 .decoder = EM28XX_TVP5150,
630 .has_msp34xx = 1,
629 .input = { { 631 .input = { {
630 .type = EM28XX_VMUX_TELEVISION, 632 .type = EM28XX_VMUX_TELEVISION,
631 .vmux = TVP5150_COMPOSITE0, 633 .vmux = TVP5150_COMPOSITE0,
632 .amux = EM28XX_AMUX_LINE_IN, 634 .amux = EM28XX_AMUX_LINE_IN,
635 .gpio = pinnacle_hybrid_pro_analog,
633 }, { 636 }, {
634 .type = EM28XX_VMUX_COMPOSITE1, 637 .type = EM28XX_VMUX_COMPOSITE1,
635 .vmux = TVP5150_COMPOSITE1, 638 .vmux = TVP5150_COMPOSITE1,
636 .amux = EM28XX_AMUX_LINE_IN, 639 .amux = EM28XX_AMUX_LINE_IN,
640 .gpio = pinnacle_hybrid_pro_analog,
637 }, { 641 }, {
638 .type = EM28XX_VMUX_SVIDEO, 642 .type = EM28XX_VMUX_SVIDEO,
639 .vmux = TVP5150_SVIDEO, 643 .vmux = TVP5150_SVIDEO,
640 .amux = EM28XX_AMUX_LINE_IN, 644 .amux = EM28XX_AMUX_LINE_IN,
645 .gpio = pinnacle_hybrid_pro_analog,
641 } }, 646 } },
642 }, 647 },
643 648
@@ -1544,6 +1549,8 @@ struct usb_device_id em28xx_id_table[] = {
1544 .driver_info = EM2750_BOARD_UNKNOWN }, 1549 .driver_info = EM2750_BOARD_UNKNOWN },
1545 { USB_DEVICE(0xeb1a, 0x2800), 1550 { USB_DEVICE(0xeb1a, 0x2800),
1546 .driver_info = EM2800_BOARD_UNKNOWN }, 1551 .driver_info = EM2800_BOARD_UNKNOWN },
1552 { USB_DEVICE(0xeb1a, 0x2710),
1553 .driver_info = EM2820_BOARD_UNKNOWN },
1547 { USB_DEVICE(0xeb1a, 0x2820), 1554 { USB_DEVICE(0xeb1a, 0x2820),
1548 .driver_info = EM2820_BOARD_UNKNOWN }, 1555 .driver_info = EM2820_BOARD_UNKNOWN },
1549 { USB_DEVICE(0xeb1a, 0x2821), 1556 { USB_DEVICE(0xeb1a, 0x2821),
@@ -1723,6 +1730,25 @@ static inline void em28xx_set_model(struct em28xx *dev)
1723 EM28XX_I2C_FREQ_100_KHZ; 1730 EM28XX_I2C_FREQ_100_KHZ;
1724} 1731}
1725 1732
1733
1734/* FIXME: Should be replaced by a proper mt9m111 driver */
1735static int em28xx_initialize_mt9m111(struct em28xx *dev)
1736{
1737 int i;
1738 unsigned char regs[][3] = {
1739 { 0x0d, 0x00, 0x01, }, /* reset and use defaults */
1740 { 0x0d, 0x00, 0x00, },
1741 { 0x0a, 0x00, 0x21, },
1742 { 0x21, 0x04, 0x00, }, /* full readout speed, no row/col skipping */
1743 };
1744
1745 for (i = 0; i < ARRAY_SIZE(regs); i++)
1746 i2c_master_send(&dev->i2c_client, &regs[i][0], 3);
1747
1748 return 0;
1749}
1750
1751
1726/* FIXME: Should be replaced by a proper mt9m001 driver */ 1752/* FIXME: Should be replaced by a proper mt9m001 driver */
1727static int em28xx_initialize_mt9m001(struct em28xx *dev) 1753static int em28xx_initialize_mt9m001(struct em28xx *dev)
1728{ 1754{
@@ -1751,7 +1777,7 @@ static int em28xx_initialize_mt9m001(struct em28xx *dev)
1751 1777
1752/* HINT method: webcam I2C chips 1778/* HINT method: webcam I2C chips
1753 * 1779 *
1754 * This method work for webcams with Micron sensors 1780 * This method works for webcams with Micron sensors
1755 */ 1781 */
1756static int em28xx_hint_sensor(struct em28xx *dev) 1782static int em28xx_hint_sensor(struct em28xx *dev)
1757{ 1783{
@@ -1761,6 +1787,7 @@ static int em28xx_hint_sensor(struct em28xx *dev)
1761 __be16 version_be; 1787 __be16 version_be;
1762 u16 version; 1788 u16 version;
1763 1789
1790 /* Micron sensor detection */
1764 dev->i2c_client.addr = 0xba >> 1; 1791 dev->i2c_client.addr = 0xba >> 1;
1765 cmd = 0; 1792 cmd = 0;
1766 i2c_master_send(&dev->i2c_client, &cmd, 1); 1793 i2c_master_send(&dev->i2c_client, &cmd, 1);
@@ -1769,23 +1796,54 @@ static int em28xx_hint_sensor(struct em28xx *dev)
1769 return -EINVAL; 1796 return -EINVAL;
1770 1797
1771 version = be16_to_cpu(version_be); 1798 version = be16_to_cpu(version_be);
1772
1773 switch (version) { 1799 switch (version) {
1774 case 0x8243: /* mt9v011 640x480 1.3 Mpix sensor */ 1800 case 0x8232: /* mt9v011 640x480 1.3 Mpix sensor */
1801 case 0x8243: /* mt9v011 rev B 640x480 1.3 Mpix sensor */
1775 dev->model = EM2820_BOARD_SILVERCREST_WEBCAM; 1802 dev->model = EM2820_BOARD_SILVERCREST_WEBCAM;
1803 em28xx_set_model(dev);
1804
1776 sensor_name = "mt9v011"; 1805 sensor_name = "mt9v011";
1777 dev->em28xx_sensor = EM28XX_MT9V011; 1806 dev->em28xx_sensor = EM28XX_MT9V011;
1778 dev->sensor_xres = 640; 1807 dev->sensor_xres = 640;
1779 dev->sensor_yres = 480; 1808 dev->sensor_yres = 480;
1780 dev->sensor_xtal = 6300000; 1809 /*
1810 * FIXME: mt9v011 uses I2S speed as xtal clk - at least with
1811 * the Silvercrest cam I have here for testing - for higher
1812 * resolutions, a high clock cause horizontal artifacts, so we
1813 * need to use a lower xclk frequency.
1814 * Yet, it would be possible to adjust xclk depending on the
1815 * desired resolution, since this affects directly the
1816 * frame rate.
1817 */
1818 dev->board.xclk = EM28XX_XCLK_FREQUENCY_4_3MHZ;
1819 dev->sensor_xtal = 4300000;
1781 1820
1782 /* probably means GRGB 16 bit bayer */ 1821 /* probably means GRGB 16 bit bayer */
1783 dev->vinmode = 0x0d; 1822 dev->vinmode = 0x0d;
1784 dev->vinctl = 0x00; 1823 dev->vinctl = 0x00;
1785 1824
1786 break; 1825 break;
1826
1827 case 0x143a: /* MT9M111 as found in the ECS G200 */
1828 dev->model = EM2750_BOARD_UNKNOWN;
1829 em28xx_set_model(dev);
1830
1831 sensor_name = "mt9m111";
1832 dev->board.xclk = EM28XX_XCLK_FREQUENCY_48MHZ;
1833 dev->em28xx_sensor = EM28XX_MT9M111;
1834 em28xx_initialize_mt9m111(dev);
1835 dev->sensor_xres = 640;
1836 dev->sensor_yres = 512;
1837
1838 dev->vinmode = 0x0a;
1839 dev->vinctl = 0x00;
1840
1841 break;
1842
1787 case 0x8431: 1843 case 0x8431:
1788 dev->model = EM2750_BOARD_UNKNOWN; 1844 dev->model = EM2750_BOARD_UNKNOWN;
1845 em28xx_set_model(dev);
1846
1789 sensor_name = "mt9m001"; 1847 sensor_name = "mt9m001";
1790 dev->em28xx_sensor = EM28XX_MT9M001; 1848 dev->em28xx_sensor = EM28XX_MT9M001;
1791 em28xx_initialize_mt9m001(dev); 1849 em28xx_initialize_mt9m001(dev);
@@ -1798,10 +1856,13 @@ static int em28xx_hint_sensor(struct em28xx *dev)
1798 1856
1799 break; 1857 break;
1800 default: 1858 default:
1801 printk("Unknown Micron Sensor 0x%04x\n", be16_to_cpu(version)); 1859 printk("Unknown Micron Sensor 0x%04x\n", version);
1802 return -EINVAL; 1860 return -EINVAL;
1803 } 1861 }
1804 1862
1863 /* Setup webcam defaults */
1864 em28xx_pre_card_setup(dev);
1865
1805 em28xx_errdev("Sensor is %s, using model %s entry.\n", 1866 em28xx_errdev("Sensor is %s, using model %s entry.\n",
1806 sensor_name, em28xx_boards[dev->model].name); 1867 sensor_name, em28xx_boards[dev->model].name);
1807 1868
@@ -1813,60 +1874,6 @@ static int em28xx_hint_sensor(struct em28xx *dev)
1813 */ 1874 */
1814void em28xx_pre_card_setup(struct em28xx *dev) 1875void em28xx_pre_card_setup(struct em28xx *dev)
1815{ 1876{
1816 int rc;
1817
1818 em28xx_set_model(dev);
1819
1820 em28xx_info("Identified as %s (card=%d)\n",
1821 dev->board.name, dev->model);
1822
1823 /* Set the default GPO/GPIO for legacy devices */
1824 dev->reg_gpo_num = EM2880_R04_GPO;
1825 dev->reg_gpio_num = EM28XX_R08_GPIO;
1826
1827 dev->wait_after_write = 5;
1828
1829 /* Based on the Chip ID, set the device configuration */
1830 rc = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
1831 if (rc > 0) {
1832 dev->chip_id = rc;
1833
1834 switch (dev->chip_id) {
1835 case CHIP_ID_EM2750:
1836 em28xx_info("chip ID is em2750\n");
1837 break;
1838 case CHIP_ID_EM2820:
1839 em28xx_info("chip ID is em2710 or em2820\n");
1840 break;
1841 case CHIP_ID_EM2840:
1842 em28xx_info("chip ID is em2840\n");
1843 break;
1844 case CHIP_ID_EM2860:
1845 em28xx_info("chip ID is em2860\n");
1846 break;
1847 case CHIP_ID_EM2870:
1848 em28xx_info("chip ID is em2870\n");
1849 dev->wait_after_write = 0;
1850 break;
1851 case CHIP_ID_EM2874:
1852 em28xx_info("chip ID is em2874\n");
1853 dev->reg_gpio_num = EM2874_R80_GPIO;
1854 dev->wait_after_write = 0;
1855 break;
1856 case CHIP_ID_EM2883:
1857 em28xx_info("chip ID is em2882/em2883\n");
1858 dev->wait_after_write = 0;
1859 break;
1860 default:
1861 em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
1862 }
1863 }
1864
1865 /* Prepopulate cached GPO register content */
1866 rc = em28xx_read_reg(dev, dev->reg_gpo_num);
1867 if (rc >= 0)
1868 dev->reg_gpo = rc;
1869
1870 /* Set the initial XCLK and I2C clock values based on the board 1877 /* Set the initial XCLK and I2C clock values based on the board
1871 definition */ 1878 definition */
1872 em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f); 1879 em28xx_write_reg(dev, EM28XX_R0F_XCLK, dev->board.xclk & 0x7f);
@@ -1876,9 +1883,8 @@ void em28xx_pre_card_setup(struct em28xx *dev)
1876 /* request some modules */ 1883 /* request some modules */
1877 switch (dev->model) { 1884 switch (dev->model) {
1878 case EM2861_BOARD_PLEXTOR_PX_TV100U: 1885 case EM2861_BOARD_PLEXTOR_PX_TV100U:
1879 /* FIXME guess */ 1886 /* Sets the msp34xx I2S speed */
1880 /* Turn on analog audio output */ 1887 dev->i2s_speed = 2048000;
1881 em28xx_write_reg(dev, EM28XX_R08_GPIO, 0xfd);
1882 break; 1888 break;
1883 case EM2861_BOARD_KWORLD_PVRTV_300U: 1889 case EM2861_BOARD_KWORLD_PVRTV_300U:
1884 case EM2880_BOARD_KWORLD_DVB_305U: 1890 case EM2880_BOARD_KWORLD_DVB_305U:
@@ -2216,7 +2222,20 @@ void em28xx_register_i2c_ir(struct em28xx *dev)
2216 2222
2217void em28xx_card_setup(struct em28xx *dev) 2223void em28xx_card_setup(struct em28xx *dev)
2218{ 2224{
2219 em28xx_set_model(dev); 2225 /*
2226 * If the device can be a webcam, seek for a sensor.
2227 * If sensor is not found, then it isn't a webcam.
2228 */
2229 if (dev->board.is_webcam) {
2230 if (em28xx_hint_sensor(dev) < 0)
2231 dev->board.is_webcam = 0;
2232 else
2233 dev->progressive = 1;
2234 } else
2235 em28xx_set_model(dev);
2236
2237 em28xx_info("Identified as %s (card=%d)\n",
2238 dev->board.name, dev->model);
2220 2239
2221 dev->tuner_type = em28xx_boards[dev->model].tuner_type; 2240 dev->tuner_type = em28xx_boards[dev->model].tuner_type;
2222 if (em28xx_boards[dev->model].tuner_addr) 2241 if (em28xx_boards[dev->model].tuner_addr)
@@ -2290,10 +2309,6 @@ void em28xx_card_setup(struct em28xx *dev)
2290 em28xx_gpio_set(dev, dev->board.tuner_gpio); 2309 em28xx_gpio_set(dev, dev->board.tuner_gpio);
2291 em28xx_set_mode(dev, EM28XX_ANALOG_MODE); 2310 em28xx_set_mode(dev, EM28XX_ANALOG_MODE);
2292 break; 2311 break;
2293 case EM2820_BOARD_SILVERCREST_WEBCAM:
2294 /* FIXME: need to document the registers bellow */
2295 em28xx_write_reg(dev, 0x0d, 0x42);
2296 em28xx_write_reg(dev, 0x13, 0x08);
2297 } 2312 }
2298 2313
2299 if (dev->board.has_snapshot_button) 2314 if (dev->board.has_snapshot_button)
@@ -2367,7 +2382,9 @@ void em28xx_card_setup(struct em28xx *dev)
2367 } 2382 }
2368 2383
2369 em28xx_tuner_setup(dev); 2384 em28xx_tuner_setup(dev);
2370 em28xx_ir_init(dev); 2385
2386 if(!disable_ir)
2387 em28xx_ir_init(dev);
2371} 2388}
2372 2389
2373 2390
@@ -2433,7 +2450,7 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2433 int minor) 2450 int minor)
2434{ 2451{
2435 struct em28xx *dev = *devhandle; 2452 struct em28xx *dev = *devhandle;
2436 int retval = -ENOMEM; 2453 int retval;
2437 int errCode; 2454 int errCode;
2438 2455
2439 dev->udev = udev; 2456 dev->udev = udev;
@@ -2450,6 +2467,58 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2450 dev->em28xx_read_reg_req = em28xx_read_reg_req; 2467 dev->em28xx_read_reg_req = em28xx_read_reg_req;
2451 dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800; 2468 dev->board.is_em2800 = em28xx_boards[dev->model].is_em2800;
2452 2469
2470 em28xx_set_model(dev);
2471
2472 /* Set the default GPO/GPIO for legacy devices */
2473 dev->reg_gpo_num = EM2880_R04_GPO;
2474 dev->reg_gpio_num = EM28XX_R08_GPIO;
2475
2476 dev->wait_after_write = 5;
2477
2478 /* Based on the Chip ID, set the device configuration */
2479 retval = em28xx_read_reg(dev, EM28XX_R0A_CHIPID);
2480 if (retval > 0) {
2481 dev->chip_id = retval;
2482
2483 switch (dev->chip_id) {
2484 case CHIP_ID_EM2710:
2485 em28xx_info("chip ID is em2710\n");
2486 break;
2487 case CHIP_ID_EM2750:
2488 em28xx_info("chip ID is em2750\n");
2489 break;
2490 case CHIP_ID_EM2820:
2491 em28xx_info("chip ID is em2820 (or em2710)\n");
2492 break;
2493 case CHIP_ID_EM2840:
2494 em28xx_info("chip ID is em2840\n");
2495 break;
2496 case CHIP_ID_EM2860:
2497 em28xx_info("chip ID is em2860\n");
2498 break;
2499 case CHIP_ID_EM2870:
2500 em28xx_info("chip ID is em2870\n");
2501 dev->wait_after_write = 0;
2502 break;
2503 case CHIP_ID_EM2874:
2504 em28xx_info("chip ID is em2874\n");
2505 dev->reg_gpio_num = EM2874_R80_GPIO;
2506 dev->wait_after_write = 0;
2507 break;
2508 case CHIP_ID_EM2883:
2509 em28xx_info("chip ID is em2882/em2883\n");
2510 dev->wait_after_write = 0;
2511 break;
2512 default:
2513 em28xx_info("em28xx chip ID = %d\n", dev->chip_id);
2514 }
2515 }
2516
2517 /* Prepopulate cached GPO register content */
2518 retval = em28xx_read_reg(dev, dev->reg_gpo_num);
2519 if (retval >= 0)
2520 dev->reg_gpo = retval;
2521
2453 em28xx_pre_card_setup(dev); 2522 em28xx_pre_card_setup(dev);
2454 2523
2455 if (!dev->board.is_em2800) { 2524 if (!dev->board.is_em2800) {
@@ -2484,14 +2553,6 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2484 dev->vinmode = 0x10; 2553 dev->vinmode = 0x10;
2485 dev->vinctl = 0x11; 2554 dev->vinctl = 0x11;
2486 2555
2487 /*
2488 * If the device can be a webcam, seek for a sensor.
2489 * If sensor is not found, then it isn't a webcam.
2490 */
2491 if (dev->board.is_webcam)
2492 if (em28xx_hint_sensor(dev) < 0)
2493 dev->board.is_webcam = 0;
2494
2495 /* Do board specific init and eeprom reading */ 2556 /* Do board specific init and eeprom reading */
2496 em28xx_card_setup(dev); 2557 em28xx_card_setup(dev);
2497 2558
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 5b78e199abd1..98e140b5d95e 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -632,6 +632,9 @@ int em28xx_capture_start(struct em28xx *dev, int start)
632 return rc; 632 return rc;
633 } 633 }
634 634
635 if (dev->board.is_webcam)
636 rc = em28xx_write_reg(dev, 0x13, 0x0c);
637
635 /* enable video capture */ 638 /* enable video capture */
636 rc = em28xx_write_reg(dev, 0x48, 0x00); 639 rc = em28xx_write_reg(dev, 0x48, 0x00);
637 640
@@ -720,7 +723,10 @@ int em28xx_resolution_set(struct em28xx *dev)
720{ 723{
721 int width, height; 724 int width, height;
722 width = norm_maxw(dev); 725 width = norm_maxw(dev);
723 height = norm_maxh(dev) >> 1; 726 height = norm_maxh(dev);
727
728 if (!dev->progressive)
729 height >>= norm_maxh(dev);
724 730
725 em28xx_set_outfmt(dev); 731 em28xx_set_outfmt(dev);
726 732
diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c
index cf0ac7f2a30d..d603575431b4 100644
--- a/drivers/media/video/em28xx/em28xx-dvb.c
+++ b/drivers/media/video/em28xx/em28xx-dvb.c
@@ -478,7 +478,6 @@ static int dvb_init(struct em28xx *dev)
478 } 478 }
479 break; 479 break;
480 case EM2880_BOARD_KWORLD_DVB_310U: 480 case EM2880_BOARD_KWORLD_DVB_310U:
481 case EM2880_BOARD_EMPIRE_DUAL_TV:
482 dvb->frontend = dvb_attach(zl10353_attach, 481 dvb->frontend = dvb_attach(zl10353_attach,
483 &em28xx_zl10353_with_xc3028, 482 &em28xx_zl10353_with_xc3028,
484 &dev->i2c_adap); 483 &dev->i2c_adap);
@@ -488,6 +487,7 @@ static int dvb_init(struct em28xx *dev)
488 } 487 }
489 break; 488 break;
490 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900: 489 case EM2880_BOARD_HAUPPAUGE_WINTV_HVR_900:
490 case EM2880_BOARD_EMPIRE_DUAL_TV:
491 dvb->frontend = dvb_attach(zl10353_attach, 491 dvb->frontend = dvb_attach(zl10353_attach,
492 &em28xx_zl10353_xc3028_no_i2c_gate, 492 &em28xx_zl10353_xc3028_no_i2c_gate,
493 &dev->i2c_adap); 493 &dev->i2c_adap);
diff --git a/drivers/media/video/em28xx/em28xx-reg.h b/drivers/media/video/em28xx/em28xx-reg.h
index a2676d63cfd0..6bf84bd787df 100644
--- a/drivers/media/video/em28xx/em28xx-reg.h
+++ b/drivers/media/video/em28xx/em28xx-reg.h
@@ -176,7 +176,8 @@
176 176
177/* FIXME: Need to be populated with the other chip ID's */ 177/* FIXME: Need to be populated with the other chip ID's */
178enum em28xx_chip_id { 178enum em28xx_chip_id {
179 CHIP_ID_EM2820 = 18, /* Also used by em2710 */ 179 CHIP_ID_EM2710 = 17,
180 CHIP_ID_EM2820 = 18, /* Also used by some em2710 */
180 CHIP_ID_EM2840 = 20, 181 CHIP_ID_EM2840 = 20,
181 CHIP_ID_EM2750 = 33, 182 CHIP_ID_EM2750 = 33,
182 CHIP_ID_EM2860 = 34, 183 CHIP_ID_EM2860 = 34,
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index ff37b4c15f44..ab079d9256c4 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -194,15 +194,24 @@ static void em28xx_copy_video(struct em28xx *dev,
194 startread = p; 194 startread = p;
195 remain = len; 195 remain = len;
196 196
197 /* Interlaces frame */ 197 if (dev->progressive)
198 if (buf->top_field)
199 fieldstart = outp; 198 fieldstart = outp;
200 else 199 else {
201 fieldstart = outp + bytesperline; 200 /* Interlaces two half frames */
201 if (buf->top_field)
202 fieldstart = outp;
203 else
204 fieldstart = outp + bytesperline;
205 }
202 206
203 linesdone = dma_q->pos / bytesperline; 207 linesdone = dma_q->pos / bytesperline;
204 currlinedone = dma_q->pos % bytesperline; 208 currlinedone = dma_q->pos % bytesperline;
205 offset = linesdone * bytesperline * 2 + currlinedone; 209
210 if (dev->progressive)
211 offset = linesdone * bytesperline + currlinedone;
212 else
213 offset = linesdone * bytesperline * 2 + currlinedone;
214
206 startwrite = fieldstart + offset; 215 startwrite = fieldstart + offset;
207 lencopy = bytesperline - currlinedone; 216 lencopy = bytesperline - currlinedone;
208 lencopy = lencopy > remain ? remain : lencopy; 217 lencopy = lencopy > remain ? remain : lencopy;
@@ -376,7 +385,7 @@ static inline int em28xx_isoc_copy(struct em28xx *dev, struct urb *urb)
376 em28xx_isocdbg("Video frame %d, length=%i, %s\n", p[2], 385 em28xx_isocdbg("Video frame %d, length=%i, %s\n", p[2],
377 len, (p[2] & 1) ? "odd" : "even"); 386 len, (p[2] & 1) ? "odd" : "even");
378 387
379 if (!(p[2] & 1)) { 388 if (dev->progressive || !(p[2] & 1)) {
380 if (buf != NULL) 389 if (buf != NULL)
381 buffer_filled(dev, dma_q, buf); 390 buffer_filled(dev, dma_q, buf);
382 get_next_buf(dma_q, &buf); 391 get_next_buf(dma_q, &buf);
@@ -689,7 +698,10 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
689 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 698 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
690 699
691 /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */ 700 /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
692 f->fmt.pix.field = dev->interlaced ? 701 if (dev->progressive)
702 f->fmt.pix.field = V4L2_FIELD_NONE;
703 else
704 f->fmt.pix.field = dev->interlaced ?
693 V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; 705 V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP;
694 706
695 mutex_unlock(&dev->lock); 707 mutex_unlock(&dev->lock);
@@ -753,7 +765,11 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
753 f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3; 765 f->fmt.pix.bytesperline = (dev->width * fmt->depth + 7) >> 3;
754 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height; 766 f->fmt.pix.sizeimage = f->fmt.pix.bytesperline * height;
755 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M; 767 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
756 f->fmt.pix.field = V4L2_FIELD_INTERLACED; 768 if (dev->progressive)
769 f->fmt.pix.field = V4L2_FIELD_NONE;
770 else
771 f->fmt.pix.field = dev->interlaced ?
772 V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP;
757 773
758 return 0; 774 return 0;
759} 775}
@@ -846,6 +862,41 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
846 return 0; 862 return 0;
847} 863}
848 864
865static int vidioc_g_parm(struct file *file, void *priv,
866 struct v4l2_streamparm *p)
867{
868 struct em28xx_fh *fh = priv;
869 struct em28xx *dev = fh->dev;
870 int rc = 0;
871
872 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
873 return -EINVAL;
874
875 if (dev->board.is_webcam)
876 rc = v4l2_device_call_until_err(&dev->v4l2_dev, 0,
877 video, g_parm, p);
878 else
879 v4l2_video_std_frame_period(dev->norm,
880 &p->parm.capture.timeperframe);
881
882 return rc;
883}
884
885static int vidioc_s_parm(struct file *file, void *priv,
886 struct v4l2_streamparm *p)
887{
888 struct em28xx_fh *fh = priv;
889 struct em28xx *dev = fh->dev;
890
891 if (!dev->board.is_webcam)
892 return -EINVAL;
893
894 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
895 return -EINVAL;
896
897 return v4l2_device_call_until_err(&dev->v4l2_dev, 0, video, s_parm, p);
898}
899
849static const char *iname[] = { 900static const char *iname[] = {
850 [EM28XX_VMUX_COMPOSITE1] = "Composite1", 901 [EM28XX_VMUX_COMPOSITE1] = "Composite1",
851 [EM28XX_VMUX_COMPOSITE2] = "Composite2", 902 [EM28XX_VMUX_COMPOSITE2] = "Composite2",
@@ -1624,6 +1675,7 @@ static int em28xx_v4l2_open(struct file *filp)
1624 struct em28xx *dev; 1675 struct em28xx *dev;
1625 enum v4l2_buf_type fh_type; 1676 enum v4l2_buf_type fh_type;
1626 struct em28xx_fh *fh; 1677 struct em28xx_fh *fh;
1678 enum v4l2_field field;
1627 1679
1628 dev = em28xx_get_device(minor, &fh_type, &radio); 1680 dev = em28xx_get_device(minor, &fh_type, &radio);
1629 1681
@@ -1665,8 +1717,13 @@ static int em28xx_v4l2_open(struct file *filp)
1665 1717
1666 dev->users++; 1718 dev->users++;
1667 1719
1720 if (dev->progressive)
1721 field = V4L2_FIELD_NONE;
1722 else
1723 field = V4L2_FIELD_INTERLACED;
1724
1668 videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops, 1725 videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops,
1669 NULL, &dev->slock, fh->type, V4L2_FIELD_INTERLACED, 1726 NULL, &dev->slock, fh->type, field,
1670 sizeof(struct em28xx_buffer), fh); 1727 sizeof(struct em28xx_buffer), fh);
1671 1728
1672 mutex_unlock(&dev->lock); 1729 mutex_unlock(&dev->lock);
@@ -1885,6 +1942,8 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
1885 .vidioc_qbuf = vidioc_qbuf, 1942 .vidioc_qbuf = vidioc_qbuf,
1886 .vidioc_dqbuf = vidioc_dqbuf, 1943 .vidioc_dqbuf = vidioc_dqbuf,
1887 .vidioc_s_std = vidioc_s_std, 1944 .vidioc_s_std = vidioc_s_std,
1945 .vidioc_g_parm = vidioc_g_parm,
1946 .vidioc_s_parm = vidioc_s_parm,
1888 .vidioc_enum_input = vidioc_enum_input, 1947 .vidioc_enum_input = vidioc_enum_input,
1889 .vidioc_g_input = vidioc_g_input, 1948 .vidioc_g_input = vidioc_g_input,
1890 .vidioc_s_input = vidioc_s_input, 1949 .vidioc_s_input = vidioc_s_input,
diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h
index 45bd513f62dc..a2add61f7d59 100644
--- a/drivers/media/video/em28xx/em28xx.h
+++ b/drivers/media/video/em28xx/em28xx.h
@@ -367,6 +367,7 @@ enum em28xx_sensor {
367 EM28XX_NOSENSOR = 0, 367 EM28XX_NOSENSOR = 0,
368 EM28XX_MT9V011, 368 EM28XX_MT9V011,
369 EM28XX_MT9M001, 369 EM28XX_MT9M001,
370 EM28XX_MT9M111,
370}; 371};
371 372
372enum em28xx_adecoder { 373enum em28xx_adecoder {
@@ -484,6 +485,9 @@ struct em28xx {
484 int sensor_xres, sensor_yres; 485 int sensor_xres, sensor_yres;
485 int sensor_xtal; 486 int sensor_xtal;
486 487
488 /* Allows progressive (e. g. non-interlaced) mode */
489 int progressive;
490
487 /* Vinmode/Vinctl used at the driver */ 491 /* Vinmode/Vinctl used at the driver */
488 int vinmode, vinctl; 492 int vinmode, vinctl;
489 493
diff --git a/drivers/media/video/gspca/Kconfig b/drivers/media/video/gspca/Kconfig
index 34f46f2bc040..e994dcac43ff 100644
--- a/drivers/media/video/gspca/Kconfig
+++ b/drivers/media/video/gspca/Kconfig
@@ -114,7 +114,7 @@ config USB_GSPCA_SN9C20X
114 114
115config USB_GSPCA_SN9C20X_EVDEV 115config USB_GSPCA_SN9C20X_EVDEV
116 bool "Enable evdev support" 116 bool "Enable evdev support"
117 depends on USB_GSPCA_SN9C20X 117 depends on USB_GSPCA_SN9C20X && INPUT
118 ---help--- 118 ---help---
119 Say Y here in order to enable evdev support for sn9c20x webcam button. 119 Say Y here in order to enable evdev support for sn9c20x webcam button.
120 120
diff --git a/drivers/media/video/hdpvr/hdpvr-video.c b/drivers/media/video/hdpvr/hdpvr-video.c
index ccd47f57f42c..d678765cbba2 100644
--- a/drivers/media/video/hdpvr/hdpvr-video.c
+++ b/drivers/media/video/hdpvr/hdpvr-video.c
@@ -1220,6 +1220,8 @@ static const struct video_device hdpvr_video_template = {
1220 V4L2_STD_PAL_G | V4L2_STD_PAL_H | V4L2_STD_PAL_I | 1220 V4L2_STD_PAL_G | V4L2_STD_PAL_H | V4L2_STD_PAL_I |
1221 V4L2_STD_PAL_D | V4L2_STD_PAL_M | V4L2_STD_PAL_N | 1221 V4L2_STD_PAL_D | V4L2_STD_PAL_M | V4L2_STD_PAL_N |
1222 V4L2_STD_PAL_60, 1222 V4L2_STD_PAL_60,
1223 .current_norm = V4L2_STD_NTSC | V4L2_STD_PAL_M |
1224 V4L2_STD_PAL_60,
1223}; 1225};
1224 1226
1225int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent, 1227int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent,
diff --git a/drivers/media/video/ivtv/ivtv-controls.c b/drivers/media/video/ivtv/ivtv-controls.c
index a3b77ed3f089..4a9c8ce0ecb3 100644
--- a/drivers/media/video/ivtv/ivtv-controls.c
+++ b/drivers/media/video/ivtv/ivtv-controls.c
@@ -17,6 +17,7 @@
17 along with this program; if not, write to the Free Software 17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20#include <linux/kernel.h>
20 21
21#include "ivtv-driver.h" 22#include "ivtv-driver.h"
22#include "ivtv-cards.h" 23#include "ivtv-cards.h"
@@ -281,7 +282,7 @@ int ivtv_s_ext_ctrls(struct file *file, void *fh, struct v4l2_ext_controls *c)
281 idx = p.audio_properties & 0x03; 282 idx = p.audio_properties & 0x03;
282 /* The audio clock of the digitizer must match the codec sample 283 /* The audio clock of the digitizer must match the codec sample
283 rate otherwise you get some very strange effects. */ 284 rate otherwise you get some very strange effects. */
284 if (idx < sizeof(freqs)) 285 if (idx < ARRAY_SIZE(freqs))
285 ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]); 286 ivtv_call_all(itv, audio, s_clock_freq, freqs[idx]);
286 return err; 287 return err;
287 } 288 }
diff --git a/drivers/media/video/mt9v011.c b/drivers/media/video/mt9v011.c
index b2260de645f0..cc85f77a5706 100644
--- a/drivers/media/video/mt9v011.c
+++ b/drivers/media/video/mt9v011.c
@@ -52,13 +52,34 @@ static struct v4l2_queryctrl mt9v011_qctrl[] = {
52 .step = 1, 52 .step = 1,
53 .default_value = 0, 53 .default_value = 0,
54 .flags = 0, 54 .flags = 0,
55 }, 55 }, {
56 .id = V4L2_CID_HFLIP,
57 .type = V4L2_CTRL_TYPE_BOOLEAN,
58 .name = "Mirror",
59 .minimum = 0,
60 .maximum = 1,
61 .step = 1,
62 .default_value = 0,
63 .flags = 0,
64 }, {
65 .id = V4L2_CID_VFLIP,
66 .type = V4L2_CTRL_TYPE_BOOLEAN,
67 .name = "Vflip",
68 .minimum = 0,
69 .maximum = 1,
70 .step = 1,
71 .default_value = 0,
72 .flags = 0,
73 }, {
74 }
56}; 75};
57 76
58struct mt9v011 { 77struct mt9v011 {
59 struct v4l2_subdev sd; 78 struct v4l2_subdev sd;
60 unsigned width, height; 79 unsigned width, height;
61 unsigned xtal; 80 unsigned xtal;
81 unsigned hflip:1;
82 unsigned vflip:1;
62 83
63 u16 global_gain, red_bal, blue_bal; 84 u16 global_gain, red_bal, blue_bal;
64}; 85};
@@ -131,7 +152,6 @@ static const struct i2c_reg_value mt9v011_init_default[] = {
131 152
132 { R0A_MT9V011_CLK_SPEED, 0x0000 }, 153 { R0A_MT9V011_CLK_SPEED, 0x0000 },
133 { R1E_MT9V011_DIGITAL_ZOOM, 0x0000 }, 154 { R1E_MT9V011_DIGITAL_ZOOM, 0x0000 },
134 { R20_MT9V011_READ_MODE, 0x1000 },
135 155
136 { R07_MT9V011_OUT_CTRL, 0x0002 }, /* chip enable */ 156 { R07_MT9V011_OUT_CTRL, 0x0002 }, /* chip enable */
137}; 157};
@@ -156,7 +176,7 @@ static void set_balance(struct v4l2_subdev *sd)
156 mt9v011_write(sd, R2D_MT9V011_RED_GAIN, red_gain); 176 mt9v011_write(sd, R2D_MT9V011_RED_GAIN, red_gain);
157} 177}
158 178
159static void calc_fps(struct v4l2_subdev *sd) 179static void calc_fps(struct v4l2_subdev *sd, u32 *numerator, u32 *denominator)
160{ 180{
161 struct mt9v011 *core = to_mt9v011(sd); 181 struct mt9v011 *core = to_mt9v011(sd);
162 unsigned height, width, hblank, vblank, speed; 182 unsigned height, width, hblank, vblank, speed;
@@ -179,6 +199,51 @@ static void calc_fps(struct v4l2_subdev *sd)
179 199
180 v4l2_dbg(1, debug, sd, "Programmed to %u.%03u fps (%d pixel clcks)\n", 200 v4l2_dbg(1, debug, sd, "Programmed to %u.%03u fps (%d pixel clcks)\n",
181 tmp / 1000, tmp % 1000, t_time); 201 tmp / 1000, tmp % 1000, t_time);
202
203 if (numerator && denominator) {
204 *numerator = 1000;
205 *denominator = (u32)frames_per_ms;
206 }
207}
208
209static u16 calc_speed(struct v4l2_subdev *sd, u32 numerator, u32 denominator)
210{
211 struct mt9v011 *core = to_mt9v011(sd);
212 unsigned height, width, hblank, vblank;
213 unsigned row_time, line_time;
214 u64 t_time, speed;
215
216 /* Avoid bogus calculus */
217 if (!numerator || !denominator)
218 return 0;
219
220 height = mt9v011_read(sd, R03_MT9V011_HEIGHT);
221 width = mt9v011_read(sd, R04_MT9V011_WIDTH);
222 hblank = mt9v011_read(sd, R05_MT9V011_HBLANK);
223 vblank = mt9v011_read(sd, R06_MT9V011_VBLANK);
224
225 row_time = width + 113 + hblank;
226 line_time = height + vblank + 1;
227
228 t_time = core->xtal * ((u64)numerator);
229 /* round to the closest value */
230 t_time += denominator / 2;
231 do_div(t_time, denominator);
232
233 speed = t_time;
234 do_div(speed, row_time * line_time);
235
236 /* Avoid having a negative value for speed */
237 if (speed < 2)
238 speed = 0;
239 else
240 speed -= 2;
241
242 /* Avoid speed overflow */
243 if (speed > 15)
244 return 15;
245
246 return (u16)speed;
182} 247}
183 248
184static void set_res(struct v4l2_subdev *sd) 249static void set_res(struct v4l2_subdev *sd)
@@ -207,9 +272,23 @@ static void set_res(struct v4l2_subdev *sd)
207 mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height); 272 mt9v011_write(sd, R03_MT9V011_HEIGHT, core->height);
208 mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height); 273 mt9v011_write(sd, R06_MT9V011_VBLANK, 508 - core->height);
209 274
210 calc_fps(sd); 275 calc_fps(sd, NULL, NULL);
211}; 276};
212 277
278static void set_read_mode(struct v4l2_subdev *sd)
279{
280 struct mt9v011 *core = to_mt9v011(sd);
281 unsigned mode = 0x1000;
282
283 if (core->hflip)
284 mode |= 0x4000;
285
286 if (core->vflip)
287 mode |= 0x8000;
288
289 mt9v011_write(sd, R20_MT9V011_READ_MODE, mode);
290}
291
213static int mt9v011_reset(struct v4l2_subdev *sd, u32 val) 292static int mt9v011_reset(struct v4l2_subdev *sd, u32 val)
214{ 293{
215 int i; 294 int i;
@@ -220,6 +299,7 @@ static int mt9v011_reset(struct v4l2_subdev *sd, u32 val)
220 299
221 set_balance(sd); 300 set_balance(sd);
222 set_res(sd); 301 set_res(sd);
302 set_read_mode(sd);
223 303
224 return 0; 304 return 0;
225}; 305};
@@ -240,6 +320,12 @@ static int mt9v011_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
240 case V4L2_CID_BLUE_BALANCE: 320 case V4L2_CID_BLUE_BALANCE:
241 ctrl->value = core->blue_bal; 321 ctrl->value = core->blue_bal;
242 return 0; 322 return 0;
323 case V4L2_CID_HFLIP:
324 ctrl->value = core->hflip ? 1 : 0;
325 return 0;
326 case V4L2_CID_VFLIP:
327 ctrl->value = core->vflip ? 1 : 0;
328 return 0;
243 } 329 }
244 return -EINVAL; 330 return -EINVAL;
245} 331}
@@ -288,6 +374,14 @@ static int mt9v011_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
288 case V4L2_CID_BLUE_BALANCE: 374 case V4L2_CID_BLUE_BALANCE:
289 core->blue_bal = ctrl->value; 375 core->blue_bal = ctrl->value;
290 break; 376 break;
377 case V4L2_CID_HFLIP:
378 core->hflip = ctrl->value;
379 set_read_mode(sd);
380 return 0;
381 case V4L2_CID_VFLIP:
382 core->vflip = ctrl->value;
383 set_read_mode(sd);
384 return 0;
291 default: 385 default:
292 return -EINVAL; 386 return -EINVAL;
293 } 387 }
@@ -322,6 +416,44 @@ static int mt9v011_try_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
322 return 0; 416 return 0;
323} 417}
324 418
419static int mt9v011_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
420{
421 struct v4l2_captureparm *cp = &parms->parm.capture;
422
423 if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
424 return -EINVAL;
425
426 memset(cp, 0, sizeof(struct v4l2_captureparm));
427 cp->capability = V4L2_CAP_TIMEPERFRAME;
428 calc_fps(sd,
429 &cp->timeperframe.numerator,
430 &cp->timeperframe.denominator);
431
432 return 0;
433}
434
435static int mt9v011_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *parms)
436{
437 struct v4l2_captureparm *cp = &parms->parm.capture;
438 struct v4l2_fract *tpf = &cp->timeperframe;
439 u16 speed;
440
441 if (parms->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
442 return -EINVAL;
443 if (cp->extendedmode != 0)
444 return -EINVAL;
445
446 speed = calc_speed(sd, tpf->numerator, tpf->denominator);
447
448 mt9v011_write(sd, R0A_MT9V011_CLK_SPEED, speed);
449 v4l2_dbg(1, debug, sd, "Setting speed to %d\n", speed);
450
451 /* Recalculate and update fps info */
452 calc_fps(sd, &tpf->numerator, &tpf->denominator);
453
454 return 0;
455}
456
325static int mt9v011_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt) 457static int mt9v011_s_fmt(struct v4l2_subdev *sd, struct v4l2_format *fmt)
326{ 458{
327 struct v4l2_pix_format *pix = &fmt->fmt.pix; 459 struct v4l2_pix_format *pix = &fmt->fmt.pix;
@@ -393,10 +525,13 @@ static int mt9v011_s_register(struct v4l2_subdev *sd,
393static int mt9v011_g_chip_ident(struct v4l2_subdev *sd, 525static int mt9v011_g_chip_ident(struct v4l2_subdev *sd,
394 struct v4l2_dbg_chip_ident *chip) 526 struct v4l2_dbg_chip_ident *chip)
395{ 527{
528 u16 version;
396 struct i2c_client *client = v4l2_get_subdevdata(sd); 529 struct i2c_client *client = v4l2_get_subdevdata(sd);
397 530
531 version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION);
532
398 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_MT9V011, 533 return v4l2_chip_ident_i2c_client(client, chip, V4L2_IDENT_MT9V011,
399 MT9V011_VERSION); 534 version);
400} 535}
401 536
402static const struct v4l2_subdev_core_ops mt9v011_core_ops = { 537static const struct v4l2_subdev_core_ops mt9v011_core_ops = {
@@ -416,6 +551,8 @@ static const struct v4l2_subdev_video_ops mt9v011_video_ops = {
416 .enum_fmt = mt9v011_enum_fmt, 551 .enum_fmt = mt9v011_enum_fmt,
417 .try_fmt = mt9v011_try_fmt, 552 .try_fmt = mt9v011_try_fmt,
418 .s_fmt = mt9v011_s_fmt, 553 .s_fmt = mt9v011_s_fmt,
554 .g_parm = mt9v011_g_parm,
555 .s_parm = mt9v011_s_parm,
419}; 556};
420 557
421static const struct v4l2_subdev_ops mt9v011_ops = { 558static const struct v4l2_subdev_ops mt9v011_ops = {
@@ -449,8 +586,9 @@ static int mt9v011_probe(struct i2c_client *c,
449 586
450 /* Check if the sensor is really a MT9V011 */ 587 /* Check if the sensor is really a MT9V011 */
451 version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION); 588 version = mt9v011_read(sd, R00_MT9V011_CHIP_VERSION);
452 if (version != MT9V011_VERSION) { 589 if ((version != MT9V011_VERSION) &&
453 v4l2_info(sd, "*** unknown micron chip detected (0x%04x.\n", 590 (version != MT9V011_REV_B_VERSION)) {
591 v4l2_info(sd, "*** unknown micron chip detected (0x%04x).\n",
454 version); 592 version);
455 kfree(core); 593 kfree(core);
456 return -EINVAL; 594 return -EINVAL;
@@ -461,8 +599,8 @@ static int mt9v011_probe(struct i2c_client *c,
461 core->height = 480; 599 core->height = 480;
462 core->xtal = 27000000; /* Hz */ 600 core->xtal = 27000000; /* Hz */
463 601
464 v4l_info(c, "chip found @ 0x%02x (%s)\n", 602 v4l_info(c, "chip found @ 0x%02x (%s - chip version 0x%04x)\n",
465 c->addr << 1, c->adapter->name); 603 c->addr << 1, c->adapter->name, version);
466 604
467 return 0; 605 return 0;
468} 606}
diff --git a/drivers/media/video/mt9v011.h b/drivers/media/video/mt9v011.h
index 9e443ee30558..3350fd6083c3 100644
--- a/drivers/media/video/mt9v011.h
+++ b/drivers/media/video/mt9v011.h
@@ -30,6 +30,7 @@
30#define R35_MT9V011_GLOBAL_GAIN 0x35 30#define R35_MT9V011_GLOBAL_GAIN 0x35
31#define RF1_MT9V011_CHIP_ENABLE 0xf1 31#define RF1_MT9V011_CHIP_ENABLE 0xf1
32 32
33#define MT9V011_VERSION 0x8243 33#define MT9V011_VERSION 0x8232
34#define MT9V011_REV_B_VERSION 0x8243
34 35
35#endif 36#endif
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c
index 2d075205bdfe..736c31d23194 100644
--- a/drivers/media/video/mx1_camera.c
+++ b/drivers/media/video/mx1_camera.c
@@ -234,6 +234,7 @@ static int mx1_camera_setup_dma(struct mx1_camera_dev *pcdev)
234 return ret; 234 return ret;
235} 235}
236 236
237/* Called under spinlock_irqsave(&pcdev->lock, ...) */
237static void mx1_videobuf_queue(struct videobuf_queue *vq, 238static void mx1_videobuf_queue(struct videobuf_queue *vq,
238 struct videobuf_buffer *vb) 239 struct videobuf_buffer *vb)
239{ 240{
@@ -241,13 +242,10 @@ static void mx1_videobuf_queue(struct videobuf_queue *vq,
241 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 242 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
242 struct mx1_camera_dev *pcdev = ici->priv; 243 struct mx1_camera_dev *pcdev = ici->priv;
243 struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb); 244 struct mx1_buffer *buf = container_of(vb, struct mx1_buffer, vb);
244 unsigned long flags;
245 245
246 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__, 246 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d\n", __func__,
247 vb, vb->baddr, vb->bsize); 247 vb, vb->baddr, vb->bsize);
248 248
249 spin_lock_irqsave(&pcdev->lock, flags);
250
251 list_add_tail(&vb->queue, &pcdev->capture); 249 list_add_tail(&vb->queue, &pcdev->capture);
252 250
253 vb->state = VIDEOBUF_ACTIVE; 251 vb->state = VIDEOBUF_ACTIVE;
@@ -264,8 +262,6 @@ static void mx1_videobuf_queue(struct videobuf_queue *vq,
264 __raw_writel(temp, pcdev->base + CSICR1); 262 __raw_writel(temp, pcdev->base + CSICR1);
265 } 263 }
266 } 264 }
267
268 spin_unlock_irqrestore(&pcdev->lock, flags);
269} 265}
270 266
271static void mx1_videobuf_release(struct videobuf_queue *vq, 267static void mx1_videobuf_release(struct videobuf_queue *vq,
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c
index e605c076ed89..9770cb7932ca 100644
--- a/drivers/media/video/mx3_camera.c
+++ b/drivers/media/video/mx3_camera.c
@@ -332,7 +332,10 @@ static enum pixel_fmt fourcc_to_ipu_pix(__u32 fourcc)
332 } 332 }
333} 333}
334 334
335/* Called with .vb_lock held */ 335/*
336 * Called with .vb_lock mutex held and
337 * under spinlock_irqsave(&mx3_cam->lock, ...)
338 */
336static void mx3_videobuf_queue(struct videobuf_queue *vq, 339static void mx3_videobuf_queue(struct videobuf_queue *vq,
337 struct videobuf_buffer *vb) 340 struct videobuf_buffer *vb)
338{ 341{
@@ -346,7 +349,8 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
346 struct idmac_video_param *video = &ichan->params.video; 349 struct idmac_video_param *video = &ichan->params.video;
347 const struct soc_camera_data_format *data_fmt = icd->current_fmt; 350 const struct soc_camera_data_format *data_fmt = icd->current_fmt;
348 dma_cookie_t cookie; 351 dma_cookie_t cookie;
349 unsigned long flags; 352
353 BUG_ON(!irqs_disabled());
350 354
351 /* This is the configuration of one sg-element */ 355 /* This is the configuration of one sg-element */
352 video->out_pixel_fmt = fourcc_to_ipu_pix(data_fmt->fourcc); 356 video->out_pixel_fmt = fourcc_to_ipu_pix(data_fmt->fourcc);
@@ -359,8 +363,6 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
359 memset((void *)vb->baddr, 0xaa, vb->bsize); 363 memset((void *)vb->baddr, 0xaa, vb->bsize);
360#endif 364#endif
361 365
362 spin_lock_irqsave(&mx3_cam->lock, flags);
363
364 list_add_tail(&vb->queue, &mx3_cam->capture); 366 list_add_tail(&vb->queue, &mx3_cam->capture);
365 367
366 if (!mx3_cam->active) { 368 if (!mx3_cam->active) {
@@ -370,24 +372,23 @@ static void mx3_videobuf_queue(struct videobuf_queue *vq,
370 vb->state = VIDEOBUF_QUEUED; 372 vb->state = VIDEOBUF_QUEUED;
371 } 373 }
372 374
373 spin_unlock_irqrestore(&mx3_cam->lock, flags); 375 spin_unlock_irq(&mx3_cam->lock);
374 376
375 cookie = txd->tx_submit(txd); 377 cookie = txd->tx_submit(txd);
376 dev_dbg(&icd->dev, "Submitted cookie %d DMA 0x%08x\n", cookie, sg_dma_address(&buf->sg)); 378 dev_dbg(&icd->dev, "Submitted cookie %d DMA 0x%08x\n", cookie, sg_dma_address(&buf->sg));
379
380 spin_lock_irq(&mx3_cam->lock);
381
377 if (cookie >= 0) 382 if (cookie >= 0)
378 return; 383 return;
379 384
380 /* Submit error */ 385 /* Submit error */
381 vb->state = VIDEOBUF_PREPARED; 386 vb->state = VIDEOBUF_PREPARED;
382 387
383 spin_lock_irqsave(&mx3_cam->lock, flags);
384
385 list_del_init(&vb->queue); 388 list_del_init(&vb->queue);
386 389
387 if (mx3_cam->active == buf) 390 if (mx3_cam->active == buf)
388 mx3_cam->active = NULL; 391 mx3_cam->active = NULL;
389
390 spin_unlock_irqrestore(&mx3_cam->lock, flags);
391} 392}
392 393
393/* Called with .vb_lock held */ 394/* Called with .vb_lock held */
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c
index 46e0d8ad880f..016bb45ba0c3 100644
--- a/drivers/media/video/pxa_camera.c
+++ b/drivers/media/video/pxa_camera.c
@@ -612,6 +612,7 @@ static void pxa_camera_stop_capture(struct pxa_camera_dev *pcdev)
612 dev_dbg(pcdev->soc_host.dev, "%s\n", __func__); 612 dev_dbg(pcdev->soc_host.dev, "%s\n", __func__);
613} 613}
614 614
615/* Called under spinlock_irqsave(&pcdev->lock, ...) */
615static void pxa_videobuf_queue(struct videobuf_queue *vq, 616static void pxa_videobuf_queue(struct videobuf_queue *vq,
616 struct videobuf_buffer *vb) 617 struct videobuf_buffer *vb)
617{ 618{
@@ -619,13 +620,10 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq,
619 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 620 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
620 struct pxa_camera_dev *pcdev = ici->priv; 621 struct pxa_camera_dev *pcdev = ici->priv;
621 struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb); 622 struct pxa_buffer *buf = container_of(vb, struct pxa_buffer, vb);
622 unsigned long flags;
623 623
624 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d active=%p\n", __func__, 624 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %d active=%p\n", __func__,
625 vb, vb->baddr, vb->bsize, pcdev->active); 625 vb, vb->baddr, vb->bsize, pcdev->active);
626 626
627 spin_lock_irqsave(&pcdev->lock, flags);
628
629 list_add_tail(&vb->queue, &pcdev->capture); 627 list_add_tail(&vb->queue, &pcdev->capture);
630 628
631 vb->state = VIDEOBUF_ACTIVE; 629 vb->state = VIDEOBUF_ACTIVE;
@@ -633,8 +631,6 @@ static void pxa_videobuf_queue(struct videobuf_queue *vq,
633 631
634 if (!pcdev->active) 632 if (!pcdev->active)
635 pxa_camera_start_capture(pcdev); 633 pxa_camera_start_capture(pcdev);
636
637 spin_unlock_irqrestore(&pcdev->lock, flags);
638} 634}
639 635
640static void pxa_videobuf_release(struct videobuf_queue *vq, 636static void pxa_videobuf_release(struct videobuf_queue *vq,
@@ -1579,6 +1575,7 @@ static int __devinit pxa_camera_probe(struct platform_device *pdev)
1579 pcdev->mclk = 20000000; 1575 pcdev->mclk = 20000000;
1580 } 1576 }
1581 1577
1578 pcdev->soc_host.dev = &pdev->dev;
1582 pcdev->mclk_divisor = mclk_get_divisor(pcdev); 1579 pcdev->mclk_divisor = mclk_get_divisor(pcdev);
1583 1580
1584 INIT_LIST_HEAD(&pcdev->capture); 1581 INIT_LIST_HEAD(&pcdev->capture);
@@ -1644,7 +1641,6 @@ static int __devinit pxa_camera_probe(struct platform_device *pdev)
1644 pcdev->soc_host.drv_name = PXA_CAM_DRV_NAME; 1641 pcdev->soc_host.drv_name = PXA_CAM_DRV_NAME;
1645 pcdev->soc_host.ops = &pxa_soc_camera_host_ops; 1642 pcdev->soc_host.ops = &pxa_soc_camera_host_ops;
1646 pcdev->soc_host.priv = pcdev; 1643 pcdev->soc_host.priv = pcdev;
1647 pcdev->soc_host.dev = &pdev->dev;
1648 pcdev->soc_host.nr = pdev->id; 1644 pcdev->soc_host.nr = pdev->id;
1649 1645
1650 err = soc_camera_host_register(&pcdev->soc_host); 1646 err = soc_camera_host_register(&pcdev->soc_host);
diff --git a/drivers/media/video/saa7134/saa7134-cards.c b/drivers/media/video/saa7134/saa7134-cards.c
index 06861b782b95..6eebe3ef97d3 100644
--- a/drivers/media/video/saa7134/saa7134-cards.c
+++ b/drivers/media/video/saa7134/saa7134-cards.c
@@ -3331,8 +3331,8 @@ struct saa7134_board saa7134_boards[] = {
3331 .gpio = 0x0200100, 3331 .gpio = 0x0200100,
3332 }, 3332 },
3333 }, 3333 },
3334 [SAA7134_BOARD_HAUPPAUGE_HVR1120] = { 3334 [SAA7134_BOARD_HAUPPAUGE_HVR1150] = {
3335 .name = "Hauppauge WinTV-HVR1120 ATSC/QAM-Hybrid", 3335 .name = "Hauppauge WinTV-HVR1150 ATSC/QAM-Hybrid",
3336 .audio_clock = 0x00187de7, 3336 .audio_clock = 0x00187de7,
3337 .tuner_type = TUNER_PHILIPS_TDA8290, 3337 .tuner_type = TUNER_PHILIPS_TDA8290,
3338 .radio_type = UNSET, 3338 .radio_type = UNSET,
@@ -3363,8 +3363,8 @@ struct saa7134_board saa7134_boards[] = {
3363 .gpio = 0x0800100, /* GPIO 23 HI for FM */ 3363 .gpio = 0x0800100, /* GPIO 23 HI for FM */
3364 }, 3364 },
3365 }, 3365 },
3366 [SAA7134_BOARD_HAUPPAUGE_HVR1110R3] = { 3366 [SAA7134_BOARD_HAUPPAUGE_HVR1120] = {
3367 .name = "Hauppauge WinTV-HVR1110r3 DVB-T/Hybrid", 3367 .name = "Hauppauge WinTV-HVR1120 DVB-T/Hybrid",
3368 .audio_clock = 0x00187de7, 3368 .audio_clock = 0x00187de7,
3369 .tuner_type = TUNER_PHILIPS_TDA8290, 3369 .tuner_type = TUNER_PHILIPS_TDA8290,
3370 .radio_type = UNSET, 3370 .radio_type = UNSET,
@@ -5862,31 +5862,31 @@ struct pci_device_id saa7134_pci_tbl[] = {
5862 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 5862 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5863 .subvendor = 0x0070, 5863 .subvendor = 0x0070,
5864 .subdevice = 0x6706, 5864 .subdevice = 0x6706,
5865 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1120, 5865 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1150,
5866 },{ 5866 },{
5867 .vendor = PCI_VENDOR_ID_PHILIPS, 5867 .vendor = PCI_VENDOR_ID_PHILIPS,
5868 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 5868 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5869 .subvendor = 0x0070, 5869 .subvendor = 0x0070,
5870 .subdevice = 0x6707, 5870 .subdevice = 0x6707,
5871 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1110R3, 5871 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1120,
5872 },{ 5872 },{
5873 .vendor = PCI_VENDOR_ID_PHILIPS, 5873 .vendor = PCI_VENDOR_ID_PHILIPS,
5874 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 5874 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5875 .subvendor = 0x0070, 5875 .subvendor = 0x0070,
5876 .subdevice = 0x6708, 5876 .subdevice = 0x6708,
5877 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1120, 5877 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1150,
5878 },{ 5878 },{
5879 .vendor = PCI_VENDOR_ID_PHILIPS, 5879 .vendor = PCI_VENDOR_ID_PHILIPS,
5880 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 5880 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5881 .subvendor = 0x0070, 5881 .subvendor = 0x0070,
5882 .subdevice = 0x6709, 5882 .subdevice = 0x6709,
5883 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1110R3, 5883 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1120,
5884 },{ 5884 },{
5885 .vendor = PCI_VENDOR_ID_PHILIPS, 5885 .vendor = PCI_VENDOR_ID_PHILIPS,
5886 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 5886 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
5887 .subvendor = 0x0070, 5887 .subvendor = 0x0070,
5888 .subdevice = 0x670a, 5888 .subdevice = 0x670a,
5889 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1110R3, 5889 .driver_data = SAA7134_BOARD_HAUPPAUGE_HVR1120,
5890 },{ 5890 },{
5891 .vendor = PCI_VENDOR_ID_PHILIPS, 5891 .vendor = PCI_VENDOR_ID_PHILIPS,
5892 .device = PCI_DEVICE_ID_PHILIPS_SAA7133, 5892 .device = PCI_DEVICE_ID_PHILIPS_SAA7133,
@@ -6363,8 +6363,8 @@ static int saa7134_tda8290_18271_callback(struct saa7134_dev *dev,
6363 switch (command) { 6363 switch (command) {
6364 case TDA18271_CALLBACK_CMD_AGC_ENABLE: /* 0 */ 6364 case TDA18271_CALLBACK_CMD_AGC_ENABLE: /* 0 */
6365 switch (dev->board) { 6365 switch (dev->board) {
6366 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
6366 case SAA7134_BOARD_HAUPPAUGE_HVR1120: 6367 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
6367 case SAA7134_BOARD_HAUPPAUGE_HVR1110R3:
6368 ret = saa7134_tda18271_hvr11x0_toggle_agc(dev, arg); 6368 ret = saa7134_tda18271_hvr11x0_toggle_agc(dev, arg);
6369 break; 6369 break;
6370 default: 6370 default:
@@ -6384,8 +6384,8 @@ static int saa7134_tda8290_callback(struct saa7134_dev *dev,
6384 int ret; 6384 int ret;
6385 6385
6386 switch (dev->board) { 6386 switch (dev->board) {
6387 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
6387 case SAA7134_BOARD_HAUPPAUGE_HVR1120: 6388 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
6388 case SAA7134_BOARD_HAUPPAUGE_HVR1110R3:
6389 /* tda8290 + tda18271 */ 6389 /* tda8290 + tda18271 */
6390 ret = saa7134_tda8290_18271_callback(dev, command, arg); 6390 ret = saa7134_tda8290_18271_callback(dev, command, arg);
6391 break; 6391 break;
@@ -6427,7 +6427,7 @@ static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data)
6427 switch (tv.model) { 6427 switch (tv.model) {
6428 case 67019: /* WinTV-HVR1110 (Retail, IR Blaster, hybrid, FM, SVid/Comp, 3.5mm audio in) */ 6428 case 67019: /* WinTV-HVR1110 (Retail, IR Blaster, hybrid, FM, SVid/Comp, 3.5mm audio in) */
6429 case 67109: /* WinTV-HVR1000 (Retail, IR Receive, analog, no FM, SVid/Comp, 3.5mm audio in) */ 6429 case 67109: /* WinTV-HVR1000 (Retail, IR Receive, analog, no FM, SVid/Comp, 3.5mm audio in) */
6430 case 67201: /* WinTV-HVR1120 (Retail, IR Receive, hybrid, FM, SVid/Comp, 3.5mm audio in) */ 6430 case 67201: /* WinTV-HVR1150 (Retail, IR Receive, hybrid, FM, SVid/Comp, 3.5mm audio in) */
6431 case 67301: /* WinTV-HVR1000 (Retail, IR Receive, analog, no FM, SVid/Comp, 3.5mm audio in) */ 6431 case 67301: /* WinTV-HVR1000 (Retail, IR Receive, analog, no FM, SVid/Comp, 3.5mm audio in) */
6432 case 67209: /* WinTV-HVR1110 (Retail, IR Receive, hybrid, FM, SVid/Comp, 3.5mm audio in) */ 6432 case 67209: /* WinTV-HVR1110 (Retail, IR Receive, hybrid, FM, SVid/Comp, 3.5mm audio in) */
6433 case 67559: /* WinTV-HVR1110 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */ 6433 case 67559: /* WinTV-HVR1110 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */
@@ -6435,7 +6435,7 @@ static void hauppauge_eeprom(struct saa7134_dev *dev, u8 *eeprom_data)
6435 case 67579: /* WinTV-HVR1110 (OEM, no IR, hybrid, no FM) */ 6435 case 67579: /* WinTV-HVR1110 (OEM, no IR, hybrid, no FM) */
6436 case 67589: /* WinTV-HVR1110 (OEM, no IR, hybrid, no FM, SVid/Comp, RCA aud) */ 6436 case 67589: /* WinTV-HVR1110 (OEM, no IR, hybrid, no FM, SVid/Comp, RCA aud) */
6437 case 67599: /* WinTV-HVR1110 (OEM, no IR, hybrid, no FM, SVid/Comp, RCA aud) */ 6437 case 67599: /* WinTV-HVR1110 (OEM, no IR, hybrid, no FM, SVid/Comp, RCA aud) */
6438 case 67651: /* WinTV-HVR1120 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */ 6438 case 67651: /* WinTV-HVR1150 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */
6439 case 67659: /* WinTV-HVR1110 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */ 6439 case 67659: /* WinTV-HVR1110 (OEM, no IR, hybrid, FM, SVid/Comp, RCA aud) */
6440 break; 6440 break;
6441 default: 6441 default:
@@ -6625,8 +6625,8 @@ int saa7134_board_init1(struct saa7134_dev *dev)
6625 6625
6626 saa_writeb (SAA7134_PRODUCTION_TEST_MODE, 0x00); 6626 saa_writeb (SAA7134_PRODUCTION_TEST_MODE, 0x00);
6627 break; 6627 break;
6628 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
6628 case SAA7134_BOARD_HAUPPAUGE_HVR1120: 6629 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
6629 case SAA7134_BOARD_HAUPPAUGE_HVR1110R3:
6630 /* GPIO 26 high for digital, low for analog */ 6630 /* GPIO 26 high for digital, low for analog */
6631 saa7134_set_gpio(dev, 26, 0); 6631 saa7134_set_gpio(dev, 26, 0);
6632 msleep(1); 6632 msleep(1);
@@ -6891,8 +6891,8 @@ int saa7134_board_init2(struct saa7134_dev *dev)
6891 dev->name, saa7134_boards[dev->board].name); 6891 dev->name, saa7134_boards[dev->board].name);
6892 } 6892 }
6893 break; 6893 break;
6894 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
6894 case SAA7134_BOARD_HAUPPAUGE_HVR1120: 6895 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
6895 case SAA7134_BOARD_HAUPPAUGE_HVR1110R3:
6896 hauppauge_eeprom(dev, dev->eedata+0x80); 6896 hauppauge_eeprom(dev, dev->eedata+0x80);
6897 break; 6897 break;
6898 case SAA7134_BOARD_HAUPPAUGE_HVR1110: 6898 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
diff --git a/drivers/media/video/saa7134/saa7134-dvb.c b/drivers/media/video/saa7134/saa7134-dvb.c
index 31930f26ffc7..98f3efd1e944 100644
--- a/drivers/media/video/saa7134/saa7134-dvb.c
+++ b/drivers/media/video/saa7134/saa7134-dvb.c
@@ -1119,7 +1119,7 @@ static int dvb_init(struct saa7134_dev *dev)
1119 &tda827x_cfg_2) < 0) 1119 &tda827x_cfg_2) < 0)
1120 goto dettach_frontend; 1120 goto dettach_frontend;
1121 break; 1121 break;
1122 case SAA7134_BOARD_HAUPPAUGE_HVR1110R3: 1122 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1123 fe0->dvb.frontend = dvb_attach(tda10048_attach, 1123 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1124 &hcw_tda10048_config, 1124 &hcw_tda10048_config,
1125 &dev->i2c_adap); 1125 &dev->i2c_adap);
@@ -1147,7 +1147,7 @@ static int dvb_init(struct saa7134_dev *dev)
1147 &tda827x_cfg_1) < 0) 1147 &tda827x_cfg_1) < 0)
1148 goto dettach_frontend; 1148 goto dettach_frontend;
1149 break; 1149 break;
1150 case SAA7134_BOARD_HAUPPAUGE_HVR1120: 1150 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
1151 fe0->dvb.frontend = dvb_attach(lgdt3305_attach, 1151 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1152 &hcw_lgdt3305_config, 1152 &hcw_lgdt3305_config,
1153 &dev->i2c_adap); 1153 &dev->i2c_adap);
diff --git a/drivers/media/video/saa7134/saa7134.h b/drivers/media/video/saa7134/saa7134.h
index 82268848f26a..fb564f14887c 100644
--- a/drivers/media/video/saa7134/saa7134.h
+++ b/drivers/media/video/saa7134/saa7134.h
@@ -278,8 +278,8 @@ struct saa7134_format {
278#define SAA7134_BOARD_ASUSTeK_TIGER 152 278#define SAA7134_BOARD_ASUSTeK_TIGER 152
279#define SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG 153 279#define SAA7134_BOARD_KWORLD_PLUS_TV_ANALOG 153
280#define SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS 154 280#define SAA7134_BOARD_AVERMEDIA_GO_007_FM_PLUS 154
281#define SAA7134_BOARD_HAUPPAUGE_HVR1120 155 281#define SAA7134_BOARD_HAUPPAUGE_HVR1150 155
282#define SAA7134_BOARD_HAUPPAUGE_HVR1110R3 156 282#define SAA7134_BOARD_HAUPPAUGE_HVR1120 156
283#define SAA7134_BOARD_AVERMEDIA_STUDIO_507UA 157 283#define SAA7134_BOARD_AVERMEDIA_STUDIO_507UA 157
284#define SAA7134_BOARD_AVERMEDIA_CARDBUS_501 158 284#define SAA7134_BOARD_AVERMEDIA_CARDBUS_501 158
285#define SAA7134_BOARD_BEHOLD_505RDS 159 285#define SAA7134_BOARD_BEHOLD_505RDS 159
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c
index 0db88a53d92c..e86878deea71 100644
--- a/drivers/media/video/sh_mobile_ceu_camera.c
+++ b/drivers/media/video/sh_mobile_ceu_camera.c
@@ -282,27 +282,24 @@ out:
282 return ret; 282 return ret;
283} 283}
284 284
285/* Called under spinlock_irqsave(&pcdev->lock, ...) */
285static void sh_mobile_ceu_videobuf_queue(struct videobuf_queue *vq, 286static void sh_mobile_ceu_videobuf_queue(struct videobuf_queue *vq,
286 struct videobuf_buffer *vb) 287 struct videobuf_buffer *vb)
287{ 288{
288 struct soc_camera_device *icd = vq->priv_data; 289 struct soc_camera_device *icd = vq->priv_data;
289 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); 290 struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
290 struct sh_mobile_ceu_dev *pcdev = ici->priv; 291 struct sh_mobile_ceu_dev *pcdev = ici->priv;
291 unsigned long flags;
292 292
293 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__, 293 dev_dbg(&icd->dev, "%s (vb=0x%p) 0x%08lx %zd\n", __func__,
294 vb, vb->baddr, vb->bsize); 294 vb, vb->baddr, vb->bsize);
295 295
296 vb->state = VIDEOBUF_QUEUED; 296 vb->state = VIDEOBUF_QUEUED;
297 spin_lock_irqsave(&pcdev->lock, flags);
298 list_add_tail(&vb->queue, &pcdev->capture); 297 list_add_tail(&vb->queue, &pcdev->capture);
299 298
300 if (!pcdev->active) { 299 if (!pcdev->active) {
301 pcdev->active = vb; 300 pcdev->active = vb;
302 sh_mobile_ceu_capture(pcdev); 301 sh_mobile_ceu_capture(pcdev);
303 } 302 }
304
305 spin_unlock_irqrestore(&pcdev->lock, flags);
306} 303}
307 304
308static void sh_mobile_ceu_videobuf_release(struct videobuf_queue *vq, 305static void sh_mobile_ceu_videobuf_release(struct videobuf_queue *vq,
diff --git a/drivers/media/video/stk-webcam.c b/drivers/media/video/stk-webcam.c
index 4d6785e63455..b154bd961e3b 100644
--- a/drivers/media/video/stk-webcam.c
+++ b/drivers/media/video/stk-webcam.c
@@ -1050,8 +1050,8 @@ static int stk_setup_format(struct stk_camera *dev)
1050 depth = 1; 1050 depth = 1;
1051 else 1051 else
1052 depth = 2; 1052 depth = 2;
1053 while (stk_sizes[i].m != dev->vsettings.mode 1053 while (i < ARRAY_SIZE(stk_sizes) &&
1054 && i < ARRAY_SIZE(stk_sizes)) 1054 stk_sizes[i].m != dev->vsettings.mode)
1055 i++; 1055 i++;
1056 if (i == ARRAY_SIZE(stk_sizes)) { 1056 if (i == ARRAY_SIZE(stk_sizes)) {
1057 STK_ERROR("Something is broken in %s\n", __func__); 1057 STK_ERROR("Something is broken in %s\n", __func__);
diff --git a/drivers/media/video/uvc/uvc_driver.c b/drivers/media/video/uvc/uvc_driver.c
index 89927b7aec28..04b47832fa0a 100644
--- a/drivers/media/video/uvc/uvc_driver.c
+++ b/drivers/media/video/uvc/uvc_driver.c
@@ -1845,11 +1845,29 @@ static struct usb_device_id uvc_ids[] = {
1845 .bInterfaceSubClass = 1, 1845 .bInterfaceSubClass = 1,
1846 .bInterfaceProtocol = 0, 1846 .bInterfaceProtocol = 0,
1847 .driver_info = UVC_QUIRK_STREAM_NO_FID }, 1847 .driver_info = UVC_QUIRK_STREAM_NO_FID },
1848 /* ViMicro */ 1848 /* ViMicro Vega */
1849 { .match_flags = USB_DEVICE_ID_MATCH_VENDOR 1849 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1850 | USB_DEVICE_ID_MATCH_INT_INFO,
1851 .idVendor = 0x0ac8,
1852 .idProduct = 0x332d,
1853 .bInterfaceClass = USB_CLASS_VIDEO,
1854 .bInterfaceSubClass = 1,
1855 .bInterfaceProtocol = 0,
1856 .driver_info = UVC_QUIRK_FIX_BANDWIDTH },
1857 /* ViMicro - Minoru3D */
1858 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1859 | USB_DEVICE_ID_MATCH_INT_INFO,
1860 .idVendor = 0x0ac8,
1861 .idProduct = 0x3410,
1862 .bInterfaceClass = USB_CLASS_VIDEO,
1863 .bInterfaceSubClass = 1,
1864 .bInterfaceProtocol = 0,
1865 .driver_info = UVC_QUIRK_FIX_BANDWIDTH },
1866 /* ViMicro Venus - Minoru3D */
1867 { .match_flags = USB_DEVICE_ID_MATCH_DEVICE
1850 | USB_DEVICE_ID_MATCH_INT_INFO, 1868 | USB_DEVICE_ID_MATCH_INT_INFO,
1851 .idVendor = 0x0ac8, 1869 .idVendor = 0x0ac8,
1852 .idProduct = 0x0000, 1870 .idProduct = 0x3420,
1853 .bInterfaceClass = USB_CLASS_VIDEO, 1871 .bInterfaceClass = USB_CLASS_VIDEO,
1854 .bInterfaceSubClass = 1, 1872 .bInterfaceSubClass = 1,
1855 .bInterfaceProtocol = 0, 1873 .bInterfaceProtocol = 0,
diff --git a/drivers/media/video/uvc/uvc_status.c b/drivers/media/video/uvc/uvc_status.c
index f152a9903862..1ca6dff73612 100644
--- a/drivers/media/video/uvc/uvc_status.c
+++ b/drivers/media/video/uvc/uvc_status.c
@@ -145,8 +145,8 @@ static void uvc_status_complete(struct urb *urb)
145 break; 145 break;
146 146
147 default: 147 default:
148 uvc_printk(KERN_INFO, "unknown event type %u.\n", 148 uvc_trace(UVC_TRACE_STATUS, "Unknown status event "
149 dev->status[0]); 149 "type %u.\n", dev->status[0]);
150 break; 150 break;
151 } 151 }
152 } 152 }
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c
index be64a502ea27..f2afc4e08379 100644
--- a/drivers/media/video/v4l2-ioctl.c
+++ b/drivers/media/video/v4l2-ioctl.c
@@ -1081,8 +1081,10 @@ static long __video_do_ioctl(struct file *file,
1081 /* Calls the specific handler */ 1081 /* Calls the specific handler */
1082 if (ops->vidioc_g_std) 1082 if (ops->vidioc_g_std)
1083 ret = ops->vidioc_g_std(file, fh, id); 1083 ret = ops->vidioc_g_std(file, fh, id);
1084 else 1084 else if (vfd->current_norm)
1085 *id = vfd->current_norm; 1085 *id = vfd->current_norm;
1086 else
1087 ret = -EINVAL;
1086 1088
1087 if (!ret) 1089 if (!ret)
1088 dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id); 1090 dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id);
@@ -1553,12 +1555,19 @@ static long __video_do_ioctl(struct file *file,
1553 break; 1555 break;
1554 ret = ops->vidioc_g_parm(file, fh, p); 1556 ret = ops->vidioc_g_parm(file, fh, p);
1555 } else { 1557 } else {
1558 v4l2_std_id std = vfd->current_norm;
1559
1556 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1560 if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
1557 return -EINVAL; 1561 return -EINVAL;
1558 1562
1559 v4l2_video_std_frame_period(vfd->current_norm,
1560 &p->parm.capture.timeperframe);
1561 ret = 0; 1563 ret = 0;
1564 if (ops->vidioc_g_std)
1565 ret = ops->vidioc_g_std(file, fh, &std);
1566 else if (std == 0)
1567 ret = -EINVAL;
1568 if (ret == 0)
1569 v4l2_video_std_frame_period(std,
1570 &p->parm.capture.timeperframe);
1562 } 1571 }
1563 1572
1564 dbgarg(cmd, "type=%d\n", p->type); 1573 dbgarg(cmd, "type=%d\n", p->type);
diff --git a/drivers/media/video/zr364xx.c b/drivers/media/video/zr364xx.c
index fc976f42f432..2622a6e63da1 100644
--- a/drivers/media/video/zr364xx.c
+++ b/drivers/media/video/zr364xx.c
@@ -695,7 +695,7 @@ static int zr364xx_release(struct file *file)
695 for (i = 0; i < 2; i++) { 695 for (i = 0; i < 2; i++) {
696 err = 696 err =
697 send_control_msg(udev, 1, init[cam->method][i].value, 697 send_control_msg(udev, 1, init[cam->method][i].value,
698 0, init[i][cam->method].bytes, 698 0, init[cam->method][i].bytes,
699 init[cam->method][i].size); 699 init[cam->method][i].size);
700 if (err < 0) { 700 if (err < 0) {
701 dev_err(&udev->dev, "error during release sequence\n"); 701 dev_err(&udev->dev, "error during release sequence\n");
diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
index bae61b22501c..7d430835655f 100644
--- a/drivers/mfd/twl4030-irq.c
+++ b/drivers/mfd/twl4030-irq.c
@@ -180,14 +180,9 @@ static struct completion irq_event;
180static int twl4030_irq_thread(void *data) 180static int twl4030_irq_thread(void *data)
181{ 181{
182 long irq = (long)data; 182 long irq = (long)data;
183 struct irq_desc *desc = irq_to_desc(irq);
184 static unsigned i2c_errors; 183 static unsigned i2c_errors;
185 static const unsigned max_i2c_errors = 100; 184 static const unsigned max_i2c_errors = 100;
186 185
187 if (!desc) {
188 pr_err("twl4030: Invalid IRQ: %ld\n", irq);
189 return -EINVAL;
190 }
191 186
192 current->flags |= PF_NOFREEZE; 187 current->flags |= PF_NOFREEZE;
193 188
@@ -240,7 +235,7 @@ static int twl4030_irq_thread(void *data)
240 } 235 }
241 local_irq_enable(); 236 local_irq_enable();
242 237
243 desc->chip->unmask(irq); 238 enable_irq(irq);
244 } 239 }
245 240
246 return 0; 241 return 0;
@@ -255,25 +250,13 @@ static int twl4030_irq_thread(void *data)
255 * thread. All we do here is acknowledge and mask the interrupt and wakeup 250 * thread. All we do here is acknowledge and mask the interrupt and wakeup
256 * the kernel thread. 251 * the kernel thread.
257 */ 252 */
258static void handle_twl4030_pih(unsigned int irq, struct irq_desc *desc) 253static irqreturn_t handle_twl4030_pih(int irq, void *devid)
259{ 254{
260 /* Acknowledge, clear *AND* mask the interrupt... */ 255 /* Acknowledge, clear *AND* mask the interrupt... */
261 desc->chip->ack(irq); 256 disable_irq_nosync(irq);
262 complete(&irq_event); 257 complete(devid);
263} 258 return IRQ_HANDLED;
264
265static struct task_struct *start_twl4030_irq_thread(long irq)
266{
267 struct task_struct *thread;
268
269 init_completion(&irq_event);
270 thread = kthread_run(twl4030_irq_thread, (void *)irq, "twl4030-irq");
271 if (!thread)
272 pr_err("twl4030: could not create irq %ld thread!\n", irq);
273
274 return thread;
275} 259}
276
277/*----------------------------------------------------------------------*/ 260/*----------------------------------------------------------------------*/
278 261
279/* 262/*
@@ -734,18 +717,28 @@ int twl_init_irq(int irq_num, unsigned irq_base, unsigned irq_end)
734 } 717 }
735 718
736 /* install an irq handler to demultiplex the TWL4030 interrupt */ 719 /* install an irq handler to demultiplex the TWL4030 interrupt */
737 task = start_twl4030_irq_thread(irq_num);
738 if (!task) {
739 pr_err("twl4030: irq thread FAIL\n");
740 status = -ESRCH;
741 goto fail;
742 }
743 720
744 set_irq_data(irq_num, task);
745 set_irq_chained_handler(irq_num, handle_twl4030_pih);
746 721
747 return status; 722 init_completion(&irq_event);
748 723
724 status = request_irq(irq_num, handle_twl4030_pih, IRQF_DISABLED,
725 "TWL4030-PIH", &irq_event);
726 if (status < 0) {
727 pr_err("twl4030: could not claim irq%d: %d\n", irq_num, status);
728 goto fail_rqirq;
729 }
730
731 task = kthread_run(twl4030_irq_thread, (void *)irq_num, "twl4030-irq");
732 if (IS_ERR(task)) {
733 pr_err("twl4030: could not create irq %d thread!\n", irq_num);
734 status = PTR_ERR(task);
735 goto fail_kthread;
736 }
737 return status;
738fail_kthread:
739 free_irq(irq_num, &irq_event);
740fail_rqirq:
741 /* clean up twl4030_sih_setup */
749fail: 742fail:
750 for (i = irq_base; i < irq_end; i++) 743 for (i = irq_base; i < irq_end; i++)
751 set_irq_chip_and_handler(i, NULL, NULL); 744 set_irq_chip_and_handler(i, NULL, NULL);
diff --git a/drivers/mmc/host/sdhci-of.c b/drivers/mmc/host/sdhci-of.c
index 908844327db0..1e8aa590bb39 100644
--- a/drivers/mmc/host/sdhci-of.c
+++ b/drivers/mmc/host/sdhci-of.c
@@ -234,7 +234,7 @@ static int __devinit sdhci_of_probe(struct of_device *ofdev,
234 return -ENODEV; 234 return -ENODEV;
235 235
236 host = sdhci_alloc_host(&ofdev->dev, sizeof(*of_host)); 236 host = sdhci_alloc_host(&ofdev->dev, sizeof(*of_host));
237 if (!host) 237 if (IS_ERR(host))
238 return -ENOMEM; 238 return -ENOMEM;
239 239
240 of_host = sdhci_priv(host); 240 of_host = sdhci_priv(host);
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index 0b98654d8eed..7a58bd5522fd 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -284,13 +284,6 @@ config MTD_L440GX
284 284
285 BE VERY CAREFUL. 285 BE VERY CAREFUL.
286 286
287config MTD_SBC8240
288 tristate "Flash device on SBC8240"
289 depends on MTD_JEDECPROBE && 8260
290 help
291 Flash access on the SBC8240 board from Wind River. See
292 <http://www.windriver.com/products/sbc8240/>
293
294config MTD_TQM8XXL 287config MTD_TQM8XXL
295 tristate "CFI Flash device mapped on TQM8XXL" 288 tristate "CFI Flash device mapped on TQM8XXL"
296 depends on MTD_CFI && TQM8xxL 289 depends on MTD_CFI && TQM8xxL
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index 8bae7f9850c0..5beb0662d724 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -50,7 +50,6 @@ obj-$(CONFIG_MTD_UCLINUX) += uclinux.o
50obj-$(CONFIG_MTD_NETtel) += nettel.o 50obj-$(CONFIG_MTD_NETtel) += nettel.o
51obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o 51obj-$(CONFIG_MTD_SCB2_FLASH) += scb2_flash.o
52obj-$(CONFIG_MTD_H720X) += h720x-flash.o 52obj-$(CONFIG_MTD_H720X) += h720x-flash.o
53obj-$(CONFIG_MTD_SBC8240) += sbc8240.o
54obj-$(CONFIG_MTD_IXP4XX) += ixp4xx.o 53obj-$(CONFIG_MTD_IXP4XX) += ixp4xx.o
55obj-$(CONFIG_MTD_IXP2000) += ixp2000.o 54obj-$(CONFIG_MTD_IXP2000) += ixp2000.o
56obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o 55obj-$(CONFIG_MTD_WRSBC8260) += wr_sbc82xx_flash.o
diff --git a/drivers/mtd/maps/sbc8240.c b/drivers/mtd/maps/sbc8240.c
deleted file mode 100644
index d5374cdcb163..000000000000
--- a/drivers/mtd/maps/sbc8240.c
+++ /dev/null
@@ -1,250 +0,0 @@
1/*
2 * Handle mapping of the flash memory access routines on the SBC8240 board.
3 *
4 * Carolyn Smith, Tektronix, Inc.
5 *
6 * This code is GPLed
7 */
8
9/*
10 * The SBC8240 has 2 flash banks.
11 * Bank 0 is a 512 KiB AMD AM29F040B; 8 x 64 KiB sectors.
12 * It contains the U-Boot code (7 sectors) and the environment (1 sector).
13 * Bank 1 is 4 x 1 MiB AMD AM29LV800BT; 15 x 64 KiB sectors, 1 x 32 KiB sector,
14 * 2 x 8 KiB sectors, 1 x 16 KiB sectors.
15 * Both parts are JEDEC compatible.
16 */
17
18#include <linux/module.h>
19#include <linux/types.h>
20#include <linux/kernel.h>
21#include <asm/io.h>
22
23#include <linux/mtd/mtd.h>
24#include <linux/mtd/map.h>
25#include <linux/mtd/cfi.h>
26
27#ifdef CONFIG_MTD_PARTITIONS
28#include <linux/mtd/partitions.h>
29#endif
30
31#define DEBUG
32
33#ifdef DEBUG
34# define debugk(fmt,args...) printk(fmt ,##args)
35#else
36# define debugk(fmt,args...)
37#endif
38
39
40#define WINDOW_ADDR0 0xFFF00000 /* 512 KiB */
41#define WINDOW_SIZE0 0x00080000
42#define BUSWIDTH0 1
43
44#define WINDOW_ADDR1 0xFF000000 /* 4 MiB */
45#define WINDOW_SIZE1 0x00400000
46#define BUSWIDTH1 8
47
48#define MSG_PREFIX "sbc8240:" /* prefix for our printk()'s */
49#define MTDID "sbc8240-%d" /* for mtdparts= partitioning */
50
51
52static struct map_info sbc8240_map[2] = {
53 {
54 .name = "sbc8240 Flash Bank #0",
55 .size = WINDOW_SIZE0,
56 .bankwidth = BUSWIDTH0,
57 },
58 {
59 .name = "sbc8240 Flash Bank #1",
60 .size = WINDOW_SIZE1,
61 .bankwidth = BUSWIDTH1,
62 }
63};
64
65#define NUM_FLASH_BANKS ARRAY_SIZE(sbc8240_map)
66
67/*
68 * The following defines the partition layout of SBC8240 boards.
69 *
70 * See include/linux/mtd/partitions.h for definition of the
71 * mtd_partition structure.
72 *
73 * The *_max_flash_size is the maximum possible mapped flash size
74 * which is not necessarily the actual flash size. It must correspond
75 * to the value specified in the mapping definition defined by the
76 * "struct map_desc *_io_desc" for the corresponding machine.
77 */
78
79#ifdef CONFIG_MTD_PARTITIONS
80
81static struct mtd_partition sbc8240_uboot_partitions [] = {
82 /* Bank 0 */
83 {
84 .name = "U-boot", /* U-Boot Firmware */
85 .offset = 0,
86 .size = 0x00070000, /* 7 x 64 KiB sectors */
87 .mask_flags = MTD_WRITEABLE, /* force read-only */
88 },
89 {
90 .name = "environment", /* U-Boot environment */
91 .offset = 0x00070000,
92 .size = 0x00010000, /* 1 x 64 KiB sector */
93 },
94};
95
96static struct mtd_partition sbc8240_fs_partitions [] = {
97 {
98 .name = "jffs", /* JFFS filesystem */
99 .offset = 0,
100 .size = 0x003C0000, /* 4 * 15 * 64KiB */
101 },
102 {
103 .name = "tmp32",
104 .offset = 0x003C0000,
105 .size = 0x00020000, /* 4 * 32KiB */
106 },
107 {
108 .name = "tmp8a",
109 .offset = 0x003E0000,
110 .size = 0x00008000, /* 4 * 8KiB */
111 },
112 {
113 .name = "tmp8b",
114 .offset = 0x003E8000,
115 .size = 0x00008000, /* 4 * 8KiB */
116 },
117 {
118 .name = "tmp16",
119 .offset = 0x003F0000,
120 .size = 0x00010000, /* 4 * 16KiB */
121 }
122};
123
124/* trivial struct to describe partition information */
125struct mtd_part_def
126{
127 int nums;
128 unsigned char *type;
129 struct mtd_partition* mtd_part;
130};
131
132static struct mtd_info *sbc8240_mtd[NUM_FLASH_BANKS];
133static struct mtd_part_def sbc8240_part_banks[NUM_FLASH_BANKS];
134
135
136#endif /* CONFIG_MTD_PARTITIONS */
137
138
139static int __init init_sbc8240_mtd (void)
140{
141 static struct _cjs {
142 u_long addr;
143 u_long size;
144 } pt[NUM_FLASH_BANKS] = {
145 {
146 .addr = WINDOW_ADDR0,
147 .size = WINDOW_SIZE0
148 },
149 {
150 .addr = WINDOW_ADDR1,
151 .size = WINDOW_SIZE1
152 },
153 };
154
155 int devicesfound = 0;
156 int i,j;
157
158 for (i = 0; i < NUM_FLASH_BANKS; i++) {
159 printk (KERN_NOTICE MSG_PREFIX
160 "Probing 0x%08lx at 0x%08lx\n", pt[i].size, pt[i].addr);
161
162 sbc8240_map[i].map_priv_1 =
163 (unsigned long) ioremap (pt[i].addr, pt[i].size);
164 if (!sbc8240_map[i].map_priv_1) {
165 printk (MSG_PREFIX "failed to ioremap\n");
166 for (j = 0; j < i; j++) {
167 iounmap((void *) sbc8240_map[j].map_priv_1);
168 sbc8240_map[j].map_priv_1 = 0;
169 }
170 return -EIO;
171 }
172 simple_map_init(&sbc8240_mtd[i]);
173
174 sbc8240_mtd[i] = do_map_probe("jedec_probe", &sbc8240_map[i]);
175
176 if (sbc8240_mtd[i]) {
177 sbc8240_mtd[i]->module = THIS_MODULE;
178 devicesfound++;
179 } else {
180 if (sbc8240_map[i].map_priv_1) {
181 iounmap((void *) sbc8240_map[i].map_priv_1);
182 sbc8240_map[i].map_priv_1 = 0;
183 }
184 }
185 }
186
187 if (!devicesfound) {
188 printk(KERN_NOTICE MSG_PREFIX
189 "No suppported flash chips found!\n");
190 return -ENXIO;
191 }
192
193#ifdef CONFIG_MTD_PARTITIONS
194 sbc8240_part_banks[0].mtd_part = sbc8240_uboot_partitions;
195 sbc8240_part_banks[0].type = "static image";
196 sbc8240_part_banks[0].nums = ARRAY_SIZE(sbc8240_uboot_partitions);
197 sbc8240_part_banks[1].mtd_part = sbc8240_fs_partitions;
198 sbc8240_part_banks[1].type = "static file system";
199 sbc8240_part_banks[1].nums = ARRAY_SIZE(sbc8240_fs_partitions);
200
201 for (i = 0; i < NUM_FLASH_BANKS; i++) {
202
203 if (!sbc8240_mtd[i]) continue;
204 if (sbc8240_part_banks[i].nums == 0) {
205 printk (KERN_NOTICE MSG_PREFIX
206 "No partition info available, registering whole device\n");
207 add_mtd_device(sbc8240_mtd[i]);
208 } else {
209 printk (KERN_NOTICE MSG_PREFIX
210 "Using %s partition definition\n", sbc8240_part_banks[i].mtd_part->name);
211 add_mtd_partitions (sbc8240_mtd[i],
212 sbc8240_part_banks[i].mtd_part,
213 sbc8240_part_banks[i].nums);
214 }
215 }
216#else
217 printk(KERN_NOTICE MSG_PREFIX
218 "Registering %d flash banks at once\n", devicesfound);
219
220 for (i = 0; i < devicesfound; i++) {
221 add_mtd_device(sbc8240_mtd[i]);
222 }
223#endif /* CONFIG_MTD_PARTITIONS */
224
225 return devicesfound == 0 ? -ENXIO : 0;
226}
227
228static void __exit cleanup_sbc8240_mtd (void)
229{
230 int i;
231
232 for (i = 0; i < NUM_FLASH_BANKS; i++) {
233 if (sbc8240_mtd[i]) {
234 del_mtd_device (sbc8240_mtd[i]);
235 map_destroy (sbc8240_mtd[i]);
236 }
237 if (sbc8240_map[i].map_priv_1) {
238 iounmap ((void *) sbc8240_map[i].map_priv_1);
239 sbc8240_map[i].map_priv_1 = 0;
240 }
241 }
242}
243
244module_init (init_sbc8240_mtd);
245module_exit (cleanup_sbc8240_mtd);
246
247MODULE_LICENSE ("GPL");
248MODULE_AUTHOR ("Carolyn Smith <carolyn.smith@tektronix.com>");
249MODULE_DESCRIPTION ("MTD map driver for SBC8240 boards");
250
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c
index c3f62654b6df..7baba40c1ed2 100644
--- a/drivers/mtd/mtd_blkdevs.c
+++ b/drivers/mtd/mtd_blkdevs.c
@@ -144,7 +144,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
144 struct mtd_blktrans_ops *tr = dev->tr; 144 struct mtd_blktrans_ops *tr = dev->tr;
145 int ret = -ENODEV; 145 int ret = -ENODEV;
146 146
147 if (!try_module_get(dev->mtd->owner)) 147 if (!get_mtd_device(NULL, dev->mtd->index))
148 goto out; 148 goto out;
149 149
150 if (!try_module_get(tr->owner)) 150 if (!try_module_get(tr->owner))
@@ -158,7 +158,7 @@ static int blktrans_open(struct block_device *bdev, fmode_t mode)
158 ret = 0; 158 ret = 0;
159 if (tr->open && (ret = tr->open(dev))) { 159 if (tr->open && (ret = tr->open(dev))) {
160 dev->mtd->usecount--; 160 dev->mtd->usecount--;
161 module_put(dev->mtd->owner); 161 put_mtd_device(dev->mtd);
162 out_tr: 162 out_tr:
163 module_put(tr->owner); 163 module_put(tr->owner);
164 } 164 }
@@ -177,7 +177,7 @@ static int blktrans_release(struct gendisk *disk, fmode_t mode)
177 177
178 if (!ret) { 178 if (!ret) {
179 dev->mtd->usecount--; 179 dev->mtd->usecount--;
180 module_put(dev->mtd->owner); 180 put_mtd_device(dev->mtd);
181 module_put(tr->owner); 181 module_put(tr->owner);
182 } 182 }
183 183
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c
index 208c6faa0358..77db5ce24d92 100644
--- a/drivers/mtd/mtdblock.c
+++ b/drivers/mtd/mtdblock.c
@@ -29,6 +29,8 @@ static struct mtdblk_dev {
29 enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state; 29 enum { STATE_EMPTY, STATE_CLEAN, STATE_DIRTY } cache_state;
30} *mtdblks[MAX_MTD_DEVICES]; 30} *mtdblks[MAX_MTD_DEVICES];
31 31
32static struct mutex mtdblks_lock;
33
32/* 34/*
33 * Cache stuff... 35 * Cache stuff...
34 * 36 *
@@ -270,15 +272,19 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
270 272
271 DEBUG(MTD_DEBUG_LEVEL1,"mtdblock_open\n"); 273 DEBUG(MTD_DEBUG_LEVEL1,"mtdblock_open\n");
272 274
275 mutex_lock(&mtdblks_lock);
273 if (mtdblks[dev]) { 276 if (mtdblks[dev]) {
274 mtdblks[dev]->count++; 277 mtdblks[dev]->count++;
278 mutex_unlock(&mtdblks_lock);
275 return 0; 279 return 0;
276 } 280 }
277 281
278 /* OK, it's not open. Create cache info for it */ 282 /* OK, it's not open. Create cache info for it */
279 mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); 283 mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
280 if (!mtdblk) 284 if (!mtdblk) {
285 mutex_unlock(&mtdblks_lock);
281 return -ENOMEM; 286 return -ENOMEM;
287 }
282 288
283 mtdblk->count = 1; 289 mtdblk->count = 1;
284 mtdblk->mtd = mtd; 290 mtdblk->mtd = mtd;
@@ -291,6 +297,7 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
291 } 297 }
292 298
293 mtdblks[dev] = mtdblk; 299 mtdblks[dev] = mtdblk;
300 mutex_unlock(&mtdblks_lock);
294 301
295 DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); 302 DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
296 303
@@ -304,6 +311,8 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
304 311
305 DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n"); 312 DEBUG(MTD_DEBUG_LEVEL1, "mtdblock_release\n");
306 313
314 mutex_lock(&mtdblks_lock);
315
307 mutex_lock(&mtdblk->cache_mutex); 316 mutex_lock(&mtdblk->cache_mutex);
308 write_cached_data(mtdblk); 317 write_cached_data(mtdblk);
309 mutex_unlock(&mtdblk->cache_mutex); 318 mutex_unlock(&mtdblk->cache_mutex);
@@ -316,6 +325,9 @@ static int mtdblock_release(struct mtd_blktrans_dev *mbd)
316 vfree(mtdblk->cache_data); 325 vfree(mtdblk->cache_data);
317 kfree(mtdblk); 326 kfree(mtdblk);
318 } 327 }
328
329 mutex_unlock(&mtdblks_lock);
330
319 DEBUG(MTD_DEBUG_LEVEL1, "ok\n"); 331 DEBUG(MTD_DEBUG_LEVEL1, "ok\n");
320 332
321 return 0; 333 return 0;
@@ -376,6 +388,8 @@ static struct mtd_blktrans_ops mtdblock_tr = {
376 388
377static int __init init_mtdblock(void) 389static int __init init_mtdblock(void)
378{ 390{
391 mutex_init(&mtdblks_lock);
392
379 return register_mtd_blktrans(&mtdblock_tr); 393 return register_mtd_blktrans(&mtdblock_tr);
380} 394}
381 395
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index fac54a3fa3f1..00ebf7af7467 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -65,8 +65,8 @@ static void mtd_release(struct device *dev)
65static int mtd_cls_suspend(struct device *dev, pm_message_t state) 65static int mtd_cls_suspend(struct device *dev, pm_message_t state)
66{ 66{
67 struct mtd_info *mtd = dev_to_mtd(dev); 67 struct mtd_info *mtd = dev_to_mtd(dev);
68 68
69 if (mtd->suspend) 69 if (mtd && mtd->suspend)
70 return mtd->suspend(mtd); 70 return mtd->suspend(mtd);
71 else 71 else
72 return 0; 72 return 0;
@@ -76,7 +76,7 @@ static int mtd_cls_resume(struct device *dev)
76{ 76{
77 struct mtd_info *mtd = dev_to_mtd(dev); 77 struct mtd_info *mtd = dev_to_mtd(dev);
78 78
79 if (mtd->resume) 79 if (mtd && mtd->resume)
80 mtd->resume(mtd); 80 mtd->resume(mtd);
81 return 0; 81 return 0;
82} 82}
@@ -298,6 +298,7 @@ int add_mtd_device(struct mtd_info *mtd)
298 mtd->dev.class = &mtd_class; 298 mtd->dev.class = &mtd_class;
299 mtd->dev.devt = MTD_DEVT(i); 299 mtd->dev.devt = MTD_DEVT(i);
300 dev_set_name(&mtd->dev, "mtd%d", i); 300 dev_set_name(&mtd->dev, "mtd%d", i);
301 dev_set_drvdata(&mtd->dev, mtd);
301 if (device_register(&mtd->dev) != 0) { 302 if (device_register(&mtd->dev) != 0) {
302 mtd_table[i] = NULL; 303 mtd_table[i] = NULL;
303 break; 304 break;
diff --git a/drivers/mtd/nand/orion_nand.c b/drivers/mtd/nand/orion_nand.c
index 7ad972229db4..0d9d4bc9c762 100644
--- a/drivers/mtd/nand/orion_nand.c
+++ b/drivers/mtd/nand/orion_nand.c
@@ -61,7 +61,7 @@ static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
61 buf64 = (uint64_t *)buf; 61 buf64 = (uint64_t *)buf;
62 while (i < len/8) { 62 while (i < len/8) {
63 uint64_t x; 63 uint64_t x;
64 asm ("ldrd\t%0, [%1]" : "=r" (x) : "r" (io_base)); 64 asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base));
65 buf64[i++] = x; 65 buf64[i++] = x;
66 } 66 }
67 i *= 8; 67 i *= 8;
diff --git a/drivers/mtd/onenand/omap2.c b/drivers/mtd/onenand/omap2.c
index 38d656b9b2ee..0108ed42e877 100644
--- a/drivers/mtd/onenand/omap2.c
+++ b/drivers/mtd/onenand/omap2.c
@@ -266,7 +266,7 @@ static inline int omap2_onenand_bufferram_offset(struct mtd_info *mtd, int area)
266 266
267 if (ONENAND_CURRENT_BUFFERRAM(this)) { 267 if (ONENAND_CURRENT_BUFFERRAM(this)) {
268 if (area == ONENAND_DATARAM) 268 if (area == ONENAND_DATARAM)
269 return mtd->writesize; 269 return this->writesize;
270 if (area == ONENAND_SPARERAM) 270 if (area == ONENAND_SPARERAM)
271 return mtd->oobsize; 271 return mtd->oobsize;
272 } 272 }
@@ -770,6 +770,7 @@ static int __devexit omap2_onenand_remove(struct platform_device *pdev)
770 } 770 }
771 iounmap(c->onenand.base); 771 iounmap(c->onenand.base);
772 release_mem_region(c->phys_base, ONENAND_IO_SIZE); 772 release_mem_region(c->phys_base, ONENAND_IO_SIZE);
773 gpmc_cs_free(c->gpmc_cs);
773 kfree(c); 774 kfree(c);
774 775
775 return 0; 776 return 0;
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 0f2034c3ed2f..e4d9ef0c965a 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -1254,6 +1254,7 @@ out_free:
1254 if (!ubi->volumes[i]) 1254 if (!ubi->volumes[i])
1255 continue; 1255 continue;
1256 kfree(ubi->volumes[i]->eba_tbl); 1256 kfree(ubi->volumes[i]->eba_tbl);
1257 ubi->volumes[i]->eba_tbl = NULL;
1257 } 1258 }
1258 return err; 1259 return err;
1259} 1260}
diff --git a/drivers/mtd/ubi/scan.c b/drivers/mtd/ubi/scan.c
index a423131b6171..b847745394b4 100644
--- a/drivers/mtd/ubi/scan.c
+++ b/drivers/mtd/ubi/scan.c
@@ -781,11 +781,22 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
781 return -EINVAL; 781 return -EINVAL;
782 } 782 }
783 783
784 /*
785 * Make sure that all PEBs have the same image sequence number.
786 * This allows us to detect situations when users flash UBI
787 * images incorrectly, so that the flash has the new UBI image
788 * and leftovers from the old one. This feature was added
789 * relatively recently, and the sequence number was always
790 * zero, because old UBI implementations always set it to zero.
791 * For this reasons, we do not panic if some PEBs have zero
792 * sequence number, while other PEBs have non-zero sequence
793 * number.
794 */
784 image_seq = be32_to_cpu(ech->image_seq); 795 image_seq = be32_to_cpu(ech->image_seq);
785 if (!si->image_seq_set) { 796 if (!si->image_seq_set) {
786 ubi->image_seq = image_seq; 797 ubi->image_seq = image_seq;
787 si->image_seq_set = 1; 798 si->image_seq_set = 1;
788 } else if (ubi->image_seq != image_seq) { 799 } else if (ubi->image_seq && ubi->image_seq != image_seq) {
789 ubi_err("bad image sequence number %d in PEB %d, " 800 ubi_err("bad image sequence number %d in PEB %d, "
790 "expected %d", image_seq, pnum, ubi->image_seq); 801 "expected %d", image_seq, pnum, ubi->image_seq);
791 ubi_dbg_dump_ec_hdr(ech); 802 ubi_dbg_dump_ec_hdr(ech);
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c
index 3e00fa8ea65f..4a7c32895be5 100644
--- a/drivers/net/3c515.c
+++ b/drivers/net/3c515.c
@@ -832,7 +832,9 @@ static int corkscrew_open(struct net_device *dev)
832 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ 832 skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */
833 vp->rx_ring[i].addr = isa_virt_to_bus(skb->data); 833 vp->rx_ring[i].addr = isa_virt_to_bus(skb->data);
834 } 834 }
835 vp->rx_ring[i - 1].next = isa_virt_to_bus(&vp->rx_ring[0]); /* Wrap the ring. */ 835 if (i != 0)
836 vp->rx_ring[i - 1].next =
837 isa_virt_to_bus(&vp->rx_ring[0]); /* Wrap the ring. */
836 outl(isa_virt_to_bus(&vp->rx_ring[0]), ioaddr + UpListPtr); 838 outl(isa_virt_to_bus(&vp->rx_ring[0]), ioaddr + UpListPtr);
837 } 839 }
838 if (vp->full_bus_master_tx) { /* Boomerang bus master Tx. */ 840 if (vp->full_bus_master_tx) { /* Boomerang bus master Tx. */
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c
index c34aee91250b..45675889850b 100644
--- a/drivers/net/3c59x.c
+++ b/drivers/net/3c59x.c
@@ -235,6 +235,7 @@ enum vortex_chips {
235 CH_3C900B_FL, 235 CH_3C900B_FL,
236 CH_3C905_1, 236 CH_3C905_1,
237 CH_3C905_2, 237 CH_3C905_2,
238 CH_3C905B_TX,
238 CH_3C905B_1, 239 CH_3C905B_1,
239 240
240 CH_3C905B_2, 241 CH_3C905B_2,
@@ -307,6 +308,8 @@ static struct vortex_chip_info {
307 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, }, 308 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, },
308 {"3c905 Boomerang 100baseT4", 309 {"3c905 Boomerang 100baseT4",
309 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, }, 310 PCI_USES_MASTER, IS_BOOMERANG|HAS_MII|EEPROM_RESET, 64, },
311 {"3C905B-TX Fast Etherlink XL PCI",
312 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
310 {"3c905B Cyclone 100baseTx", 313 {"3c905B Cyclone 100baseTx",
311 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, }, 314 PCI_USES_MASTER, IS_CYCLONE|HAS_NWAY|HAS_HWCKSM|EXTRA_PREAMBLE, 128, },
312 315
@@ -389,6 +392,7 @@ static struct pci_device_id vortex_pci_tbl[] = {
389 { 0x10B7, 0x900A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C900B_FL }, 392 { 0x10B7, 0x900A, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C900B_FL },
390 { 0x10B7, 0x9050, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905_1 }, 393 { 0x10B7, 0x9050, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905_1 },
391 { 0x10B7, 0x9051, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905_2 }, 394 { 0x10B7, 0x9051, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905_2 },
395 { 0x10B7, 0x9054, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905B_TX },
392 { 0x10B7, 0x9055, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905B_1 }, 396 { 0x10B7, 0x9055, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905B_1 },
393 397
394 { 0x10B7, 0x9058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905B_2 }, 398 { 0x10B7, 0x9058, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C905B_2 },
@@ -2721,13 +2725,15 @@ dump_tx_ring(struct net_device *dev)
2721 &vp->tx_ring[vp->dirty_tx % TX_RING_SIZE]); 2725 &vp->tx_ring[vp->dirty_tx % TX_RING_SIZE]);
2722 issue_and_wait(dev, DownStall); 2726 issue_and_wait(dev, DownStall);
2723 for (i = 0; i < TX_RING_SIZE; i++) { 2727 for (i = 0; i < TX_RING_SIZE; i++) {
2724 pr_err(" %d: @%p length %8.8x status %8.8x\n", i, 2728 unsigned int length;
2725 &vp->tx_ring[i], 2729
2726#if DO_ZEROCOPY 2730#if DO_ZEROCOPY
2727 le32_to_cpu(vp->tx_ring[i].frag[0].length), 2731 length = le32_to_cpu(vp->tx_ring[i].frag[0].length);
2728#else 2732#else
2729 le32_to_cpu(vp->tx_ring[i].length), 2733 length = le32_to_cpu(vp->tx_ring[i].length);
2730#endif 2734#endif
2735 pr_err(" %d: @%p length %8.8x status %8.8x\n",
2736 i, &vp->tx_ring[i], length,
2731 le32_to_cpu(vp->tx_ring[i].status)); 2737 le32_to_cpu(vp->tx_ring[i].status));
2732 } 2738 }
2733 if (!stalled) 2739 if (!stalled)
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
index 50efde11ea6c..d0dbbf39349a 100644
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -515,7 +515,7 @@ rx_status_loop:
515 dma_addr_t mapping; 515 dma_addr_t mapping;
516 struct sk_buff *skb, *new_skb; 516 struct sk_buff *skb, *new_skb;
517 struct cp_desc *desc; 517 struct cp_desc *desc;
518 unsigned buflen; 518 const unsigned buflen = cp->rx_buf_sz;
519 519
520 skb = cp->rx_skb[rx_tail]; 520 skb = cp->rx_skb[rx_tail];
521 BUG_ON(!skb); 521 BUG_ON(!skb);
@@ -549,8 +549,7 @@ rx_status_loop:
549 pr_debug("%s: rx slot %d status 0x%x len %d\n", 549 pr_debug("%s: rx slot %d status 0x%x len %d\n",
550 dev->name, rx_tail, status, len); 550 dev->name, rx_tail, status, len);
551 551
552 buflen = cp->rx_buf_sz + NET_IP_ALIGN; 552 new_skb = netdev_alloc_skb(dev, buflen + NET_IP_ALIGN);
553 new_skb = netdev_alloc_skb(dev, buflen);
554 if (!new_skb) { 553 if (!new_skb) {
555 dev->stats.rx_dropped++; 554 dev->stats.rx_dropped++;
556 goto rx_next; 555 goto rx_next;
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 3ed49f1337c7..985a0550c803 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -1727,12 +1727,14 @@ config KS8842
1727 tristate "Micrel KSZ8842" 1727 tristate "Micrel KSZ8842"
1728 depends on HAS_IOMEM 1728 depends on HAS_IOMEM
1729 help 1729 help
1730 This platform driver is for Micrel KSZ8842 chip. 1730 This platform driver is for Micrel KSZ8842 / KS8842
1731 2-port ethernet switch chip (managed, VLAN, QoS).
1731 1732
1732config KS8851 1733config KS8851
1733 tristate "Micrel KS8851 SPI" 1734 tristate "Micrel KS8851 SPI"
1734 depends on SPI 1735 depends on SPI
1735 select MII 1736 select MII
1737 select CRC32
1736 help 1738 help
1737 SPI driver for Micrel KS8851 SPI attached network chip. 1739 SPI driver for Micrel KS8851 SPI attached network chip.
1738 1740
diff --git a/drivers/net/arm/w90p910_ether.c b/drivers/net/arm/w90p910_ether.c
index 616fb7985a34..ddd231cb54b7 100644
--- a/drivers/net/arm/w90p910_ether.c
+++ b/drivers/net/arm/w90p910_ether.c
@@ -1080,7 +1080,7 @@ static struct platform_driver w90p910_ether_driver = {
1080 .probe = w90p910_ether_probe, 1080 .probe = w90p910_ether_probe,
1081 .remove = __devexit_p(w90p910_ether_remove), 1081 .remove = __devexit_p(w90p910_ether_remove),
1082 .driver = { 1082 .driver = {
1083 .name = "w90p910-emc", 1083 .name = "nuc900-emc",
1084 .owner = THIS_MODULE, 1084 .owner = THIS_MODULE,
1085 }, 1085 },
1086}; 1086};
@@ -1101,5 +1101,5 @@ module_exit(w90p910_ether_exit);
1101MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>"); 1101MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
1102MODULE_DESCRIPTION("w90p910 MAC driver!"); 1102MODULE_DESCRIPTION("w90p910 MAC driver!");
1103MODULE_LICENSE("GPL"); 1103MODULE_LICENSE("GPL");
1104MODULE_ALIAS("platform:w90p910-emc"); 1104MODULE_ALIAS("platform:nuc900-emc");
1105 1105
diff --git a/drivers/net/atl1c/atl1c_ethtool.c b/drivers/net/atl1c/atl1c_ethtool.c
index 607007d75b6f..00d11b480af3 100644
--- a/drivers/net/atl1c/atl1c_ethtool.c
+++ b/drivers/net/atl1c/atl1c_ethtool.c
@@ -232,11 +232,11 @@ static void atl1c_get_drvinfo(struct net_device *netdev,
232{ 232{
233 struct atl1c_adapter *adapter = netdev_priv(netdev); 233 struct atl1c_adapter *adapter = netdev_priv(netdev);
234 234
235 strncpy(drvinfo->driver, atl1c_driver_name, sizeof(drvinfo->driver)); 235 strlcpy(drvinfo->driver, atl1c_driver_name, sizeof(drvinfo->driver));
236 strncpy(drvinfo->version, atl1c_driver_version, 236 strlcpy(drvinfo->version, atl1c_driver_version,
237 sizeof(drvinfo->version)); 237 sizeof(drvinfo->version));
238 strncpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); 238 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
239 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 239 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
240 sizeof(drvinfo->bus_info)); 240 sizeof(drvinfo->bus_info));
241 drvinfo->n_stats = 0; 241 drvinfo->n_stats = 0;
242 drvinfo->testinfo_len = 0; 242 drvinfo->testinfo_len = 0;
diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index 94d7325caf4f..8bca12f71390 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -3378,11 +3378,11 @@ static void atl1_get_drvinfo(struct net_device *netdev,
3378{ 3378{
3379 struct atl1_adapter *adapter = netdev_priv(netdev); 3379 struct atl1_adapter *adapter = netdev_priv(netdev);
3380 3380
3381 strncpy(drvinfo->driver, ATLX_DRIVER_NAME, sizeof(drvinfo->driver)); 3381 strlcpy(drvinfo->driver, ATLX_DRIVER_NAME, sizeof(drvinfo->driver));
3382 strncpy(drvinfo->version, ATLX_DRIVER_VERSION, 3382 strlcpy(drvinfo->version, ATLX_DRIVER_VERSION,
3383 sizeof(drvinfo->version)); 3383 sizeof(drvinfo->version));
3384 strncpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version)); 3384 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
3385 strncpy(drvinfo->bus_info, pci_name(adapter->pdev), 3385 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
3386 sizeof(drvinfo->bus_info)); 3386 sizeof(drvinfo->bus_info));
3387 drvinfo->eedump_len = ATL1_EEDUMP_LEN; 3387 drvinfo->eedump_len = ATL1_EEDUMP_LEN;
3388} 3388}
diff --git a/drivers/net/b44.c b/drivers/net/b44.c
index 36d4d377ec2f..bafca672ea7d 100644
--- a/drivers/net/b44.c
+++ b/drivers/net/b44.c
@@ -952,9 +952,10 @@ static int b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
952 int rc = NETDEV_TX_OK; 952 int rc = NETDEV_TX_OK;
953 dma_addr_t mapping; 953 dma_addr_t mapping;
954 u32 len, entry, ctrl; 954 u32 len, entry, ctrl;
955 unsigned long flags;
955 956
956 len = skb->len; 957 len = skb->len;
957 spin_lock_irq(&bp->lock); 958 spin_lock_irqsave(&bp->lock, flags);
958 959
959 /* This is a hard error, log it. */ 960 /* This is a hard error, log it. */
960 if (unlikely(TX_BUFFS_AVAIL(bp) < 1)) { 961 if (unlikely(TX_BUFFS_AVAIL(bp) < 1)) {
@@ -1027,7 +1028,7 @@ static int b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
1027 dev->trans_start = jiffies; 1028 dev->trans_start = jiffies;
1028 1029
1029out_unlock: 1030out_unlock:
1030 spin_unlock_irq(&bp->lock); 1031 spin_unlock_irqrestore(&bp->lock, flags);
1031 1032
1032 return rc; 1033 return rc;
1033 1034
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index b70cc99962fc..06b901152d44 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -399,9 +399,11 @@ static int bnx2_unregister_cnic(struct net_device *dev)
399 struct bnx2_napi *bnapi = &bp->bnx2_napi[0]; 399 struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
400 struct cnic_eth_dev *cp = &bp->cnic_eth_dev; 400 struct cnic_eth_dev *cp = &bp->cnic_eth_dev;
401 401
402 mutex_lock(&bp->cnic_lock);
402 cp->drv_state = 0; 403 cp->drv_state = 0;
403 bnapi->cnic_present = 0; 404 bnapi->cnic_present = 0;
404 rcu_assign_pointer(bp->cnic_ops, NULL); 405 rcu_assign_pointer(bp->cnic_ops, NULL);
406 mutex_unlock(&bp->cnic_lock);
405 synchronize_rcu(); 407 synchronize_rcu();
406 return 0; 408 return 0;
407} 409}
@@ -429,13 +431,13 @@ bnx2_cnic_stop(struct bnx2 *bp)
429 struct cnic_ops *c_ops; 431 struct cnic_ops *c_ops;
430 struct cnic_ctl_info info; 432 struct cnic_ctl_info info;
431 433
432 rcu_read_lock(); 434 mutex_lock(&bp->cnic_lock);
433 c_ops = rcu_dereference(bp->cnic_ops); 435 c_ops = bp->cnic_ops;
434 if (c_ops) { 436 if (c_ops) {
435 info.cmd = CNIC_CTL_STOP_CMD; 437 info.cmd = CNIC_CTL_STOP_CMD;
436 c_ops->cnic_ctl(bp->cnic_data, &info); 438 c_ops->cnic_ctl(bp->cnic_data, &info);
437 } 439 }
438 rcu_read_unlock(); 440 mutex_unlock(&bp->cnic_lock);
439} 441}
440 442
441static void 443static void
@@ -444,8 +446,8 @@ bnx2_cnic_start(struct bnx2 *bp)
444 struct cnic_ops *c_ops; 446 struct cnic_ops *c_ops;
445 struct cnic_ctl_info info; 447 struct cnic_ctl_info info;
446 448
447 rcu_read_lock(); 449 mutex_lock(&bp->cnic_lock);
448 c_ops = rcu_dereference(bp->cnic_ops); 450 c_ops = bp->cnic_ops;
449 if (c_ops) { 451 if (c_ops) {
450 if (!(bp->flags & BNX2_FLAG_USING_MSIX)) { 452 if (!(bp->flags & BNX2_FLAG_USING_MSIX)) {
451 struct bnx2_napi *bnapi = &bp->bnx2_napi[0]; 453 struct bnx2_napi *bnapi = &bp->bnx2_napi[0];
@@ -455,7 +457,7 @@ bnx2_cnic_start(struct bnx2 *bp)
455 info.cmd = CNIC_CTL_START_CMD; 457 info.cmd = CNIC_CTL_START_CMD;
456 c_ops->cnic_ctl(bp->cnic_data, &info); 458 c_ops->cnic_ctl(bp->cnic_data, &info);
457 } 459 }
458 rcu_read_unlock(); 460 mutex_unlock(&bp->cnic_lock);
459} 461}
460 462
461#else 463#else
@@ -7663,6 +7665,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev)
7663 7665
7664 spin_lock_init(&bp->phy_lock); 7666 spin_lock_init(&bp->phy_lock);
7665 spin_lock_init(&bp->indirect_lock); 7667 spin_lock_init(&bp->indirect_lock);
7668#ifdef BCM_CNIC
7669 mutex_init(&bp->cnic_lock);
7670#endif
7666 INIT_WORK(&bp->reset_task, bnx2_reset_task); 7671 INIT_WORK(&bp->reset_task, bnx2_reset_task);
7667 7672
7668 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); 7673 dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0);
diff --git a/drivers/net/bnx2.h b/drivers/net/bnx2.h
index f1edfaa9e56a..a4f12fd0ecd2 100644
--- a/drivers/net/bnx2.h
+++ b/drivers/net/bnx2.h
@@ -6902,6 +6902,7 @@ struct bnx2 {
6902 u32 idle_chk_status_idx; 6902 u32 idle_chk_status_idx;
6903 6903
6904#ifdef BCM_CNIC 6904#ifdef BCM_CNIC
6905 struct mutex cnic_lock;
6905 struct cnic_eth_dev cnic_eth_dev; 6906 struct cnic_eth_dev cnic_eth_dev;
6906#endif 6907#endif
6907 6908
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 9e4283aff828..e1a4f8214239 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -611,11 +611,18 @@ nla_put_failure:
611 return -EMSGSIZE; 611 return -EMSGSIZE;
612} 612}
613 613
614static int can_newlink(struct net_device *dev,
615 struct nlattr *tb[], struct nlattr *data[])
616{
617 return -EOPNOTSUPP;
618}
619
614static struct rtnl_link_ops can_link_ops __read_mostly = { 620static struct rtnl_link_ops can_link_ops __read_mostly = {
615 .kind = "can", 621 .kind = "can",
616 .maxtype = IFLA_CAN_MAX, 622 .maxtype = IFLA_CAN_MAX,
617 .policy = can_policy, 623 .policy = can_policy,
618 .setup = can_setup, 624 .setup = can_setup,
625 .newlink = can_newlink,
619 .changelink = can_changelink, 626 .changelink = can_changelink,
620 .fill_info = can_fill_info, 627 .fill_info = can_fill_info,
621 .fill_xstats = can_fill_xstats, 628 .fill_xstats = can_fill_xstats,
diff --git a/drivers/net/cnic.c b/drivers/net/cnic.c
index 4869d77cbe91..74c342959b7b 100644
--- a/drivers/net/cnic.c
+++ b/drivers/net/cnic.c
@@ -138,6 +138,16 @@ static struct cnic_dev *cnic_from_netdev(struct net_device *netdev)
138 return NULL; 138 return NULL;
139} 139}
140 140
141static inline void ulp_get(struct cnic_ulp_ops *ulp_ops)
142{
143 atomic_inc(&ulp_ops->ref_count);
144}
145
146static inline void ulp_put(struct cnic_ulp_ops *ulp_ops)
147{
148 atomic_dec(&ulp_ops->ref_count);
149}
150
141static void cnic_ctx_wr(struct cnic_dev *dev, u32 cid_addr, u32 off, u32 val) 151static void cnic_ctx_wr(struct cnic_dev *dev, u32 cid_addr, u32 off, u32 val)
142{ 152{
143 struct cnic_local *cp = dev->cnic_priv; 153 struct cnic_local *cp = dev->cnic_priv;
@@ -358,6 +368,7 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)
358 } 368 }
359 read_unlock(&cnic_dev_lock); 369 read_unlock(&cnic_dev_lock);
360 370
371 atomic_set(&ulp_ops->ref_count, 0);
361 rcu_assign_pointer(cnic_ulp_tbl[ulp_type], ulp_ops); 372 rcu_assign_pointer(cnic_ulp_tbl[ulp_type], ulp_ops);
362 mutex_unlock(&cnic_lock); 373 mutex_unlock(&cnic_lock);
363 374
@@ -379,6 +390,8 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)
379int cnic_unregister_driver(int ulp_type) 390int cnic_unregister_driver(int ulp_type)
380{ 391{
381 struct cnic_dev *dev; 392 struct cnic_dev *dev;
393 struct cnic_ulp_ops *ulp_ops;
394 int i = 0;
382 395
383 if (ulp_type >= MAX_CNIC_ULP_TYPE) { 396 if (ulp_type >= MAX_CNIC_ULP_TYPE) {
384 printk(KERN_ERR PFX "cnic_unregister_driver: Bad type %d\n", 397 printk(KERN_ERR PFX "cnic_unregister_driver: Bad type %d\n",
@@ -386,7 +399,8 @@ int cnic_unregister_driver(int ulp_type)
386 return -EINVAL; 399 return -EINVAL;
387 } 400 }
388 mutex_lock(&cnic_lock); 401 mutex_lock(&cnic_lock);
389 if (!cnic_ulp_tbl[ulp_type]) { 402 ulp_ops = cnic_ulp_tbl[ulp_type];
403 if (!ulp_ops) {
390 printk(KERN_ERR PFX "cnic_unregister_driver: Type %d has not " 404 printk(KERN_ERR PFX "cnic_unregister_driver: Type %d has not "
391 "been registered\n", ulp_type); 405 "been registered\n", ulp_type);
392 goto out_unlock; 406 goto out_unlock;
@@ -411,6 +425,14 @@ int cnic_unregister_driver(int ulp_type)
411 425
412 mutex_unlock(&cnic_lock); 426 mutex_unlock(&cnic_lock);
413 synchronize_rcu(); 427 synchronize_rcu();
428 while ((atomic_read(&ulp_ops->ref_count) != 0) && (i < 20)) {
429 msleep(100);
430 i++;
431 }
432
433 if (atomic_read(&ulp_ops->ref_count) != 0)
434 printk(KERN_WARNING PFX "%s: Failed waiting for ref count to go"
435 " to zero.\n", dev->netdev->name);
414 return 0; 436 return 0;
415 437
416out_unlock: 438out_unlock:
@@ -466,6 +488,7 @@ EXPORT_SYMBOL(cnic_register_driver);
466static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type) 488static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
467{ 489{
468 struct cnic_local *cp = dev->cnic_priv; 490 struct cnic_local *cp = dev->cnic_priv;
491 int i = 0;
469 492
470 if (ulp_type >= MAX_CNIC_ULP_TYPE) { 493 if (ulp_type >= MAX_CNIC_ULP_TYPE) {
471 printk(KERN_ERR PFX "cnic_unregister_device: Bad type %d\n", 494 printk(KERN_ERR PFX "cnic_unregister_device: Bad type %d\n",
@@ -486,6 +509,15 @@ static int cnic_unregister_device(struct cnic_dev *dev, int ulp_type)
486 509
487 synchronize_rcu(); 510 synchronize_rcu();
488 511
512 while (test_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[ulp_type]) &&
513 i < 20) {
514 msleep(100);
515 i++;
516 }
517 if (test_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[ulp_type]))
518 printk(KERN_WARNING PFX "%s: Failed waiting for ULP up call"
519 " to complete.\n", dev->netdev->name);
520
489 return 0; 521 return 0;
490} 522}
491EXPORT_SYMBOL(cnic_unregister_driver); 523EXPORT_SYMBOL(cnic_unregister_driver);
@@ -1076,18 +1108,23 @@ static void cnic_ulp_stop(struct cnic_dev *dev)
1076 if (cp->cnic_uinfo) 1108 if (cp->cnic_uinfo)
1077 cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL); 1109 cnic_send_nlmsg(cp, ISCSI_KEVENT_IF_DOWN, NULL);
1078 1110
1079 rcu_read_lock();
1080 for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { 1111 for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) {
1081 struct cnic_ulp_ops *ulp_ops; 1112 struct cnic_ulp_ops *ulp_ops;
1082 1113
1083 ulp_ops = rcu_dereference(cp->ulp_ops[if_type]); 1114 mutex_lock(&cnic_lock);
1084 if (!ulp_ops) 1115 ulp_ops = cp->ulp_ops[if_type];
1116 if (!ulp_ops) {
1117 mutex_unlock(&cnic_lock);
1085 continue; 1118 continue;
1119 }
1120 set_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
1121 mutex_unlock(&cnic_lock);
1086 1122
1087 if (test_and_clear_bit(ULP_F_START, &cp->ulp_flags[if_type])) 1123 if (test_and_clear_bit(ULP_F_START, &cp->ulp_flags[if_type]))
1088 ulp_ops->cnic_stop(cp->ulp_handle[if_type]); 1124 ulp_ops->cnic_stop(cp->ulp_handle[if_type]);
1125
1126 clear_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
1089 } 1127 }
1090 rcu_read_unlock();
1091} 1128}
1092 1129
1093static void cnic_ulp_start(struct cnic_dev *dev) 1130static void cnic_ulp_start(struct cnic_dev *dev)
@@ -1095,18 +1132,23 @@ static void cnic_ulp_start(struct cnic_dev *dev)
1095 struct cnic_local *cp = dev->cnic_priv; 1132 struct cnic_local *cp = dev->cnic_priv;
1096 int if_type; 1133 int if_type;
1097 1134
1098 rcu_read_lock();
1099 for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) { 1135 for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) {
1100 struct cnic_ulp_ops *ulp_ops; 1136 struct cnic_ulp_ops *ulp_ops;
1101 1137
1102 ulp_ops = rcu_dereference(cp->ulp_ops[if_type]); 1138 mutex_lock(&cnic_lock);
1103 if (!ulp_ops || !ulp_ops->cnic_start) 1139 ulp_ops = cp->ulp_ops[if_type];
1140 if (!ulp_ops || !ulp_ops->cnic_start) {
1141 mutex_unlock(&cnic_lock);
1104 continue; 1142 continue;
1143 }
1144 set_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
1145 mutex_unlock(&cnic_lock);
1105 1146
1106 if (!test_and_set_bit(ULP_F_START, &cp->ulp_flags[if_type])) 1147 if (!test_and_set_bit(ULP_F_START, &cp->ulp_flags[if_type]))
1107 ulp_ops->cnic_start(cp->ulp_handle[if_type]); 1148 ulp_ops->cnic_start(cp->ulp_handle[if_type]);
1149
1150 clear_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
1108 } 1151 }
1109 rcu_read_unlock();
1110} 1152}
1111 1153
1112static int cnic_ctl(void *data, struct cnic_ctl_info *info) 1154static int cnic_ctl(void *data, struct cnic_ctl_info *info)
@@ -1116,22 +1158,18 @@ static int cnic_ctl(void *data, struct cnic_ctl_info *info)
1116 switch (info->cmd) { 1158 switch (info->cmd) {
1117 case CNIC_CTL_STOP_CMD: 1159 case CNIC_CTL_STOP_CMD:
1118 cnic_hold(dev); 1160 cnic_hold(dev);
1119 mutex_lock(&cnic_lock);
1120 1161
1121 cnic_ulp_stop(dev); 1162 cnic_ulp_stop(dev);
1122 cnic_stop_hw(dev); 1163 cnic_stop_hw(dev);
1123 1164
1124 mutex_unlock(&cnic_lock);
1125 cnic_put(dev); 1165 cnic_put(dev);
1126 break; 1166 break;
1127 case CNIC_CTL_START_CMD: 1167 case CNIC_CTL_START_CMD:
1128 cnic_hold(dev); 1168 cnic_hold(dev);
1129 mutex_lock(&cnic_lock);
1130 1169
1131 if (!cnic_start_hw(dev)) 1170 if (!cnic_start_hw(dev))
1132 cnic_ulp_start(dev); 1171 cnic_ulp_start(dev);
1133 1172
1134 mutex_unlock(&cnic_lock);
1135 cnic_put(dev); 1173 cnic_put(dev);
1136 break; 1174 break;
1137 default: 1175 default:
@@ -1145,19 +1183,23 @@ static void cnic_ulp_init(struct cnic_dev *dev)
1145 int i; 1183 int i;
1146 struct cnic_local *cp = dev->cnic_priv; 1184 struct cnic_local *cp = dev->cnic_priv;
1147 1185
1148 rcu_read_lock();
1149 for (i = 0; i < MAX_CNIC_ULP_TYPE_EXT; i++) { 1186 for (i = 0; i < MAX_CNIC_ULP_TYPE_EXT; i++) {
1150 struct cnic_ulp_ops *ulp_ops; 1187 struct cnic_ulp_ops *ulp_ops;
1151 1188
1152 ulp_ops = rcu_dereference(cnic_ulp_tbl[i]); 1189 mutex_lock(&cnic_lock);
1153 if (!ulp_ops || !ulp_ops->cnic_init) 1190 ulp_ops = cnic_ulp_tbl[i];
1191 if (!ulp_ops || !ulp_ops->cnic_init) {
1192 mutex_unlock(&cnic_lock);
1154 continue; 1193 continue;
1194 }
1195 ulp_get(ulp_ops);
1196 mutex_unlock(&cnic_lock);
1155 1197
1156 if (!test_and_set_bit(ULP_F_INIT, &cp->ulp_flags[i])) 1198 if (!test_and_set_bit(ULP_F_INIT, &cp->ulp_flags[i]))
1157 ulp_ops->cnic_init(dev); 1199 ulp_ops->cnic_init(dev);
1158 1200
1201 ulp_put(ulp_ops);
1159 } 1202 }
1160 rcu_read_unlock();
1161} 1203}
1162 1204
1163static void cnic_ulp_exit(struct cnic_dev *dev) 1205static void cnic_ulp_exit(struct cnic_dev *dev)
@@ -1165,19 +1207,23 @@ static void cnic_ulp_exit(struct cnic_dev *dev)
1165 int i; 1207 int i;
1166 struct cnic_local *cp = dev->cnic_priv; 1208 struct cnic_local *cp = dev->cnic_priv;
1167 1209
1168 rcu_read_lock();
1169 for (i = 0; i < MAX_CNIC_ULP_TYPE_EXT; i++) { 1210 for (i = 0; i < MAX_CNIC_ULP_TYPE_EXT; i++) {
1170 struct cnic_ulp_ops *ulp_ops; 1211 struct cnic_ulp_ops *ulp_ops;
1171 1212
1172 ulp_ops = rcu_dereference(cnic_ulp_tbl[i]); 1213 mutex_lock(&cnic_lock);
1173 if (!ulp_ops || !ulp_ops->cnic_exit) 1214 ulp_ops = cnic_ulp_tbl[i];
1215 if (!ulp_ops || !ulp_ops->cnic_exit) {
1216 mutex_unlock(&cnic_lock);
1174 continue; 1217 continue;
1218 }
1219 ulp_get(ulp_ops);
1220 mutex_unlock(&cnic_lock);
1175 1221
1176 if (test_and_clear_bit(ULP_F_INIT, &cp->ulp_flags[i])) 1222 if (test_and_clear_bit(ULP_F_INIT, &cp->ulp_flags[i]))
1177 ulp_ops->cnic_exit(dev); 1223 ulp_ops->cnic_exit(dev);
1178 1224
1225 ulp_put(ulp_ops);
1179 } 1226 }
1180 rcu_read_unlock();
1181} 1227}
1182 1228
1183static int cnic_cm_offload_pg(struct cnic_sock *csk) 1229static int cnic_cm_offload_pg(struct cnic_sock *csk)
@@ -2393,21 +2439,45 @@ static int cnic_start_bnx2_hw(struct cnic_dev *dev)
2393 return 0; 2439 return 0;
2394} 2440}
2395 2441
2396static int cnic_start_hw(struct cnic_dev *dev) 2442static int cnic_register_netdev(struct cnic_dev *dev)
2397{ 2443{
2398 struct cnic_local *cp = dev->cnic_priv; 2444 struct cnic_local *cp = dev->cnic_priv;
2399 struct cnic_eth_dev *ethdev = cp->ethdev; 2445 struct cnic_eth_dev *ethdev = cp->ethdev;
2400 int err; 2446 int err;
2401 2447
2402 if (test_bit(CNIC_F_CNIC_UP, &dev->flags)) 2448 if (!ethdev)
2403 return -EALREADY; 2449 return -ENODEV;
2450
2451 if (ethdev->drv_state & CNIC_DRV_STATE_REGD)
2452 return 0;
2404 2453
2405 err = ethdev->drv_register_cnic(dev->netdev, cp->cnic_ops, dev); 2454 err = ethdev->drv_register_cnic(dev->netdev, cp->cnic_ops, dev);
2406 if (err) { 2455 if (err)
2407 printk(KERN_ERR PFX "%s: register_cnic failed\n", 2456 printk(KERN_ERR PFX "%s: register_cnic failed\n",
2408 dev->netdev->name); 2457 dev->netdev->name);
2409 goto err2; 2458
2410 } 2459 return err;
2460}
2461
2462static void cnic_unregister_netdev(struct cnic_dev *dev)
2463{
2464 struct cnic_local *cp = dev->cnic_priv;
2465 struct cnic_eth_dev *ethdev = cp->ethdev;
2466
2467 if (!ethdev)
2468 return;
2469
2470 ethdev->drv_unregister_cnic(dev->netdev);
2471}
2472
2473static int cnic_start_hw(struct cnic_dev *dev)
2474{
2475 struct cnic_local *cp = dev->cnic_priv;
2476 struct cnic_eth_dev *ethdev = cp->ethdev;
2477 int err;
2478
2479 if (test_bit(CNIC_F_CNIC_UP, &dev->flags))
2480 return -EALREADY;
2411 2481
2412 dev->regview = ethdev->io_base; 2482 dev->regview = ethdev->io_base;
2413 cp->chip_id = ethdev->chip_id; 2483 cp->chip_id = ethdev->chip_id;
@@ -2438,18 +2508,13 @@ static int cnic_start_hw(struct cnic_dev *dev)
2438 return 0; 2508 return 0;
2439 2509
2440err1: 2510err1:
2441 ethdev->drv_unregister_cnic(dev->netdev);
2442 cp->free_resc(dev); 2511 cp->free_resc(dev);
2443 pci_dev_put(dev->pcidev); 2512 pci_dev_put(dev->pcidev);
2444err2:
2445 return err; 2513 return err;
2446} 2514}
2447 2515
2448static void cnic_stop_bnx2_hw(struct cnic_dev *dev) 2516static void cnic_stop_bnx2_hw(struct cnic_dev *dev)
2449{ 2517{
2450 struct cnic_local *cp = dev->cnic_priv;
2451 struct cnic_eth_dev *ethdev = cp->ethdev;
2452
2453 cnic_disable_bnx2_int_sync(dev); 2518 cnic_disable_bnx2_int_sync(dev);
2454 2519
2455 cnic_reg_wr_ind(dev, BNX2_CP_SCRATCH + 0x20, 0); 2520 cnic_reg_wr_ind(dev, BNX2_CP_SCRATCH + 0x20, 0);
@@ -2461,8 +2526,6 @@ static void cnic_stop_bnx2_hw(struct cnic_dev *dev)
2461 cnic_setup_5709_context(dev, 0); 2526 cnic_setup_5709_context(dev, 0);
2462 cnic_free_irq(dev); 2527 cnic_free_irq(dev);
2463 2528
2464 ethdev->drv_unregister_cnic(dev->netdev);
2465
2466 cnic_free_resc(dev); 2529 cnic_free_resc(dev);
2467} 2530}
2468 2531
@@ -2543,7 +2606,7 @@ static struct cnic_dev *init_bnx2_cnic(struct net_device *dev)
2543 probe = symbol_get(bnx2_cnic_probe); 2606 probe = symbol_get(bnx2_cnic_probe);
2544 if (probe) { 2607 if (probe) {
2545 ethdev = (*probe)(dev); 2608 ethdev = (*probe)(dev);
2546 symbol_put_addr(probe); 2609 symbol_put(bnx2_cnic_probe);
2547 } 2610 }
2548 if (!ethdev) 2611 if (!ethdev)
2549 return NULL; 2612 return NULL;
@@ -2646,10 +2709,12 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
2646 else if (event == NETDEV_UNREGISTER) 2709 else if (event == NETDEV_UNREGISTER)
2647 cnic_ulp_exit(dev); 2710 cnic_ulp_exit(dev);
2648 else if (event == NETDEV_UP) { 2711 else if (event == NETDEV_UP) {
2649 mutex_lock(&cnic_lock); 2712 if (cnic_register_netdev(dev) != 0) {
2713 cnic_put(dev);
2714 goto done;
2715 }
2650 if (!cnic_start_hw(dev)) 2716 if (!cnic_start_hw(dev))
2651 cnic_ulp_start(dev); 2717 cnic_ulp_start(dev);
2652 mutex_unlock(&cnic_lock);
2653 } 2718 }
2654 2719
2655 rcu_read_lock(); 2720 rcu_read_lock();
@@ -2668,10 +2733,9 @@ static int cnic_netdev_event(struct notifier_block *this, unsigned long event,
2668 rcu_read_unlock(); 2733 rcu_read_unlock();
2669 2734
2670 if (event == NETDEV_GOING_DOWN) { 2735 if (event == NETDEV_GOING_DOWN) {
2671 mutex_lock(&cnic_lock);
2672 cnic_ulp_stop(dev); 2736 cnic_ulp_stop(dev);
2673 cnic_stop_hw(dev); 2737 cnic_stop_hw(dev);
2674 mutex_unlock(&cnic_lock); 2738 cnic_unregister_netdev(dev);
2675 } else if (event == NETDEV_UNREGISTER) { 2739 } else if (event == NETDEV_UNREGISTER) {
2676 write_lock(&cnic_dev_lock); 2740 write_lock(&cnic_dev_lock);
2677 list_del_init(&dev->list); 2741 list_del_init(&dev->list);
@@ -2703,6 +2767,7 @@ static void cnic_release(void)
2703 } 2767 }
2704 2768
2705 cnic_ulp_exit(dev); 2769 cnic_ulp_exit(dev);
2770 cnic_unregister_netdev(dev);
2706 list_del_init(&dev->list); 2771 list_del_init(&dev->list);
2707 cnic_free_dev(dev); 2772 cnic_free_dev(dev);
2708 } 2773 }
diff --git a/drivers/net/cnic.h b/drivers/net/cnic.h
index 5192d4a9df5a..a94b302bb464 100644
--- a/drivers/net/cnic.h
+++ b/drivers/net/cnic.h
@@ -176,6 +176,7 @@ struct cnic_local {
176 unsigned long ulp_flags[MAX_CNIC_ULP_TYPE]; 176 unsigned long ulp_flags[MAX_CNIC_ULP_TYPE];
177#define ULP_F_INIT 0 177#define ULP_F_INIT 0
178#define ULP_F_START 1 178#define ULP_F_START 1
179#define ULP_F_CALL_PENDING 2
179 struct cnic_ulp_ops *ulp_ops[MAX_CNIC_ULP_TYPE]; 180 struct cnic_ulp_ops *ulp_ops[MAX_CNIC_ULP_TYPE];
180 181
181 /* protected by ulp_lock */ 182 /* protected by ulp_lock */
diff --git a/drivers/net/cnic_if.h b/drivers/net/cnic_if.h
index d1bce27ee99e..a49235739eef 100644
--- a/drivers/net/cnic_if.h
+++ b/drivers/net/cnic_if.h
@@ -290,6 +290,7 @@ struct cnic_ulp_ops {
290 void (*iscsi_nl_send_msg)(struct cnic_dev *dev, u32 msg_type, 290 void (*iscsi_nl_send_msg)(struct cnic_dev *dev, u32 msg_type,
291 char *data, u16 data_size); 291 char *data, u16 data_size);
292 struct module *owner; 292 struct module *owner;
293 atomic_t ref_count;
293}; 294};
294 295
295extern int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops); 296extern int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops);
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index 41b648a67fec..3a6735dc9f6a 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -1899,7 +1899,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
1899 nic->ru_running = RU_SUSPENDED; 1899 nic->ru_running = RU_SUSPENDED;
1900 pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr, 1900 pci_dma_sync_single_for_device(nic->pdev, rx->dma_addr,
1901 sizeof(struct rfd), 1901 sizeof(struct rfd),
1902 PCI_DMA_BIDIRECTIONAL); 1902 PCI_DMA_FROMDEVICE);
1903 return -ENODATA; 1903 return -ENODATA;
1904 } 1904 }
1905 1905
diff --git a/drivers/net/e1000e/ich8lan.c b/drivers/net/e1000e/ich8lan.c
index d56c7473144a..99df2abf82a9 100644
--- a/drivers/net/e1000e/ich8lan.c
+++ b/drivers/net/e1000e/ich8lan.c
@@ -338,10 +338,7 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
338{ 338{
339 struct e1000_nvm_info *nvm = &hw->nvm; 339 struct e1000_nvm_info *nvm = &hw->nvm;
340 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 340 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
341 union ich8_hws_flash_status hsfsts; 341 u32 gfpreg, sector_base_addr, sector_end_addr;
342 u32 gfpreg;
343 u32 sector_base_addr;
344 u32 sector_end_addr;
345 u16 i; 342 u16 i;
346 343
347 /* Can't read flash registers if the register set isn't mapped. */ 344 /* Can't read flash registers if the register set isn't mapped. */
@@ -375,20 +372,6 @@ static s32 e1000_init_nvm_params_ich8lan(struct e1000_hw *hw)
375 /* Adjust to word count */ 372 /* Adjust to word count */
376 nvm->flash_bank_size /= sizeof(u16); 373 nvm->flash_bank_size /= sizeof(u16);
377 374
378 /*
379 * Make sure the flash bank size does not overwrite the 4k
380 * sector ranges. We may have 64k allotted to us but we only care
381 * about the first 2 4k sectors. Therefore, if we have anything less
382 * than 64k set in the HSFSTS register, we will reduce the bank size
383 * down to 4k and let the rest remain unused. If berasesz == 3, then
384 * we are working in 64k mode. Otherwise we are not.
385 */
386 if (nvm->flash_bank_size > E1000_ICH8_SHADOW_RAM_WORDS) {
387 hsfsts.regval = er16flash(ICH_FLASH_HSFSTS);
388 if (hsfsts.hsf_status.berasesz != 3)
389 nvm->flash_bank_size = E1000_ICH8_SHADOW_RAM_WORDS;
390 }
391
392 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS; 375 nvm->word_size = E1000_ICH8_SHADOW_RAM_WORDS;
393 376
394 /* Clear shadow ram */ 377 /* Clear shadow ram */
@@ -594,8 +577,8 @@ static DEFINE_MUTEX(nvm_mutex);
594 **/ 577 **/
595static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw) 578static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
596{ 579{
597 u32 extcnf_ctrl; 580 u32 extcnf_ctrl, timeout = PHY_CFG_TIMEOUT;
598 u32 timeout = PHY_CFG_TIMEOUT; 581 s32 ret_val = 0;
599 582
600 might_sleep(); 583 might_sleep();
601 584
@@ -603,28 +586,46 @@ static s32 e1000_acquire_swflag_ich8lan(struct e1000_hw *hw)
603 586
604 while (timeout) { 587 while (timeout) {
605 extcnf_ctrl = er32(EXTCNF_CTRL); 588 extcnf_ctrl = er32(EXTCNF_CTRL);
589 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG))
590 break;
606 591
607 if (!(extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)) { 592 mdelay(1);
608 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG; 593 timeout--;
609 ew32(EXTCNF_CTRL, extcnf_ctrl); 594 }
595
596 if (!timeout) {
597 hw_dbg(hw, "SW/FW/HW has locked the resource for too long.\n");
598 ret_val = -E1000_ERR_CONFIG;
599 goto out;
600 }
601
602 timeout = PHY_CFG_TIMEOUT * 2;
603
604 extcnf_ctrl |= E1000_EXTCNF_CTRL_SWFLAG;
605 ew32(EXTCNF_CTRL, extcnf_ctrl);
606
607 while (timeout) {
608 extcnf_ctrl = er32(EXTCNF_CTRL);
609 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
610 break;
610 611
611 extcnf_ctrl = er32(EXTCNF_CTRL);
612 if (extcnf_ctrl & E1000_EXTCNF_CTRL_SWFLAG)
613 break;
614 }
615 mdelay(1); 612 mdelay(1);
616 timeout--; 613 timeout--;
617 } 614 }
618 615
619 if (!timeout) { 616 if (!timeout) {
620 hw_dbg(hw, "FW or HW has locked the resource for too long.\n"); 617 hw_dbg(hw, "Failed to acquire the semaphore.\n");
621 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG; 618 extcnf_ctrl &= ~E1000_EXTCNF_CTRL_SWFLAG;
622 ew32(EXTCNF_CTRL, extcnf_ctrl); 619 ew32(EXTCNF_CTRL, extcnf_ctrl);
623 mutex_unlock(&nvm_mutex); 620 ret_val = -E1000_ERR_CONFIG;
624 return -E1000_ERR_CONFIG; 621 goto out;
625 } 622 }
626 623
627 return 0; 624out:
625 if (ret_val)
626 mutex_unlock(&nvm_mutex);
627
628 return ret_val;
628} 629}
629 630
630/** 631/**
@@ -1306,7 +1307,7 @@ static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1306 struct e1000_nvm_info *nvm = &hw->nvm; 1307 struct e1000_nvm_info *nvm = &hw->nvm;
1307 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 1308 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
1308 u32 act_offset; 1309 u32 act_offset;
1309 s32 ret_val; 1310 s32 ret_val = 0;
1310 u32 bank = 0; 1311 u32 bank = 0;
1311 u16 i, word; 1312 u16 i, word;
1312 1313
@@ -1321,12 +1322,15 @@ static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1321 goto out; 1322 goto out;
1322 1323
1323 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); 1324 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
1324 if (ret_val) 1325 if (ret_val) {
1325 goto release; 1326 hw_dbg(hw, "Could not detect valid bank, assuming bank 0\n");
1327 bank = 0;
1328 }
1326 1329
1327 act_offset = (bank) ? nvm->flash_bank_size : 0; 1330 act_offset = (bank) ? nvm->flash_bank_size : 0;
1328 act_offset += offset; 1331 act_offset += offset;
1329 1332
1333 ret_val = 0;
1330 for (i = 0; i < words; i++) { 1334 for (i = 0; i < words; i++) {
1331 if ((dev_spec->shadow_ram) && 1335 if ((dev_spec->shadow_ram) &&
1332 (dev_spec->shadow_ram[offset+i].modified)) { 1336 (dev_spec->shadow_ram[offset+i].modified)) {
@@ -1341,7 +1345,6 @@ static s32 e1000_read_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1341 } 1345 }
1342 } 1346 }
1343 1347
1344release:
1345 e1000_release_swflag_ich8lan(hw); 1348 e1000_release_swflag_ich8lan(hw);
1346 1349
1347out: 1350out:
@@ -1592,7 +1595,6 @@ static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1592{ 1595{
1593 struct e1000_nvm_info *nvm = &hw->nvm; 1596 struct e1000_nvm_info *nvm = &hw->nvm;
1594 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; 1597 struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan;
1595 s32 ret_val;
1596 u16 i; 1598 u16 i;
1597 1599
1598 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) || 1600 if ((offset >= nvm->word_size) || (words > nvm->word_size - offset) ||
@@ -1601,17 +1603,11 @@ static s32 e1000_write_nvm_ich8lan(struct e1000_hw *hw, u16 offset, u16 words,
1601 return -E1000_ERR_NVM; 1603 return -E1000_ERR_NVM;
1602 } 1604 }
1603 1605
1604 ret_val = e1000_acquire_swflag_ich8lan(hw);
1605 if (ret_val)
1606 return ret_val;
1607
1608 for (i = 0; i < words; i++) { 1606 for (i = 0; i < words; i++) {
1609 dev_spec->shadow_ram[offset+i].modified = 1; 1607 dev_spec->shadow_ram[offset+i].modified = 1;
1610 dev_spec->shadow_ram[offset+i].value = data[i]; 1608 dev_spec->shadow_ram[offset+i].value = data[i];
1611 } 1609 }
1612 1610
1613 e1000_release_swflag_ich8lan(hw);
1614
1615 return 0; 1611 return 0;
1616} 1612}
1617 1613
@@ -1652,8 +1648,8 @@ static s32 e1000_update_nvm_checksum_ich8lan(struct e1000_hw *hw)
1652 */ 1648 */
1653 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank); 1649 ret_val = e1000_valid_nvm_bank_detect_ich8lan(hw, &bank);
1654 if (ret_val) { 1650 if (ret_val) {
1655 e1000_release_swflag_ich8lan(hw); 1651 hw_dbg(hw, "Could not detect valid bank, assuming bank 0\n");
1656 goto out; 1652 bank = 0;
1657 } 1653 }
1658 1654
1659 if (bank == 0) { 1655 if (bank == 0) {
@@ -2039,12 +2035,8 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
2039 iteration = 1; 2035 iteration = 1;
2040 break; 2036 break;
2041 case 2: 2037 case 2:
2042 if (hw->mac.type == e1000_ich9lan) { 2038 sector_size = ICH_FLASH_SEG_SIZE_8K;
2043 sector_size = ICH_FLASH_SEG_SIZE_8K; 2039 iteration = 1;
2044 iteration = flash_bank_size / ICH_FLASH_SEG_SIZE_8K;
2045 } else {
2046 return -E1000_ERR_NVM;
2047 }
2048 break; 2040 break;
2049 case 3: 2041 case 3:
2050 sector_size = ICH_FLASH_SEG_SIZE_64K; 2042 sector_size = ICH_FLASH_SEG_SIZE_64K;
@@ -2056,7 +2048,7 @@ static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank)
2056 2048
2057 /* Start with the base address, then add the sector offset. */ 2049 /* Start with the base address, then add the sector offset. */
2058 flash_linear_addr = hw->nvm.flash_base_addr; 2050 flash_linear_addr = hw->nvm.flash_base_addr;
2059 flash_linear_addr += (bank) ? (sector_size * iteration) : 0; 2051 flash_linear_addr += (bank) ? flash_bank_size : 0;
2060 2052
2061 for (j = 0; j < iteration ; j++) { 2053 for (j = 0; j < iteration ; j++) {
2062 do { 2054 do {
diff --git a/drivers/net/e1000e/netdev.c b/drivers/net/e1000e/netdev.c
index 63415bb6f48f..fa92a683aefd 100644
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -4538,8 +4538,7 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
4538 /* Allow time for pending master requests to run */ 4538 /* Allow time for pending master requests to run */
4539 e1000e_disable_pcie_master(&adapter->hw); 4539 e1000e_disable_pcie_master(&adapter->hw);
4540 4540
4541 if ((adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) && 4541 if (adapter->flags2 & FLAG2_HAS_PHY_WAKEUP) {
4542 !(hw->mac.ops.check_mng_mode(hw))) {
4543 /* enable wakeup by the PHY */ 4542 /* enable wakeup by the PHY */
4544 retval = e1000_init_phy_wakeup(adapter, wufc); 4543 retval = e1000_init_phy_wakeup(adapter, wufc);
4545 if (retval) 4544 if (retval)
@@ -4557,7 +4556,8 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake)
4557 *enable_wake = !!wufc; 4556 *enable_wake = !!wufc;
4558 4557
4559 /* make sure adapter isn't asleep if manageability is enabled */ 4558 /* make sure adapter isn't asleep if manageability is enabled */
4560 if (adapter->flags & FLAG_MNG_PT_ENABLED) 4559 if ((adapter->flags & FLAG_MNG_PT_ENABLED) ||
4560 (hw->mac.ops.check_mng_mode(hw)))
4561 *enable_wake = true; 4561 *enable_wake = true;
4562 4562
4563 if (adapter->hw.phy.type == e1000_phy_igp_3) 4563 if (adapter->hw.phy.type == e1000_phy_igp_3)
@@ -4670,14 +4670,6 @@ static int e1000_resume(struct pci_dev *pdev)
4670 return err; 4670 return err;
4671 } 4671 }
4672 4672
4673 /* AER (Advanced Error Reporting) hooks */
4674 err = pci_enable_pcie_error_reporting(pdev);
4675 if (err) {
4676 dev_err(&pdev->dev, "pci_enable_pcie_error_reporting failed "
4677 "0x%x\n", err);
4678 /* non-fatal, continue */
4679 }
4680
4681 pci_set_master(pdev); 4673 pci_set_master(pdev);
4682 4674
4683 pci_enable_wake(pdev, PCI_D3hot, 0); 4675 pci_enable_wake(pdev, PCI_D3hot, 0);
@@ -4990,6 +4982,14 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
4990 if (err) 4982 if (err)
4991 goto err_pci_reg; 4983 goto err_pci_reg;
4992 4984
4985 /* AER (Advanced Error Reporting) hooks */
4986 err = pci_enable_pcie_error_reporting(pdev);
4987 if (err) {
4988 dev_err(&pdev->dev, "pci_enable_pcie_error_reporting failed "
4989 "0x%x\n", err);
4990 /* non-fatal, continue */
4991 }
4992
4993 pci_set_master(pdev); 4993 pci_set_master(pdev);
4994 /* PCI config space info */ 4994 /* PCI config space info */
4995 err = pci_save_state(pdev); 4995 err = pci_save_state(pdev);
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c
index 1686dca28748..1f016d66684a 100644
--- a/drivers/net/eexpress.c
+++ b/drivers/net/eexpress.c
@@ -1474,13 +1474,13 @@ static void eexp_hw_init586(struct net_device *dev)
1474 outw(0x0000, ioaddr + 0x800c); 1474 outw(0x0000, ioaddr + 0x800c);
1475 outw(0x0000, ioaddr + 0x800e); 1475 outw(0x0000, ioaddr + 0x800e);
1476 1476
1477 for (i = 0; i < (sizeof(start_code)); i+=32) { 1477 for (i = 0; i < ARRAY_SIZE(start_code) * 2; i+=32) {
1478 int j; 1478 int j;
1479 outw(i, ioaddr + SM_PTR); 1479 outw(i, ioaddr + SM_PTR);
1480 for (j = 0; j < 16; j+=2) 1480 for (j = 0; j < 16 && (i+j)/2 < ARRAY_SIZE(start_code); j+=2)
1481 outw(start_code[(i+j)/2], 1481 outw(start_code[(i+j)/2],
1482 ioaddr+0x4000+j); 1482 ioaddr+0x4000+j);
1483 for (j = 0; j < 16; j+=2) 1483 for (j = 0; j < 16 && (i+j+16)/2 < ARRAY_SIZE(start_code); j+=2)
1484 outw(start_code[(i+j+16)/2], 1484 outw(start_code[(i+j+16)/2],
1485 ioaddr+0x8000+j); 1485 ioaddr+0x8000+j);
1486 } 1486 }
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h
index 78952f8324e2..fa311a950996 100644
--- a/drivers/net/ehea/ehea.h
+++ b/drivers/net/ehea/ehea.h
@@ -40,7 +40,7 @@
40#include <asm/io.h> 40#include <asm/io.h>
41 41
42#define DRV_NAME "ehea" 42#define DRV_NAME "ehea"
43#define DRV_VERSION "EHEA_0101" 43#define DRV_VERSION "EHEA_0102"
44 44
45/* eHEA capability flags */ 45/* eHEA capability flags */
46#define DLPAR_PORT_ADD_REM 1 46#define DLPAR_PORT_ADD_REM 1
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c
index e8d46cc1bec2..977c3d358279 100644
--- a/drivers/net/ehea/ehea_main.c
+++ b/drivers/net/ehea/ehea_main.c
@@ -1545,6 +1545,9 @@ static int ehea_clean_portres(struct ehea_port *port, struct ehea_port_res *pr)
1545{ 1545{
1546 int ret, i; 1546 int ret, i;
1547 1547
1548 if (pr->qp)
1549 netif_napi_del(&pr->napi);
1550
1548 ret = ehea_destroy_qp(pr->qp); 1551 ret = ehea_destroy_qp(pr->qp);
1549 1552
1550 if (!ret) { 1553 if (!ret) {
diff --git a/drivers/net/fec.c b/drivers/net/fec.c
index d4b98074b1b7..c9fd82d3a80d 100644
--- a/drivers/net/fec.c
+++ b/drivers/net/fec.c
@@ -285,6 +285,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
285{ 285{
286 struct fec_enet_private *fep = netdev_priv(dev); 286 struct fec_enet_private *fep = netdev_priv(dev);
287 struct bufdesc *bdp; 287 struct bufdesc *bdp;
288 void *bufaddr;
288 unsigned short status; 289 unsigned short status;
289 unsigned long flags; 290 unsigned long flags;
290 291
@@ -312,7 +313,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
312 status &= ~BD_ENET_TX_STATS; 313 status &= ~BD_ENET_TX_STATS;
313 314
314 /* Set buffer length and buffer pointer */ 315 /* Set buffer length and buffer pointer */
315 bdp->cbd_bufaddr = __pa(skb->data); 316 bufaddr = skb->data;
316 bdp->cbd_datlen = skb->len; 317 bdp->cbd_datlen = skb->len;
317 318
318 /* 319 /*
@@ -320,11 +321,11 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
320 * 4-byte boundaries. Use bounce buffers to copy data 321 * 4-byte boundaries. Use bounce buffers to copy data
321 * and get it aligned. Ugh. 322 * and get it aligned. Ugh.
322 */ 323 */
323 if (bdp->cbd_bufaddr & FEC_ALIGNMENT) { 324 if (((unsigned long) bufaddr) & FEC_ALIGNMENT) {
324 unsigned int index; 325 unsigned int index;
325 index = bdp - fep->tx_bd_base; 326 index = bdp - fep->tx_bd_base;
326 memcpy(fep->tx_bounce[index], (void *)skb->data, skb->len); 327 memcpy(fep->tx_bounce[index], (void *)skb->data, skb->len);
327 bdp->cbd_bufaddr = __pa(fep->tx_bounce[index]); 328 bufaddr = fep->tx_bounce[index];
328 } 329 }
329 330
330 /* Save skb pointer */ 331 /* Save skb pointer */
@@ -336,7 +337,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev)
336 /* Push the data cache so the CPM does not get stale memory 337 /* Push the data cache so the CPM does not get stale memory
337 * data. 338 * data.
338 */ 339 */
339 bdp->cbd_bufaddr = dma_map_single(&dev->dev, skb->data, 340 bdp->cbd_bufaddr = dma_map_single(&dev->dev, bufaddr,
340 FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE); 341 FEC_ENET_TX_FRSIZE, DMA_TO_DEVICE);
341 342
342 /* Send it on its way. Tell FEC it's ready, interrupt when done, 343 /* Send it on its way. Tell FEC it's ready, interrupt when done,
diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c
index cc786333d95c..c40113f58963 100644
--- a/drivers/net/fec_mpc52xx.c
+++ b/drivers/net/fec_mpc52xx.c
@@ -309,6 +309,7 @@ static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
309{ 309{
310 struct mpc52xx_fec_priv *priv = netdev_priv(dev); 310 struct mpc52xx_fec_priv *priv = netdev_priv(dev);
311 struct bcom_fec_bd *bd; 311 struct bcom_fec_bd *bd;
312 unsigned long flags;
312 313
313 if (bcom_queue_full(priv->tx_dmatsk)) { 314 if (bcom_queue_full(priv->tx_dmatsk)) {
314 if (net_ratelimit()) 315 if (net_ratelimit())
@@ -316,7 +317,7 @@ static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
316 return NETDEV_TX_BUSY; 317 return NETDEV_TX_BUSY;
317 } 318 }
318 319
319 spin_lock_irq(&priv->lock); 320 spin_lock_irqsave(&priv->lock, flags);
320 dev->trans_start = jiffies; 321 dev->trans_start = jiffies;
321 322
322 bd = (struct bcom_fec_bd *) 323 bd = (struct bcom_fec_bd *)
@@ -332,7 +333,7 @@ static int mpc52xx_fec_start_xmit(struct sk_buff *skb, struct net_device *dev)
332 netif_stop_queue(dev); 333 netif_stop_queue(dev);
333 } 334 }
334 335
335 spin_unlock_irq(&priv->lock); 336 spin_unlock_irqrestore(&priv->lock, flags);
336 337
337 return NETDEV_TX_OK; 338 return NETDEV_TX_OK;
338} 339}
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index f8ffcbf0bc39..e212f2c5448b 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -936,6 +936,7 @@ int startup_gfar(struct net_device *dev)
936 struct gfar __iomem *regs = priv->regs; 936 struct gfar __iomem *regs = priv->regs;
937 int err = 0; 937 int err = 0;
938 u32 rctrl = 0; 938 u32 rctrl = 0;
939 u32 tctrl = 0;
939 u32 attrs = 0; 940 u32 attrs = 0;
940 941
941 gfar_write(&regs->imask, IMASK_INIT_CLEAR); 942 gfar_write(&regs->imask, IMASK_INIT_CLEAR);
@@ -1111,11 +1112,19 @@ int startup_gfar(struct net_device *dev)
1111 rctrl |= RCTRL_PADDING(priv->padding); 1112 rctrl |= RCTRL_PADDING(priv->padding);
1112 } 1113 }
1113 1114
1115 /* keep vlan related bits if it's enabled */
1116 if (priv->vlgrp) {
1117 rctrl |= RCTRL_VLEX | RCTRL_PRSDEP_INIT;
1118 tctrl |= TCTRL_VLINS;
1119 }
1120
1114 /* Init rctrl based on our settings */ 1121 /* Init rctrl based on our settings */
1115 gfar_write(&priv->regs->rctrl, rctrl); 1122 gfar_write(&priv->regs->rctrl, rctrl);
1116 1123
1117 if (dev->features & NETIF_F_IP_CSUM) 1124 if (dev->features & NETIF_F_IP_CSUM)
1118 gfar_write(&priv->regs->tctrl, TCTRL_INIT_CSUM); 1125 tctrl |= TCTRL_INIT_CSUM;
1126
1127 gfar_write(&priv->regs->tctrl, tctrl);
1119 1128
1120 /* Set the extraction length and index */ 1129 /* Set the extraction length and index */
1121 attrs = ATTRELI_EL(priv->rx_stash_size) | 1130 attrs = ATTRELI_EL(priv->rx_stash_size) |
@@ -1450,7 +1459,6 @@ static void gfar_vlan_rx_register(struct net_device *dev,
1450 1459
1451 /* Enable VLAN tag extraction */ 1460 /* Enable VLAN tag extraction */
1452 tempval = gfar_read(&priv->regs->rctrl); 1461 tempval = gfar_read(&priv->regs->rctrl);
1453 tempval |= RCTRL_VLEX;
1454 tempval |= (RCTRL_VLEX | RCTRL_PRSDEP_INIT); 1462 tempval |= (RCTRL_VLEX | RCTRL_PRSDEP_INIT);
1455 gfar_write(&priv->regs->rctrl, tempval); 1463 gfar_write(&priv->regs->rctrl, tempval);
1456 } else { 1464 } else {
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index dbf06e9313cc..2234118eedbb 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -366,9 +366,8 @@ static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
366 return -EINVAL; 366 return -EINVAL;
367 } 367 }
368 368
369 priv->rxic = mk_ic_value( 369 priv->rxic = mk_ic_value(cvals->rx_max_coalesced_frames,
370 gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs), 370 gfar_usecs2ticks(priv, cvals->rx_coalesce_usecs));
371 cvals->rx_max_coalesced_frames);
372 371
373 /* Set up tx coalescing */ 372 /* Set up tx coalescing */
374 if ((cvals->tx_coalesce_usecs == 0) || 373 if ((cvals->tx_coalesce_usecs == 0) ||
@@ -390,9 +389,8 @@ static int gfar_scoalesce(struct net_device *dev, struct ethtool_coalesce *cvals
390 return -EINVAL; 389 return -EINVAL;
391 } 390 }
392 391
393 priv->txic = mk_ic_value( 392 priv->txic = mk_ic_value(cvals->tx_max_coalesced_frames,
394 gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs), 393 gfar_usecs2ticks(priv, cvals->tx_coalesce_usecs));
395 cvals->tx_max_coalesced_frames);
396 394
397 gfar_write(&priv->regs->rxic, 0); 395 gfar_write(&priv->regs->rxic, 0);
398 if (priv->rxcoalescing) 396 if (priv->rxcoalescing)
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c
index beb84213b671..f0f890803710 100644
--- a/drivers/net/ibm_newemac/core.c
+++ b/drivers/net/ibm_newemac/core.c
@@ -1305,6 +1305,8 @@ static int emac_close(struct net_device *ndev)
1305 1305
1306 free_irq(dev->emac_irq, dev); 1306 free_irq(dev->emac_irq, dev);
1307 1307
1308 netif_carrier_off(ndev);
1309
1308 return 0; 1310 return 0;
1309} 1311}
1310 1312
diff --git a/drivers/net/igbvf/vf.c b/drivers/net/igbvf/vf.c
index 2a4faf9ade69..a9a61efa964c 100644
--- a/drivers/net/igbvf/vf.c
+++ b/drivers/net/igbvf/vf.c
@@ -274,6 +274,8 @@ static s32 e1000_set_vfta_vf(struct e1000_hw *hw, u16 vid, bool set)
274 274
275 err = mbx->ops.read_posted(hw, msgbuf, 2); 275 err = mbx->ops.read_posted(hw, msgbuf, 2);
276 276
277 msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
278
277 /* if nacked the vlan was rejected */ 279 /* if nacked the vlan was rejected */
278 if (!err && (msgbuf[0] == (E1000_VF_SET_VLAN | E1000_VT_MSGTYPE_NACK))) 280 if (!err && (msgbuf[0] == (E1000_VF_SET_VLAN | E1000_VT_MSGTYPE_NACK)))
279 err = -E1000_ERR_MAC_INIT; 281 err = -E1000_ERR_MAC_INIT;
@@ -317,6 +319,8 @@ static void e1000_rar_set_vf(struct e1000_hw *hw, u8 * addr, u32 index)
317 if (!ret_val) 319 if (!ret_val)
318 ret_val = mbx->ops.read_posted(hw, msgbuf, 3); 320 ret_val = mbx->ops.read_posted(hw, msgbuf, 3);
319 321
322 msgbuf[0] &= ~E1000_VT_MSGTYPE_CTS;
323
320 /* if nacked the address was rejected, use "perm_addr" */ 324 /* if nacked the address was rejected, use "perm_addr" */
321 if (!ret_val && 325 if (!ret_val &&
322 (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK))) 326 (msgbuf[0] == (E1000_VF_SET_MAC_ADDR | E1000_VT_MSGTYPE_NACK)))
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index c4361d466597..ee1cff5c9b21 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -23,7 +23,6 @@
23#include <linux/init.h> 23#include <linux/init.h>
24#include <linux/errno.h> 24#include <linux/errno.h>
25#include <linux/netdevice.h> 25#include <linux/netdevice.h>
26#include <linux/etherdevice.h>
27#include <linux/slab.h> 26#include <linux/slab.h>
28#include <linux/rtnetlink.h> 27#include <linux/rtnetlink.h>
29#include <linux/interrupt.h> 28#include <linux/interrupt.h>
@@ -205,9 +204,6 @@ static const struct net_device_ops au1k_irda_netdev_ops = {
205 .ndo_start_xmit = au1k_irda_hard_xmit, 204 .ndo_start_xmit = au1k_irda_hard_xmit,
206 .ndo_tx_timeout = au1k_tx_timeout, 205 .ndo_tx_timeout = au1k_tx_timeout,
207 .ndo_do_ioctl = au1k_irda_ioctl, 206 .ndo_do_ioctl = au1k_irda_ioctl,
208 .ndo_change_mtu = eth_change_mtu,
209 .ndo_validate_addr = eth_validate_addr,
210 .ndo_set_mac_address = eth_mac_addr,
211}; 207};
212 208
213static int au1k_irda_net_init(struct net_device *dev) 209static int au1k_irda_net_init(struct net_device *dev)
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c
index 3376a4f39e0a..77d10edefd25 100644
--- a/drivers/net/irda/pxaficp_ir.c
+++ b/drivers/net/irda/pxaficp_ir.c
@@ -803,9 +803,6 @@ static const struct net_device_ops pxa_irda_netdev_ops = {
803 .ndo_stop = pxa_irda_stop, 803 .ndo_stop = pxa_irda_stop,
804 .ndo_start_xmit = pxa_irda_hard_xmit, 804 .ndo_start_xmit = pxa_irda_hard_xmit,
805 .ndo_do_ioctl = pxa_irda_ioctl, 805 .ndo_do_ioctl = pxa_irda_ioctl,
806 .ndo_change_mtu = eth_change_mtu,
807 .ndo_validate_addr = eth_validate_addr,
808 .ndo_set_mac_address = eth_mac_addr,
809}; 806};
810 807
811static int pxa_irda_probe(struct platform_device *pdev) 808static int pxa_irda_probe(struct platform_device *pdev)
@@ -830,6 +827,7 @@ static int pxa_irda_probe(struct platform_device *pdev)
830 if (!dev) 827 if (!dev)
831 goto err_mem_3; 828 goto err_mem_3;
832 829
830 SET_NETDEV_DEV(dev, &pdev->dev);
833 si = netdev_priv(dev); 831 si = netdev_priv(dev);
834 si->dev = &pdev->dev; 832 si->dev = &pdev->dev;
835 si->pdata = pdev->dev.platform_data; 833 si->pdata = pdev->dev.platform_data;
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c
index 2aeb2e6aec1b..b039cb081e94 100644
--- a/drivers/net/irda/sa1100_ir.c
+++ b/drivers/net/irda/sa1100_ir.c
@@ -24,7 +24,6 @@
24#include <linux/init.h> 24#include <linux/init.h>
25#include <linux/errno.h> 25#include <linux/errno.h>
26#include <linux/netdevice.h> 26#include <linux/netdevice.h>
27#include <linux/etherdevice.h>
28#include <linux/slab.h> 27#include <linux/slab.h>
29#include <linux/rtnetlink.h> 28#include <linux/rtnetlink.h>
30#include <linux/interrupt.h> 29#include <linux/interrupt.h>
@@ -881,9 +880,6 @@ static const struct net_device_ops sa1100_irda_netdev_ops = {
881 .ndo_stop = sa1100_irda_stop, 880 .ndo_stop = sa1100_irda_stop,
882 .ndo_start_xmit = sa1100_irda_hard_xmit, 881 .ndo_start_xmit = sa1100_irda_hard_xmit,
883 .ndo_do_ioctl = sa1100_irda_ioctl, 882 .ndo_do_ioctl = sa1100_irda_ioctl,
884 .ndo_change_mtu = eth_change_mtu,
885 .ndo_validate_addr = eth_validate_addr,
886 .ndo_set_mac_address = eth_mac_addr,
887}; 883};
888 884
889static int sa1100_irda_probe(struct platform_device *pdev) 885static int sa1100_irda_probe(struct platform_device *pdev)
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index d0883835b0c6..fe4f2b2bff96 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -115,7 +115,7 @@ static int __init w83977af_init(void)
115 115
116 IRDA_DEBUG(0, "%s()\n", __func__ ); 116 IRDA_DEBUG(0, "%s()\n", __func__ );
117 117
118 for (i=0; (io[i] < 2000) && (i < ARRAY_SIZE(dev_self)); i++) { 118 for (i=0; i < ARRAY_SIZE(dev_self) && io[i] < 2000; i++) {
119 if (w83977af_open(i, io[i], irq[i], dma[i]) == 0) 119 if (w83977af_open(i, io[i], irq[i], dma[i]) == 0)
120 return 0; 120 return 0;
121 } 121 }
diff --git a/drivers/net/ixgbe/ixgbe.h b/drivers/net/ixgbe/ixgbe.h
index 1b12c7ba275f..2c4dc8221dcd 100644
--- a/drivers/net/ixgbe/ixgbe.h
+++ b/drivers/net/ixgbe/ixgbe.h
@@ -96,6 +96,8 @@
96#define IXGBE_TX_FLAGS_VLAN_PRIO_MASK 0x0000e000 96#define IXGBE_TX_FLAGS_VLAN_PRIO_MASK 0x0000e000
97#define IXGBE_TX_FLAGS_VLAN_SHIFT 16 97#define IXGBE_TX_FLAGS_VLAN_SHIFT 16
98 98
99#define IXGBE_MAX_RSC_INT_RATE 162760
100
99/* wrapper around a pointer to a socket buffer, 101/* wrapper around a pointer to a socket buffer,
100 * so a DMA handle can be stored along with the buffer */ 102 * so a DMA handle can be stored along with the buffer */
101struct ixgbe_tx_buffer { 103struct ixgbe_tx_buffer {
@@ -134,6 +136,8 @@ struct ixgbe_ring {
134 136
135 u8 queue_index; /* needed for multiqueue queue management */ 137 u8 queue_index; /* needed for multiqueue queue management */
136 138
139#define IXGBE_RING_RX_PS_ENABLED (u8)(1)
140 u8 flags; /* per ring feature flags */
137 u16 head; 141 u16 head;
138 u16 tail; 142 u16 tail;
139 143
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index b9923047ce11..522c03bc1dad 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -50,6 +50,51 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
50 u8 *eeprom_data); 50 u8 *eeprom_data);
51 51
52/** 52/**
53 * ixgbe_set_pcie_completion_timeout - set pci-e completion timeout
54 * @hw: pointer to the HW structure
55 *
56 * The defaults for 82598 should be in the range of 50us to 50ms,
57 * however the hardware default for these parts is 500us to 1ms which is less
58 * than the 10ms recommended by the pci-e spec. To address this we need to
59 * increase the value to either 10ms to 250ms for capability version 1 config,
60 * or 16ms to 55ms for version 2.
61 **/
62void ixgbe_set_pcie_completion_timeout(struct ixgbe_hw *hw)
63{
64 struct ixgbe_adapter *adapter = hw->back;
65 u32 gcr = IXGBE_READ_REG(hw, IXGBE_GCR);
66 u16 pcie_devctl2;
67
68 /* only take action if timeout value is defaulted to 0 */
69 if (gcr & IXGBE_GCR_CMPL_TMOUT_MASK)
70 goto out;
71
72 /*
73 * if capababilities version is type 1 we can write the
74 * timeout of 10ms to 250ms through the GCR register
75 */
76 if (!(gcr & IXGBE_GCR_CAP_VER2)) {
77 gcr |= IXGBE_GCR_CMPL_TMOUT_10ms;
78 goto out;
79 }
80
81 /*
82 * for version 2 capabilities we need to write the config space
83 * directly in order to set the completion timeout value for
84 * 16ms to 55ms
85 */
86 pci_read_config_word(adapter->pdev,
87 IXGBE_PCI_DEVICE_CONTROL2, &pcie_devctl2);
88 pcie_devctl2 |= IXGBE_PCI_DEVICE_CONTROL2_16ms;
89 pci_write_config_word(adapter->pdev,
90 IXGBE_PCI_DEVICE_CONTROL2, pcie_devctl2);
91out:
92 /* disable completion timeout resend */
93 gcr &= ~IXGBE_GCR_CMPL_TMOUT_RESEND;
94 IXGBE_WRITE_REG(hw, IXGBE_GCR, gcr);
95}
96
97/**
53 * ixgbe_get_pcie_msix_count_82598 - Gets MSI-X vector count 98 * ixgbe_get_pcie_msix_count_82598 - Gets MSI-X vector count
54 * @hw: pointer to hardware structure 99 * @hw: pointer to hardware structure
55 * 100 *
@@ -153,6 +198,26 @@ out:
153} 198}
154 199
155/** 200/**
201 * ixgbe_start_hw_82598 - Prepare hardware for Tx/Rx
202 * @hw: pointer to hardware structure
203 *
204 * Starts the hardware using the generic start_hw function.
205 * Then set pcie completion timeout
206 **/
207s32 ixgbe_start_hw_82598(struct ixgbe_hw *hw)
208{
209 s32 ret_val = 0;
210
211 ret_val = ixgbe_start_hw_generic(hw);
212
213 /* set the completion timeout for interface */
214 if (ret_val == 0)
215 ixgbe_set_pcie_completion_timeout(hw);
216
217 return ret_val;
218}
219
220/**
156 * ixgbe_get_link_capabilities_82598 - Determines link capabilities 221 * ixgbe_get_link_capabilities_82598 - Determines link capabilities
157 * @hw: pointer to hardware structure 222 * @hw: pointer to hardware structure
158 * @speed: pointer to link speed 223 * @speed: pointer to link speed
@@ -1085,7 +1150,7 @@ out:
1085static struct ixgbe_mac_operations mac_ops_82598 = { 1150static struct ixgbe_mac_operations mac_ops_82598 = {
1086 .init_hw = &ixgbe_init_hw_generic, 1151 .init_hw = &ixgbe_init_hw_generic,
1087 .reset_hw = &ixgbe_reset_hw_82598, 1152 .reset_hw = &ixgbe_reset_hw_82598,
1088 .start_hw = &ixgbe_start_hw_generic, 1153 .start_hw = &ixgbe_start_hw_82598,
1089 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic, 1154 .clear_hw_cntrs = &ixgbe_clear_hw_cntrs_generic,
1090 .get_media_type = &ixgbe_get_media_type_82598, 1155 .get_media_type = &ixgbe_get_media_type_82598,
1091 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82598, 1156 .get_supported_physical_layer = &ixgbe_get_supported_physical_layer_82598,
diff --git a/drivers/net/ixgbe/ixgbe_ethtool.c b/drivers/net/ixgbe/ixgbe_ethtool.c
index 2a978008fd6e..dff8dfac7ed9 100644
--- a/drivers/net/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ixgbe/ixgbe_ethtool.c
@@ -1948,6 +1948,7 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
1948 struct ethtool_coalesce *ec) 1948 struct ethtool_coalesce *ec)
1949{ 1949{
1950 struct ixgbe_adapter *adapter = netdev_priv(netdev); 1950 struct ixgbe_adapter *adapter = netdev_priv(netdev);
1951 struct ixgbe_q_vector *q_vector;
1951 int i; 1952 int i;
1952 1953
1953 if (ec->tx_max_coalesced_frames_irq) 1954 if (ec->tx_max_coalesced_frames_irq)
@@ -1975,18 +1976,31 @@ static int ixgbe_set_coalesce(struct net_device *netdev,
1975 * any other value means disable eitr, which is best 1976 * any other value means disable eitr, which is best
1976 * served by setting the interrupt rate very high 1977 * served by setting the interrupt rate very high
1977 */ 1978 */
1978 adapter->eitr_param = IXGBE_MAX_INT_RATE; 1979 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
1980 adapter->eitr_param = IXGBE_MAX_RSC_INT_RATE;
1981 else
1982 adapter->eitr_param = IXGBE_MAX_INT_RATE;
1979 adapter->itr_setting = 0; 1983 adapter->itr_setting = 0;
1980 } 1984 }
1981 1985
1982 for (i = 0; i < adapter->num_msix_vectors - NON_Q_VECTORS; i++) { 1986 /* MSI/MSIx Interrupt Mode */
1983 struct ixgbe_q_vector *q_vector = adapter->q_vector[i]; 1987 if (adapter->flags &
1984 if (q_vector->txr_count && !q_vector->rxr_count) 1988 (IXGBE_FLAG_MSIX_ENABLED | IXGBE_FLAG_MSI_ENABLED)) {
1985 /* tx vector gets half the rate */ 1989 int num_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
1986 q_vector->eitr = (adapter->eitr_param >> 1); 1990 for (i = 0; i < num_vectors; i++) {
1987 else 1991 q_vector = adapter->q_vector[i];
1988 /* rx only or mixed */ 1992 if (q_vector->txr_count && !q_vector->rxr_count)
1989 q_vector->eitr = adapter->eitr_param; 1993 /* tx vector gets half the rate */
1994 q_vector->eitr = (adapter->eitr_param >> 1);
1995 else
1996 /* rx only or mixed */
1997 q_vector->eitr = adapter->eitr_param;
1998 ixgbe_write_eitr(q_vector);
1999 }
2000 /* Legacy Interrupt Mode */
2001 } else {
2002 q_vector = adapter->q_vector[0];
2003 q_vector->eitr = adapter->eitr_param;
1990 ixgbe_write_eitr(q_vector); 2004 ixgbe_write_eitr(q_vector);
1991 } 2005 }
1992 2006
@@ -1999,13 +2013,13 @@ static int ixgbe_set_flags(struct net_device *netdev, u32 data)
1999 2013
2000 ethtool_op_set_flags(netdev, data); 2014 ethtool_op_set_flags(netdev, data);
2001 2015
2002 if (!(adapter->flags & IXGBE_FLAG2_RSC_CAPABLE)) 2016 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE))
2003 return 0; 2017 return 0;
2004 2018
2005 /* if state changes we need to update adapter->flags and reset */ 2019 /* if state changes we need to update adapter->flags and reset */
2006 if ((!!(data & ETH_FLAG_LRO)) != 2020 if ((!!(data & ETH_FLAG_LRO)) !=
2007 (!!(adapter->flags & IXGBE_FLAG2_RSC_ENABLED))) { 2021 (!!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED))) {
2008 adapter->flags ^= IXGBE_FLAG2_RSC_ENABLED; 2022 adapter->flags2 ^= IXGBE_FLAG2_RSC_ENABLED;
2009 if (netif_running(netdev)) 2023 if (netif_running(netdev))
2010 ixgbe_reinit_locked(adapter); 2024 ixgbe_reinit_locked(adapter);
2011 else 2025 else
diff --git a/drivers/net/ixgbe/ixgbe_fcoe.c b/drivers/net/ixgbe/ixgbe_fcoe.c
index fa9f24e23683..28cf104e36cc 100644
--- a/drivers/net/ixgbe/ixgbe_fcoe.c
+++ b/drivers/net/ixgbe/ixgbe_fcoe.c
@@ -336,7 +336,7 @@ int ixgbe_fcoe_ddp(struct ixgbe_adapter *adapter,
336 /* return 0 to bypass going to ULD for DDPed data */ 336 /* return 0 to bypass going to ULD for DDPed data */
337 if (fcstat == IXGBE_RXDADV_STAT_FCSTAT_DDP) 337 if (fcstat == IXGBE_RXDADV_STAT_FCSTAT_DDP)
338 rc = 0; 338 rc = 0;
339 else 339 else if (ddp->len)
340 rc = ddp->len; 340 rc = ddp->len;
341 } 341 }
342 342
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index 200454f30f6a..77b0381a2b5c 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -492,12 +492,12 @@ static void ixgbe_receive_skb(struct ixgbe_q_vector *q_vector,
492 492
493 skb_record_rx_queue(skb, ring->queue_index); 493 skb_record_rx_queue(skb, ring->queue_index);
494 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) { 494 if (!(adapter->flags & IXGBE_FLAG_IN_NETPOLL)) {
495 if (adapter->vlgrp && is_vlan && (tag != 0)) 495 if (adapter->vlgrp && is_vlan && (tag & VLAN_VID_MASK))
496 vlan_gro_receive(napi, adapter->vlgrp, tag, skb); 496 vlan_gro_receive(napi, adapter->vlgrp, tag, skb);
497 else 497 else
498 napi_gro_receive(napi, skb); 498 napi_gro_receive(napi, skb);
499 } else { 499 } else {
500 if (adapter->vlgrp && is_vlan && (tag != 0)) 500 if (adapter->vlgrp && is_vlan && (tag & VLAN_VID_MASK))
501 vlan_hwaccel_rx(skb, adapter->vlgrp, tag); 501 vlan_hwaccel_rx(skb, adapter->vlgrp, tag);
502 else 502 else
503 netif_rx(skb); 503 netif_rx(skb);
@@ -585,7 +585,7 @@ static void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter,
585 rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i); 585 rx_desc = IXGBE_RX_DESC_ADV(*rx_ring, i);
586 586
587 if (!bi->page_dma && 587 if (!bi->page_dma &&
588 (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED)) { 588 (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED)) {
589 if (!bi->page) { 589 if (!bi->page) {
590 bi->page = alloc_page(GFP_ATOMIC); 590 bi->page = alloc_page(GFP_ATOMIC);
591 if (!bi->page) { 591 if (!bi->page) {
@@ -629,7 +629,7 @@ static void ixgbe_alloc_rx_buffers(struct ixgbe_adapter *adapter,
629 } 629 }
630 /* Refresh the desc even if buffer_addrs didn't change because 630 /* Refresh the desc even if buffer_addrs didn't change because
631 * each write-back erases this info. */ 631 * each write-back erases this info. */
632 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 632 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) {
633 rx_desc->read.pkt_addr = cpu_to_le64(bi->page_dma); 633 rx_desc->read.pkt_addr = cpu_to_le64(bi->page_dma);
634 rx_desc->read.hdr_addr = cpu_to_le64(bi->dma); 634 rx_desc->read.hdr_addr = cpu_to_le64(bi->dma);
635 } else { 635 } else {
@@ -726,7 +726,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
726 break; 726 break;
727 (*work_done)++; 727 (*work_done)++;
728 728
729 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 729 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) {
730 hdr_info = le16_to_cpu(ixgbe_get_hdr_info(rx_desc)); 730 hdr_info = le16_to_cpu(ixgbe_get_hdr_info(rx_desc));
731 len = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >> 731 len = (hdr_info & IXGBE_RXDADV_HDRBUFLEN_MASK) >>
732 IXGBE_RXDADV_HDRBUFLEN_SHIFT; 732 IXGBE_RXDADV_HDRBUFLEN_SHIFT;
@@ -780,7 +780,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
780 prefetch(next_rxd); 780 prefetch(next_rxd);
781 cleaned_count++; 781 cleaned_count++;
782 782
783 if (adapter->flags & IXGBE_FLAG2_RSC_CAPABLE) 783 if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)
784 rsc_count = ixgbe_get_rsc_count(rx_desc); 784 rsc_count = ixgbe_get_rsc_count(rx_desc);
785 785
786 if (rsc_count) { 786 if (rsc_count) {
@@ -798,7 +798,7 @@ static bool ixgbe_clean_rx_irq(struct ixgbe_q_vector *q_vector,
798 rx_ring->stats.packets++; 798 rx_ring->stats.packets++;
799 rx_ring->stats.bytes += skb->len; 799 rx_ring->stats.bytes += skb->len;
800 } else { 800 } else {
801 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 801 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) {
802 rx_buffer_info->skb = next_buffer->skb; 802 rx_buffer_info->skb = next_buffer->skb;
803 rx_buffer_info->dma = next_buffer->dma; 803 rx_buffer_info->dma = next_buffer->dma;
804 next_buffer->skb = skb; 804 next_buffer->skb = skb;
@@ -1898,46 +1898,19 @@ static void ixgbe_configure_tx(struct ixgbe_adapter *adapter)
1898 1898
1899#define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2 1899#define IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT 2
1900 1900
1901static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter, int index) 1901static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter,
1902 struct ixgbe_ring *rx_ring)
1902{ 1903{
1903 struct ixgbe_ring *rx_ring;
1904 u32 srrctl; 1904 u32 srrctl;
1905 int queue0 = 0; 1905 int index;
1906 unsigned long mask;
1907 struct ixgbe_ring_feature *feature = adapter->ring_feature; 1906 struct ixgbe_ring_feature *feature = adapter->ring_feature;
1908 1907
1909 if (adapter->hw.mac.type == ixgbe_mac_82599EB) { 1908 index = rx_ring->reg_idx;
1910 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) { 1909 if (adapter->hw.mac.type == ixgbe_mac_82598EB) {
1911 int dcb_i = feature[RING_F_DCB].indices; 1910 unsigned long mask;
1912 if (dcb_i == 8)
1913 queue0 = index >> 4;
1914 else if (dcb_i == 4)
1915 queue0 = index >> 5;
1916 else
1917 dev_err(&adapter->pdev->dev, "Invalid DCB "
1918 "configuration\n");
1919#ifdef IXGBE_FCOE
1920 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
1921 struct ixgbe_ring_feature *f;
1922
1923 rx_ring = &adapter->rx_ring[queue0];
1924 f = &adapter->ring_feature[RING_F_FCOE];
1925 if ((queue0 == 0) && (index > rx_ring->reg_idx))
1926 queue0 = f->mask + index -
1927 rx_ring->reg_idx - 1;
1928 }
1929#endif /* IXGBE_FCOE */
1930 } else {
1931 queue0 = index;
1932 }
1933 } else {
1934 mask = (unsigned long) feature[RING_F_RSS].mask; 1911 mask = (unsigned long) feature[RING_F_RSS].mask;
1935 queue0 = index & mask;
1936 index = index & mask; 1912 index = index & mask;
1937 } 1913 }
1938
1939 rx_ring = &adapter->rx_ring[queue0];
1940
1941 srrctl = IXGBE_READ_REG(&adapter->hw, IXGBE_SRRCTL(index)); 1914 srrctl = IXGBE_READ_REG(&adapter->hw, IXGBE_SRRCTL(index));
1942 1915
1943 srrctl &= ~IXGBE_SRRCTL_BSIZEHDR_MASK; 1916 srrctl &= ~IXGBE_SRRCTL_BSIZEHDR_MASK;
@@ -1946,7 +1919,7 @@ static void ixgbe_configure_srrctl(struct ixgbe_adapter *adapter, int index)
1946 srrctl |= (IXGBE_RX_HDR_SIZE << IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) & 1919 srrctl |= (IXGBE_RX_HDR_SIZE << IXGBE_SRRCTL_BSIZEHDRSIZE_SHIFT) &
1947 IXGBE_SRRCTL_BSIZEHDR_MASK; 1920 IXGBE_SRRCTL_BSIZEHDR_MASK;
1948 1921
1949 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 1922 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) {
1950#if (PAGE_SIZE / 2) > IXGBE_MAX_RXBUFFER 1923#if (PAGE_SIZE / 2) > IXGBE_MAX_RXBUFFER
1951 srrctl |= IXGBE_MAX_RXBUFFER >> IXGBE_SRRCTL_BSIZEPKT_SHIFT; 1924 srrctl |= IXGBE_MAX_RXBUFFER >> IXGBE_SRRCTL_BSIZEPKT_SHIFT;
1952#else 1925#else
@@ -2002,6 +1975,7 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2002{ 1975{
2003 u64 rdba; 1976 u64 rdba;
2004 struct ixgbe_hw *hw = &adapter->hw; 1977 struct ixgbe_hw *hw = &adapter->hw;
1978 struct ixgbe_ring *rx_ring;
2005 struct net_device *netdev = adapter->netdev; 1979 struct net_device *netdev = adapter->netdev;
2006 int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; 1980 int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN;
2007 int i, j; 1981 int i, j;
@@ -2018,11 +1992,6 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2018 /* Decide whether to use packet split mode or not */ 1992 /* Decide whether to use packet split mode or not */
2019 adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED; 1993 adapter->flags |= IXGBE_FLAG_RX_PS_ENABLED;
2020 1994
2021#ifdef IXGBE_FCOE
2022 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)
2023 adapter->flags &= ~IXGBE_FLAG_RX_PS_ENABLED;
2024#endif /* IXGBE_FCOE */
2025
2026 /* Set the RX buffer length according to the mode */ 1995 /* Set the RX buffer length according to the mode */
2027 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 1996 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) {
2028 rx_buf_len = IXGBE_RX_HDR_SIZE; 1997 rx_buf_len = IXGBE_RX_HDR_SIZE;
@@ -2036,7 +2005,7 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2036 IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), psrtype); 2005 IXGBE_WRITE_REG(hw, IXGBE_PSRTYPE(0), psrtype);
2037 } 2006 }
2038 } else { 2007 } else {
2039 if (!(adapter->flags & IXGBE_FLAG2_RSC_ENABLED) && 2008 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) &&
2040 (netdev->mtu <= ETH_DATA_LEN)) 2009 (netdev->mtu <= ETH_DATA_LEN))
2041 rx_buf_len = MAXIMUM_ETHERNET_VLAN_SIZE; 2010 rx_buf_len = MAXIMUM_ETHERNET_VLAN_SIZE;
2042 else 2011 else
@@ -2070,29 +2039,35 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2070 * the Base and Length of the Rx Descriptor Ring 2039 * the Base and Length of the Rx Descriptor Ring
2071 */ 2040 */
2072 for (i = 0; i < adapter->num_rx_queues; i++) { 2041 for (i = 0; i < adapter->num_rx_queues; i++) {
2073 rdba = adapter->rx_ring[i].dma; 2042 rx_ring = &adapter->rx_ring[i];
2074 j = adapter->rx_ring[i].reg_idx; 2043 rdba = rx_ring->dma;
2044 j = rx_ring->reg_idx;
2075 IXGBE_WRITE_REG(hw, IXGBE_RDBAL(j), (rdba & DMA_BIT_MASK(32))); 2045 IXGBE_WRITE_REG(hw, IXGBE_RDBAL(j), (rdba & DMA_BIT_MASK(32)));
2076 IXGBE_WRITE_REG(hw, IXGBE_RDBAH(j), (rdba >> 32)); 2046 IXGBE_WRITE_REG(hw, IXGBE_RDBAH(j), (rdba >> 32));
2077 IXGBE_WRITE_REG(hw, IXGBE_RDLEN(j), rdlen); 2047 IXGBE_WRITE_REG(hw, IXGBE_RDLEN(j), rdlen);
2078 IXGBE_WRITE_REG(hw, IXGBE_RDH(j), 0); 2048 IXGBE_WRITE_REG(hw, IXGBE_RDH(j), 0);
2079 IXGBE_WRITE_REG(hw, IXGBE_RDT(j), 0); 2049 IXGBE_WRITE_REG(hw, IXGBE_RDT(j), 0);
2080 adapter->rx_ring[i].head = IXGBE_RDH(j); 2050 rx_ring->head = IXGBE_RDH(j);
2081 adapter->rx_ring[i].tail = IXGBE_RDT(j); 2051 rx_ring->tail = IXGBE_RDT(j);
2082 adapter->rx_ring[i].rx_buf_len = rx_buf_len; 2052 rx_ring->rx_buf_len = rx_buf_len;
2053
2054 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED)
2055 rx_ring->flags |= IXGBE_RING_RX_PS_ENABLED;
2083 2056
2084#ifdef IXGBE_FCOE 2057#ifdef IXGBE_FCOE
2085 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) { 2058 if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) {
2086 struct ixgbe_ring_feature *f; 2059 struct ixgbe_ring_feature *f;
2087 f = &adapter->ring_feature[RING_F_FCOE]; 2060 f = &adapter->ring_feature[RING_F_FCOE];
2088 if ((rx_buf_len < IXGBE_FCOE_JUMBO_FRAME_SIZE) && 2061 if ((i >= f->mask) && (i < f->mask + f->indices)) {
2089 (i >= f->mask) && (i < f->mask + f->indices)) 2062 rx_ring->flags &= ~IXGBE_RING_RX_PS_ENABLED;
2090 adapter->rx_ring[i].rx_buf_len = 2063 if (rx_buf_len < IXGBE_FCOE_JUMBO_FRAME_SIZE)
2091 IXGBE_FCOE_JUMBO_FRAME_SIZE; 2064 rx_ring->rx_buf_len =
2065 IXGBE_FCOE_JUMBO_FRAME_SIZE;
2066 }
2092 } 2067 }
2093 2068
2094#endif /* IXGBE_FCOE */ 2069#endif /* IXGBE_FCOE */
2095 ixgbe_configure_srrctl(adapter, j); 2070 ixgbe_configure_srrctl(adapter, rx_ring);
2096 } 2071 }
2097 2072
2098 if (hw->mac.type == ixgbe_mac_82598EB) { 2073 if (hw->mac.type == ixgbe_mac_82598EB) {
@@ -2165,10 +2140,11 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2165 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl); 2140 IXGBE_WRITE_REG(hw, IXGBE_RDRXCTL, rdrxctl);
2166 } 2141 }
2167 2142
2168 if (adapter->flags & IXGBE_FLAG2_RSC_ENABLED) { 2143 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) {
2169 /* Enable 82599 HW-RSC */ 2144 /* Enable 82599 HW-RSC */
2170 for (i = 0; i < adapter->num_rx_queues; i++) { 2145 for (i = 0; i < adapter->num_rx_queues; i++) {
2171 j = adapter->rx_ring[i].reg_idx; 2146 rx_ring = &adapter->rx_ring[i];
2147 j = rx_ring->reg_idx;
2172 rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j)); 2148 rscctrl = IXGBE_READ_REG(hw, IXGBE_RSCCTL(j));
2173 rscctrl |= IXGBE_RSCCTL_RSCEN; 2149 rscctrl |= IXGBE_RSCCTL_RSCEN;
2174 /* 2150 /*
@@ -2176,7 +2152,7 @@ static void ixgbe_configure_rx(struct ixgbe_adapter *adapter)
2176 * total size of max desc * buf_len is not greater 2152 * total size of max desc * buf_len is not greater
2177 * than 65535 2153 * than 65535
2178 */ 2154 */
2179 if (adapter->flags & IXGBE_FLAG_RX_PS_ENABLED) { 2155 if (rx_ring->flags & IXGBE_RING_RX_PS_ENABLED) {
2180#if (MAX_SKB_FRAGS > 16) 2156#if (MAX_SKB_FRAGS > 16)
2181 rscctrl |= IXGBE_RSCCTL_MAXDESC_16; 2157 rscctrl |= IXGBE_RSCCTL_MAXDESC_16;
2182#elif (MAX_SKB_FRAGS > 8) 2158#elif (MAX_SKB_FRAGS > 8)
@@ -3812,8 +3788,8 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
3812 adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82598; 3788 adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82598;
3813 } else if (hw->mac.type == ixgbe_mac_82599EB) { 3789 } else if (hw->mac.type == ixgbe_mac_82599EB) {
3814 adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82599; 3790 adapter->max_msix_q_vectors = MAX_MSIX_Q_VECTORS_82599;
3815 adapter->flags |= IXGBE_FLAG2_RSC_CAPABLE; 3791 adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE;
3816 adapter->flags |= IXGBE_FLAG2_RSC_ENABLED; 3792 adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED;
3817 adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; 3793 adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
3818 adapter->ring_feature[RING_F_FDIR].indices = 3794 adapter->ring_feature[RING_F_FDIR].indices =
3819 IXGBE_MAX_FDIR_INDICES; 3795 IXGBE_MAX_FDIR_INDICES;
@@ -5360,12 +5336,19 @@ static int ixgbe_del_sanmac_netdev(struct net_device *dev)
5360static void ixgbe_netpoll(struct net_device *netdev) 5336static void ixgbe_netpoll(struct net_device *netdev)
5361{ 5337{
5362 struct ixgbe_adapter *adapter = netdev_priv(netdev); 5338 struct ixgbe_adapter *adapter = netdev_priv(netdev);
5339 int i;
5363 5340
5364 disable_irq(adapter->pdev->irq);
5365 adapter->flags |= IXGBE_FLAG_IN_NETPOLL; 5341 adapter->flags |= IXGBE_FLAG_IN_NETPOLL;
5366 ixgbe_intr(adapter->pdev->irq, netdev); 5342 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) {
5343 int num_q_vectors = adapter->num_msix_vectors - NON_Q_VECTORS;
5344 for (i = 0; i < num_q_vectors; i++) {
5345 struct ixgbe_q_vector *q_vector = adapter->q_vector[i];
5346 ixgbe_msix_clean_many(0, q_vector);
5347 }
5348 } else {
5349 ixgbe_intr(adapter->pdev->irq, netdev);
5350 }
5367 adapter->flags &= ~IXGBE_FLAG_IN_NETPOLL; 5351 adapter->flags &= ~IXGBE_FLAG_IN_NETPOLL;
5368 enable_irq(adapter->pdev->irq);
5369} 5352}
5370#endif 5353#endif
5371 5354
@@ -5611,7 +5594,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
5611 if (pci_using_dac) 5594 if (pci_using_dac)
5612 netdev->features |= NETIF_F_HIGHDMA; 5595 netdev->features |= NETIF_F_HIGHDMA;
5613 5596
5614 if (adapter->flags & IXGBE_FLAG2_RSC_ENABLED) 5597 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
5615 netdev->features |= NETIF_F_LRO; 5598 netdev->features |= NETIF_F_LRO;
5616 5599
5617 /* make sure the EEPROM is good */ 5600 /* make sure the EEPROM is good */
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h
index fa87309dc087..be90eb4575f6 100644
--- a/drivers/net/ixgbe/ixgbe_type.h
+++ b/drivers/net/ixgbe/ixgbe_type.h
@@ -718,6 +718,12 @@
718#define IXGBE_ECC_STATUS_82599 0x110E0 718#define IXGBE_ECC_STATUS_82599 0x110E0
719#define IXGBE_BAR_CTRL_82599 0x110F4 719#define IXGBE_BAR_CTRL_82599 0x110F4
720 720
721/* PCI Express Control */
722#define IXGBE_GCR_CMPL_TMOUT_MASK 0x0000F000
723#define IXGBE_GCR_CMPL_TMOUT_10ms 0x00001000
724#define IXGBE_GCR_CMPL_TMOUT_RESEND 0x00010000
725#define IXGBE_GCR_CAP_VER2 0x00040000
726
721/* Time Sync Registers */ 727/* Time Sync Registers */
722#define IXGBE_TSYNCRXCTL 0x05188 /* Rx Time Sync Control register - RW */ 728#define IXGBE_TSYNCRXCTL 0x05188 /* Rx Time Sync Control register - RW */
723#define IXGBE_TSYNCTXCTL 0x08C00 /* Tx Time Sync Control register - RW */ 729#define IXGBE_TSYNCTXCTL 0x08C00 /* Tx Time Sync Control register - RW */
@@ -1521,6 +1527,7 @@
1521 1527
1522/* PCI Bus Info */ 1528/* PCI Bus Info */
1523#define IXGBE_PCI_LINK_STATUS 0xB2 1529#define IXGBE_PCI_LINK_STATUS 0xB2
1530#define IXGBE_PCI_DEVICE_CONTROL2 0xC8
1524#define IXGBE_PCI_LINK_WIDTH 0x3F0 1531#define IXGBE_PCI_LINK_WIDTH 0x3F0
1525#define IXGBE_PCI_LINK_WIDTH_1 0x10 1532#define IXGBE_PCI_LINK_WIDTH_1 0x10
1526#define IXGBE_PCI_LINK_WIDTH_2 0x20 1533#define IXGBE_PCI_LINK_WIDTH_2 0x20
@@ -1531,6 +1538,7 @@
1531#define IXGBE_PCI_LINK_SPEED_5000 0x2 1538#define IXGBE_PCI_LINK_SPEED_5000 0x2
1532#define IXGBE_PCI_HEADER_TYPE_REGISTER 0x0E 1539#define IXGBE_PCI_HEADER_TYPE_REGISTER 0x0E
1533#define IXGBE_PCI_HEADER_TYPE_MULTIFUNC 0x80 1540#define IXGBE_PCI_HEADER_TYPE_MULTIFUNC 0x80
1541#define IXGBE_PCI_DEVICE_CONTROL2_16ms 0x0005
1534 1542
1535/* Number of 100 microseconds we wait for PCI Express master disable */ 1543/* Number of 100 microseconds we wait for PCI Express master disable */
1536#define IXGBE_PCI_MASTER_DISABLE_TIMEOUT 800 1544#define IXGBE_PCI_MASTER_DISABLE_TIMEOUT 800
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c
index 2a0174b62e96..92fb8235c766 100644
--- a/drivers/net/ixp2000/ixpdev.c
+++ b/drivers/net/ixp2000/ixpdev.c
@@ -41,6 +41,7 @@ static int ixpdev_xmit(struct sk_buff *skb, struct net_device *dev)
41 struct ixpdev_priv *ip = netdev_priv(dev); 41 struct ixpdev_priv *ip = netdev_priv(dev);
42 struct ixpdev_tx_desc *desc; 42 struct ixpdev_tx_desc *desc;
43 int entry; 43 int entry;
44 unsigned long flags;
44 45
45 if (unlikely(skb->len > PAGE_SIZE)) { 46 if (unlikely(skb->len > PAGE_SIZE)) {
46 /* @@@ Count drops. */ 47 /* @@@ Count drops. */
@@ -63,11 +64,11 @@ static int ixpdev_xmit(struct sk_buff *skb, struct net_device *dev)
63 64
64 dev->trans_start = jiffies; 65 dev->trans_start = jiffies;
65 66
66 local_irq_disable(); 67 local_irq_save(flags);
67 ip->tx_queue_entries++; 68 ip->tx_queue_entries++;
68 if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN) 69 if (ip->tx_queue_entries == TX_BUF_COUNT_PER_CHAN)
69 netif_stop_queue(dev); 70 netif_stop_queue(dev);
70 local_irq_enable(); 71 local_irq_restore(flags);
71 72
72 return 0; 73 return 0;
73} 74}
diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 5b5c25368d1e..e3601cf3f931 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -620,6 +620,7 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
620 dma_addr_t mapping; 620 dma_addr_t mapping;
621 unsigned int len, entry; 621 unsigned int len, entry;
622 u32 ctrl; 622 u32 ctrl;
623 unsigned long flags;
623 624
624#ifdef DEBUG 625#ifdef DEBUG
625 int i; 626 int i;
@@ -635,12 +636,12 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
635#endif 636#endif
636 637
637 len = skb->len; 638 len = skb->len;
638 spin_lock_irq(&bp->lock); 639 spin_lock_irqsave(&bp->lock, flags);
639 640
640 /* This is a hard error, log it. */ 641 /* This is a hard error, log it. */
641 if (TX_BUFFS_AVAIL(bp) < 1) { 642 if (TX_BUFFS_AVAIL(bp) < 1) {
642 netif_stop_queue(dev); 643 netif_stop_queue(dev);
643 spin_unlock_irq(&bp->lock); 644 spin_unlock_irqrestore(&bp->lock, flags);
644 dev_err(&bp->pdev->dev, 645 dev_err(&bp->pdev->dev,
645 "BUG! Tx Ring full when queue awake!\n"); 646 "BUG! Tx Ring full when queue awake!\n");
646 dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n", 647 dev_dbg(&bp->pdev->dev, "tx_head = %u, tx_tail = %u\n",
@@ -674,7 +675,7 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev)
674 if (TX_BUFFS_AVAIL(bp) < 1) 675 if (TX_BUFFS_AVAIL(bp) < 1)
675 netif_stop_queue(dev); 676 netif_stop_queue(dev);
676 677
677 spin_unlock_irq(&bp->lock); 678 spin_unlock_irqrestore(&bp->lock, flags);
678 679
679 dev->trans_start = jiffies; 680 dev->trans_start = jiffies;
680 681
diff --git a/drivers/net/mlx4/en_rx.c b/drivers/net/mlx4/en_rx.c
index 91bdfdfd431f..3ac0404d0d11 100644
--- a/drivers/net/mlx4/en_rx.c
+++ b/drivers/net/mlx4/en_rx.c
@@ -506,8 +506,9 @@ static int mlx4_en_complete_rx_desc(struct mlx4_en_priv *priv,
506 PCI_DMA_FROMDEVICE); 506 PCI_DMA_FROMDEVICE);
507 } 507 }
508 /* Adjust size of last fragment to match actual length */ 508 /* Adjust size of last fragment to match actual length */
509 skb_frags_rx[nr - 1].size = length - 509 if (nr > 0)
510 priv->frag_info[nr - 1].frag_prefix_size; 510 skb_frags_rx[nr - 1].size = length -
511 priv->frag_info[nr - 1].frag_prefix_size;
511 return nr; 512 return nr;
512 513
513fail: 514fail:
diff --git a/drivers/net/mlx4/en_tx.c b/drivers/net/mlx4/en_tx.c
index 08c43f2ae72b..62208401c4df 100644
--- a/drivers/net/mlx4/en_tx.c
+++ b/drivers/net/mlx4/en_tx.c
@@ -249,6 +249,7 @@ static u32 mlx4_en_free_tx_desc(struct mlx4_en_priv *priv,
249 pci_unmap_page(mdev->pdev, 249 pci_unmap_page(mdev->pdev,
250 (dma_addr_t) be64_to_cpu(data->addr), 250 (dma_addr_t) be64_to_cpu(data->addr),
251 frag->size, PCI_DMA_TODEVICE); 251 frag->size, PCI_DMA_TODEVICE);
252 ++data;
252 } 253 }
253 } 254 }
254 /* Stamp the freed descriptor */ 255 /* Stamp the freed descriptor */
@@ -436,6 +437,7 @@ static inline void mlx4_en_xmit_poll(struct mlx4_en_priv *priv, int tx_ind)
436{ 437{
437 struct mlx4_en_cq *cq = &priv->tx_cq[tx_ind]; 438 struct mlx4_en_cq *cq = &priv->tx_cq[tx_ind];
438 struct mlx4_en_tx_ring *ring = &priv->tx_ring[tx_ind]; 439 struct mlx4_en_tx_ring *ring = &priv->tx_ring[tx_ind];
440 unsigned long flags;
439 441
440 /* If we don't have a pending timer, set one up to catch our recent 442 /* If we don't have a pending timer, set one up to catch our recent
441 post in case the interface becomes idle */ 443 post in case the interface becomes idle */
@@ -444,9 +446,9 @@ static inline void mlx4_en_xmit_poll(struct mlx4_en_priv *priv, int tx_ind)
444 446
445 /* Poll the CQ every mlx4_en_TX_MODER_POLL packets */ 447 /* Poll the CQ every mlx4_en_TX_MODER_POLL packets */
446 if ((++ring->poll_cnt & (MLX4_EN_TX_POLL_MODER - 1)) == 0) 448 if ((++ring->poll_cnt & (MLX4_EN_TX_POLL_MODER - 1)) == 0)
447 if (spin_trylock_irq(&ring->comp_lock)) { 449 if (spin_trylock_irqsave(&ring->comp_lock, flags)) {
448 mlx4_en_process_tx_cq(priv->dev, cq); 450 mlx4_en_process_tx_cq(priv->dev, cq);
449 spin_unlock_irq(&ring->comp_lock); 451 spin_unlock_irqrestore(&ring->comp_lock, flags);
450 } 452 }
451} 453}
452 454
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h
index f86e05047d19..a9c1fcca5e75 100644
--- a/drivers/net/netxen/netxen_nic.h
+++ b/drivers/net/netxen/netxen_nic.h
@@ -1254,7 +1254,7 @@ struct netxen_adapter {
1254 u8 mc_enabled; 1254 u8 mc_enabled;
1255 u8 max_mc_count; 1255 u8 max_mc_count;
1256 u8 rss_supported; 1256 u8 rss_supported;
1257 u8 resv2; 1257 u8 link_changed;
1258 u32 resv3; 1258 u32 resv3;
1259 1259
1260 u8 has_link_events; 1260 u8 has_link_events;
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c
index 7acf204e38c9..5d3343ef3d86 100644
--- a/drivers/net/netxen/netxen_nic_init.c
+++ b/drivers/net/netxen/netxen_nic_init.c
@@ -184,13 +184,6 @@ void netxen_free_sw_resources(struct netxen_adapter *adapter)
184 kfree(recv_ctx->rds_rings); 184 kfree(recv_ctx->rds_rings);
185 185
186skip_rds: 186skip_rds:
187 if (recv_ctx->sds_rings == NULL)
188 goto skip_sds;
189
190 for(ring = 0; ring < adapter->max_sds_rings; ring++)
191 recv_ctx->sds_rings[ring].consumer = 0;
192
193skip_sds:
194 if (adapter->tx_ring == NULL) 187 if (adapter->tx_ring == NULL)
195 return; 188 return;
196 189
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c
index 637ac8b89bac..28f270f5ac78 100644
--- a/drivers/net/netxen/netxen_nic_main.c
+++ b/drivers/net/netxen/netxen_nic_main.c
@@ -94,10 +94,6 @@ static struct pci_device_id netxen_pci_tbl[] __devinitdata = {
94 94
95MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); 95MODULE_DEVICE_TABLE(pci, netxen_pci_tbl);
96 96
97static struct workqueue_struct *netxen_workq;
98#define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp)
99#define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq)
100
101static void netxen_watchdog(unsigned long); 97static void netxen_watchdog(unsigned long);
102 98
103static uint32_t crb_cmd_producer[4] = { 99static uint32_t crb_cmd_producer[4] = {
@@ -171,6 +167,8 @@ netxen_free_sds_rings(struct netxen_recv_context *recv_ctx)
171{ 167{
172 if (recv_ctx->sds_rings != NULL) 168 if (recv_ctx->sds_rings != NULL)
173 kfree(recv_ctx->sds_rings); 169 kfree(recv_ctx->sds_rings);
170
171 recv_ctx->sds_rings = NULL;
174} 172}
175 173
176static int 174static int
@@ -193,6 +191,21 @@ netxen_napi_add(struct netxen_adapter *adapter, struct net_device *netdev)
193} 191}
194 192
195static void 193static void
194netxen_napi_del(struct netxen_adapter *adapter)
195{
196 int ring;
197 struct nx_host_sds_ring *sds_ring;
198 struct netxen_recv_context *recv_ctx = &adapter->recv_ctx;
199
200 for (ring = 0; ring < adapter->max_sds_rings; ring++) {
201 sds_ring = &recv_ctx->sds_rings[ring];
202 netif_napi_del(&sds_ring->napi);
203 }
204
205 netxen_free_sds_rings(&adapter->recv_ctx);
206}
207
208static void
196netxen_napi_enable(struct netxen_adapter *adapter) 209netxen_napi_enable(struct netxen_adapter *adapter)
197{ 210{
198 int ring; 211 int ring;
@@ -221,7 +234,7 @@ netxen_napi_disable(struct netxen_adapter *adapter)
221 } 234 }
222} 235}
223 236
224static int nx_set_dma_mask(struct netxen_adapter *adapter, uint8_t revision_id) 237static int nx_set_dma_mask(struct netxen_adapter *adapter)
225{ 238{
226 struct pci_dev *pdev = adapter->pdev; 239 struct pci_dev *pdev = adapter->pdev;
227 uint64_t mask, cmask; 240 uint64_t mask, cmask;
@@ -229,19 +242,17 @@ static int nx_set_dma_mask(struct netxen_adapter *adapter, uint8_t revision_id)
229 adapter->pci_using_dac = 0; 242 adapter->pci_using_dac = 0;
230 243
231 mask = DMA_BIT_MASK(32); 244 mask = DMA_BIT_MASK(32);
232 /*
233 * Consistent DMA mask is set to 32 bit because it cannot be set to
234 * 35 bits. For P3 also leave it at 32 bits for now. Only the rings
235 * come off this pool.
236 */
237 cmask = DMA_BIT_MASK(32); 245 cmask = DMA_BIT_MASK(32);
238 246
247 if (NX_IS_REVISION_P2(adapter->ahw.revision_id)) {
239#ifndef CONFIG_IA64 248#ifndef CONFIG_IA64
240 if (revision_id >= NX_P3_B0)
241 mask = DMA_BIT_MASK(39);
242 else if (revision_id == NX_P2_C1)
243 mask = DMA_BIT_MASK(35); 249 mask = DMA_BIT_MASK(35);
244#endif 250#endif
251 } else {
252 mask = DMA_BIT_MASK(39);
253 cmask = mask;
254 }
255
245 if (pci_set_dma_mask(pdev, mask) == 0 && 256 if (pci_set_dma_mask(pdev, mask) == 0 &&
246 pci_set_consistent_dma_mask(pdev, cmask) == 0) { 257 pci_set_consistent_dma_mask(pdev, cmask) == 0) {
247 adapter->pci_using_dac = 1; 258 adapter->pci_using_dac = 1;
@@ -256,13 +267,13 @@ static int
256nx_update_dma_mask(struct netxen_adapter *adapter) 267nx_update_dma_mask(struct netxen_adapter *adapter)
257{ 268{
258 int change, shift, err; 269 int change, shift, err;
259 uint64_t mask, old_mask; 270 uint64_t mask, old_mask, old_cmask;
260 struct pci_dev *pdev = adapter->pdev; 271 struct pci_dev *pdev = adapter->pdev;
261 272
262 change = 0; 273 change = 0;
263 274
264 shift = NXRD32(adapter, CRB_DMA_SHIFT); 275 shift = NXRD32(adapter, CRB_DMA_SHIFT);
265 if (shift >= 32) 276 if (shift > 32)
266 return 0; 277 return 0;
267 278
268 if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && (shift > 9)) 279 if (NX_IS_REVISION_P3(adapter->ahw.revision_id) && (shift > 9))
@@ -272,14 +283,29 @@ nx_update_dma_mask(struct netxen_adapter *adapter)
272 283
273 if (change) { 284 if (change) {
274 old_mask = pdev->dma_mask; 285 old_mask = pdev->dma_mask;
275 mask = (1ULL<<(32+shift)) - 1; 286 old_cmask = pdev->dev.coherent_dma_mask;
287
288 mask = DMA_BIT_MASK(32+shift);
276 289
277 err = pci_set_dma_mask(pdev, mask); 290 err = pci_set_dma_mask(pdev, mask);
278 if (err) 291 if (err)
279 return pci_set_dma_mask(pdev, old_mask); 292 goto err_out;
293
294 if (NX_IS_REVISION_P3(adapter->ahw.revision_id)) {
295
296 err = pci_set_consistent_dma_mask(pdev, mask);
297 if (err)
298 goto err_out;
299 }
300 dev_info(&pdev->dev, "using %d-bit dma mask\n", 32+shift);
280 } 301 }
281 302
282 return 0; 303 return 0;
304
305err_out:
306 pci_set_dma_mask(pdev, old_mask);
307 pci_set_consistent_dma_mask(pdev, old_cmask);
308 return err;
283} 309}
284 310
285static void netxen_check_options(struct netxen_adapter *adapter) 311static void netxen_check_options(struct netxen_adapter *adapter)
@@ -867,7 +893,6 @@ netxen_nic_down(struct netxen_adapter *adapter, struct net_device *netdev)
867 spin_unlock(&adapter->tx_clean_lock); 893 spin_unlock(&adapter->tx_clean_lock);
868 894
869 del_timer_sync(&adapter->watchdog_timer); 895 del_timer_sync(&adapter->watchdog_timer);
870 FLUSH_SCHEDULED_WORK();
871} 896}
872 897
873 898
@@ -881,10 +906,12 @@ netxen_nic_attach(struct netxen_adapter *adapter)
881 struct nx_host_tx_ring *tx_ring; 906 struct nx_host_tx_ring *tx_ring;
882 907
883 err = netxen_init_firmware(adapter); 908 err = netxen_init_firmware(adapter);
884 if (err != 0) { 909 if (err)
885 printk(KERN_ERR "Failed to init firmware\n"); 910 return err;
886 return -EIO; 911
887 } 912 err = netxen_napi_add(adapter, netdev);
913 if (err)
914 return err;
888 915
889 if (adapter->fw_major < 4) 916 if (adapter->fw_major < 4)
890 adapter->max_rds_rings = 3; 917 adapter->max_rds_rings = 3;
@@ -948,6 +975,7 @@ netxen_nic_detach(struct netxen_adapter *adapter)
948 netxen_free_hw_resources(adapter); 975 netxen_free_hw_resources(adapter);
949 netxen_release_rx_buffers(adapter); 976 netxen_release_rx_buffers(adapter);
950 netxen_nic_free_irq(adapter); 977 netxen_nic_free_irq(adapter);
978 netxen_napi_del(adapter);
951 netxen_free_sw_resources(adapter); 979 netxen_free_sw_resources(adapter);
952 980
953 adapter->is_up = 0; 981 adapter->is_up = 0;
@@ -1006,7 +1034,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1006 revision_id = pdev->revision; 1034 revision_id = pdev->revision;
1007 adapter->ahw.revision_id = revision_id; 1035 adapter->ahw.revision_id = revision_id;
1008 1036
1009 err = nx_set_dma_mask(adapter, revision_id); 1037 err = nx_set_dma_mask(adapter);
1010 if (err) 1038 if (err)
1011 goto err_out_free_netdev; 1039 goto err_out_free_netdev;
1012 1040
@@ -1092,9 +1120,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1092 1120
1093 netdev->irq = adapter->msix_entries[0].vector; 1121 netdev->irq = adapter->msix_entries[0].vector;
1094 1122
1095 if (netxen_napi_add(adapter, netdev))
1096 goto err_out_disable_msi;
1097
1098 init_timer(&adapter->watchdog_timer); 1123 init_timer(&adapter->watchdog_timer);
1099 adapter->watchdog_timer.function = &netxen_watchdog; 1124 adapter->watchdog_timer.function = &netxen_watchdog;
1100 adapter->watchdog_timer.data = (unsigned long)adapter; 1125 adapter->watchdog_timer.data = (unsigned long)adapter;
@@ -1164,6 +1189,9 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
1164 1189
1165 unregister_netdev(netdev); 1190 unregister_netdev(netdev);
1166 1191
1192 cancel_work_sync(&adapter->watchdog_task);
1193 cancel_work_sync(&adapter->tx_timeout_task);
1194
1167 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) { 1195 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) {
1168 netxen_nic_detach(adapter); 1196 netxen_nic_detach(adapter);
1169 } 1197 }
@@ -1172,7 +1200,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev)
1172 netxen_free_adapter_offload(adapter); 1200 netxen_free_adapter_offload(adapter);
1173 1201
1174 netxen_teardown_intr(adapter); 1202 netxen_teardown_intr(adapter);
1175 netxen_free_sds_rings(&adapter->recv_ctx);
1176 1203
1177 netxen_cleanup_pci_map(adapter); 1204 netxen_cleanup_pci_map(adapter);
1178 1205
@@ -1198,6 +1225,9 @@ netxen_nic_suspend(struct pci_dev *pdev, pm_message_t state)
1198 if (netif_running(netdev)) 1225 if (netif_running(netdev))
1199 netxen_nic_down(adapter, netdev); 1226 netxen_nic_down(adapter, netdev);
1200 1227
1228 cancel_work_sync(&adapter->watchdog_task);
1229 cancel_work_sync(&adapter->tx_timeout_task);
1230
1201 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) 1231 if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC)
1202 netxen_nic_detach(adapter); 1232 netxen_nic_detach(adapter);
1203 1233
@@ -1536,11 +1566,6 @@ static int netxen_nic_check_temp(struct netxen_adapter *adapter)
1536 "%s: Device temperature %d degrees C exceeds" 1566 "%s: Device temperature %d degrees C exceeds"
1537 " maximum allowed. Hardware has been shut down.\n", 1567 " maximum allowed. Hardware has been shut down.\n",
1538 netdev->name, temp_val); 1568 netdev->name, temp_val);
1539
1540 netif_device_detach(netdev);
1541 netxen_nic_down(adapter, netdev);
1542 netxen_nic_detach(adapter);
1543
1544 rv = 1; 1569 rv = 1;
1545 } else if (temp_state == NX_TEMP_WARN) { 1570 } else if (temp_state == NX_TEMP_WARN) {
1546 if (adapter->temp == NX_TEMP_NORMAL) { 1571 if (adapter->temp == NX_TEMP_NORMAL) {
@@ -1574,10 +1599,7 @@ void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup)
1574 netif_carrier_off(netdev); 1599 netif_carrier_off(netdev);
1575 netif_stop_queue(netdev); 1600 netif_stop_queue(netdev);
1576 } 1601 }
1577 1602 adapter->link_changed = !adapter->has_link_events;
1578 if (!adapter->has_link_events)
1579 netxen_nic_set_link_parameters(adapter);
1580
1581 } else if (!adapter->ahw.linkup && linkup) { 1603 } else if (!adapter->ahw.linkup && linkup) {
1582 printk(KERN_INFO "%s: %s NIC Link is up\n", 1604 printk(KERN_INFO "%s: %s NIC Link is up\n",
1583 netxen_nic_driver_name, netdev->name); 1605 netxen_nic_driver_name, netdev->name);
@@ -1586,9 +1608,7 @@ void netxen_advert_link_change(struct netxen_adapter *adapter, int linkup)
1586 netif_carrier_on(netdev); 1608 netif_carrier_on(netdev);
1587 netif_wake_queue(netdev); 1609 netif_wake_queue(netdev);
1588 } 1610 }
1589 1611 adapter->link_changed = !adapter->has_link_events;
1590 if (!adapter->has_link_events)
1591 netxen_nic_set_link_parameters(adapter);
1592 } 1612 }
1593} 1613}
1594 1614
@@ -1615,11 +1635,36 @@ static void netxen_nic_handle_phy_intr(struct netxen_adapter *adapter)
1615 netxen_advert_link_change(adapter, linkup); 1635 netxen_advert_link_change(adapter, linkup);
1616} 1636}
1617 1637
1638static void netxen_nic_thermal_shutdown(struct netxen_adapter *adapter)
1639{
1640 struct net_device *netdev = adapter->netdev;
1641
1642 netif_device_detach(netdev);
1643 netxen_nic_down(adapter, netdev);
1644 netxen_nic_detach(adapter);
1645}
1646
1618static void netxen_watchdog(unsigned long v) 1647static void netxen_watchdog(unsigned long v)
1619{ 1648{
1620 struct netxen_adapter *adapter = (struct netxen_adapter *)v; 1649 struct netxen_adapter *adapter = (struct netxen_adapter *)v;
1621 1650
1622 SCHEDULE_WORK(&adapter->watchdog_task); 1651 if (netxen_nic_check_temp(adapter))
1652 goto do_sched;
1653
1654 if (!adapter->has_link_events) {
1655 netxen_nic_handle_phy_intr(adapter);
1656
1657 if (adapter->link_changed)
1658 goto do_sched;
1659 }
1660
1661 if (netif_running(adapter->netdev))
1662 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
1663
1664 return;
1665
1666do_sched:
1667 schedule_work(&adapter->watchdog_task);
1623} 1668}
1624 1669
1625void netxen_watchdog_task(struct work_struct *work) 1670void netxen_watchdog_task(struct work_struct *work)
@@ -1627,11 +1672,13 @@ void netxen_watchdog_task(struct work_struct *work)
1627 struct netxen_adapter *adapter = 1672 struct netxen_adapter *adapter =
1628 container_of(work, struct netxen_adapter, watchdog_task); 1673 container_of(work, struct netxen_adapter, watchdog_task);
1629 1674
1630 if (netxen_nic_check_temp(adapter)) 1675 if (adapter->temp == NX_TEMP_PANIC) {
1676 netxen_nic_thermal_shutdown(adapter);
1631 return; 1677 return;
1678 }
1632 1679
1633 if (!adapter->has_link_events) 1680 if (adapter->link_changed)
1634 netxen_nic_handle_phy_intr(adapter); 1681 netxen_nic_set_link_parameters(adapter);
1635 1682
1636 if (netif_running(adapter->netdev)) 1683 if (netif_running(adapter->netdev))
1637 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); 1684 mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ);
@@ -1639,9 +1686,8 @@ void netxen_watchdog_task(struct work_struct *work)
1639 1686
1640static void netxen_tx_timeout(struct net_device *netdev) 1687static void netxen_tx_timeout(struct net_device *netdev)
1641{ 1688{
1642 struct netxen_adapter *adapter = (struct netxen_adapter *) 1689 struct netxen_adapter *adapter = netdev_priv(netdev);
1643 netdev_priv(netdev); 1690 schedule_work(&adapter->tx_timeout_task);
1644 SCHEDULE_WORK(&adapter->tx_timeout_task);
1645} 1691}
1646 1692
1647static void netxen_tx_timeout_task(struct work_struct *work) 1693static void netxen_tx_timeout_task(struct work_struct *work)
@@ -1798,9 +1844,6 @@ static int __init netxen_init_module(void)
1798{ 1844{
1799 printk(KERN_INFO "%s\n", netxen_nic_driver_string); 1845 printk(KERN_INFO "%s\n", netxen_nic_driver_string);
1800 1846
1801 if ((netxen_workq = create_singlethread_workqueue("netxen")) == NULL)
1802 return -ENOMEM;
1803
1804 return pci_register_driver(&netxen_driver); 1847 return pci_register_driver(&netxen_driver);
1805} 1848}
1806 1849
@@ -1809,7 +1852,6 @@ module_init(netxen_init_module);
1809static void __exit netxen_exit_module(void) 1852static void __exit netxen_exit_module(void)
1810{ 1853{
1811 pci_unregister_driver(&netxen_driver); 1854 pci_unregister_driver(&netxen_driver);
1812 destroy_workqueue(netxen_workq);
1813} 1855}
1814 1856
1815module_exit(netxen_exit_module); 1857module_exit(netxen_exit_module);
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c
index 28368157dac4..23e1a0750fe0 100644
--- a/drivers/net/pcnet32.c
+++ b/drivers/net/pcnet32.c
@@ -1611,8 +1611,11 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1611 if (pcnet32_dwio_read_csr(ioaddr, 0) == 4 1611 if (pcnet32_dwio_read_csr(ioaddr, 0) == 4
1612 && pcnet32_dwio_check(ioaddr)) { 1612 && pcnet32_dwio_check(ioaddr)) {
1613 a = &pcnet32_dwio; 1613 a = &pcnet32_dwio;
1614 } else 1614 } else {
1615 if (pcnet32_debug & NETIF_MSG_PROBE)
1616 printk(KERN_ERR PFX "No access methods\n");
1615 goto err_release_region; 1617 goto err_release_region;
1618 }
1616 } 1619 }
1617 1620
1618 chip_version = 1621 chip_version =
@@ -1719,7 +1722,9 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1719 ret = -ENOMEM; 1722 ret = -ENOMEM;
1720 goto err_release_region; 1723 goto err_release_region;
1721 } 1724 }
1722 SET_NETDEV_DEV(dev, &pdev->dev); 1725
1726 if (pdev)
1727 SET_NETDEV_DEV(dev, &pdev->dev);
1723 1728
1724 if (pcnet32_debug & NETIF_MSG_PROBE) 1729 if (pcnet32_debug & NETIF_MSG_PROBE)
1725 printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr); 1730 printk(KERN_INFO PFX "%s at %#3lx,", chipname, ioaddr);
@@ -1818,7 +1823,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1818 1823
1819 spin_lock_init(&lp->lock); 1824 spin_lock_init(&lp->lock);
1820 1825
1821 SET_NETDEV_DEV(dev, &pdev->dev);
1822 lp->name = chipname; 1826 lp->name = chipname;
1823 lp->shared_irq = shared; 1827 lp->shared_irq = shared;
1824 lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */ 1828 lp->tx_ring_size = TX_RING_SIZE; /* default tx ring size */
@@ -1835,7 +1839,7 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1835 lp->chip_version = chip_version; 1839 lp->chip_version = chip_version;
1836 lp->msg_enable = pcnet32_debug; 1840 lp->msg_enable = pcnet32_debug;
1837 if ((cards_found >= MAX_UNITS) 1841 if ((cards_found >= MAX_UNITS)
1838 || (options[cards_found] > sizeof(options_mapping))) 1842 || (options[cards_found] >= sizeof(options_mapping)))
1839 lp->options = PCNET32_PORT_ASEL; 1843 lp->options = PCNET32_PORT_ASEL;
1840 else 1844 else
1841 lp->options = options_mapping[options[cards_found]]; 1845 lp->options = options_mapping[options[cards_found]];
@@ -1852,12 +1856,6 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1852 ((cards_found >= MAX_UNITS) || full_duplex[cards_found])) 1856 ((cards_found >= MAX_UNITS) || full_duplex[cards_found]))
1853 lp->options |= PCNET32_PORT_FD; 1857 lp->options |= PCNET32_PORT_FD;
1854 1858
1855 if (!a) {
1856 if (pcnet32_debug & NETIF_MSG_PROBE)
1857 printk(KERN_ERR PFX "No access methods\n");
1858 ret = -ENODEV;
1859 goto err_free_consistent;
1860 }
1861 lp->a = *a; 1859 lp->a = *a;
1862 1860
1863 /* prior to register_netdev, dev->name is not yet correct */ 1861 /* prior to register_netdev, dev->name is not yet correct */
@@ -1973,14 +1971,13 @@ pcnet32_probe1(unsigned long ioaddr, int shared, struct pci_dev *pdev)
1973 1971
1974 return 0; 1972 return 0;
1975 1973
1976 err_free_ring: 1974err_free_ring:
1977 pcnet32_free_ring(dev); 1975 pcnet32_free_ring(dev);
1978 err_free_consistent:
1979 pci_free_consistent(lp->pci_dev, sizeof(*lp->init_block), 1976 pci_free_consistent(lp->pci_dev, sizeof(*lp->init_block),
1980 lp->init_block, lp->init_dma_addr); 1977 lp->init_block, lp->init_dma_addr);
1981 err_free_netdev: 1978err_free_netdev:
1982 free_netdev(dev); 1979 free_netdev(dev);
1983 err_release_region: 1980err_release_region:
1984 release_region(ioaddr, PCNET32_TOTAL_SIZE); 1981 release_region(ioaddr, PCNET32_TOTAL_SIZE);
1985 return ret; 1982 return ret;
1986} 1983}
@@ -2089,6 +2086,7 @@ static void pcnet32_free_ring(struct net_device *dev)
2089static int pcnet32_open(struct net_device *dev) 2086static int pcnet32_open(struct net_device *dev)
2090{ 2087{
2091 struct pcnet32_private *lp = netdev_priv(dev); 2088 struct pcnet32_private *lp = netdev_priv(dev);
2089 struct pci_dev *pdev = lp->pci_dev;
2092 unsigned long ioaddr = dev->base_addr; 2090 unsigned long ioaddr = dev->base_addr;
2093 u16 val; 2091 u16 val;
2094 int i; 2092 int i;
@@ -2149,9 +2147,9 @@ static int pcnet32_open(struct net_device *dev)
2149 lp->a.write_csr(ioaddr, 124, val); 2147 lp->a.write_csr(ioaddr, 124, val);
2150 2148
2151 /* Allied Telesyn AT 2700/2701 FX are 100Mbit only and do not negotiate */ 2149 /* Allied Telesyn AT 2700/2701 FX are 100Mbit only and do not negotiate */
2152 if (lp->pci_dev->subsystem_vendor == PCI_VENDOR_ID_AT && 2150 if (pdev && pdev->subsystem_vendor == PCI_VENDOR_ID_AT &&
2153 (lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX || 2151 (pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2700FX ||
2154 lp->pci_dev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) { 2152 pdev->subsystem_device == PCI_SUBDEVICE_ID_AT_2701FX)) {
2155 if (lp->options & PCNET32_PORT_ASEL) { 2153 if (lp->options & PCNET32_PORT_ASEL) {
2156 lp->options = PCNET32_PORT_FD | PCNET32_PORT_100; 2154 lp->options = PCNET32_PORT_FD | PCNET32_PORT_100;
2157 if (netif_msg_link(lp)) 2155 if (netif_msg_link(lp))
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 639d11bc444e..cd37d739ac74 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -1384,7 +1384,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1384 1384
1385 /* create a fragment for each channel */ 1385 /* create a fragment for each channel */
1386 bits = B; 1386 bits = B;
1387 while (nfree > 0 && len > 0) { 1387 while (len > 0) {
1388 list = list->next; 1388 list = list->next;
1389 if (list == &ppp->channels) { 1389 if (list == &ppp->channels) {
1390 i = 0; 1390 i = 0;
@@ -1431,29 +1431,31 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1431 *otherwise divide it according to the speed 1431 *otherwise divide it according to the speed
1432 *of the channel we are going to transmit on 1432 *of the channel we are going to transmit on
1433 */ 1433 */
1434 if (pch->speed == 0) { 1434 if (nfree > 0) {
1435 flen = totlen/nfree ; 1435 if (pch->speed == 0) {
1436 if (nbigger > 0) { 1436 flen = totlen/nfree ;
1437 flen++; 1437 if (nbigger > 0) {
1438 nbigger--; 1438 flen++;
1439 } 1439 nbigger--;
1440 } else { 1440 }
1441 flen = (((totfree - nzero)*(totlen + hdrlen*totfree)) / 1441 } else {
1442 ((totspeed*totfree)/pch->speed)) - hdrlen; 1442 flen = (((totfree - nzero)*(totlen + hdrlen*totfree)) /
1443 if (nbigger > 0) { 1443 ((totspeed*totfree)/pch->speed)) - hdrlen;
1444 flen += ((totfree - nzero)*pch->speed)/totspeed; 1444 if (nbigger > 0) {
1445 nbigger -= ((totfree - nzero)*pch->speed)/ 1445 flen += ((totfree - nzero)*pch->speed)/totspeed;
1446 nbigger -= ((totfree - nzero)*pch->speed)/
1446 totspeed; 1447 totspeed;
1448 }
1447 } 1449 }
1450 nfree--;
1448 } 1451 }
1449 nfree--;
1450 1452
1451 /* 1453 /*
1452 *check if we are on the last channel or 1454 *check if we are on the last channel or
1453 *we exceded the lenght of the data to 1455 *we exceded the lenght of the data to
1454 *fragment 1456 *fragment
1455 */ 1457 */
1456 if ((nfree == 0) || (flen > len)) 1458 if ((nfree <= 0) || (flen > len))
1457 flen = len; 1459 flen = len;
1458 /* 1460 /*
1459 *it is not worth to tx on slow channels: 1461 *it is not worth to tx on slow channels:
@@ -1467,7 +1469,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1467 continue; 1469 continue;
1468 } 1470 }
1469 1471
1470 mtu = pch->chan->mtu + 2 - hdrlen; 1472 mtu = pch->chan->mtu - hdrlen;
1471 if (mtu < 4) 1473 if (mtu < 4)
1472 mtu = 4; 1474 mtu = 4;
1473 if (flen > mtu) 1475 if (flen > mtu)
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index f0031f1f97e5..5f2090233d7b 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -1063,6 +1063,7 @@ static void *pppoe_seq_next(struct seq_file *seq, void *v, loff_t *pos)
1063 else { 1063 else {
1064 int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote); 1064 int hash = hash_item(po->pppoe_pa.sid, po->pppoe_pa.remote);
1065 1065
1066 po = NULL;
1066 while (++hash < PPPOE_HASH_SIZE) { 1067 while (++hash < PPPOE_HASH_SIZE) {
1067 po = pn->hash_table[hash]; 1068 po = pn->hash_table[hash];
1068 if (po) 1069 if (po)
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index e7935d09c896..e0f9219a0aea 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -2680,6 +2680,7 @@ out_unregister_pppol2tp_proto:
2680static void __exit pppol2tp_exit(void) 2680static void __exit pppol2tp_exit(void)
2681{ 2681{
2682 unregister_pppox_proto(PX_PROTO_OL2TP); 2682 unregister_pppox_proto(PX_PROTO_OL2TP);
2683 unregister_pernet_gen_device(pppol2tp_net_id, &pppol2tp_net_ops);
2683 proto_unregister(&pppol2tp_sk_proto); 2684 proto_unregister(&pppol2tp_sk_proto);
2684} 2685}
2685 2686
diff --git a/drivers/net/s6gmac.c b/drivers/net/s6gmac.c
index 5345e47b35ac..4525cbe8dd69 100644
--- a/drivers/net/s6gmac.c
+++ b/drivers/net/s6gmac.c
@@ -793,7 +793,7 @@ static inline int s6gmac_phy_start(struct net_device *dev)
793 struct s6gmac *pd = netdev_priv(dev); 793 struct s6gmac *pd = netdev_priv(dev);
794 int i = 0; 794 int i = 0;
795 struct phy_device *p = NULL; 795 struct phy_device *p = NULL;
796 while ((!(p = pd->mii.bus->phy_map[i])) && (i < PHY_MAX_ADDR)) 796 while ((i < PHY_MAX_ADDR) && (!(p = pd->mii.bus->phy_map[i])))
797 i++; 797 i++;
798 p = phy_connect(dev, dev_name(&p->dev), &s6gmac_adjust_link, 0, 798 p = phy_connect(dev, dev_name(&p->dev), &s6gmac_adjust_link, 0,
799 PHY_INTERFACE_MODE_RGMII); 799 PHY_INTERFACE_MODE_RGMII);
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 3550c5dcd93c..0a551d8f5d95 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -1488,6 +1488,8 @@ static int sky2_up(struct net_device *dev)
1488 sky2_set_vlan_mode(hw, port, sky2->vlgrp != NULL); 1488 sky2_set_vlan_mode(hw, port, sky2->vlgrp != NULL);
1489#endif 1489#endif
1490 1490
1491 sky2->restarting = 0;
1492
1491 err = sky2_rx_start(sky2); 1493 err = sky2_rx_start(sky2);
1492 if (err) 1494 if (err)
1493 goto err_out; 1495 goto err_out;
@@ -1500,6 +1502,9 @@ static int sky2_up(struct net_device *dev)
1500 1502
1501 sky2_set_multicast(dev); 1503 sky2_set_multicast(dev);
1502 1504
1505 /* wake queue incase we are restarting */
1506 netif_wake_queue(dev);
1507
1503 if (netif_msg_ifup(sky2)) 1508 if (netif_msg_ifup(sky2))
1504 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name); 1509 printk(KERN_INFO PFX "%s: enabling interface\n", dev->name);
1505 return 0; 1510 return 0;
@@ -1533,6 +1538,8 @@ static inline int tx_dist(unsigned tail, unsigned head)
1533/* Number of list elements available for next tx */ 1538/* Number of list elements available for next tx */
1534static inline int tx_avail(const struct sky2_port *sky2) 1539static inline int tx_avail(const struct sky2_port *sky2)
1535{ 1540{
1541 if (unlikely(sky2->restarting))
1542 return 0;
1536 return sky2->tx_pending - tx_dist(sky2->tx_cons, sky2->tx_prod); 1543 return sky2->tx_pending - tx_dist(sky2->tx_cons, sky2->tx_prod);
1537} 1544}
1538 1545
@@ -1818,6 +1825,10 @@ static int sky2_down(struct net_device *dev)
1818 if (netif_msg_ifdown(sky2)) 1825 if (netif_msg_ifdown(sky2))
1819 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name); 1826 printk(KERN_INFO PFX "%s: disabling interface\n", dev->name);
1820 1827
1828 /* explicitly shut off tx incase we're restarting */
1829 sky2->restarting = 1;
1830 netif_tx_disable(dev);
1831
1821 /* Force flow control off */ 1832 /* Force flow control off */
1822 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF); 1833 sky2_write8(hw, SK_REG(port, GMAC_CTRL), GMC_PAUSE_OFF);
1823 1834
@@ -2359,7 +2370,7 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last)
2359{ 2370{
2360 struct sky2_port *sky2 = netdev_priv(dev); 2371 struct sky2_port *sky2 = netdev_priv(dev);
2361 2372
2362 if (netif_running(dev)) { 2373 if (likely(netif_running(dev) && !sky2->restarting)) {
2363 netif_tx_lock(dev); 2374 netif_tx_lock(dev);
2364 sky2_tx_complete(sky2, last); 2375 sky2_tx_complete(sky2, last);
2365 netif_tx_unlock(dev); 2376 netif_tx_unlock(dev);
@@ -4283,6 +4294,7 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
4283 spin_lock_init(&sky2->phy_lock); 4294 spin_lock_init(&sky2->phy_lock);
4284 sky2->tx_pending = TX_DEF_PENDING; 4295 sky2->tx_pending = TX_DEF_PENDING;
4285 sky2->rx_pending = RX_DEF_PENDING; 4296 sky2->rx_pending = RX_DEF_PENDING;
4297 sky2->restarting = 0;
4286 4298
4287 hw->dev[port] = dev; 4299 hw->dev[port] = dev;
4288 4300
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index b5549c9e5107..4486b066b43f 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -2051,6 +2051,7 @@ struct sky2_port {
2051 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */ 2051 u8 duplex; /* DUPLEX_HALF, DUPLEX_FULL */
2052 u8 rx_csum; 2052 u8 rx_csum;
2053 u8 wol; 2053 u8 wol;
2054 u8 restarting;
2054 enum flow_control flow_mode; 2055 enum flow_control flow_mode;
2055 enum flow_control flow_status; 2056 enum flow_control flow_status;
2056 2057
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index 1c70e999cc50..7567f510eff5 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -196,21 +196,23 @@ static void PRINT_PKT(u_char *buf, int length)
196/* this enables an interrupt in the interrupt mask register */ 196/* this enables an interrupt in the interrupt mask register */
197#define SMC_ENABLE_INT(lp, x) do { \ 197#define SMC_ENABLE_INT(lp, x) do { \
198 unsigned char mask; \ 198 unsigned char mask; \
199 spin_lock_irq(&lp->lock); \ 199 unsigned long smc_enable_flags; \
200 spin_lock_irqsave(&lp->lock, smc_enable_flags); \
200 mask = SMC_GET_INT_MASK(lp); \ 201 mask = SMC_GET_INT_MASK(lp); \
201 mask |= (x); \ 202 mask |= (x); \
202 SMC_SET_INT_MASK(lp, mask); \ 203 SMC_SET_INT_MASK(lp, mask); \
203 spin_unlock_irq(&lp->lock); \ 204 spin_unlock_irqrestore(&lp->lock, smc_enable_flags); \
204} while (0) 205} while (0)
205 206
206/* this disables an interrupt from the interrupt mask register */ 207/* this disables an interrupt from the interrupt mask register */
207#define SMC_DISABLE_INT(lp, x) do { \ 208#define SMC_DISABLE_INT(lp, x) do { \
208 unsigned char mask; \ 209 unsigned char mask; \
209 spin_lock_irq(&lp->lock); \ 210 unsigned long smc_disable_flags; \
211 spin_lock_irqsave(&lp->lock, smc_disable_flags); \
210 mask = SMC_GET_INT_MASK(lp); \ 212 mask = SMC_GET_INT_MASK(lp); \
211 mask &= ~(x); \ 213 mask &= ~(x); \
212 SMC_SET_INT_MASK(lp, mask); \ 214 SMC_SET_INT_MASK(lp, mask); \
213 spin_unlock_irq(&lp->lock); \ 215 spin_unlock_irqrestore(&lp->lock, smc_disable_flags); \
214} while (0) 216} while (0)
215 217
216/* 218/*
@@ -520,21 +522,21 @@ static inline void smc_rcv(struct net_device *dev)
520 * any other concurrent access and C would always interrupt B. But life 522 * any other concurrent access and C would always interrupt B. But life
521 * isn't that easy in a SMP world... 523 * isn't that easy in a SMP world...
522 */ 524 */
523#define smc_special_trylock(lock) \ 525#define smc_special_trylock(lock, flags) \
524({ \ 526({ \
525 int __ret; \ 527 int __ret; \
526 local_irq_disable(); \ 528 local_irq_save(flags); \
527 __ret = spin_trylock(lock); \ 529 __ret = spin_trylock(lock); \
528 if (!__ret) \ 530 if (!__ret) \
529 local_irq_enable(); \ 531 local_irq_restore(flags); \
530 __ret; \ 532 __ret; \
531}) 533})
532#define smc_special_lock(lock) spin_lock_irq(lock) 534#define smc_special_lock(lock, flags) spin_lock_irqsave(lock, flags)
533#define smc_special_unlock(lock) spin_unlock_irq(lock) 535#define smc_special_unlock(lock, flags) spin_unlock_irqrestore(lock, flags)
534#else 536#else
535#define smc_special_trylock(lock) (1) 537#define smc_special_trylock(lock, flags) (1)
536#define smc_special_lock(lock) do { } while (0) 538#define smc_special_lock(lock, flags) do { } while (0)
537#define smc_special_unlock(lock) do { } while (0) 539#define smc_special_unlock(lock, flags) do { } while (0)
538#endif 540#endif
539 541
540/* 542/*
@@ -548,10 +550,11 @@ static void smc_hardware_send_pkt(unsigned long data)
548 struct sk_buff *skb; 550 struct sk_buff *skb;
549 unsigned int packet_no, len; 551 unsigned int packet_no, len;
550 unsigned char *buf; 552 unsigned char *buf;
553 unsigned long flags;
551 554
552 DBG(3, "%s: %s\n", dev->name, __func__); 555 DBG(3, "%s: %s\n", dev->name, __func__);
553 556
554 if (!smc_special_trylock(&lp->lock)) { 557 if (!smc_special_trylock(&lp->lock, flags)) {
555 netif_stop_queue(dev); 558 netif_stop_queue(dev);
556 tasklet_schedule(&lp->tx_task); 559 tasklet_schedule(&lp->tx_task);
557 return; 560 return;
@@ -559,7 +562,7 @@ static void smc_hardware_send_pkt(unsigned long data)
559 562
560 skb = lp->pending_tx_skb; 563 skb = lp->pending_tx_skb;
561 if (unlikely(!skb)) { 564 if (unlikely(!skb)) {
562 smc_special_unlock(&lp->lock); 565 smc_special_unlock(&lp->lock, flags);
563 return; 566 return;
564 } 567 }
565 lp->pending_tx_skb = NULL; 568 lp->pending_tx_skb = NULL;
@@ -569,7 +572,7 @@ static void smc_hardware_send_pkt(unsigned long data)
569 printk("%s: Memory allocation failed.\n", dev->name); 572 printk("%s: Memory allocation failed.\n", dev->name);
570 dev->stats.tx_errors++; 573 dev->stats.tx_errors++;
571 dev->stats.tx_fifo_errors++; 574 dev->stats.tx_fifo_errors++;
572 smc_special_unlock(&lp->lock); 575 smc_special_unlock(&lp->lock, flags);
573 goto done; 576 goto done;
574 } 577 }
575 578
@@ -608,7 +611,7 @@ static void smc_hardware_send_pkt(unsigned long data)
608 611
609 /* queue the packet for TX */ 612 /* queue the packet for TX */
610 SMC_SET_MMU_CMD(lp, MC_ENQUEUE); 613 SMC_SET_MMU_CMD(lp, MC_ENQUEUE);
611 smc_special_unlock(&lp->lock); 614 smc_special_unlock(&lp->lock, flags);
612 615
613 dev->trans_start = jiffies; 616 dev->trans_start = jiffies;
614 dev->stats.tx_packets++; 617 dev->stats.tx_packets++;
@@ -633,6 +636,7 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
633 struct smc_local *lp = netdev_priv(dev); 636 struct smc_local *lp = netdev_priv(dev);
634 void __iomem *ioaddr = lp->base; 637 void __iomem *ioaddr = lp->base;
635 unsigned int numPages, poll_count, status; 638 unsigned int numPages, poll_count, status;
639 unsigned long flags;
636 640
637 DBG(3, "%s: %s\n", dev->name, __func__); 641 DBG(3, "%s: %s\n", dev->name, __func__);
638 642
@@ -658,7 +662,7 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
658 return 0; 662 return 0;
659 } 663 }
660 664
661 smc_special_lock(&lp->lock); 665 smc_special_lock(&lp->lock, flags);
662 666
663 /* now, try to allocate the memory */ 667 /* now, try to allocate the memory */
664 SMC_SET_MMU_CMD(lp, MC_ALLOC | numPages); 668 SMC_SET_MMU_CMD(lp, MC_ALLOC | numPages);
@@ -676,7 +680,7 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
676 } 680 }
677 } while (--poll_count); 681 } while (--poll_count);
678 682
679 smc_special_unlock(&lp->lock); 683 smc_special_unlock(&lp->lock, flags);
680 684
681 lp->pending_tx_skb = skb; 685 lp->pending_tx_skb = skb;
682 if (!poll_count) { 686 if (!poll_count) {
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index eb72d2e9ab3d..acfdccd44567 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -5059,7 +5059,7 @@ mii_get_phy(struct net_device *dev)
5059 if ((id == 0) || (id == 65535)) continue; /* Valid ID? */ 5059 if ((id == 0) || (id == 65535)) continue; /* Valid ID? */
5060 for (j=0; j<limit; j++) { /* Search PHY table */ 5060 for (j=0; j<limit; j++) { /* Search PHY table */
5061 if (id != phy_info[j].id) continue; /* ID match? */ 5061 if (id != phy_info[j].id) continue; /* ID match? */
5062 for (k=0; lp->phy[k].id && (k < DE4X5_MAX_PHY); k++); 5062 for (k=0; k < DE4X5_MAX_PHY && lp->phy[k].id; k++);
5063 if (k < DE4X5_MAX_PHY) { 5063 if (k < DE4X5_MAX_PHY) {
5064 memcpy((char *)&lp->phy[k], 5064 memcpy((char *)&lp->phy[k],
5065 (char *)&phy_info[j], sizeof(struct phy_table)); 5065 (char *)&phy_info[j], sizeof(struct phy_table));
@@ -5072,7 +5072,7 @@ mii_get_phy(struct net_device *dev)
5072 break; 5072 break;
5073 } 5073 }
5074 if ((j == limit) && (i < DE4X5_MAX_MII)) { 5074 if ((j == limit) && (i < DE4X5_MAX_MII)) {
5075 for (k=0; lp->phy[k].id && (k < DE4X5_MAX_PHY); k++); 5075 for (k=0; k < DE4X5_MAX_PHY && lp->phy[k].id; k++);
5076 lp->phy[k].addr = i; 5076 lp->phy[k].addr = i;
5077 lp->phy[k].id = id; 5077 lp->phy[k].id = id;
5078 lp->phy[k].spd.reg = GENERIC_REG; /* ANLPA register */ 5078 lp->phy[k].spd.reg = GENERIC_REG; /* ANLPA register */
@@ -5091,7 +5091,7 @@ mii_get_phy(struct net_device *dev)
5091 purgatory: 5091 purgatory:
5092 lp->active = 0; 5092 lp->active = 0;
5093 if (lp->phy[0].id) { /* Reset the PHY devices */ 5093 if (lp->phy[0].id) { /* Reset the PHY devices */
5094 for (k=0; lp->phy[k].id && (k < DE4X5_MAX_PHY); k++) { /*For each PHY*/ 5094 for (k=0; k < DE4X5_MAX_PHY && lp->phy[k].id; k++) { /*For each PHY*/
5095 mii_wr(MII_CR_RST, MII_CR, lp->phy[k].addr, DE4X5_MII); 5095 mii_wr(MII_CR_RST, MII_CR, lp->phy[k].addr, DE4X5_MII);
5096 while (mii_rd(MII_CR, lp->phy[k].addr, DE4X5_MII) & MII_CR_RST); 5096 while (mii_rd(MII_CR, lp->phy[k].addr, DE4X5_MII) & MII_CR_RST);
5097 5097
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 99a63649f4fc..4cf9a6588751 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -652,8 +652,9 @@ tulip_start_xmit(struct sk_buff *skb, struct net_device *dev)
652 int entry; 652 int entry;
653 u32 flag; 653 u32 flag;
654 dma_addr_t mapping; 654 dma_addr_t mapping;
655 unsigned long flags;
655 656
656 spin_lock_irq(&tp->lock); 657 spin_lock_irqsave(&tp->lock, flags);
657 658
658 /* Calculate the next Tx descriptor entry. */ 659 /* Calculate the next Tx descriptor entry. */
659 entry = tp->cur_tx % TX_RING_SIZE; 660 entry = tp->cur_tx % TX_RING_SIZE;
@@ -688,7 +689,7 @@ tulip_start_xmit(struct sk_buff *skb, struct net_device *dev)
688 /* Trigger an immediate transmit demand. */ 689 /* Trigger an immediate transmit demand. */
689 iowrite32(0, tp->base_addr + CSR1); 690 iowrite32(0, tp->base_addr + CSR1);
690 691
691 spin_unlock_irq(&tp->lock); 692 spin_unlock_irqrestore(&tp->lock, flags);
692 693
693 dev->trans_start = jiffies; 694 dev->trans_start = jiffies;
694 695
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 027f7aba26af..42b6c6319bc2 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1048,20 +1048,15 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
1048 return err; 1048 return err;
1049} 1049}
1050 1050
1051static int tun_get_iff(struct net *net, struct file *file, struct ifreq *ifr) 1051static int tun_get_iff(struct net *net, struct tun_struct *tun,
1052 struct ifreq *ifr)
1052{ 1053{
1053 struct tun_struct *tun = tun_get(file);
1054
1055 if (!tun)
1056 return -EBADFD;
1057
1058 DBG(KERN_INFO "%s: tun_get_iff\n", tun->dev->name); 1054 DBG(KERN_INFO "%s: tun_get_iff\n", tun->dev->name);
1059 1055
1060 strcpy(ifr->ifr_name, tun->dev->name); 1056 strcpy(ifr->ifr_name, tun->dev->name);
1061 1057
1062 ifr->ifr_flags = tun_flags(tun); 1058 ifr->ifr_flags = tun_flags(tun);
1063 1059
1064 tun_put(tun);
1065 return 0; 1060 return 0;
1066} 1061}
1067 1062
@@ -1105,8 +1100,8 @@ static int set_offload(struct net_device *dev, unsigned long arg)
1105 return 0; 1100 return 0;
1106} 1101}
1107 1102
1108static int tun_chr_ioctl(struct inode *inode, struct file *file, 1103static long tun_chr_ioctl(struct file *file, unsigned int cmd,
1109 unsigned int cmd, unsigned long arg) 1104 unsigned long arg)
1110{ 1105{
1111 struct tun_file *tfile = file->private_data; 1106 struct tun_file *tfile = file->private_data;
1112 struct tun_struct *tun; 1107 struct tun_struct *tun;
@@ -1128,34 +1123,32 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1128 (unsigned int __user*)argp); 1123 (unsigned int __user*)argp);
1129 } 1124 }
1130 1125
1126 rtnl_lock();
1127
1131 tun = __tun_get(tfile); 1128 tun = __tun_get(tfile);
1132 if (cmd == TUNSETIFF && !tun) { 1129 if (cmd == TUNSETIFF && !tun) {
1133 int err;
1134
1135 ifr.ifr_name[IFNAMSIZ-1] = '\0'; 1130 ifr.ifr_name[IFNAMSIZ-1] = '\0';
1136 1131
1137 rtnl_lock(); 1132 ret = tun_set_iff(tfile->net, file, &ifr);
1138 err = tun_set_iff(tfile->net, file, &ifr);
1139 rtnl_unlock();
1140 1133
1141 if (err) 1134 if (ret)
1142 return err; 1135 goto unlock;
1143 1136
1144 if (copy_to_user(argp, &ifr, sizeof(ifr))) 1137 if (copy_to_user(argp, &ifr, sizeof(ifr)))
1145 return -EFAULT; 1138 ret = -EFAULT;
1146 return 0; 1139 goto unlock;
1147 } 1140 }
1148 1141
1149 1142 ret = -EBADFD;
1150 if (!tun) 1143 if (!tun)
1151 return -EBADFD; 1144 goto unlock;
1152 1145
1153 DBG(KERN_INFO "%s: tun_chr_ioctl cmd %d\n", tun->dev->name, cmd); 1146 DBG(KERN_INFO "%s: tun_chr_ioctl cmd %d\n", tun->dev->name, cmd);
1154 1147
1155 ret = 0; 1148 ret = 0;
1156 switch (cmd) { 1149 switch (cmd) {
1157 case TUNGETIFF: 1150 case TUNGETIFF:
1158 ret = tun_get_iff(current->nsproxy->net_ns, file, &ifr); 1151 ret = tun_get_iff(current->nsproxy->net_ns, tun, &ifr);
1159 if (ret) 1152 if (ret)
1160 break; 1153 break;
1161 1154
@@ -1201,7 +1194,6 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1201 1194
1202 case TUNSETLINK: 1195 case TUNSETLINK:
1203 /* Only allow setting the type when the interface is down */ 1196 /* Only allow setting the type when the interface is down */
1204 rtnl_lock();
1205 if (tun->dev->flags & IFF_UP) { 1197 if (tun->dev->flags & IFF_UP) {
1206 DBG(KERN_INFO "%s: Linktype set failed because interface is up\n", 1198 DBG(KERN_INFO "%s: Linktype set failed because interface is up\n",
1207 tun->dev->name); 1199 tun->dev->name);
@@ -1211,7 +1203,6 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1211 DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type); 1203 DBG(KERN_INFO "%s: linktype set to %d\n", tun->dev->name, tun->dev->type);
1212 ret = 0; 1204 ret = 0;
1213 } 1205 }
1214 rtnl_unlock();
1215 break; 1206 break;
1216 1207
1217#ifdef TUN_DEBUG 1208#ifdef TUN_DEBUG
@@ -1220,9 +1211,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1220 break; 1211 break;
1221#endif 1212#endif
1222 case TUNSETOFFLOAD: 1213 case TUNSETOFFLOAD:
1223 rtnl_lock();
1224 ret = set_offload(tun->dev, arg); 1214 ret = set_offload(tun->dev, arg);
1225 rtnl_unlock();
1226 break; 1215 break;
1227 1216
1228 case TUNSETTXFILTER: 1217 case TUNSETTXFILTER:
@@ -1230,9 +1219,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1230 ret = -EINVAL; 1219 ret = -EINVAL;
1231 if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV) 1220 if ((tun->flags & TUN_TYPE_MASK) != TUN_TAP_DEV)
1232 break; 1221 break;
1233 rtnl_lock();
1234 ret = update_filter(&tun->txflt, (void __user *)arg); 1222 ret = update_filter(&tun->txflt, (void __user *)arg);
1235 rtnl_unlock();
1236 break; 1223 break;
1237 1224
1238 case SIOCGIFHWADDR: 1225 case SIOCGIFHWADDR:
@@ -1248,9 +1235,7 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1248 DBG(KERN_DEBUG "%s: set hw address: %pM\n", 1235 DBG(KERN_DEBUG "%s: set hw address: %pM\n",
1249 tun->dev->name, ifr.ifr_hwaddr.sa_data); 1236 tun->dev->name, ifr.ifr_hwaddr.sa_data);
1250 1237
1251 rtnl_lock();
1252 ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr); 1238 ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr);
1253 rtnl_unlock();
1254 break; 1239 break;
1255 1240
1256 case TUNGETSNDBUF: 1241 case TUNGETSNDBUF:
@@ -1273,7 +1258,10 @@ static int tun_chr_ioctl(struct inode *inode, struct file *file,
1273 break; 1258 break;
1274 }; 1259 };
1275 1260
1276 tun_put(tun); 1261unlock:
1262 rtnl_unlock();
1263 if (tun)
1264 tun_put(tun);
1277 return ret; 1265 return ret;
1278} 1266}
1279 1267
@@ -1361,7 +1349,7 @@ static const struct file_operations tun_fops = {
1361 .write = do_sync_write, 1349 .write = do_sync_write,
1362 .aio_write = tun_chr_aio_write, 1350 .aio_write = tun_chr_aio_write,
1363 .poll = tun_chr_poll, 1351 .poll = tun_chr_poll,
1364 .ioctl = tun_chr_ioctl, 1352 .unlocked_ioctl = tun_chr_ioctl,
1365 .open = tun_chr_open, 1353 .open = tun_chr_open,
1366 .release = tun_chr_close, 1354 .release = tun_chr_close,
1367 .fasync = tun_chr_fasync 1355 .fasync = tun_chr_fasync
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c
index 3b957e6412ee..8a7b8c7bd781 100644
--- a/drivers/net/ucc_geth.c
+++ b/drivers/net/ucc_geth.c
@@ -3111,10 +3111,11 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3111 u8 __iomem *bd; /* BD pointer */ 3111 u8 __iomem *bd; /* BD pointer */
3112 u32 bd_status; 3112 u32 bd_status;
3113 u8 txQ = 0; 3113 u8 txQ = 0;
3114 unsigned long flags;
3114 3115
3115 ugeth_vdbg("%s: IN", __func__); 3116 ugeth_vdbg("%s: IN", __func__);
3116 3117
3117 spin_lock_irq(&ugeth->lock); 3118 spin_lock_irqsave(&ugeth->lock, flags);
3118 3119
3119 dev->stats.tx_bytes += skb->len; 3120 dev->stats.tx_bytes += skb->len;
3120 3121
@@ -3171,7 +3172,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev)
3171 uccf = ugeth->uccf; 3172 uccf = ugeth->uccf;
3172 out_be16(uccf->p_utodr, UCC_FAST_TOD); 3173 out_be16(uccf->p_utodr, UCC_FAST_TOD);
3173#endif 3174#endif
3174 spin_unlock_irq(&ugeth->lock); 3175 spin_unlock_irqrestore(&ugeth->lock, flags);
3175 3176
3176 return 0; 3177 return 0;
3177} 3178}
diff --git a/drivers/net/usb/pegasus.h b/drivers/net/usb/pegasus.h
index c7467823cd1c..f968c834ff63 100644
--- a/drivers/net/usb/pegasus.h
+++ b/drivers/net/usb/pegasus.h
@@ -250,6 +250,8 @@ PEGASUS_DEV( "IO DATA USB ET/TX", VENDOR_IODATA, 0x0904,
250 DEFAULT_GPIO_RESET ) 250 DEFAULT_GPIO_RESET )
251PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913, 251PEGASUS_DEV( "IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913,
252 DEFAULT_GPIO_RESET | PEGASUS_II ) 252 DEFAULT_GPIO_RESET | PEGASUS_II )
253PEGASUS_DEV( "IO DATA USB ETX-US2", VENDOR_IODATA, 0x092a,
254 DEFAULT_GPIO_RESET | PEGASUS_II )
253PEGASUS_DEV( "Kingston KNU101TX Ethernet", VENDOR_KINGSTON, 0x000a, 255PEGASUS_DEV( "Kingston KNU101TX Ethernet", VENDOR_KINGSTON, 0x000a,
254 DEFAULT_GPIO_RESET) 256 DEFAULT_GPIO_RESET)
255PEGASUS_DEV( "LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x4002, 257PEGASUS_DEV( "LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x4002,
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c
index 88c30a58b4bd..934f7671650a 100644
--- a/drivers/net/via-rhine.c
+++ b/drivers/net/via-rhine.c
@@ -1218,6 +1218,7 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev)
1218 struct rhine_private *rp = netdev_priv(dev); 1218 struct rhine_private *rp = netdev_priv(dev);
1219 void __iomem *ioaddr = rp->base; 1219 void __iomem *ioaddr = rp->base;
1220 unsigned entry; 1220 unsigned entry;
1221 unsigned long flags;
1221 1222
1222 /* Caution: the write order is important here, set the field 1223 /* Caution: the write order is important here, set the field
1223 with the "ownership" bits last. */ 1224 with the "ownership" bits last. */
@@ -1261,7 +1262,7 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev)
1261 cpu_to_le32(TXDESC | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN)); 1262 cpu_to_le32(TXDESC | (skb->len >= ETH_ZLEN ? skb->len : ETH_ZLEN));
1262 1263
1263 /* lock eth irq */ 1264 /* lock eth irq */
1264 spin_lock_irq(&rp->lock); 1265 spin_lock_irqsave(&rp->lock, flags);
1265 wmb(); 1266 wmb();
1266 rp->tx_ring[entry].tx_status = cpu_to_le32(DescOwn); 1267 rp->tx_ring[entry].tx_status = cpu_to_le32(DescOwn);
1267 wmb(); 1268 wmb();
@@ -1280,7 +1281,7 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev)
1280 1281
1281 dev->trans_start = jiffies; 1282 dev->trans_start = jiffies;
1282 1283
1283 spin_unlock_irq(&rp->lock); 1284 spin_unlock_irqrestore(&rp->lock, flags);
1284 1285
1285 if (debug > 4) { 1286 if (debug > 4) {
1286 printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", 1287 printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n",
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 3ba35956327a..cee08a1e497a 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -1778,7 +1778,7 @@ static void velocity_error(struct velocity_info *vptr, int status)
1778 * mode 1778 * mode
1779 */ 1779 */
1780 if (vptr->rev_id < REV_ID_VT3216_A0) { 1780 if (vptr->rev_id < REV_ID_VT3216_A0) {
1781 if (vptr->mii_status | VELOCITY_DUPLEX_FULL) 1781 if (vptr->mii_status & VELOCITY_DUPLEX_FULL)
1782 BYTE_REG_BITS_ON(TCR_TB2BDIS, &regs->TCR); 1782 BYTE_REG_BITS_ON(TCR_TB2BDIS, &regs->TCR);
1783 else 1783 else
1784 BYTE_REG_BITS_OFF(TCR_TB2BDIS, &regs->TCR); 1784 BYTE_REG_BITS_OFF(TCR_TB2BDIS, &regs->TCR);
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 2a6e81d5b579..bbedf03a2124 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -70,6 +70,9 @@ struct virtnet_info
70 struct sk_buff_head recv; 70 struct sk_buff_head recv;
71 struct sk_buff_head send; 71 struct sk_buff_head send;
72 72
73 /* Work struct for refilling if we run low on memory. */
74 struct delayed_work refill;
75
73 /* Chain pages by the private ptr. */ 76 /* Chain pages by the private ptr. */
74 struct page *pages; 77 struct page *pages;
75}; 78};
@@ -273,19 +276,22 @@ drop:
273 dev_kfree_skb(skb); 276 dev_kfree_skb(skb);
274} 277}
275 278
276static void try_fill_recv_maxbufs(struct virtnet_info *vi) 279static bool try_fill_recv_maxbufs(struct virtnet_info *vi, gfp_t gfp)
277{ 280{
278 struct sk_buff *skb; 281 struct sk_buff *skb;
279 struct scatterlist sg[2+MAX_SKB_FRAGS]; 282 struct scatterlist sg[2+MAX_SKB_FRAGS];
280 int num, err, i; 283 int num, err, i;
284 bool oom = false;
281 285
282 sg_init_table(sg, 2+MAX_SKB_FRAGS); 286 sg_init_table(sg, 2+MAX_SKB_FRAGS);
283 for (;;) { 287 for (;;) {
284 struct virtio_net_hdr *hdr; 288 struct virtio_net_hdr *hdr;
285 289
286 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN); 290 skb = netdev_alloc_skb(vi->dev, MAX_PACKET_LEN + NET_IP_ALIGN);
287 if (unlikely(!skb)) 291 if (unlikely(!skb)) {
292 oom = true;
288 break; 293 break;
294 }
289 295
290 skb_reserve(skb, NET_IP_ALIGN); 296 skb_reserve(skb, NET_IP_ALIGN);
291 skb_put(skb, MAX_PACKET_LEN); 297 skb_put(skb, MAX_PACKET_LEN);
@@ -296,7 +302,7 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
296 if (vi->big_packets) { 302 if (vi->big_packets) {
297 for (i = 0; i < MAX_SKB_FRAGS; i++) { 303 for (i = 0; i < MAX_SKB_FRAGS; i++) {
298 skb_frag_t *f = &skb_shinfo(skb)->frags[i]; 304 skb_frag_t *f = &skb_shinfo(skb)->frags[i];
299 f->page = get_a_page(vi, GFP_ATOMIC); 305 f->page = get_a_page(vi, gfp);
300 if (!f->page) 306 if (!f->page)
301 break; 307 break;
302 308
@@ -325,31 +331,35 @@ static void try_fill_recv_maxbufs(struct virtnet_info *vi)
325 if (unlikely(vi->num > vi->max)) 331 if (unlikely(vi->num > vi->max))
326 vi->max = vi->num; 332 vi->max = vi->num;
327 vi->rvq->vq_ops->kick(vi->rvq); 333 vi->rvq->vq_ops->kick(vi->rvq);
334 return !oom;
328} 335}
329 336
330static void try_fill_recv(struct virtnet_info *vi) 337/* Returns false if we couldn't fill entirely (OOM). */
338static bool try_fill_recv(struct virtnet_info *vi, gfp_t gfp)
331{ 339{
332 struct sk_buff *skb; 340 struct sk_buff *skb;
333 struct scatterlist sg[1]; 341 struct scatterlist sg[1];
334 int err; 342 int err;
343 bool oom = false;
335 344
336 if (!vi->mergeable_rx_bufs) { 345 if (!vi->mergeable_rx_bufs)
337 try_fill_recv_maxbufs(vi); 346 return try_fill_recv_maxbufs(vi, gfp);
338 return;
339 }
340 347
341 for (;;) { 348 for (;;) {
342 skb_frag_t *f; 349 skb_frag_t *f;
343 350
344 skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN); 351 skb = netdev_alloc_skb(vi->dev, GOOD_COPY_LEN + NET_IP_ALIGN);
345 if (unlikely(!skb)) 352 if (unlikely(!skb)) {
353 oom = true;
346 break; 354 break;
355 }
347 356
348 skb_reserve(skb, NET_IP_ALIGN); 357 skb_reserve(skb, NET_IP_ALIGN);
349 358
350 f = &skb_shinfo(skb)->frags[0]; 359 f = &skb_shinfo(skb)->frags[0];
351 f->page = get_a_page(vi, GFP_ATOMIC); 360 f->page = get_a_page(vi, gfp);
352 if (!f->page) { 361 if (!f->page) {
362 oom = true;
353 kfree_skb(skb); 363 kfree_skb(skb);
354 break; 364 break;
355 } 365 }
@@ -373,6 +383,7 @@ static void try_fill_recv(struct virtnet_info *vi)
373 if (unlikely(vi->num > vi->max)) 383 if (unlikely(vi->num > vi->max))
374 vi->max = vi->num; 384 vi->max = vi->num;
375 vi->rvq->vq_ops->kick(vi->rvq); 385 vi->rvq->vq_ops->kick(vi->rvq);
386 return !oom;
376} 387}
377 388
378static void skb_recv_done(struct virtqueue *rvq) 389static void skb_recv_done(struct virtqueue *rvq)
@@ -385,6 +396,23 @@ static void skb_recv_done(struct virtqueue *rvq)
385 } 396 }
386} 397}
387 398
399static void refill_work(struct work_struct *work)
400{
401 struct virtnet_info *vi;
402 bool still_empty;
403
404 vi = container_of(work, struct virtnet_info, refill.work);
405 napi_disable(&vi->napi);
406 try_fill_recv(vi, GFP_KERNEL);
407 still_empty = (vi->num == 0);
408 napi_enable(&vi->napi);
409
410 /* In theory, this can happen: if we don't get any buffers in
411 * we will *never* try to fill again. */
412 if (still_empty)
413 schedule_delayed_work(&vi->refill, HZ/2);
414}
415
388static int virtnet_poll(struct napi_struct *napi, int budget) 416static int virtnet_poll(struct napi_struct *napi, int budget)
389{ 417{
390 struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi); 418 struct virtnet_info *vi = container_of(napi, struct virtnet_info, napi);
@@ -400,10 +428,10 @@ again:
400 received++; 428 received++;
401 } 429 }
402 430
403 /* FIXME: If we oom and completely run out of inbufs, we need 431 if (vi->num < vi->max / 2) {
404 * to start a timer trying to fill more. */ 432 if (!try_fill_recv(vi, GFP_ATOMIC))
405 if (vi->num < vi->max / 2) 433 schedule_delayed_work(&vi->refill, 0);
406 try_fill_recv(vi); 434 }
407 435
408 /* Out of packets? */ 436 /* Out of packets? */
409 if (received < budget) { 437 if (received < budget) {
@@ -893,6 +921,7 @@ static int virtnet_probe(struct virtio_device *vdev)
893 vi->vdev = vdev; 921 vi->vdev = vdev;
894 vdev->priv = vi; 922 vdev->priv = vi;
895 vi->pages = NULL; 923 vi->pages = NULL;
924 INIT_DELAYED_WORK(&vi->refill, refill_work);
896 925
897 /* If they give us a callback when all buffers are done, we don't need 926 /* If they give us a callback when all buffers are done, we don't need
898 * the timer. */ 927 * the timer. */
@@ -941,7 +970,7 @@ static int virtnet_probe(struct virtio_device *vdev)
941 } 970 }
942 971
943 /* Last of all, set up some receive buffers. */ 972 /* Last of all, set up some receive buffers. */
944 try_fill_recv(vi); 973 try_fill_recv(vi, GFP_KERNEL);
945 974
946 /* If we didn't even get one input buffer, we're useless. */ 975 /* If we didn't even get one input buffer, we're useless. */
947 if (vi->num == 0) { 976 if (vi->num == 0) {
@@ -958,6 +987,7 @@ static int virtnet_probe(struct virtio_device *vdev)
958 987
959unregister: 988unregister:
960 unregister_netdev(dev); 989 unregister_netdev(dev);
990 cancel_delayed_work_sync(&vi->refill);
961free_vqs: 991free_vqs:
962 vdev->config->del_vqs(vdev); 992 vdev->config->del_vqs(vdev);
963free: 993free:
@@ -986,6 +1016,7 @@ static void virtnet_remove(struct virtio_device *vdev)
986 BUG_ON(vi->num != 0); 1016 BUG_ON(vi->num != 0);
987 1017
988 unregister_netdev(vi->dev); 1018 unregister_netdev(vi->dev);
1019 cancel_delayed_work_sync(&vi->refill);
989 1020
990 vdev->config->del_vqs(vi->vdev); 1021 vdev->config->del_vqs(vi->vdev);
991 1022
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index c70604f0329e..8ce5e4cee168 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -5918,20 +5918,19 @@ static int airo_set_essid(struct net_device *dev,
5918 readSsidRid(local, &SSID_rid); 5918 readSsidRid(local, &SSID_rid);
5919 5919
5920 /* Check if we asked for `any' */ 5920 /* Check if we asked for `any' */
5921 if(dwrq->flags == 0) { 5921 if (dwrq->flags == 0) {
5922 /* Just send an empty SSID list */ 5922 /* Just send an empty SSID list */
5923 memset(&SSID_rid, 0, sizeof(SSID_rid)); 5923 memset(&SSID_rid, 0, sizeof(SSID_rid));
5924 } else { 5924 } else {
5925 int index = (dwrq->flags & IW_ENCODE_INDEX) - 1; 5925 unsigned index = (dwrq->flags & IW_ENCODE_INDEX) - 1;
5926 5926
5927 /* Check the size of the string */ 5927 /* Check the size of the string */
5928 if(dwrq->length > IW_ESSID_MAX_SIZE) { 5928 if (dwrq->length > IW_ESSID_MAX_SIZE)
5929 return -E2BIG ; 5929 return -E2BIG ;
5930 } 5930
5931 /* Check if index is valid */ 5931 /* Check if index is valid */
5932 if((index < 0) || (index >= 4)) { 5932 if (index >= ARRAY_SIZE(SSID_rid.ssids))
5933 return -EINVAL; 5933 return -EINVAL;
5934 }
5935 5934
5936 /* Set the SSID */ 5935 /* Set the SSID */
5937 memset(SSID_rid.ssids[index].ssid, 0, 5936 memset(SSID_rid.ssids[index].ssid, 0,
@@ -6819,7 +6818,7 @@ static int airo_set_txpow(struct net_device *dev,
6819 return -EINVAL; 6818 return -EINVAL;
6820 } 6819 }
6821 clear_bit (FLAG_RADIO_OFF, &local->flags); 6820 clear_bit (FLAG_RADIO_OFF, &local->flags);
6822 for (i = 0; cap_rid.txPowerLevels[i] && (i < 8); i++) 6821 for (i = 0; i < 8 && cap_rid.txPowerLevels[i]; i++)
6823 if (v == cap_rid.txPowerLevels[i]) { 6822 if (v == cap_rid.txPowerLevels[i]) {
6824 readConfigRid(local, 1); 6823 readConfigRid(local, 1);
6825 local->config.txPower = v; 6824 local->config.txPower = v;
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c
index 9d38cf60a0db..88c3d8573869 100644
--- a/drivers/net/wireless/ath/ar9170/main.c
+++ b/drivers/net/wireless/ath/ar9170/main.c
@@ -1967,13 +1967,14 @@ static int ar9170_conf_tx(struct ieee80211_hw *hw, u16 queue,
1967 int ret; 1967 int ret;
1968 1968
1969 mutex_lock(&ar->mutex); 1969 mutex_lock(&ar->mutex);
1970 if ((param) && !(queue > __AR9170_NUM_TXQ)) { 1970 if (queue < __AR9170_NUM_TXQ) {
1971 memcpy(&ar->edcf[ar9170_qos_hwmap[queue]], 1971 memcpy(&ar->edcf[ar9170_qos_hwmap[queue]],
1972 param, sizeof(*param)); 1972 param, sizeof(*param));
1973 1973
1974 ret = ar9170_set_qos(ar); 1974 ret = ar9170_set_qos(ar);
1975 } else 1975 } else {
1976 ret = -EINVAL; 1976 ret = -EINVAL;
1977 }
1977 1978
1978 mutex_unlock(&ar->mutex); 1979 mutex_unlock(&ar->mutex);
1979 return ret; 1980 return ret;
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c
index 754b1f8d8da9..007eb85fc67e 100644
--- a/drivers/net/wireless/ath/ar9170/usb.c
+++ b/drivers/net/wireless/ath/ar9170/usb.c
@@ -598,11 +598,15 @@ static int ar9170_usb_request_firmware(struct ar9170_usb *aru)
598 598
599 err = request_firmware(&aru->init_values, "ar9170-1.fw", 599 err = request_firmware(&aru->init_values, "ar9170-1.fw",
600 &aru->udev->dev); 600 &aru->udev->dev);
601 if (err) {
602 dev_err(&aru->udev->dev, "file with init values not found.\n");
603 return err;
604 }
601 605
602 err = request_firmware(&aru->firmware, "ar9170-2.fw", &aru->udev->dev); 606 err = request_firmware(&aru->firmware, "ar9170-2.fw", &aru->udev->dev);
603 if (err) { 607 if (err) {
604 release_firmware(aru->init_values); 608 release_firmware(aru->init_values);
605 dev_err(&aru->udev->dev, "file with init values not found.\n"); 609 dev_err(&aru->udev->dev, "firmware file not found.\n");
606 return err; 610 return err;
607 } 611 }
608 612
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c
index a2fda702b620..ce0e86c36a82 100644
--- a/drivers/net/wireless/ath/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/eeprom.c
@@ -460,7 +460,7 @@ static int ath9k_hw_4k_check_eeprom(struct ath_hw *ah)
460 integer = swab32(eep->modalHeader.antCtrlCommon); 460 integer = swab32(eep->modalHeader.antCtrlCommon);
461 eep->modalHeader.antCtrlCommon = integer; 461 eep->modalHeader.antCtrlCommon = integer;
462 462
463 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 463 for (i = 0; i < AR5416_EEP4K_MAX_CHAINS; i++) {
464 integer = swab32(eep->modalHeader.antCtrlChain[i]); 464 integer = swab32(eep->modalHeader.antCtrlChain[i]);
465 eep->modalHeader.antCtrlChain[i] = integer; 465 eep->modalHeader.antCtrlChain[i] = integer;
466 } 466 }
@@ -914,7 +914,7 @@ static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
914 ctlMode, numCtlModes, isHt40CtlMode, 914 ctlMode, numCtlModes, isHt40CtlMode,
915 (pCtlMode[ctlMode] & EXT_ADDITIVE)); 915 (pCtlMode[ctlMode] & EXT_ADDITIVE));
916 916
917 for (i = 0; (i < AR5416_NUM_CTLS) && 917 for (i = 0; (i < AR5416_EEP4K_NUM_CTLS) &&
918 pEepData->ctlIndex[i]; i++) { 918 pEepData->ctlIndex[i]; i++) {
919 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 919 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
920 " LOOP-Ctlidx %d: cfgCtl 0x%2.2x " 920 " LOOP-Ctlidx %d: cfgCtl 0x%2.2x "
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index 44c29b3f6728..6dcac73b4d29 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -6226,7 +6226,7 @@ static void ipw_add_scan_channels(struct ipw_priv *priv,
6226 }; 6226 };
6227 6227
6228 u8 channel; 6228 u8 channel;
6229 while (channel_index < IPW_SCAN_CHANNELS) { 6229 while (channel_index < IPW_SCAN_CHANNELS - 1) {
6230 channel = 6230 channel =
6231 priv->speed_scan[priv->speed_scan_pos]; 6231 priv->speed_scan[priv->speed_scan_pos];
6232 if (channel == 0) { 6232 if (channel == 0) {
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.h b/drivers/net/wireless/iwlwifi/iwl-3945.h
index fbb3a573463e..2de6471d4be9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.h
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.h
@@ -112,7 +112,7 @@ enum iwl3945_antenna {
112#define IWL_TX_FIFO_NONE 7 112#define IWL_TX_FIFO_NONE 7
113 113
114/* Minimum number of queues. MAX_NUM is defined in hw specific files */ 114/* Minimum number of queues. MAX_NUM is defined in hw specific files */
115#define IWL_MIN_NUM_QUEUES 4 115#define IWL39_MIN_NUM_QUEUES 4
116 116
117#define IEEE80211_DATA_LEN 2304 117#define IEEE80211_DATA_LEN 2304
118#define IEEE80211_4ADDR_LEN 30 118#define IEEE80211_4ADDR_LEN 30
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index 6ab07165ea28..18b135f510e5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -1332,6 +1332,9 @@ int iwl_setup_mac(struct iwl_priv *priv)
1332 1332
1333 hw->wiphy->custom_regulatory = true; 1333 hw->wiphy->custom_regulatory = true;
1334 1334
1335 /* Firmware does not support this */
1336 hw->wiphy->disable_beacon_hints = true;
1337
1335 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX; 1338 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX;
1336 /* we create the 802.11 header and a zero-length SSID element */ 1339 /* we create the 802.11 header and a zero-length SSID element */
1337 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 1340 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2;
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
index 11e08c068917..ca00cc8ad4c7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c
@@ -308,18 +308,18 @@ static ssize_t iwl_dbgfs_nvm_read(struct file *file,
308 return -ENODATA; 308 return -ENODATA;
309 } 309 }
310 310
311 ptr = priv->eeprom;
312 if (!ptr) {
313 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
314 return -ENOMEM;
315 }
316
311 /* 4 characters for byte 0xYY */ 317 /* 4 characters for byte 0xYY */
312 buf = kzalloc(buf_size, GFP_KERNEL); 318 buf = kzalloc(buf_size, GFP_KERNEL);
313 if (!buf) { 319 if (!buf) {
314 IWL_ERR(priv, "Can not allocate Buffer\n"); 320 IWL_ERR(priv, "Can not allocate Buffer\n");
315 return -ENOMEM; 321 return -ENOMEM;
316 } 322 }
317
318 ptr = priv->eeprom;
319 if (!ptr) {
320 IWL_ERR(priv, "Invalid EEPROM/OTP memory\n");
321 return -ENOMEM;
322 }
323 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s\n", 323 pos += scnprintf(buf + pos, buf_size - pos, "NVM Type: %s\n",
324 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP) 324 (priv->nvm_device_type == NVM_DEVICE_TYPE_OTP)
325 ? "OTP" : "EEPROM"); 325 ? "OTP" : "EEPROM");
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index e2d620f0b6e8..650e20af20fa 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -258,8 +258,10 @@ struct iwl_channel_info {
258#define IWL_TX_FIFO_HCCA_2 6 258#define IWL_TX_FIFO_HCCA_2 6
259#define IWL_TX_FIFO_NONE 7 259#define IWL_TX_FIFO_NONE 7
260 260
261/* Minimum number of queues. MAX_NUM is defined in hw specific files */ 261/* Minimum number of queues. MAX_NUM is defined in hw specific files.
262#define IWL_MIN_NUM_QUEUES 4 262 * Set the minimum to accommodate the 4 standard TX queues, 1 command
263 * queue, 2 (unused) HCCA queues, and 4 HT queues (one for each AC) */
264#define IWL_MIN_NUM_QUEUES 10
263 265
264/* Power management (not Tx power) structures */ 266/* Power management (not Tx power) structures */
265 267
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 2addf735b193..ffd5c61a7553 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -566,6 +566,8 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
566 unsigned long flags; 566 unsigned long flags;
567 567
568 spin_lock_irqsave(&priv->sta_lock, flags); 568 spin_lock_irqsave(&priv->sta_lock, flags);
569 IWL_DEBUG_WEP(priv, "Removing default WEP key: idx=%d\n",
570 keyconf->keyidx);
569 571
570 if (!test_and_clear_bit(keyconf->keyidx, &priv->ucode_key_table)) 572 if (!test_and_clear_bit(keyconf->keyidx, &priv->ucode_key_table))
571 IWL_ERR(priv, "index %d not used in uCode key table.\n", 573 IWL_ERR(priv, "index %d not used in uCode key table.\n",
@@ -573,6 +575,11 @@ int iwl_remove_default_wep_key(struct iwl_priv *priv,
573 575
574 priv->default_wep_key--; 576 priv->default_wep_key--;
575 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0])); 577 memset(&priv->wep_keys[keyconf->keyidx], 0, sizeof(priv->wep_keys[0]));
578 if (iwl_is_rfkill(priv)) {
579 IWL_DEBUG_WEP(priv, "Not sending REPLY_WEPKEY command due to RFKILL.\n");
580 spin_unlock_irqrestore(&priv->sta_lock, flags);
581 return 0;
582 }
576 ret = iwl_send_static_wepkey_cmd(priv, 1); 583 ret = iwl_send_static_wepkey_cmd(priv, 1);
577 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n", 584 IWL_DEBUG_WEP(priv, "Remove default WEP key: idx=%d ret=%d\n",
578 keyconf->keyidx, ret); 585 keyconf->keyidx, ret);
@@ -853,6 +860,11 @@ int iwl_remove_dynamic_key(struct iwl_priv *priv,
853 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK; 860 priv->stations[sta_id].sta.sta.modify_mask = STA_MODIFY_KEY_MASK;
854 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK; 861 priv->stations[sta_id].sta.mode = STA_CONTROL_MODIFY_MSK;
855 862
863 if (iwl_is_rfkill(priv)) {
864 IWL_DEBUG_WEP(priv, "Not sending REPLY_ADD_STA command because RFKILL enabled. \n");
865 spin_unlock_irqrestore(&priv->sta_lock, flags);
866 return 0;
867 }
856 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC); 868 ret = iwl_send_add_sta(priv, &priv->stations[sta_id].sta, CMD_ASYNC);
857 spin_unlock_irqrestore(&priv->sta_lock, flags); 869 spin_unlock_irqrestore(&priv->sta_lock, flags);
858 return ret; 870 return ret;
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 9bbeec9427f0..2e89040e63be 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -720,8 +720,6 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
720 goto drop_unlock; 720 goto drop_unlock;
721 } 721 }
722 722
723 spin_unlock_irqrestore(&priv->lock, flags);
724
725 hdr_len = ieee80211_hdrlen(fc); 723 hdr_len = ieee80211_hdrlen(fc);
726 724
727 /* Find (or create) index into station table for destination station */ 725 /* Find (or create) index into station table for destination station */
@@ -729,7 +727,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
729 if (sta_id == IWL_INVALID_STATION) { 727 if (sta_id == IWL_INVALID_STATION) {
730 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", 728 IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n",
731 hdr->addr1); 729 hdr->addr1);
732 goto drop; 730 goto drop_unlock;
733 } 731 }
734 732
735 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); 733 IWL_DEBUG_TX(priv, "station Id %d\n", sta_id);
@@ -750,14 +748,17 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
750 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; 748 txq_id = priv->stations[sta_id].tid[tid].agg.txq_id;
751 swq_id = iwl_virtual_agg_queue_num(swq_id, txq_id); 749 swq_id = iwl_virtual_agg_queue_num(swq_id, txq_id);
752 } 750 }
753 priv->stations[sta_id].tid[tid].tfds_in_queue++;
754 } 751 }
755 752
756 txq = &priv->txq[txq_id]; 753 txq = &priv->txq[txq_id];
757 q = &txq->q; 754 q = &txq->q;
758 txq->swq_id = swq_id; 755 txq->swq_id = swq_id;
759 756
760 spin_lock_irqsave(&priv->lock, flags); 757 if (unlikely(iwl_queue_space(q) < q->high_mark))
758 goto drop_unlock;
759
760 if (ieee80211_is_data_qos(fc))
761 priv->stations[sta_id].tid[tid].tfds_in_queue++;
761 762
762 /* Set up driver data for this TFD */ 763 /* Set up driver data for this TFD */
763 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info)); 764 memset(&(txq->txb[q->write_ptr]), 0, sizeof(struct iwl_tx_info));
@@ -902,7 +903,6 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb)
902 903
903drop_unlock: 904drop_unlock:
904 spin_unlock_irqrestore(&priv->lock, flags); 905 spin_unlock_irqrestore(&priv->lock, flags);
905drop:
906 return -1; 906 return -1;
907} 907}
908EXPORT_SYMBOL(iwl_tx_skb); 908EXPORT_SYMBOL(iwl_tx_skb);
@@ -1171,6 +1171,8 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn)
1171 IWL_ERR(priv, "Start AGG on invalid station\n"); 1171 IWL_ERR(priv, "Start AGG on invalid station\n");
1172 return -ENXIO; 1172 return -ENXIO;
1173 } 1173 }
1174 if (unlikely(tid >= MAX_TID_COUNT))
1175 return -EINVAL;
1174 1176
1175 if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) { 1177 if (priv->stations[sta_id].tid[tid].agg.state != IWL_AGG_OFF) {
1176 IWL_ERR(priv, "Start AGG when state is not IWL_AGG_OFF !\n"); 1178 IWL_ERR(priv, "Start AGG when state is not IWL_AGG_OFF !\n");
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c
index 956798f2c80c..523843369ca2 100644
--- a/drivers/net/wireless/iwlwifi/iwl3945-base.c
+++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c
@@ -3968,6 +3968,9 @@ static int iwl3945_setup_mac(struct iwl_priv *priv)
3968 3968
3969 hw->wiphy->custom_regulatory = true; 3969 hw->wiphy->custom_regulatory = true;
3970 3970
3971 /* Firmware does not support this */
3972 hw->wiphy->disable_beacon_hints = true;
3973
3971 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945; 3974 hw->wiphy->max_scan_ssids = PROBE_OPTION_MAX_3945;
3972 /* we create the 802.11 header and a zero-length SSID element */ 3975 /* we create the 802.11 header and a zero-length SSID element */
3973 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2; 3976 hw->wiphy->max_scan_ie_len = IWL_MAX_PROBE_REQUEST - 24 - 2;
@@ -4018,10 +4021,10 @@ static int iwl3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *e
4018 SET_IEEE80211_DEV(hw, &pdev->dev); 4021 SET_IEEE80211_DEV(hw, &pdev->dev);
4019 4022
4020 if ((iwl3945_mod_params.num_of_queues > IWL39_MAX_NUM_QUEUES) || 4023 if ((iwl3945_mod_params.num_of_queues > IWL39_MAX_NUM_QUEUES) ||
4021 (iwl3945_mod_params.num_of_queues < IWL_MIN_NUM_QUEUES)) { 4024 (iwl3945_mod_params.num_of_queues < IWL39_MIN_NUM_QUEUES)) {
4022 IWL_ERR(priv, 4025 IWL_ERR(priv,
4023 "invalid queues_num, should be between %d and %d\n", 4026 "invalid queues_num, should be between %d and %d\n",
4024 IWL_MIN_NUM_QUEUES, IWL39_MAX_NUM_QUEUES); 4027 IWL39_MIN_NUM_QUEUES, IWL39_MAX_NUM_QUEUES);
4025 err = -EINVAL; 4028 err = -EINVAL;
4026 goto out_ieee80211_free_hw; 4029 goto out_ieee80211_free_hw;
4027 } 4030 }
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.c b/drivers/net/wireless/iwmc3200wifi/commands.c
index 834a7f544e5d..e2334d123599 100644
--- a/drivers/net/wireless/iwmc3200wifi/commands.c
+++ b/drivers/net/wireless/iwmc3200wifi/commands.c
@@ -220,6 +220,7 @@ int iwm_store_rxiq_calib_result(struct iwm_priv *iwm)
220 eeprom_rxiq = iwm_eeprom_access(iwm, IWM_EEPROM_CALIB_RXIQ); 220 eeprom_rxiq = iwm_eeprom_access(iwm, IWM_EEPROM_CALIB_RXIQ);
221 if (IS_ERR(eeprom_rxiq)) { 221 if (IS_ERR(eeprom_rxiq)) {
222 IWM_ERR(iwm, "Couldn't access EEPROM RX IQ entry\n"); 222 IWM_ERR(iwm, "Couldn't access EEPROM RX IQ entry\n");
223 kfree(rxiq);
223 return PTR_ERR(eeprom_rxiq); 224 return PTR_ERR(eeprom_rxiq);
224 } 225 }
225 226
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c
index aea5ccf24ccf..bf294e41753b 100644
--- a/drivers/net/wireless/iwmc3200wifi/netdev.c
+++ b/drivers/net/wireless/iwmc3200wifi/netdev.c
@@ -106,10 +106,8 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev,
106 int ret = 0; 106 int ret = 0;
107 107
108 wdev = iwm_wdev_alloc(sizeof_bus, dev); 108 wdev = iwm_wdev_alloc(sizeof_bus, dev);
109 if (!wdev) { 109 if (IS_ERR(wdev))
110 dev_err(dev, "no memory for wireless device instance\n"); 110 return wdev;
111 return ERR_PTR(-ENOMEM);
112 }
113 111
114 iwm = wdev_to_iwm(wdev); 112 iwm = wdev_to_iwm(wdev);
115 iwm->bus_ops = if_ops; 113 iwm->bus_ops = if_ops;
diff --git a/drivers/net/wireless/libertas/11d.c b/drivers/net/wireless/libertas/11d.c
index 9a5408e7d94a..5c6968101f0d 100644
--- a/drivers/net/wireless/libertas/11d.c
+++ b/drivers/net/wireless/libertas/11d.c
@@ -47,7 +47,7 @@ static u8 lbs_region_2_code(u8 *region)
47{ 47{
48 u8 i; 48 u8 i;
49 49
50 for (i = 0; region[i] && i < COUNTRY_CODE_LEN; i++) 50 for (i = 0; i < COUNTRY_CODE_LEN && region[i]; i++)
51 region[i] = toupper(region[i]); 51 region[i] = toupper(region[i]);
52 52
53 for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) { 53 for (i = 0; i < ARRAY_SIZE(region_code_mapping); i++) {
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index 0a2e29140add..c8a1998d4744 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -56,8 +56,8 @@ struct rxpd {
56 u8 bss_type; 56 u8 bss_type;
57 /* BSS number */ 57 /* BSS number */
58 u8 bss_num; 58 u8 bss_num;
59 } bss; 59 } __attribute__ ((packed)) bss;
60 } u; 60 } __attribute__ ((packed)) u;
61 61
62 /* SNR */ 62 /* SNR */
63 u8 snr; 63 u8 snr;
diff --git a/drivers/net/wireless/libertas/scan.c b/drivers/net/wireless/libertas/scan.c
index 601b54249677..6c95af3023cc 100644
--- a/drivers/net/wireless/libertas/scan.c
+++ b/drivers/net/wireless/libertas/scan.c
@@ -5,6 +5,7 @@
5 * for sending scan commands to the firmware. 5 * for sending scan commands to the firmware.
6 */ 6 */
7#include <linux/types.h> 7#include <linux/types.h>
8#include <linux/kernel.h>
8#include <linux/etherdevice.h> 9#include <linux/etherdevice.h>
9#include <linux/if_arp.h> 10#include <linux/if_arp.h>
10#include <asm/unaligned.h> 11#include <asm/unaligned.h>
@@ -876,7 +877,7 @@ static inline char *lbs_translate_scan(struct lbs_private *priv,
876 iwe.u.bitrate.disabled = 0; 877 iwe.u.bitrate.disabled = 0;
877 iwe.u.bitrate.value = 0; 878 iwe.u.bitrate.value = 0;
878 879
879 for (j = 0; bss->rates[j] && (j < sizeof(bss->rates)); j++) { 880 for (j = 0; j < ARRAY_SIZE(bss->rates) && bss->rates[j]; j++) {
880 /* Bit rate given in 500 kb/s units */ 881 /* Bit rate given in 500 kb/s units */
881 iwe.u.bitrate.value = bss->rates[j] * 500000; 882 iwe.u.bitrate.value = bss->rates[j] * 500000;
882 current_val = iwe_stream_add_value(info, start, current_val, 883 current_val = iwe_stream_add_value(info, start, current_val,
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index a263d5c84c08..83967afe0821 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -261,7 +261,7 @@ struct mwl8k_vif {
261 */ 261 */
262}; 262};
263 263
264#define MWL8K_VIF(_vif) (struct mwl8k_vif *)(&((_vif)->drv_priv)) 264#define MWL8K_VIF(_vif) ((struct mwl8k_vif *)&((_vif)->drv_priv))
265 265
266static const struct ieee80211_channel mwl8k_channels[] = { 266static const struct ieee80211_channel mwl8k_channels[] = {
267 { .center_freq = 2412, .hw_value = 1, }, 267 { .center_freq = 2412, .hw_value = 1, },
@@ -1012,6 +1012,8 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit)
1012 rmb(); 1012 rmb();
1013 1013
1014 skb = rxq->rx_skb[rxq->rx_head]; 1014 skb = rxq->rx_skb[rxq->rx_head];
1015 if (skb == NULL)
1016 break;
1015 rxq->rx_skb[rxq->rx_head] = NULL; 1017 rxq->rx_skb[rxq->rx_head] = NULL;
1016 1018
1017 rxq->rx_head = (rxq->rx_head + 1) % MWL8K_RX_DESCS; 1019 rxq->rx_head = (rxq->rx_head + 1) % MWL8K_RX_DESCS;
@@ -1591,6 +1593,9 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1591 timeout = wait_for_completion_timeout(&cmd_wait, 1593 timeout = wait_for_completion_timeout(&cmd_wait,
1592 msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS)); 1594 msecs_to_jiffies(MWL8K_CMD_TIMEOUT_MS));
1593 1595
1596 pci_unmap_single(priv->pdev, dma_addr, dma_size,
1597 PCI_DMA_BIDIRECTIONAL);
1598
1594 result = &cmd->result; 1599 result = &cmd->result;
1595 if (!timeout) { 1600 if (!timeout) {
1596 spin_lock_irq(&priv->fw_lock); 1601 spin_lock_irq(&priv->fw_lock);
@@ -1610,8 +1615,6 @@ static int mwl8k_post_cmd(struct ieee80211_hw *hw, struct mwl8k_cmd_pkt *cmd)
1610 *result); 1615 *result);
1611 } 1616 }
1612 1617
1613 pci_unmap_single(priv->pdev, dma_addr, dma_size,
1614 PCI_DMA_BIDIRECTIONAL);
1615 return rc; 1618 return rc;
1616} 1619}
1617 1620
@@ -1654,18 +1657,18 @@ static int mwl8k_cmd_get_hw_spec(struct ieee80211_hw *hw)
1654 memset(cmd->perm_addr, 0xff, sizeof(cmd->perm_addr)); 1657 memset(cmd->perm_addr, 0xff, sizeof(cmd->perm_addr));
1655 cmd->ps_cookie = cpu_to_le32(priv->cookie_dma); 1658 cmd->ps_cookie = cpu_to_le32(priv->cookie_dma);
1656 cmd->rx_queue_ptr = cpu_to_le32(priv->rxq[0].rx_desc_dma); 1659 cmd->rx_queue_ptr = cpu_to_le32(priv->rxq[0].rx_desc_dma);
1657 cmd->num_tx_queues = MWL8K_TX_QUEUES; 1660 cmd->num_tx_queues = cpu_to_le32(MWL8K_TX_QUEUES);
1658 for (i = 0; i < MWL8K_TX_QUEUES; i++) 1661 for (i = 0; i < MWL8K_TX_QUEUES; i++)
1659 cmd->tx_queue_ptrs[i] = cpu_to_le32(priv->txq[i].tx_desc_dma); 1662 cmd->tx_queue_ptrs[i] = cpu_to_le32(priv->txq[i].tx_desc_dma);
1660 cmd->num_tx_desc_per_queue = MWL8K_TX_DESCS; 1663 cmd->num_tx_desc_per_queue = cpu_to_le32(MWL8K_TX_DESCS);
1661 cmd->total_rx_desc = MWL8K_RX_DESCS; 1664 cmd->total_rx_desc = cpu_to_le32(MWL8K_RX_DESCS);
1662 1665
1663 rc = mwl8k_post_cmd(hw, &cmd->header); 1666 rc = mwl8k_post_cmd(hw, &cmd->header);
1664 1667
1665 if (!rc) { 1668 if (!rc) {
1666 SET_IEEE80211_PERM_ADDR(hw, cmd->perm_addr); 1669 SET_IEEE80211_PERM_ADDR(hw, cmd->perm_addr);
1667 priv->num_mcaddrs = le16_to_cpu(cmd->num_mcaddrs); 1670 priv->num_mcaddrs = le16_to_cpu(cmd->num_mcaddrs);
1668 priv->fw_rev = cmd->fw_rev; 1671 priv->fw_rev = le32_to_cpu(cmd->fw_rev);
1669 priv->hw_rev = cmd->hw_rev; 1672 priv->hw_rev = cmd->hw_rev;
1670 priv->region_code = le16_to_cpu(cmd->region_code); 1673 priv->region_code = le16_to_cpu(cmd->region_code);
1671 } 1674 }
@@ -3216,15 +3219,19 @@ static int mwl8k_configure_filter_wt(struct work_struct *wt)
3216 struct dev_addr_list *mclist = worker->mclist; 3219 struct dev_addr_list *mclist = worker->mclist;
3217 3220
3218 struct mwl8k_priv *priv = hw->priv; 3221 struct mwl8k_priv *priv = hw->priv;
3219 struct mwl8k_vif *mv_vif;
3220 int rc = 0; 3222 int rc = 0;
3221 3223
3222 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { 3224 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
3223 if (*total_flags & FIF_BCN_PRBRESP_PROMISC) 3225 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
3224 rc = mwl8k_cmd_set_pre_scan(hw); 3226 rc = mwl8k_cmd_set_pre_scan(hw);
3225 else { 3227 else {
3226 mv_vif = MWL8K_VIF(priv->vif); 3228 u8 *bssid;
3227 rc = mwl8k_cmd_set_post_scan(hw, mv_vif->bssid); 3229
3230 bssid = "\x00\x00\x00\x00\x00\x00";
3231 if (priv->vif != NULL)
3232 bssid = MWL8K_VIF(priv->vif)->bssid;
3233
3234 rc = mwl8k_cmd_set_post_scan(hw, bssid);
3228 } 3235 }
3229 } 3236 }
3230 3237
@@ -3726,6 +3733,8 @@ static void __devexit mwl8k_remove(struct pci_dev *pdev)
3726 3733
3727 ieee80211_stop_queues(hw); 3734 ieee80211_stop_queues(hw);
3728 3735
3736 ieee80211_unregister_hw(hw);
3737
3729 /* Remove tx reclaim tasklet */ 3738 /* Remove tx reclaim tasklet */
3730 tasklet_kill(&priv->tx_reclaim_task); 3739 tasklet_kill(&priv->tx_reclaim_task);
3731 3740
@@ -3739,8 +3748,6 @@ static void __devexit mwl8k_remove(struct pci_dev *pdev)
3739 for (i = 0; i < MWL8K_TX_QUEUES; i++) 3748 for (i = 0; i < MWL8K_TX_QUEUES; i++)
3740 mwl8k_txq_reclaim(hw, i, 1); 3749 mwl8k_txq_reclaim(hw, i, 1);
3741 3750
3742 ieee80211_unregister_hw(hw);
3743
3744 for (i = 0; i < MWL8K_TX_QUEUES; i++) 3751 for (i = 0; i < MWL8K_TX_QUEUES; i++)
3745 mwl8k_txq_deinit(hw, i); 3752 mwl8k_txq_deinit(hw, i);
3746 3753
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c
index 632fac86a308..b3946272c72e 100644
--- a/drivers/net/wireless/orinoco/hw.c
+++ b/drivers/net/wireless/orinoco/hw.c
@@ -70,7 +70,7 @@ int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc)
70 int err = 0; 70 int err = 0;
71 u8 tsc_arr[4][IW_ENCODE_SEQ_MAX_SIZE]; 71 u8 tsc_arr[4][IW_ENCODE_SEQ_MAX_SIZE];
72 72
73 if ((key < 0) || (key > 4)) 73 if ((key < 0) || (key >= 4))
74 return -EINVAL; 74 return -EINVAL;
75 75
76 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_TKIP_IV, 76 err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CURRENT_TKIP_IV,
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
index a498dde024e1..49c9e2c1433d 100644
--- a/drivers/net/wireless/rt2x00/rt2x00.h
+++ b/drivers/net/wireless/rt2x00/rt2x00.h
@@ -849,13 +849,15 @@ struct rt2x00_dev {
849static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev, 849static inline void rt2x00_rf_read(struct rt2x00_dev *rt2x00dev,
850 const unsigned int word, u32 *data) 850 const unsigned int word, u32 *data)
851{ 851{
852 *data = rt2x00dev->rf[word]; 852 BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
853 *data = rt2x00dev->rf[word - 1];
853} 854}
854 855
855static inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev, 856static inline void rt2x00_rf_write(struct rt2x00_dev *rt2x00dev,
856 const unsigned int word, u32 data) 857 const unsigned int word, u32 data)
857{ 858{
858 rt2x00dev->rf[word] = data; 859 BUG_ON(word < 1 || word > rt2x00dev->ops->rf_size / sizeof(u32));
860 rt2x00dev->rf[word - 1] = data;
859} 861}
860 862
861/* 863/*
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c
index 294250e294dd..87a95588a8e3 100644
--- a/drivers/net/wireless/rtl818x/rtl8187_dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c
@@ -869,6 +869,9 @@ static int rtl8187b_init_hw(struct ieee80211_hw *dev)
869 priv->aifsn[3] = 3; /* AIFSN[AC_BE] */ 869 priv->aifsn[3] = 3; /* AIFSN[AC_BE] */
870 rtl818x_iowrite8(priv, &priv->map->ACM_CONTROL, 0); 870 rtl818x_iowrite8(priv, &priv->map->ACM_CONTROL, 0);
871 871
872 /* ENEDCA flag must always be set, transmit issues? */
873 rtl818x_iowrite8(priv, &priv->map->MSR, RTL818X_MSR_ENEDCA);
874
872 return 0; 875 return 0;
873} 876}
874 877
@@ -1173,13 +1176,16 @@ static void rtl8187_bss_info_changed(struct ieee80211_hw *dev,
1173 rtl818x_iowrite8(priv, &priv->map->BSSID[i], 1176 rtl818x_iowrite8(priv, &priv->map->BSSID[i],
1174 info->bssid[i]); 1177 info->bssid[i]);
1175 1178
1179 if (priv->is_rtl8187b)
1180 reg = RTL818X_MSR_ENEDCA;
1181 else
1182 reg = 0;
1183
1176 if (is_valid_ether_addr(info->bssid)) { 1184 if (is_valid_ether_addr(info->bssid)) {
1177 reg = RTL818X_MSR_INFRA; 1185 reg |= RTL818X_MSR_INFRA;
1178 if (priv->is_rtl8187b)
1179 reg |= RTL818X_MSR_ENEDCA;
1180 rtl818x_iowrite8(priv, &priv->map->MSR, reg); 1186 rtl818x_iowrite8(priv, &priv->map->MSR, reg);
1181 } else { 1187 } else {
1182 reg = RTL818X_MSR_NO_LINK; 1188 reg |= RTL818X_MSR_NO_LINK;
1183 rtl818x_iowrite8(priv, &priv->map->MSR, reg); 1189 rtl818x_iowrite8(priv, &priv->map->MSR, reg);
1184 } 1190 }
1185 1191
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 40b07b988224..3bd3c779fff3 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -698,7 +698,7 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
698 && !mac->pass_ctrl) 698 && !mac->pass_ctrl)
699 return 0; 699 return 0;
700 700
701 fc = *(__le16 *)buffer; 701 fc = get_unaligned((__le16*)buffer);
702 need_padding = ieee80211_is_data_qos(fc) ^ ieee80211_has_a4(fc); 702 need_padding = ieee80211_is_data_qos(fc) ^ ieee80211_has_a4(fc);
703 703
704 skb = dev_alloc_skb(length + (need_padding ? 2 : 0)); 704 skb = dev_alloc_skb(length + (need_padding ? 2 : 0));
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c
index a07580138e81..c2fd6187773f 100644
--- a/drivers/net/yellowfin.c
+++ b/drivers/net/yellowfin.c
@@ -346,7 +346,7 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
346static int yellowfin_open(struct net_device *dev); 346static int yellowfin_open(struct net_device *dev);
347static void yellowfin_timer(unsigned long data); 347static void yellowfin_timer(unsigned long data);
348static void yellowfin_tx_timeout(struct net_device *dev); 348static void yellowfin_tx_timeout(struct net_device *dev);
349static void yellowfin_init_ring(struct net_device *dev); 349static int yellowfin_init_ring(struct net_device *dev);
350static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev); 350static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev);
351static irqreturn_t yellowfin_interrupt(int irq, void *dev_instance); 351static irqreturn_t yellowfin_interrupt(int irq, void *dev_instance);
352static int yellowfin_rx(struct net_device *dev); 352static int yellowfin_rx(struct net_device *dev);
@@ -573,19 +573,24 @@ static int yellowfin_open(struct net_device *dev)
573{ 573{
574 struct yellowfin_private *yp = netdev_priv(dev); 574 struct yellowfin_private *yp = netdev_priv(dev);
575 void __iomem *ioaddr = yp->base; 575 void __iomem *ioaddr = yp->base;
576 int i; 576 int i, ret;
577 577
578 /* Reset the chip. */ 578 /* Reset the chip. */
579 iowrite32(0x80000000, ioaddr + DMACtrl); 579 iowrite32(0x80000000, ioaddr + DMACtrl);
580 580
581 i = request_irq(dev->irq, &yellowfin_interrupt, IRQF_SHARED, dev->name, dev); 581 ret = request_irq(dev->irq, &yellowfin_interrupt, IRQF_SHARED, dev->name, dev);
582 if (i) return i; 582 if (ret)
583 return ret;
583 584
584 if (yellowfin_debug > 1) 585 if (yellowfin_debug > 1)
585 printk(KERN_DEBUG "%s: yellowfin_open() irq %d.\n", 586 printk(KERN_DEBUG "%s: yellowfin_open() irq %d.\n",
586 dev->name, dev->irq); 587 dev->name, dev->irq);
587 588
588 yellowfin_init_ring(dev); 589 ret = yellowfin_init_ring(dev);
590 if (ret) {
591 free_irq(dev->irq, dev);
592 return ret;
593 }
589 594
590 iowrite32(yp->rx_ring_dma, ioaddr + RxPtr); 595 iowrite32(yp->rx_ring_dma, ioaddr + RxPtr);
591 iowrite32(yp->tx_ring_dma, ioaddr + TxPtr); 596 iowrite32(yp->tx_ring_dma, ioaddr + TxPtr);
@@ -725,10 +730,10 @@ static void yellowfin_tx_timeout(struct net_device *dev)
725} 730}
726 731
727/* Initialize the Rx and Tx rings, along with various 'dev' bits. */ 732/* Initialize the Rx and Tx rings, along with various 'dev' bits. */
728static void yellowfin_init_ring(struct net_device *dev) 733static int yellowfin_init_ring(struct net_device *dev)
729{ 734{
730 struct yellowfin_private *yp = netdev_priv(dev); 735 struct yellowfin_private *yp = netdev_priv(dev);
731 int i; 736 int i, j;
732 737
733 yp->tx_full = 0; 738 yp->tx_full = 0;
734 yp->cur_rx = yp->cur_tx = 0; 739 yp->cur_rx = yp->cur_tx = 0;
@@ -753,6 +758,11 @@ static void yellowfin_init_ring(struct net_device *dev)
753 yp->rx_ring[i].addr = cpu_to_le32(pci_map_single(yp->pci_dev, 758 yp->rx_ring[i].addr = cpu_to_le32(pci_map_single(yp->pci_dev,
754 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE)); 759 skb->data, yp->rx_buf_sz, PCI_DMA_FROMDEVICE));
755 } 760 }
761 if (i != RX_RING_SIZE) {
762 for (j = 0; j < i; j++)
763 dev_kfree_skb(yp->rx_skbuff[j]);
764 return -ENOMEM;
765 }
756 yp->rx_ring[i-1].dbdma_cmd = cpu_to_le32(CMD_STOP); 766 yp->rx_ring[i-1].dbdma_cmd = cpu_to_le32(CMD_STOP);
757 yp->dirty_rx = (unsigned int)(i - RX_RING_SIZE); 767 yp->dirty_rx = (unsigned int)(i - RX_RING_SIZE);
758 768
@@ -769,8 +779,6 @@ static void yellowfin_init_ring(struct net_device *dev)
769 yp->tx_ring[--i].dbdma_cmd = cpu_to_le32(CMD_STOP | BRANCH_ALWAYS); 779 yp->tx_ring[--i].dbdma_cmd = cpu_to_le32(CMD_STOP | BRANCH_ALWAYS);
770#else 780#else
771{ 781{
772 int j;
773
774 /* Tx ring needs a pair of descriptors, the second for the status. */ 782 /* Tx ring needs a pair of descriptors, the second for the status. */
775 for (i = 0; i < TX_RING_SIZE; i++) { 783 for (i = 0; i < TX_RING_SIZE; i++) {
776 j = 2*i; 784 j = 2*i;
@@ -805,7 +813,7 @@ static void yellowfin_init_ring(struct net_device *dev)
805} 813}
806#endif 814#endif
807 yp->tx_tail_desc = &yp->tx_status[0]; 815 yp->tx_tail_desc = &yp->tx_status[0];
808 return; 816 return 0;
809} 817}
810 818
811static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev) 819static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev)
diff --git a/drivers/net/zorro8390.c b/drivers/net/zorro8390.c
index 37c84e3b8be0..81c753a617ab 100644
--- a/drivers/net/zorro8390.c
+++ b/drivers/net/zorro8390.c
@@ -120,6 +120,9 @@ static int __devinit zorro8390_init_one(struct zorro_dev *z,
120 for (i = ARRAY_SIZE(cards)-1; i >= 0; i--) 120 for (i = ARRAY_SIZE(cards)-1; i >= 0; i--)
121 if (z->id == cards[i].id) 121 if (z->id == cards[i].id)
122 break; 122 break;
123 if (i < 0)
124 return -ENODEV;
125
123 board = z->resource.start; 126 board = z->resource.start;
124 ioaddr = board+cards[i].offset; 127 ioaddr = board+cards[i].offset;
125 dev = alloc_ei_netdev(); 128 dev = alloc_ei_netdev();
diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c
index 0f0e0b919ef4..a45b0c0d574e 100644
--- a/drivers/parisc/ccio-dma.c
+++ b/drivers/parisc/ccio-dma.c
@@ -70,7 +70,6 @@
70#undef CCIO_COLLECT_STATS 70#undef CCIO_COLLECT_STATS
71#endif 71#endif
72 72
73#include <linux/proc_fs.h>
74#include <asm/runway.h> /* for proc_runway_root */ 73#include <asm/runway.h> /* for proc_runway_root */
75 74
76#ifdef DEBUG_CCIO_INIT 75#ifdef DEBUG_CCIO_INIT
diff --git a/drivers/parisc/dino.c b/drivers/parisc/dino.c
index c590974e9815..d69bde6a2343 100644
--- a/drivers/parisc/dino.c
+++ b/drivers/parisc/dino.c
@@ -614,7 +614,7 @@ dino_fixup_bus(struct pci_bus *bus)
614 dev_name(&bus->self->dev), i, 614 dev_name(&bus->self->dev), i,
615 bus->self->resource[i].start, 615 bus->self->resource[i].start,
616 bus->self->resource[i].end); 616 bus->self->resource[i].end);
617 pci_assign_resource(bus->self, i); 617 WARN_ON(pci_assign_resource(bus->self, i));
618 DBG("DEBUG %s after assign %d [0x%lx,0x%lx]\n", 618 DBG("DEBUG %s after assign %d [0x%lx,0x%lx]\n",
619 dev_name(&bus->self->dev), i, 619 dev_name(&bus->self->dev), i,
620 bus->self->resource[i].start, 620 bus->self->resource[i].start,
diff --git a/drivers/parisc/eisa_eeprom.c b/drivers/parisc/eisa_eeprom.c
index 685d94e69d44..8c0b26e9b98a 100644
--- a/drivers/parisc/eisa_eeprom.c
+++ b/drivers/parisc/eisa_eeprom.c
@@ -55,7 +55,7 @@ static ssize_t eisa_eeprom_read(struct file * file,
55 ssize_t ret; 55 ssize_t ret;
56 int i; 56 int i;
57 57
58 if (*ppos >= HPEE_MAX_LENGTH) 58 if (*ppos < 0 || *ppos >= HPEE_MAX_LENGTH)
59 return 0; 59 return 0;
60 60
61 count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos; 61 count = *ppos + count < HPEE_MAX_LENGTH ? count : HPEE_MAX_LENGTH - *ppos;
diff --git a/drivers/parisc/hppb.c b/drivers/parisc/hppb.c
index 13856415b432..815db175d427 100644
--- a/drivers/parisc/hppb.c
+++ b/drivers/parisc/hppb.c
@@ -62,7 +62,8 @@ static int hppb_probe(struct parisc_device *dev)
62 } 62 }
63 card = card->next; 63 card = card->next;
64 } 64 }
65 printk(KERN_INFO "Found GeckoBoa at 0x%x\n", dev->hpa.start); 65 printk(KERN_INFO "Found GeckoBoa at 0x%llx\n",
66 (unsigned long long) dev->hpa.start);
66 67
67 card->hpa = dev->hpa.start; 68 card->hpa = dev->hpa.start;
68 card->mmio_region.name = "HP-PB Bus"; 69 card->mmio_region.name = "HP-PB Bus";
@@ -73,8 +74,10 @@ static int hppb_probe(struct parisc_device *dev)
73 74
74 status = ccio_request_resource(dev, &card->mmio_region); 75 status = ccio_request_resource(dev, &card->mmio_region);
75 if(status < 0) { 76 if(status < 0) {
76 printk(KERN_ERR "%s: failed to claim HP-PB bus space (%08x, %08x)\n", 77 printk(KERN_ERR "%s: failed to claim HP-PB "
77 __FILE__, card->mmio_region.start, card->mmio_region.end); 78 "bus space (0x%08llx, 0x%08llx)\n",
79 __FILE__, (unsigned long long) card->mmio_region.start,
80 (unsigned long long) card->mmio_region.end);
78 } 81 }
79 82
80 return 0; 83 return 0;
diff --git a/drivers/parisc/lba_pci.c b/drivers/parisc/lba_pci.c
index ede614616f8e..3aeb3279c92a 100644
--- a/drivers/parisc/lba_pci.c
+++ b/drivers/parisc/lba_pci.c
@@ -992,7 +992,7 @@ lba_pat_resources(struct parisc_device *pa_dev, struct lba_device *lba_dev)
992 return; 992 return;
993 993
994 io_pdc_cell = kzalloc(sizeof(pdc_pat_cell_mod_maddr_block_t), GFP_KERNEL); 994 io_pdc_cell = kzalloc(sizeof(pdc_pat_cell_mod_maddr_block_t), GFP_KERNEL);
995 if (!pa_pdc_cell) { 995 if (!io_pdc_cell) {
996 kfree(pa_pdc_cell); 996 kfree(pa_pdc_cell);
997 return; 997 return;
998 } 998 }
diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index f9f9a5f1bbd0..13a64bc081b6 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -370,7 +370,7 @@ pdcspath_layer_read(struct pdcspath_entry *entry, char *buf)
370 if (!i) /* entry is not ready */ 370 if (!i) /* entry is not ready */
371 return -ENODATA; 371 return -ENODATA;
372 372
373 for (i = 0; devpath->layers[i] && (likely(i < 6)); i++) 373 for (i = 0; i < 6 && devpath->layers[i]; i++)
374 out += sprintf(out, "%u ", devpath->layers[i]); 374 out += sprintf(out, "%u ", devpath->layers[i]);
375 375
376 out += sprintf(out, "\n"); 376 out += sprintf(out, "\n");
diff --git a/drivers/pci/hotplug/sgi_hotplug.c b/drivers/pci/hotplug/sgi_hotplug.c
index a4494d78e7c2..8aebe1e9d3d6 100644
--- a/drivers/pci/hotplug/sgi_hotplug.c
+++ b/drivers/pci/hotplug/sgi_hotplug.c
@@ -90,11 +90,10 @@ static struct hotplug_slot_ops sn_hotplug_slot_ops = {
90 90
91static DEFINE_MUTEX(sn_hotplug_mutex); 91static DEFINE_MUTEX(sn_hotplug_mutex);
92 92
93static ssize_t path_show (struct hotplug_slot *bss_hotplug_slot, 93static ssize_t path_show(struct pci_slot *pci_slot, char *buf)
94 char *buf)
95{ 94{
96 int retval = -ENOENT; 95 int retval = -ENOENT;
97 struct slot *slot = bss_hotplug_slot->private; 96 struct slot *slot = pci_slot->hotplug->private;
98 97
99 if (!slot) 98 if (!slot)
100 return retval; 99 return retval;
@@ -103,7 +102,7 @@ static ssize_t path_show (struct hotplug_slot *bss_hotplug_slot,
103 return retval; 102 return retval;
104} 103}
105 104
106static struct hotplug_slot_attribute sn_slot_path_attr = __ATTR_RO(path); 105static struct pci_slot_attribute sn_slot_path_attr = __ATTR_RO(path);
107 106
108static int sn_pci_slot_valid(struct pci_bus *pci_bus, int device) 107static int sn_pci_slot_valid(struct pci_bus *pci_bus, int device)
109{ 108{
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index ebc9b8dca881..2314ad7ee5fe 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -1505,7 +1505,6 @@ static int domain_context_mapping_one(struct dmar_domain *domain, int segment,
1505 } 1505 }
1506 1506
1507 set_bit(num, iommu->domain_ids); 1507 set_bit(num, iommu->domain_ids);
1508 set_bit(iommu->seq_id, &domain->iommu_bmp);
1509 iommu->domains[num] = domain; 1508 iommu->domains[num] = domain;
1510 id = num; 1509 id = num;
1511 } 1510 }
@@ -1648,6 +1647,14 @@ static int domain_context_mapped(struct pci_dev *pdev)
1648 tmp->devfn); 1647 tmp->devfn);
1649} 1648}
1650 1649
1650/* Returns a number of VTD pages, but aligned to MM page size */
1651static inline unsigned long aligned_nrpages(unsigned long host_addr,
1652 size_t size)
1653{
1654 host_addr &= ~PAGE_MASK;
1655 return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT;
1656}
1657
1651static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn, 1658static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1652 struct scatterlist *sg, unsigned long phys_pfn, 1659 struct scatterlist *sg, unsigned long phys_pfn,
1653 unsigned long nr_pages, int prot) 1660 unsigned long nr_pages, int prot)
@@ -1675,7 +1682,7 @@ static int __domain_mapping(struct dmar_domain *domain, unsigned long iov_pfn,
1675 uint64_t tmp; 1682 uint64_t tmp;
1676 1683
1677 if (!sg_res) { 1684 if (!sg_res) {
1678 sg_res = (sg->offset + sg->length + VTD_PAGE_SIZE - 1) >> VTD_PAGE_SHIFT; 1685 sg_res = aligned_nrpages(sg->offset, sg->length);
1679 sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset; 1686 sg->dma_address = ((dma_addr_t)iov_pfn << VTD_PAGE_SHIFT) + sg->offset;
1680 sg->dma_length = sg->length; 1687 sg->dma_length = sg->length;
1681 pteval = page_to_phys(sg_page(sg)) | prot; 1688 pteval = page_to_phys(sg_page(sg)) | prot;
@@ -2415,14 +2422,6 @@ error:
2415 return ret; 2422 return ret;
2416} 2423}
2417 2424
2418/* Returns a number of VTD pages, but aligned to MM page size */
2419static inline unsigned long aligned_nrpages(unsigned long host_addr,
2420 size_t size)
2421{
2422 host_addr &= ~PAGE_MASK;
2423 return PAGE_ALIGN(host_addr + size) >> VTD_PAGE_SHIFT;
2424}
2425
2426/* This takes a number of _MM_ pages, not VTD pages */ 2425/* This takes a number of _MM_ pages, not VTD pages */
2427static struct iova *intel_alloc_iova(struct device *dev, 2426static struct iova *intel_alloc_iova(struct device *dev,
2428 struct dmar_domain *domain, 2427 struct dmar_domain *domain,
@@ -2551,6 +2550,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2551 int prot = 0; 2550 int prot = 0;
2552 int ret; 2551 int ret;
2553 struct intel_iommu *iommu; 2552 struct intel_iommu *iommu;
2553 unsigned long paddr_pfn = paddr >> PAGE_SHIFT;
2554 2554
2555 BUG_ON(dir == DMA_NONE); 2555 BUG_ON(dir == DMA_NONE);
2556 2556
@@ -2585,7 +2585,7 @@ static dma_addr_t __intel_map_single(struct device *hwdev, phys_addr_t paddr,
2585 * is not a big problem 2585 * is not a big problem
2586 */ 2586 */
2587 ret = domain_pfn_mapping(domain, mm_to_dma_pfn(iova->pfn_lo), 2587 ret = domain_pfn_mapping(domain, mm_to_dma_pfn(iova->pfn_lo),
2588 paddr >> VTD_PAGE_SHIFT, size, prot); 2588 mm_to_dma_pfn(paddr_pfn), size, prot);
2589 if (ret) 2589 if (ret)
2590 goto error; 2590 goto error;
2591 2591
@@ -2875,7 +2875,7 @@ static int intel_map_sg(struct device *hwdev, struct scatterlist *sglist, int ne
2875 2875
2876 start_vpfn = mm_to_dma_pfn(iova->pfn_lo); 2876 start_vpfn = mm_to_dma_pfn(iova->pfn_lo);
2877 2877
2878 ret = domain_sg_mapping(domain, start_vpfn, sglist, mm_to_dma_pfn(size), prot); 2878 ret = domain_sg_mapping(domain, start_vpfn, sglist, size, prot);
2879 if (unlikely(ret)) { 2879 if (unlikely(ret)) {
2880 /* clear the page */ 2880 /* clear the page */
2881 dma_pte_clear_range(domain, start_vpfn, 2881 dma_pte_clear_range(domain, start_vpfn,
@@ -3408,6 +3408,7 @@ static int md_domain_init(struct dmar_domain *domain, int guest_width)
3408 3408
3409 domain->iommu_count = 0; 3409 domain->iommu_count = 0;
3410 domain->iommu_coherency = 0; 3410 domain->iommu_coherency = 0;
3411 domain->iommu_snooping = 0;
3411 domain->max_addr = 0; 3412 domain->max_addr = 0;
3412 3413
3413 /* always allocate the top pgd */ 3414 /* always allocate the top pgd */
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index d76c4c85367e..f99bc7f089f1 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -508,7 +508,7 @@ static int pci_restore_standard_config(struct pci_dev *pci_dev)
508 return error; 508 return error;
509 } 509 }
510 510
511 return pci_dev->state_saved ? pci_restore_state(pci_dev) : 0; 511 return pci_restore_state(pci_dev);
512} 512}
513 513
514static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev) 514static void pci_pm_default_resume_noirq(struct pci_dev *pci_dev)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index dbd0f947f497..7b70312181d7 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -846,6 +846,8 @@ pci_restore_state(struct pci_dev *dev)
846 int i; 846 int i;
847 u32 val; 847 u32 val;
848 848
849 if (!dev->state_saved)
850 return 0;
849 /* PCI Express register must be restored first */ 851 /* PCI Express register must be restored first */
850 pci_restore_pcie_state(dev); 852 pci_restore_pcie_state(dev);
851 853
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c
index b711fb7181e2..1898c7b47907 100644
--- a/drivers/pci/setup-res.c
+++ b/drivers/pci/setup-res.c
@@ -100,16 +100,16 @@ int pci_claim_resource(struct pci_dev *dev, int resource)
100{ 100{
101 struct resource *res = &dev->resource[resource]; 101 struct resource *res = &dev->resource[resource];
102 struct resource *root; 102 struct resource *root;
103 char *dtype = resource < PCI_BRIDGE_RESOURCES ? "device" : "bridge";
104 int err; 103 int err;
105 104
106 root = pci_find_parent_resource(dev, res); 105 root = pci_find_parent_resource(dev, res);
107 106
108 err = -EINVAL; 107 err = -EINVAL;
109 if (root != NULL) 108 if (root != NULL)
110 err = insert_resource(root, res); 109 err = request_resource(root, res);
111 110
112 if (err) { 111 if (err) {
112 const char *dtype = resource < PCI_BRIDGE_RESOURCES ? "device" : "bridge";
113 dev_err(&dev->dev, "BAR %d: %s of %s %pR\n", 113 dev_err(&dev->dev, "BAR %d: %s of %s %pR\n",
114 resource, 114 resource,
115 root ? "address space collision on" : 115 root ? "address space collision on" :
diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 46dad12f952f..77c6097ced80 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -277,31 +277,6 @@ config THINKPAD_ACPI_UNSAFE_LEDS
277 Say N here, unless you are building a kernel for your own 277 Say N here, unless you are building a kernel for your own
278 use, and need to control the important firmware LEDs. 278 use, and need to control the important firmware LEDs.
279 279
280config THINKPAD_ACPI_DOCK
281 bool "Legacy Docking Station Support"
282 depends on THINKPAD_ACPI
283 depends on ACPI_DOCK=n
284 default n
285 ---help---
286 Allows the thinkpad_acpi driver to handle docking station events.
287 This support was made obsolete by the generic ACPI docking station
288 support (CONFIG_ACPI_DOCK). It will allow locking and removing the
289 laptop from the docking station, but will not properly connect PCI
290 devices.
291
292 If you are not sure, say N here.
293
294config THINKPAD_ACPI_BAY
295 bool "Legacy Removable Bay Support"
296 depends on THINKPAD_ACPI
297 default y
298 ---help---
299 Allows the thinkpad_acpi driver to handle removable bays. It will
300 electrically disable the device in the bay, and also generate
301 notifications when the bay lever is ejected or inserted.
302
303 If you are not sure, say Y here.
304
305config THINKPAD_ACPI_VIDEO 280config THINKPAD_ACPI_VIDEO
306 bool "Video output control support" 281 bool "Video output control support"
307 depends on THINKPAD_ACPI 282 depends on THINKPAD_ACPI
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index ec560f16d720..222ffb892f22 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -143,6 +143,7 @@ struct eeepc_hotk {
143 struct rfkill *bluetooth_rfkill; 143 struct rfkill *bluetooth_rfkill;
144 struct rfkill *wwan3g_rfkill; 144 struct rfkill *wwan3g_rfkill;
145 struct hotplug_slot *hotplug_slot; 145 struct hotplug_slot *hotplug_slot;
146 struct work_struct hotplug_work;
146}; 147};
147 148
148/* The actual device the driver binds to */ 149/* The actual device the driver binds to */
@@ -660,7 +661,7 @@ static int eeepc_get_adapter_status(struct hotplug_slot *hotplug_slot,
660 return 0; 661 return 0;
661} 662}
662 663
663static void eeepc_rfkill_hotplug(void) 664static void eeepc_hotplug_work(struct work_struct *work)
664{ 665{
665 struct pci_dev *dev; 666 struct pci_dev *dev;
666 struct pci_bus *bus = pci_find_bus(0, 1); 667 struct pci_bus *bus = pci_find_bus(0, 1);
@@ -701,7 +702,7 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
701 if (event != ACPI_NOTIFY_BUS_CHECK) 702 if (event != ACPI_NOTIFY_BUS_CHECK)
702 return; 703 return;
703 704
704 eeepc_rfkill_hotplug(); 705 schedule_work(&ehotk->hotplug_work);
705} 706}
706 707
707static void eeepc_hotk_notify(struct acpi_device *device, u32 event) 708static void eeepc_hotk_notify(struct acpi_device *device, u32 event)
@@ -892,7 +893,7 @@ static int eeepc_hotk_resume(struct acpi_device *device)
892 893
893 rfkill_set_sw_state(ehotk->wlan_rfkill, wlan != 1); 894 rfkill_set_sw_state(ehotk->wlan_rfkill, wlan != 1);
894 895
895 eeepc_rfkill_hotplug(); 896 schedule_work(&ehotk->hotplug_work);
896 } 897 }
897 898
898 if (ehotk->bluetooth_rfkill) 899 if (ehotk->bluetooth_rfkill)
@@ -1093,6 +1094,8 @@ static int eeepc_rfkill_init(struct device *dev)
1093{ 1094{
1094 int result = 0; 1095 int result = 0;
1095 1096
1097 INIT_WORK(&ehotk->hotplug_work, eeepc_hotplug_work);
1098
1096 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6"); 1099 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P6");
1097 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7"); 1100 eeepc_register_rfkill_notifier("\\_SB.PCI0.P0P7");
1098 1101
diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
index ca508564a181..a2ad53e15874 100644
--- a/drivers/platform/x86/hp-wmi.c
+++ b/drivers/platform/x86/hp-wmi.c
@@ -520,11 +520,13 @@ static int hp_wmi_resume_handler(struct platform_device *device)
520 * the input layer will only actually pass it on if the state 520 * the input layer will only actually pass it on if the state
521 * changed. 521 * changed.
522 */ 522 */
523 523 if (hp_wmi_input_dev) {
524 input_report_switch(hp_wmi_input_dev, SW_DOCK, hp_wmi_dock_state()); 524 input_report_switch(hp_wmi_input_dev, SW_DOCK,
525 input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, 525 hp_wmi_dock_state());
526 hp_wmi_tablet_state()); 526 input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE,
527 input_sync(hp_wmi_input_dev); 527 hp_wmi_tablet_state());
528 input_sync(hp_wmi_input_dev);
529 }
528 530
529 return 0; 531 return 0;
530} 532}
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index a463fd72c495..e85600852502 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -239,12 +239,6 @@ struct ibm_init_struct {
239}; 239};
240 240
241static struct { 241static struct {
242#ifdef CONFIG_THINKPAD_ACPI_BAY
243 u32 bay_status:1;
244 u32 bay_eject:1;
245 u32 bay_status2:1;
246 u32 bay_eject2:1;
247#endif
248 u32 bluetooth:1; 242 u32 bluetooth:1;
249 u32 hotkey:1; 243 u32 hotkey:1;
250 u32 hotkey_mask:1; 244 u32 hotkey_mask:1;
@@ -589,18 +583,6 @@ static int acpi_ec_write(int i, u8 v)
589 return 1; 583 return 1;
590} 584}
591 585
592#if defined(CONFIG_THINKPAD_ACPI_DOCK) || defined(CONFIG_THINKPAD_ACPI_BAY)
593static int _sta(acpi_handle handle)
594{
595 int status;
596
597 if (!handle || !acpi_evalf(handle, &status, "_STA", "d"))
598 status = 0;
599
600 return status;
601}
602#endif
603
604static int issue_thinkpad_cmos_command(int cmos_cmd) 586static int issue_thinkpad_cmos_command(int cmos_cmd)
605{ 587{
606 if (!cmos_handle) 588 if (!cmos_handle)
@@ -784,6 +766,8 @@ static int dispatch_procfs_write(struct file *file,
784 766
785 if (!ibm || !ibm->write) 767 if (!ibm || !ibm->write)
786 return -EINVAL; 768 return -EINVAL;
769 if (count > PAGE_SIZE - 2)
770 return -EINVAL;
787 771
788 kernbuf = kmalloc(count + 2, GFP_KERNEL); 772 kernbuf = kmalloc(count + 2, GFP_KERNEL);
789 if (!kernbuf) 773 if (!kernbuf)
@@ -4442,293 +4426,6 @@ static struct ibm_struct light_driver_data = {
4442}; 4426};
4443 4427
4444/************************************************************************* 4428/*************************************************************************
4445 * Dock subdriver
4446 */
4447
4448#ifdef CONFIG_THINKPAD_ACPI_DOCK
4449
4450static void dock_notify(struct ibm_struct *ibm, u32 event);
4451static int dock_read(char *p);
4452static int dock_write(char *buf);
4453
4454TPACPI_HANDLE(dock, root, "\\_SB.GDCK", /* X30, X31, X40 */
4455 "\\_SB.PCI0.DOCK", /* 600e/x,770e,770x,A2xm/p,T20-22,X20-21 */
4456 "\\_SB.PCI0.PCI1.DOCK", /* all others */
4457 "\\_SB.PCI.ISA.SLCE", /* 570 */
4458 ); /* A21e,G4x,R30,R31,R32,R40,R40e,R50e */
4459
4460/* don't list other alternatives as we install a notify handler on the 570 */
4461TPACPI_HANDLE(pci, root, "\\_SB.PCI"); /* 570 */
4462
4463static const struct acpi_device_id ibm_pci_device_ids[] = {
4464 {PCI_ROOT_HID_STRING, 0},
4465 {"", 0},
4466};
4467
4468static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
4469 {
4470 .notify = dock_notify,
4471 .handle = &dock_handle,
4472 .type = ACPI_SYSTEM_NOTIFY,
4473 },
4474 {
4475 /* THIS ONE MUST NEVER BE USED FOR DRIVER AUTOLOADING.
4476 * We just use it to get notifications of dock hotplug
4477 * in very old thinkpads */
4478 .hid = ibm_pci_device_ids,
4479 .notify = dock_notify,
4480 .handle = &pci_handle,
4481 .type = ACPI_SYSTEM_NOTIFY,
4482 },
4483};
4484
4485static struct ibm_struct dock_driver_data[2] = {
4486 {
4487 .name = "dock",
4488 .read = dock_read,
4489 .write = dock_write,
4490 .acpi = &ibm_dock_acpidriver[0],
4491 },
4492 {
4493 .name = "dock",
4494 .acpi = &ibm_dock_acpidriver[1],
4495 },
4496};
4497
4498#define dock_docked() (_sta(dock_handle) & 1)
4499
4500static int __init dock_init(struct ibm_init_struct *iibm)
4501{
4502 vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver\n");
4503
4504 TPACPI_ACPIHANDLE_INIT(dock);
4505
4506 vdbg_printk(TPACPI_DBG_INIT, "dock is %s\n",
4507 str_supported(dock_handle != NULL));
4508
4509 return (dock_handle)? 0 : 1;
4510}
4511
4512static int __init dock_init2(struct ibm_init_struct *iibm)
4513{
4514 int dock2_needed;
4515
4516 vdbg_printk(TPACPI_DBG_INIT, "initializing dock subdriver part 2\n");
4517
4518 if (dock_driver_data[0].flags.acpi_driver_registered &&
4519 dock_driver_data[0].flags.acpi_notify_installed) {
4520 TPACPI_ACPIHANDLE_INIT(pci);
4521 dock2_needed = (pci_handle != NULL);
4522 vdbg_printk(TPACPI_DBG_INIT,
4523 "dock PCI handler for the TP 570 is %s\n",
4524 str_supported(dock2_needed));
4525 } else {
4526 vdbg_printk(TPACPI_DBG_INIT,
4527 "dock subdriver part 2 not required\n");
4528 dock2_needed = 0;
4529 }
4530
4531 return (dock2_needed)? 0 : 1;
4532}
4533
4534static void dock_notify(struct ibm_struct *ibm, u32 event)
4535{
4536 int docked = dock_docked();
4537 int pci = ibm->acpi->hid && ibm->acpi->device &&
4538 acpi_match_device_ids(ibm->acpi->device, ibm_pci_device_ids);
4539 int data;
4540
4541 if (event == 1 && !pci) /* 570 */
4542 data = 1; /* button */
4543 else if (event == 1 && pci) /* 570 */
4544 data = 3; /* dock */
4545 else if (event == 3 && docked)
4546 data = 1; /* button */
4547 else if (event == 3 && !docked)
4548 data = 2; /* undock */
4549 else if (event == 0 && docked)
4550 data = 3; /* dock */
4551 else {
4552 printk(TPACPI_ERR "unknown dock event %d, status %d\n",
4553 event, _sta(dock_handle));
4554 data = 0; /* unknown */
4555 }
4556 acpi_bus_generate_proc_event(ibm->acpi->device, event, data);
4557 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
4558 dev_name(&ibm->acpi->device->dev),
4559 event, data);
4560}
4561
4562static int dock_read(char *p)
4563{
4564 int len = 0;
4565 int docked = dock_docked();
4566
4567 if (!dock_handle)
4568 len += sprintf(p + len, "status:\t\tnot supported\n");
4569 else if (!docked)
4570 len += sprintf(p + len, "status:\t\tundocked\n");
4571 else {
4572 len += sprintf(p + len, "status:\t\tdocked\n");
4573 len += sprintf(p + len, "commands:\tdock, undock\n");
4574 }
4575
4576 return len;
4577}
4578
4579static int dock_write(char *buf)
4580{
4581 char *cmd;
4582
4583 if (!dock_docked())
4584 return -ENODEV;
4585
4586 while ((cmd = next_cmd(&buf))) {
4587 if (strlencmp(cmd, "undock") == 0) {
4588 if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 0) ||
4589 !acpi_evalf(dock_handle, NULL, "_EJ0", "vd", 1))
4590 return -EIO;
4591 } else if (strlencmp(cmd, "dock") == 0) {
4592 if (!acpi_evalf(dock_handle, NULL, "_DCK", "vd", 1))
4593 return -EIO;
4594 } else
4595 return -EINVAL;
4596 }
4597
4598 return 0;
4599}
4600
4601#endif /* CONFIG_THINKPAD_ACPI_DOCK */
4602
4603/*************************************************************************
4604 * Bay subdriver
4605 */
4606
4607#ifdef CONFIG_THINKPAD_ACPI_BAY
4608
4609TPACPI_HANDLE(bay, root, "\\_SB.PCI.IDE.SECN.MAST", /* 570 */
4610 "\\_SB.PCI0.IDE0.IDES.IDSM", /* 600e/x, 770e, 770x */
4611 "\\_SB.PCI0.SATA.SCND.MSTR", /* T60, X60, Z60 */
4612 "\\_SB.PCI0.IDE0.SCND.MSTR", /* all others */
4613 ); /* A21e, R30, R31 */
4614TPACPI_HANDLE(bay_ej, bay, "_EJ3", /* 600e/x, A2xm/p, A3x */
4615 "_EJ0", /* all others */
4616 ); /* 570,A21e,G4x,R30,R31,R32,R40e,R50e */
4617TPACPI_HANDLE(bay2, root, "\\_SB.PCI0.IDE0.PRIM.SLAV", /* A3x, R32 */
4618 "\\_SB.PCI0.IDE0.IDEP.IDPS", /* 600e/x, 770e, 770x */
4619 ); /* all others */
4620TPACPI_HANDLE(bay2_ej, bay2, "_EJ3", /* 600e/x, 770e, A3x */
4621 "_EJ0", /* 770x */
4622 ); /* all others */
4623
4624static int __init bay_init(struct ibm_init_struct *iibm)
4625{
4626 vdbg_printk(TPACPI_DBG_INIT, "initializing bay subdriver\n");
4627
4628 TPACPI_ACPIHANDLE_INIT(bay);
4629 if (bay_handle)
4630 TPACPI_ACPIHANDLE_INIT(bay_ej);
4631 TPACPI_ACPIHANDLE_INIT(bay2);
4632 if (bay2_handle)
4633 TPACPI_ACPIHANDLE_INIT(bay2_ej);
4634
4635 tp_features.bay_status = bay_handle &&
4636 acpi_evalf(bay_handle, NULL, "_STA", "qv");
4637 tp_features.bay_status2 = bay2_handle &&
4638 acpi_evalf(bay2_handle, NULL, "_STA", "qv");
4639
4640 tp_features.bay_eject = bay_handle && bay_ej_handle &&
4641 (strlencmp(bay_ej_path, "_EJ0") == 0 || experimental);
4642 tp_features.bay_eject2 = bay2_handle && bay2_ej_handle &&
4643 (strlencmp(bay2_ej_path, "_EJ0") == 0 || experimental);
4644
4645 vdbg_printk(TPACPI_DBG_INIT,
4646 "bay 1: status %s, eject %s; bay 2: status %s, eject %s\n",
4647 str_supported(tp_features.bay_status),
4648 str_supported(tp_features.bay_eject),
4649 str_supported(tp_features.bay_status2),
4650 str_supported(tp_features.bay_eject2));
4651
4652 return (tp_features.bay_status || tp_features.bay_eject ||
4653 tp_features.bay_status2 || tp_features.bay_eject2)? 0 : 1;
4654}
4655
4656static void bay_notify(struct ibm_struct *ibm, u32 event)
4657{
4658 acpi_bus_generate_proc_event(ibm->acpi->device, event, 0);
4659 acpi_bus_generate_netlink_event(ibm->acpi->device->pnp.device_class,
4660 dev_name(&ibm->acpi->device->dev),
4661 event, 0);
4662}
4663
4664#define bay_occupied(b) (_sta(b##_handle) & 1)
4665
4666static int bay_read(char *p)
4667{
4668 int len = 0;
4669 int occupied = bay_occupied(bay);
4670 int occupied2 = bay_occupied(bay2);
4671 int eject, eject2;
4672
4673 len += sprintf(p + len, "status:\t\t%s\n",
4674 tp_features.bay_status ?
4675 (occupied ? "occupied" : "unoccupied") :
4676 "not supported");
4677 if (tp_features.bay_status2)
4678 len += sprintf(p + len, "status2:\t%s\n", occupied2 ?
4679 "occupied" : "unoccupied");
4680
4681 eject = tp_features.bay_eject && occupied;
4682 eject2 = tp_features.bay_eject2 && occupied2;
4683
4684 if (eject && eject2)
4685 len += sprintf(p + len, "commands:\teject, eject2\n");
4686 else if (eject)
4687 len += sprintf(p + len, "commands:\teject\n");
4688 else if (eject2)
4689 len += sprintf(p + len, "commands:\teject2\n");
4690
4691 return len;
4692}
4693
4694static int bay_write(char *buf)
4695{
4696 char *cmd;
4697
4698 if (!tp_features.bay_eject && !tp_features.bay_eject2)
4699 return -ENODEV;
4700
4701 while ((cmd = next_cmd(&buf))) {
4702 if (tp_features.bay_eject && strlencmp(cmd, "eject") == 0) {
4703 if (!acpi_evalf(bay_ej_handle, NULL, NULL, "vd", 1))
4704 return -EIO;
4705 } else if (tp_features.bay_eject2 &&
4706 strlencmp(cmd, "eject2") == 0) {
4707 if (!acpi_evalf(bay2_ej_handle, NULL, NULL, "vd", 1))
4708 return -EIO;
4709 } else
4710 return -EINVAL;
4711 }
4712
4713 return 0;
4714}
4715
4716static struct tp_acpi_drv_struct ibm_bay_acpidriver = {
4717 .notify = bay_notify,
4718 .handle = &bay_handle,
4719 .type = ACPI_SYSTEM_NOTIFY,
4720};
4721
4722static struct ibm_struct bay_driver_data = {
4723 .name = "bay",
4724 .read = bay_read,
4725 .write = bay_write,
4726 .acpi = &ibm_bay_acpidriver,
4727};
4728
4729#endif /* CONFIG_THINKPAD_ACPI_BAY */
4730
4731/*************************************************************************
4732 * CMOS subdriver 4429 * CMOS subdriver
4733 */ 4430 */
4734 4431
@@ -5945,14 +5642,48 @@ static struct backlight_ops ibm_backlight_data = {
5945 5642
5946/* --------------------------------------------------------------------- */ 5643/* --------------------------------------------------------------------- */
5947 5644
5645/*
5646 * These are only useful for models that have only one possibility
5647 * of GPU. If the BIOS model handles both ATI and Intel, don't use
5648 * these quirks.
5649 */
5650#define TPACPI_BRGHT_Q_NOEC 0x0001 /* Must NOT use EC HBRV */
5651#define TPACPI_BRGHT_Q_EC 0x0002 /* Should or must use EC HBRV */
5652#define TPACPI_BRGHT_Q_ASK 0x8000 /* Ask for user report */
5653
5654static const struct tpacpi_quirk brightness_quirk_table[] __initconst = {
5655 /* Models with ATI GPUs known to require ECNVRAM mode */
5656 TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC), /* T43/p ATI */
5657
5658 /* Models with ATI GPUs (waiting confirmation) */
5659 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
5660 TPACPI_Q_IBM('1', 'Q', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
5661 TPACPI_Q_IBM('7', '6', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
5662 TPACPI_Q_IBM('7', '8', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_EC),
5663
5664 /* Models with Intel Extreme Graphics 2 (waiting confirmation) */
5665 TPACPI_Q_IBM('1', 'V', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC),
5666 TPACPI_Q_IBM('1', 'W', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC),
5667 TPACPI_Q_IBM('1', 'U', TPACPI_BRGHT_Q_ASK|TPACPI_BRGHT_Q_NOEC),
5668
5669 /* Models with Intel GMA900 */
5670 TPACPI_Q_IBM('7', '0', TPACPI_BRGHT_Q_NOEC), /* T43, R52 */
5671 TPACPI_Q_IBM('7', '4', TPACPI_BRGHT_Q_NOEC), /* X41 */
5672 TPACPI_Q_IBM('7', '5', TPACPI_BRGHT_Q_NOEC), /* X41 Tablet */
5673};
5674
5948static int __init brightness_init(struct ibm_init_struct *iibm) 5675static int __init brightness_init(struct ibm_init_struct *iibm)
5949{ 5676{
5950 int b; 5677 int b;
5678 unsigned long quirks;
5951 5679
5952 vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n"); 5680 vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
5953 5681
5954 mutex_init(&brightness_mutex); 5682 mutex_init(&brightness_mutex);
5955 5683
5684 quirks = tpacpi_check_quirks(brightness_quirk_table,
5685 ARRAY_SIZE(brightness_quirk_table));
5686
5956 /* 5687 /*
5957 * We always attempt to detect acpi support, so as to switch 5688 * We always attempt to detect acpi support, so as to switch
5958 * Lenovo Vista BIOS to ACPI brightness mode even if we are not 5689 * Lenovo Vista BIOS to ACPI brightness mode even if we are not
@@ -6009,23 +5740,13 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
6009 /* TPACPI_BRGHT_MODE_AUTO not implemented yet, just use default */ 5740 /* TPACPI_BRGHT_MODE_AUTO not implemented yet, just use default */
6010 if (brightness_mode == TPACPI_BRGHT_MODE_AUTO || 5741 if (brightness_mode == TPACPI_BRGHT_MODE_AUTO ||
6011 brightness_mode == TPACPI_BRGHT_MODE_MAX) { 5742 brightness_mode == TPACPI_BRGHT_MODE_MAX) {
6012 if (thinkpad_id.vendor == PCI_VENDOR_ID_IBM) { 5743 if (quirks & TPACPI_BRGHT_Q_EC)
6013 /* 5744 brightness_mode = TPACPI_BRGHT_MODE_ECNVRAM;
6014 * IBM models that define HBRV probably have 5745 else
6015 * EC-based backlight level control
6016 */
6017 if (acpi_evalf(ec_handle, NULL, "HBRV", "qd"))
6018 /* T40-T43, R50-R52, R50e, R51e, X31-X41 */
6019 brightness_mode = TPACPI_BRGHT_MODE_ECNVRAM;
6020 else
6021 /* all other IBM ThinkPads */
6022 brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP;
6023 } else
6024 /* All Lenovo ThinkPads */
6025 brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP; 5746 brightness_mode = TPACPI_BRGHT_MODE_UCMS_STEP;
6026 5747
6027 dbg_printk(TPACPI_DBG_BRGHT, 5748 dbg_printk(TPACPI_DBG_BRGHT,
6028 "selected brightness_mode=%d\n", 5749 "driver auto-selected brightness_mode=%d\n",
6029 brightness_mode); 5750 brightness_mode);
6030 } 5751 }
6031 5752
@@ -6052,6 +5773,15 @@ static int __init brightness_init(struct ibm_init_struct *iibm)
6052 vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT, 5773 vdbg_printk(TPACPI_DBG_INIT | TPACPI_DBG_BRGHT,
6053 "brightness is supported\n"); 5774 "brightness is supported\n");
6054 5775
5776 if (quirks & TPACPI_BRGHT_Q_ASK) {
5777 printk(TPACPI_NOTICE
5778 "brightness: will use unverified default: "
5779 "brightness_mode=%d\n", brightness_mode);
5780 printk(TPACPI_NOTICE
5781 "brightness: please report to %s whether it works well "
5782 "or not on your ThinkPad\n", TPACPI_MAIL);
5783 }
5784
6055 ibm_backlight_device->props.max_brightness = 5785 ibm_backlight_device->props.max_brightness =
6056 (tp_features.bright_16levels)? 15 : 7; 5786 (tp_features.bright_16levels)? 15 : 7;
6057 ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK; 5787 ibm_backlight_device->props.brightness = b & TP_EC_BACKLIGHT_LVLMSK;
@@ -7854,22 +7584,6 @@ static struct ibm_init_struct ibms_init[] __initdata = {
7854 .init = light_init, 7584 .init = light_init,
7855 .data = &light_driver_data, 7585 .data = &light_driver_data,
7856 }, 7586 },
7857#ifdef CONFIG_THINKPAD_ACPI_DOCK
7858 {
7859 .init = dock_init,
7860 .data = &dock_driver_data[0],
7861 },
7862 {
7863 .init = dock_init2,
7864 .data = &dock_driver_data[1],
7865 },
7866#endif
7867#ifdef CONFIG_THINKPAD_ACPI_BAY
7868 {
7869 .init = bay_init,
7870 .data = &bay_driver_data,
7871 },
7872#endif
7873 { 7587 {
7874 .init = cmos_init, 7588 .init = cmos_init,
7875 .data = &cmos_driver_data, 7589 .data = &cmos_driver_data,
@@ -7968,12 +7682,6 @@ TPACPI_PARAM(hotkey);
7968TPACPI_PARAM(bluetooth); 7682TPACPI_PARAM(bluetooth);
7969TPACPI_PARAM(video); 7683TPACPI_PARAM(video);
7970TPACPI_PARAM(light); 7684TPACPI_PARAM(light);
7971#ifdef CONFIG_THINKPAD_ACPI_DOCK
7972TPACPI_PARAM(dock);
7973#endif
7974#ifdef CONFIG_THINKPAD_ACPI_BAY
7975TPACPI_PARAM(bay);
7976#endif /* CONFIG_THINKPAD_ACPI_BAY */
7977TPACPI_PARAM(cmos); 7685TPACPI_PARAM(cmos);
7978TPACPI_PARAM(led); 7686TPACPI_PARAM(led);
7979TPACPI_PARAM(beep); 7687TPACPI_PARAM(beep);
diff --git a/drivers/platform/x86/toshiba_acpi.c b/drivers/platform/x86/toshiba_acpi.c
index 81d31ea507d1..51c0a8bee414 100644
--- a/drivers/platform/x86/toshiba_acpi.c
+++ b/drivers/platform/x86/toshiba_acpi.c
@@ -335,6 +335,7 @@ static void bt_rfkill_poll(struct rfkill *rfkill, void *data)
335 if (hci_result != HCI_SUCCESS) { 335 if (hci_result != HCI_SUCCESS) {
336 /* Can't do anything useful */ 336 /* Can't do anything useful */
337 mutex_unlock(&dev->mutex); 337 mutex_unlock(&dev->mutex);
338 return;
338 } 339 }
339 340
340 new_rfk_state = value; 341 new_rfk_state = value;
diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 043b208d971d..f215a5919192 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -270,7 +270,7 @@ u32 method_id, const struct acpi_buffer *in, struct acpi_buffer *out)
270 acpi_status status; 270 acpi_status status;
271 struct acpi_object_list input; 271 struct acpi_object_list input;
272 union acpi_object params[3]; 272 union acpi_object params[3];
273 char method[4] = "WM"; 273 char method[5] = "WM";
274 274
275 if (!find_guid(guid_string, &wblock)) 275 if (!find_guid(guid_string, &wblock))
276 return AE_ERROR; 276 return AE_ERROR;
@@ -328,8 +328,8 @@ struct acpi_buffer *out)
328 acpi_status status, wc_status = AE_ERROR; 328 acpi_status status, wc_status = AE_ERROR;
329 struct acpi_object_list input, wc_input; 329 struct acpi_object_list input, wc_input;
330 union acpi_object wc_params[1], wq_params[1]; 330 union acpi_object wc_params[1], wq_params[1];
331 char method[4]; 331 char method[5];
332 char wc_method[4] = "WC"; 332 char wc_method[5] = "WC";
333 333
334 if (!guid_string || !out) 334 if (!guid_string || !out)
335 return AE_BAD_PARAMETER; 335 return AE_BAD_PARAMETER;
@@ -410,7 +410,7 @@ const struct acpi_buffer *in)
410 acpi_handle handle; 410 acpi_handle handle;
411 struct acpi_object_list input; 411 struct acpi_object_list input;
412 union acpi_object params[2]; 412 union acpi_object params[2];
413 char method[4] = "WS"; 413 char method[5] = "WS";
414 414
415 if (!guid_string || !in) 415 if (!guid_string || !in)
416 return AE_BAD_DATA; 416 return AE_BAD_DATA;
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index ac8cc8cea1e3..fea17e7805e9 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -244,7 +244,7 @@ int pps_register_cdev(struct pps_device *pps)
244 } 244 }
245 pps->dev = device_create(pps_class, pps->info.dev, pps->devno, NULL, 245 pps->dev = device_create(pps_class, pps->info.dev, pps->devno, NULL,
246 "pps%d", pps->id); 246 "pps%d", pps->id);
247 if (err) 247 if (IS_ERR(pps->dev))
248 goto del_cdev; 248 goto del_cdev;
249 dev_set_drvdata(pps->dev, pps); 249 dev_set_drvdata(pps->dev, pps);
250 250
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 749836668655..3f62dd50bbbe 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -2135,9 +2135,9 @@ static int dasd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
2135 struct dasd_device *base; 2135 struct dasd_device *base;
2136 2136
2137 block = bdev->bd_disk->private_data; 2137 block = bdev->bd_disk->private_data;
2138 base = block->base;
2139 if (!block) 2138 if (!block)
2140 return -ENODEV; 2139 return -ENODEV;
2140 base = block->base;
2141 2141
2142 if (!base->discipline || 2142 if (!base->discipline ||
2143 !base->discipline->fill_geometry) 2143 !base->discipline->fill_geometry)
diff --git a/drivers/s390/cio/device.c b/drivers/s390/cio/device.c
index 3c57c1a18bb8..d593bc76afe3 100644
--- a/drivers/s390/cio/device.c
+++ b/drivers/s390/cio/device.c
@@ -772,10 +772,8 @@ static struct ccw_device * io_subchannel_create_ccwdev(struct subchannel *sch)
772 cdev = io_subchannel_allocate_dev(sch); 772 cdev = io_subchannel_allocate_dev(sch);
773 if (!IS_ERR(cdev)) { 773 if (!IS_ERR(cdev)) {
774 ret = io_subchannel_initialize_dev(sch, cdev); 774 ret = io_subchannel_initialize_dev(sch, cdev);
775 if (ret) { 775 if (ret)
776 kfree(cdev);
777 cdev = ERR_PTR(ret); 776 cdev = ERR_PTR(ret);
778 }
779 } 777 }
780 return cdev; 778 return cdev;
781} 779}
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 8030e25152fb..c75d6f35cb5f 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -553,40 +553,35 @@ static void _zfcp_erp_unit_reopen_all(struct zfcp_port *port, int clear,
553 _zfcp_erp_unit_reopen(unit, clear, id, ref); 553 _zfcp_erp_unit_reopen(unit, clear, id, ref);
554} 554}
555 555
556static void zfcp_erp_strategy_followup_actions(struct zfcp_erp_action *act) 556static void zfcp_erp_strategy_followup_failed(struct zfcp_erp_action *act)
557{ 557{
558 struct zfcp_adapter *adapter = act->adapter;
559 struct zfcp_port *port = act->port;
560 struct zfcp_unit *unit = act->unit;
561 u32 status = act->status;
562
563 /* initiate follow-up actions depending on success of finished action */
564 switch (act->action) { 558 switch (act->action) {
565
566 case ZFCP_ERP_ACTION_REOPEN_ADAPTER: 559 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
567 if (status == ZFCP_ERP_SUCCEEDED) 560 _zfcp_erp_adapter_reopen(act->adapter, 0, "ersff_1", NULL);
568 _zfcp_erp_port_reopen_all(adapter, 0, "ersfa_1", NULL);
569 else
570 _zfcp_erp_adapter_reopen(adapter, 0, "ersfa_2", NULL);
571 break; 561 break;
572
573 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED: 562 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
574 if (status == ZFCP_ERP_SUCCEEDED) 563 _zfcp_erp_port_forced_reopen(act->port, 0, "ersff_2", NULL);
575 _zfcp_erp_port_reopen(port, 0, "ersfa_3", NULL);
576 else
577 _zfcp_erp_adapter_reopen(adapter, 0, "ersfa_4", NULL);
578 break; 564 break;
579
580 case ZFCP_ERP_ACTION_REOPEN_PORT: 565 case ZFCP_ERP_ACTION_REOPEN_PORT:
581 if (status == ZFCP_ERP_SUCCEEDED) 566 _zfcp_erp_port_reopen(act->port, 0, "ersff_3", NULL);
582 _zfcp_erp_unit_reopen_all(port, 0, "ersfa_5", NULL);
583 else
584 _zfcp_erp_port_forced_reopen(port, 0, "ersfa_6", NULL);
585 break; 567 break;
586
587 case ZFCP_ERP_ACTION_REOPEN_UNIT: 568 case ZFCP_ERP_ACTION_REOPEN_UNIT:
588 if (status != ZFCP_ERP_SUCCEEDED) 569 _zfcp_erp_unit_reopen(act->unit, 0, "ersff_4", NULL);
589 _zfcp_erp_port_reopen(unit->port, 0, "ersfa_7", NULL); 570 break;
571 }
572}
573
574static void zfcp_erp_strategy_followup_success(struct zfcp_erp_action *act)
575{
576 switch (act->action) {
577 case ZFCP_ERP_ACTION_REOPEN_ADAPTER:
578 _zfcp_erp_port_reopen_all(act->adapter, 0, "ersfs_1", NULL);
579 break;
580 case ZFCP_ERP_ACTION_REOPEN_PORT_FORCED:
581 _zfcp_erp_port_reopen(act->port, 0, "ersfs_2", NULL);
582 break;
583 case ZFCP_ERP_ACTION_REOPEN_PORT:
584 _zfcp_erp_unit_reopen_all(act->port, 0, "ersfs_3", NULL);
590 break; 585 break;
591 } 586 }
592} 587}
@@ -801,7 +796,7 @@ static int zfcp_erp_port_forced_strategy(struct zfcp_erp_action *erp_action)
801 return ZFCP_ERP_FAILED; 796 return ZFCP_ERP_FAILED;
802 797
803 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING: 798 case ZFCP_ERP_STEP_PHYS_PORT_CLOSING:
804 if (status & ZFCP_STATUS_PORT_PHYS_OPEN) 799 if (!(status & ZFCP_STATUS_PORT_PHYS_OPEN))
805 return ZFCP_ERP_SUCCEEDED; 800 return ZFCP_ERP_SUCCEEDED;
806 } 801 }
807 return ZFCP_ERP_FAILED; 802 return ZFCP_ERP_FAILED;
@@ -853,11 +848,17 @@ void zfcp_erp_port_strategy_open_lookup(struct work_struct *work)
853 gid_pn_work); 848 gid_pn_work);
854 849
855 retval = zfcp_fc_ns_gid_pn(&port->erp_action); 850 retval = zfcp_fc_ns_gid_pn(&port->erp_action);
856 if (retval == -ENOMEM) 851 if (!retval) {
857 zfcp_erp_notify(&port->erp_action, ZFCP_ERP_NOMEM); 852 port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP;
858 port->erp_action.step = ZFCP_ERP_STEP_NAMESERVER_LOOKUP; 853 goto out;
859 if (retval) 854 }
860 zfcp_erp_notify(&port->erp_action, ZFCP_ERP_FAILED); 855 if (retval == -ENOMEM) {
856 zfcp_erp_notify(&port->erp_action, ZFCP_STATUS_ERP_LOWMEM);
857 goto out;
858 }
859 /* all other error condtions */
860 zfcp_erp_notify(&port->erp_action, 0);
861out:
861 zfcp_port_put(port); 862 zfcp_port_put(port);
862} 863}
863 864
@@ -1289,7 +1290,10 @@ static int zfcp_erp_strategy(struct zfcp_erp_action *erp_action)
1289 retval = zfcp_erp_strategy_statechange(erp_action, retval); 1290 retval = zfcp_erp_strategy_statechange(erp_action, retval);
1290 if (retval == ZFCP_ERP_EXIT) 1291 if (retval == ZFCP_ERP_EXIT)
1291 goto unlock; 1292 goto unlock;
1292 zfcp_erp_strategy_followup_actions(erp_action); 1293 if (retval == ZFCP_ERP_SUCCEEDED)
1294 zfcp_erp_strategy_followup_success(erp_action);
1295 if (retval == ZFCP_ERP_FAILED)
1296 zfcp_erp_strategy_followup_failed(erp_action);
1293 1297
1294 unlock: 1298 unlock:
1295 write_unlock(&adapter->erp_lock); 1299 write_unlock(&adapter->erp_lock);
diff --git a/drivers/s390/scsi/zfcp_fc.c b/drivers/s390/scsi/zfcp_fc.c
index 2f0705d76b72..47daebfa7e59 100644
--- a/drivers/s390/scsi/zfcp_fc.c
+++ b/drivers/s390/scsi/zfcp_fc.c
@@ -79,11 +79,9 @@ static int zfcp_wka_port_get(struct zfcp_wka_port *wka_port)
79 79
80 mutex_unlock(&wka_port->mutex); 80 mutex_unlock(&wka_port->mutex);
81 81
82 wait_event_timeout( 82 wait_event(wka_port->completion_wq,
83 wka_port->completion_wq, 83 wka_port->status == ZFCP_WKA_PORT_ONLINE ||
84 wka_port->status == ZFCP_WKA_PORT_ONLINE || 84 wka_port->status == ZFCP_WKA_PORT_OFFLINE);
85 wka_port->status == ZFCP_WKA_PORT_OFFLINE,
86 HZ >> 1);
87 85
88 if (wka_port->status == ZFCP_WKA_PORT_ONLINE) { 86 if (wka_port->status == ZFCP_WKA_PORT_ONLINE) {
89 atomic_inc(&wka_port->refcount); 87 atomic_inc(&wka_port->refcount);
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index c57658f3d34f..47795fbf081f 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -670,8 +670,11 @@ static int zfcp_fsf_req_sbal_get(struct zfcp_adapter *adapter)
670 zfcp_fsf_sbal_check(adapter), 5 * HZ); 670 zfcp_fsf_sbal_check(adapter), 5 * HZ);
671 if (ret > 0) 671 if (ret > 0)
672 return 0; 672 return 0;
673 if (!ret) 673 if (!ret) {
674 atomic_inc(&adapter->qdio_outb_full); 674 atomic_inc(&adapter->qdio_outb_full);
675 /* assume hanging outbound queue, try queue recovery */
676 zfcp_erp_adapter_reopen(adapter, 0, "fsrsg_1", NULL);
677 }
675 678
676 spin_lock_bh(&adapter->req_q_lock); 679 spin_lock_bh(&adapter->req_q_lock);
677 return -EIO; 680 return -EIO;
@@ -722,7 +725,7 @@ static struct zfcp_fsf_req *zfcp_fsf_req_create(struct zfcp_adapter *adapter,
722 req = zfcp_fsf_alloc_qtcb(pool); 725 req = zfcp_fsf_alloc_qtcb(pool);
723 726
724 if (unlikely(!req)) 727 if (unlikely(!req))
725 return ERR_PTR(-EIO); 728 return ERR_PTR(-ENOMEM);
726 729
727 if (adapter->req_no == 0) 730 if (adapter->req_no == 0)
728 adapter->req_no++; 731 adapter->req_no++;
@@ -1010,6 +1013,23 @@ skip_fsfstatus:
1010 send_ct->handler(send_ct->handler_data); 1013 send_ct->handler(send_ct->handler_data);
1011} 1014}
1012 1015
1016static void zfcp_fsf_setup_ct_els_unchained(struct qdio_buffer_element *sbale,
1017 struct scatterlist *sg_req,
1018 struct scatterlist *sg_resp)
1019{
1020 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ;
1021 sbale[2].addr = sg_virt(sg_req);
1022 sbale[2].length = sg_req->length;
1023 sbale[3].addr = sg_virt(sg_resp);
1024 sbale[3].length = sg_resp->length;
1025 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY;
1026}
1027
1028static int zfcp_fsf_one_sbal(struct scatterlist *sg)
1029{
1030 return sg_is_last(sg) && sg->length <= PAGE_SIZE;
1031}
1032
1013static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req, 1033static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1014 struct scatterlist *sg_req, 1034 struct scatterlist *sg_req,
1015 struct scatterlist *sg_resp, 1035 struct scatterlist *sg_resp,
@@ -1020,30 +1040,30 @@ static int zfcp_fsf_setup_ct_els_sbals(struct zfcp_fsf_req *req,
1020 int bytes; 1040 int bytes;
1021 1041
1022 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) { 1042 if (!(feat & FSF_FEATURE_ELS_CT_CHAINED_SBALS)) {
1023 if (sg_req->length > PAGE_SIZE || sg_resp->length > PAGE_SIZE || 1043 if (!zfcp_fsf_one_sbal(sg_req) || !zfcp_fsf_one_sbal(sg_resp))
1024 !sg_is_last(sg_req) || !sg_is_last(sg_resp))
1025 return -EOPNOTSUPP; 1044 return -EOPNOTSUPP;
1026 1045
1027 sbale[0].flags |= SBAL_FLAGS0_TYPE_WRITE_READ; 1046 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp);
1028 sbale[2].addr = sg_virt(sg_req); 1047 return 0;
1029 sbale[2].length = sg_req->length; 1048 }
1030 sbale[3].addr = sg_virt(sg_resp); 1049
1031 sbale[3].length = sg_resp->length; 1050 /* use single, unchained SBAL if it can hold the request */
1032 sbale[3].flags |= SBAL_FLAGS_LAST_ENTRY; 1051 if (zfcp_fsf_one_sbal(sg_req) && zfcp_fsf_one_sbal(sg_resp)) {
1052 zfcp_fsf_setup_ct_els_unchained(sbale, sg_req, sg_resp);
1033 return 0; 1053 return 0;
1034 } 1054 }
1035 1055
1036 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ, 1056 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ,
1037 sg_req, max_sbals); 1057 sg_req, max_sbals);
1038 if (bytes <= 0) 1058 if (bytes <= 0)
1039 return -ENOMEM; 1059 return -EIO;
1040 req->qtcb->bottom.support.req_buf_length = bytes; 1060 req->qtcb->bottom.support.req_buf_length = bytes;
1041 req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL; 1061 req->sbale_curr = ZFCP_LAST_SBALE_PER_SBAL;
1042 1062
1043 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ, 1063 bytes = zfcp_qdio_sbals_from_sg(req, SBAL_FLAGS0_TYPE_WRITE_READ,
1044 sg_resp, max_sbals); 1064 sg_resp, max_sbals);
1045 if (bytes <= 0) 1065 if (bytes <= 0)
1046 return -ENOMEM; 1066 return -EIO;
1047 req->qtcb->bottom.support.resp_buf_length = bytes; 1067 req->qtcb->bottom.support.resp_buf_length = bytes;
1048 1068
1049 return 0; 1069 return 0;
@@ -1607,10 +1627,10 @@ static void zfcp_fsf_open_wka_port_handler(struct zfcp_fsf_req *req)
1607 case FSF_ACCESS_DENIED: 1627 case FSF_ACCESS_DENIED:
1608 wka_port->status = ZFCP_WKA_PORT_OFFLINE; 1628 wka_port->status = ZFCP_WKA_PORT_OFFLINE;
1609 break; 1629 break;
1610 case FSF_PORT_ALREADY_OPEN:
1611 break;
1612 case FSF_GOOD: 1630 case FSF_GOOD:
1613 wka_port->handle = header->port_handle; 1631 wka_port->handle = header->port_handle;
1632 /* fall through */
1633 case FSF_PORT_ALREADY_OPEN:
1614 wka_port->status = ZFCP_WKA_PORT_ONLINE; 1634 wka_port->status = ZFCP_WKA_PORT_ONLINE;
1615 } 1635 }
1616out: 1636out:
@@ -1731,15 +1751,16 @@ static void zfcp_fsf_close_physical_port_handler(struct zfcp_fsf_req *req)
1731 zfcp_fsf_access_denied_port(req, port); 1751 zfcp_fsf_access_denied_port(req, port);
1732 break; 1752 break;
1733 case FSF_PORT_BOXED: 1753 case FSF_PORT_BOXED:
1734 zfcp_erp_port_boxed(port, "fscpph2", req);
1735 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
1736 ZFCP_STATUS_FSFREQ_RETRY;
1737 /* can't use generic zfcp_erp_modify_port_status because 1754 /* can't use generic zfcp_erp_modify_port_status because
1738 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */ 1755 * ZFCP_STATUS_COMMON_OPEN must not be reset for the port */
1739 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status); 1756 atomic_clear_mask(ZFCP_STATUS_PORT_PHYS_OPEN, &port->status);
1740 list_for_each_entry(unit, &port->unit_list_head, list) 1757 list_for_each_entry(unit, &port->unit_list_head, list)
1741 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN, 1758 atomic_clear_mask(ZFCP_STATUS_COMMON_OPEN,
1742 &unit->status); 1759 &unit->status);
1760 zfcp_erp_port_boxed(port, "fscpph2", req);
1761 req->status |= ZFCP_STATUS_FSFREQ_ERROR |
1762 ZFCP_STATUS_FSFREQ_RETRY;
1763
1743 break; 1764 break;
1744 case FSF_ADAPTER_STATUS_AVAILABLE: 1765 case FSF_ADAPTER_STATUS_AVAILABLE:
1745 switch (header->fsf_status_qual.word[0]) { 1766 switch (header->fsf_status_qual.word[0]) {
@@ -2541,7 +2562,6 @@ struct zfcp_fsf_req *zfcp_fsf_control_file(struct zfcp_adapter *adapter,
2541 bytes = zfcp_qdio_sbals_from_sg(req, direction, fsf_cfdc->sg, 2562 bytes = zfcp_qdio_sbals_from_sg(req, direction, fsf_cfdc->sg,
2542 FSF_MAX_SBALS_PER_REQ); 2563 FSF_MAX_SBALS_PER_REQ);
2543 if (bytes != ZFCP_CFDC_MAX_SIZE) { 2564 if (bytes != ZFCP_CFDC_MAX_SIZE) {
2544 retval = -ENOMEM;
2545 zfcp_fsf_req_free(req); 2565 zfcp_fsf_req_free(req);
2546 goto out; 2566 goto out;
2547 } 2567 }
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 967ede73f4c5..6925a1784682 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -167,20 +167,21 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
167 struct zfcp_unit *unit = scpnt->device->hostdata; 167 struct zfcp_unit *unit = scpnt->device->hostdata;
168 struct zfcp_fsf_req *old_req, *abrt_req; 168 struct zfcp_fsf_req *old_req, *abrt_req;
169 unsigned long flags; 169 unsigned long flags;
170 unsigned long old_req_id = (unsigned long) scpnt->host_scribble; 170 unsigned long old_reqid = (unsigned long) scpnt->host_scribble;
171 int retval = SUCCESS; 171 int retval = SUCCESS;
172 int retry = 3; 172 int retry = 3;
173 char *dbf_tag;
173 174
174 /* avoid race condition between late normal completion and abort */ 175 /* avoid race condition between late normal completion and abort */
175 write_lock_irqsave(&adapter->abort_lock, flags); 176 write_lock_irqsave(&adapter->abort_lock, flags);
176 177
177 spin_lock(&adapter->req_list_lock); 178 spin_lock(&adapter->req_list_lock);
178 old_req = zfcp_reqlist_find(adapter, old_req_id); 179 old_req = zfcp_reqlist_find(adapter, old_reqid);
179 spin_unlock(&adapter->req_list_lock); 180 spin_unlock(&adapter->req_list_lock);
180 if (!old_req) { 181 if (!old_req) {
181 write_unlock_irqrestore(&adapter->abort_lock, flags); 182 write_unlock_irqrestore(&adapter->abort_lock, flags);
182 zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, NULL, 183 zfcp_scsi_dbf_event_abort("lte1", adapter, scpnt, NULL,
183 old_req_id); 184 old_reqid);
184 return FAILED; /* completion could be in progress */ 185 return FAILED; /* completion could be in progress */
185 } 186 }
186 old_req->data = NULL; 187 old_req->data = NULL;
@@ -189,7 +190,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
189 write_unlock_irqrestore(&adapter->abort_lock, flags); 190 write_unlock_irqrestore(&adapter->abort_lock, flags);
190 191
191 while (retry--) { 192 while (retry--) {
192 abrt_req = zfcp_fsf_abort_fcp_command(old_req_id, unit); 193 abrt_req = zfcp_fsf_abort_fcp_command(old_reqid, unit);
193 if (abrt_req) 194 if (abrt_req)
194 break; 195 break;
195 196
@@ -197,7 +198,7 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
197 if (!(atomic_read(&adapter->status) & 198 if (!(atomic_read(&adapter->status) &
198 ZFCP_STATUS_COMMON_RUNNING)) { 199 ZFCP_STATUS_COMMON_RUNNING)) {
199 zfcp_scsi_dbf_event_abort("nres", adapter, scpnt, NULL, 200 zfcp_scsi_dbf_event_abort("nres", adapter, scpnt, NULL,
200 old_req_id); 201 old_reqid);
201 return SUCCESS; 202 return SUCCESS;
202 } 203 }
203 } 204 }
@@ -208,13 +209,14 @@ static int zfcp_scsi_eh_abort_handler(struct scsi_cmnd *scpnt)
208 abrt_req->status & ZFCP_STATUS_FSFREQ_COMPLETED); 209 abrt_req->status & ZFCP_STATUS_FSFREQ_COMPLETED);
209 210
210 if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED) 211 if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTSUCCEEDED)
211 zfcp_scsi_dbf_event_abort("okay", adapter, scpnt, abrt_req, 0); 212 dbf_tag = "okay";
212 else if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED) 213 else if (abrt_req->status & ZFCP_STATUS_FSFREQ_ABORTNOTNEEDED)
213 zfcp_scsi_dbf_event_abort("lte2", adapter, scpnt, abrt_req, 0); 214 dbf_tag = "lte2";
214 else { 215 else {
215 zfcp_scsi_dbf_event_abort("fail", adapter, scpnt, abrt_req, 0); 216 dbf_tag = "fail";
216 retval = FAILED; 217 retval = FAILED;
217 } 218 }
219 zfcp_scsi_dbf_event_abort(dbf_tag, adapter, scpnt, abrt_req, old_reqid);
218 zfcp_fsf_req_free(abrt_req); 220 zfcp_fsf_req_free(abrt_req);
219 return retval; 221 return retval;
220} 222}
@@ -534,6 +536,9 @@ static void zfcp_scsi_rport_register(struct zfcp_port *port)
534 struct fc_rport_identifiers ids; 536 struct fc_rport_identifiers ids;
535 struct fc_rport *rport; 537 struct fc_rport *rport;
536 538
539 if (port->rport)
540 return;
541
537 ids.node_name = port->wwnn; 542 ids.node_name = port->wwnn;
538 ids.port_name = port->wwpn; 543 ids.port_name = port->wwpn;
539 ids.port_id = port->d_id; 544 ids.port_id = port->d_id;
@@ -557,8 +562,10 @@ static void zfcp_scsi_rport_block(struct zfcp_port *port)
557{ 562{
558 struct fc_rport *rport = port->rport; 563 struct fc_rport *rport = port->rport;
559 564
560 if (rport) 565 if (rport) {
561 fc_remote_port_delete(rport); 566 fc_remote_port_delete(rport);
567 port->rport = NULL;
568 }
562} 569}
563 570
564void zfcp_scsi_schedule_rport_register(struct zfcp_port *port) 571void zfcp_scsi_schedule_rport_register(struct zfcp_port *port)
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 3e51e64d1108..0fe5cce818cb 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -494,9 +494,14 @@ static ssize_t zfcp_sysfs_adapter_q_full_show(struct device *dev,
494 struct Scsi_Host *scsi_host = class_to_shost(dev); 494 struct Scsi_Host *scsi_host = class_to_shost(dev);
495 struct zfcp_adapter *adapter = 495 struct zfcp_adapter *adapter =
496 (struct zfcp_adapter *) scsi_host->hostdata[0]; 496 (struct zfcp_adapter *) scsi_host->hostdata[0];
497 u64 util;
498
499 spin_lock_bh(&adapter->qdio_stat_lock);
500 util = adapter->req_q_util;
501 spin_unlock_bh(&adapter->qdio_stat_lock);
497 502
498 return sprintf(buf, "%d %llu\n", atomic_read(&adapter->qdio_outb_full), 503 return sprintf(buf, "%d %llu\n", atomic_read(&adapter->qdio_outb_full),
499 (unsigned long long)adapter->req_q_util); 504 (unsigned long long)util);
500} 505}
501static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL); 506static DEVICE_ATTR(queue_full, S_IRUGO, zfcp_sysfs_adapter_q_full_show, NULL);
502 507
diff --git a/drivers/sbus/char/bbc_envctrl.c b/drivers/sbus/char/bbc_envctrl.c
index 15dab96d05e3..7c815d3327f7 100644
--- a/drivers/sbus/char/bbc_envctrl.c
+++ b/drivers/sbus/char/bbc_envctrl.c
@@ -537,8 +537,12 @@ int bbc_envctrl_init(struct bbc_i2c_bus *bp)
537 } 537 }
538 if (temp_index != 0 && fan_index != 0) { 538 if (temp_index != 0 && fan_index != 0) {
539 kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld"); 539 kenvctrld_task = kthread_run(kenvctrld, NULL, "kenvctrld");
540 if (IS_ERR(kenvctrld_task)) 540 if (IS_ERR(kenvctrld_task)) {
541 return PTR_ERR(kenvctrld_task); 541 int err = PTR_ERR(kenvctrld_task);
542
543 kenvctrld_task = NULL;
544 return err;
545 }
542 } 546 }
543 547
544 return 0; 548 return 0;
@@ -561,7 +565,8 @@ void bbc_envctrl_cleanup(struct bbc_i2c_bus *bp)
561 struct bbc_cpu_temperature *tp, *tpos; 565 struct bbc_cpu_temperature *tp, *tpos;
562 struct bbc_fan_control *fp, *fpos; 566 struct bbc_fan_control *fp, *fpos;
563 567
564 kthread_stop(kenvctrld_task); 568 if (kenvctrld_task)
569 kthread_stop(kenvctrld_task);
565 570
566 list_for_each_entry_safe(tp, tpos, &bp->temps, bp_list) { 571 list_for_each_entry_safe(tp, tpos, &bp->temps, bp_list) {
567 list_del(&tp->bp_list); 572 list_del(&tp->bp_list);
diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
index 2bc22be5f849..145ab9ba55ea 100644
--- a/drivers/scsi/libfc/fc_exch.c
+++ b/drivers/scsi/libfc/fc_exch.c
@@ -415,9 +415,9 @@ static void fc_exch_timeout(struct work_struct *work)
415 e_stat = ep->esb_stat; 415 e_stat = ep->esb_stat;
416 if (e_stat & ESB_ST_COMPLETE) { 416 if (e_stat & ESB_ST_COMPLETE) {
417 ep->esb_stat = e_stat & ~ESB_ST_REC_QUAL; 417 ep->esb_stat = e_stat & ~ESB_ST_REC_QUAL;
418 spin_unlock_bh(&ep->ex_lock);
418 if (e_stat & ESB_ST_REC_QUAL) 419 if (e_stat & ESB_ST_REC_QUAL)
419 fc_exch_rrq(ep); 420 fc_exch_rrq(ep);
420 spin_unlock_bh(&ep->ex_lock);
421 goto done; 421 goto done;
422 } else { 422 } else {
423 resp = ep->resp; 423 resp = ep->resp;
@@ -1624,14 +1624,14 @@ static void fc_exch_rrq(struct fc_exch *ep)
1624 struct fc_lport *lp; 1624 struct fc_lport *lp;
1625 struct fc_els_rrq *rrq; 1625 struct fc_els_rrq *rrq;
1626 struct fc_frame *fp; 1626 struct fc_frame *fp;
1627 struct fc_seq *rrq_sp;
1628 u32 did; 1627 u32 did;
1629 1628
1630 lp = ep->lp; 1629 lp = ep->lp;
1631 1630
1632 fp = fc_frame_alloc(lp, sizeof(*rrq)); 1631 fp = fc_frame_alloc(lp, sizeof(*rrq));
1633 if (!fp) 1632 if (!fp)
1634 return; 1633 goto retry;
1634
1635 rrq = fc_frame_payload_get(fp, sizeof(*rrq)); 1635 rrq = fc_frame_payload_get(fp, sizeof(*rrq));
1636 memset(rrq, 0, sizeof(*rrq)); 1636 memset(rrq, 0, sizeof(*rrq));
1637 rrq->rrq_cmd = ELS_RRQ; 1637 rrq->rrq_cmd = ELS_RRQ;
@@ -1647,13 +1647,20 @@ static void fc_exch_rrq(struct fc_exch *ep)
1647 fc_host_port_id(lp->host), FC_TYPE_ELS, 1647 fc_host_port_id(lp->host), FC_TYPE_ELS,
1648 FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0); 1648 FC_FC_FIRST_SEQ | FC_FC_END_SEQ | FC_FC_SEQ_INIT, 0);
1649 1649
1650 rrq_sp = fc_exch_seq_send(lp, fp, fc_exch_rrq_resp, NULL, ep, 1650 if (fc_exch_seq_send(lp, fp, fc_exch_rrq_resp, NULL, ep, lp->e_d_tov))
1651 lp->e_d_tov); 1651 return;
1652 if (!rrq_sp) { 1652
1653 ep->esb_stat |= ESB_ST_REC_QUAL; 1653retry:
1654 fc_exch_timer_set_locked(ep, ep->r_a_tov); 1654 spin_lock_bh(&ep->ex_lock);
1655 if (ep->state & (FC_EX_RST_CLEANUP | FC_EX_DONE)) {
1656 spin_unlock_bh(&ep->ex_lock);
1657 /* drop hold for rec qual */
1658 fc_exch_release(ep);
1655 return; 1659 return;
1656 } 1660 }
1661 ep->esb_stat |= ESB_ST_REC_QUAL;
1662 fc_exch_timer_set_locked(ep, ep->r_a_tov);
1663 spin_unlock_bh(&ep->ex_lock);
1657} 1664}
1658 1665
1659 1666
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 716cc344c5df..a751f6230c22 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1974,10 +1974,10 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
1974 * good and have never sent us a successful tmf response 1974 * good and have never sent us a successful tmf response
1975 * then sent more data for the cmd. 1975 * then sent more data for the cmd.
1976 */ 1976 */
1977 spin_lock(&session->lock); 1977 spin_lock_bh(&session->lock);
1978 fail_scsi_task(task, DID_ABORT); 1978 fail_scsi_task(task, DID_ABORT);
1979 conn->tmf_state = TMF_INITIAL; 1979 conn->tmf_state = TMF_INITIAL;
1980 spin_unlock(&session->lock); 1980 spin_unlock_bh(&session->lock);
1981 iscsi_start_tx(conn); 1981 iscsi_start_tx(conn);
1982 goto success_unlocked; 1982 goto success_unlocked;
1983 case TMF_TIMEDOUT: 1983 case TMF_TIMEDOUT:
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 54fa1e42dc4d..b3381959acce 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -766,6 +766,7 @@ static int sas_ex_join_wide_port(struct domain_device *parent, int phy_id)
766 if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr, 766 if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr,
767 SAS_ADDR_SIZE) && ephy->port) { 767 SAS_ADDR_SIZE) && ephy->port) {
768 sas_port_add_phy(ephy->port, phy->phy); 768 sas_port_add_phy(ephy->port, phy->phy);
769 phy->port = ephy->port;
769 phy->phy_state = PHY_DEVICE_DISCOVERED; 770 phy->phy_state = PHY_DEVICE_DISCOVERED;
770 return 0; 771 return 0;
771 } 772 }
@@ -945,11 +946,21 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
945 if (ex->ex_phy[i].phy_state == PHY_VACANT || 946 if (ex->ex_phy[i].phy_state == PHY_VACANT ||
946 ex->ex_phy[i].phy_state == PHY_NOT_PRESENT) 947 ex->ex_phy[i].phy_state == PHY_NOT_PRESENT)
947 continue; 948 continue;
948 949 /*
950 * Due to races, the phy might not get added to the
951 * wide port, so we add the phy to the wide port here.
952 */
949 if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) == 953 if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) ==
950 SAS_ADDR(child->sas_addr)) 954 SAS_ADDR(child->sas_addr)) {
951 ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED; 955 ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED;
956 res = sas_ex_join_wide_port(dev, i);
957 if (!res)
958 SAS_DPRINTK("Attaching ex phy%d to wide port %016llx\n",
959 i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr));
960
961 }
952 } 962 }
963 res = 0;
953 } 964 }
954 965
955 return res; 966 return res;
@@ -1598,7 +1609,7 @@ static int sas_get_phy_attached_sas_addr(struct domain_device *dev,
1598} 1609}
1599 1610
1600static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id, 1611static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id,
1601 int from_phy) 1612 int from_phy, bool update)
1602{ 1613{
1603 struct expander_device *ex = &dev->ex_dev; 1614 struct expander_device *ex = &dev->ex_dev;
1604 int res = 0; 1615 int res = 0;
@@ -1611,7 +1622,9 @@ static int sas_find_bcast_phy(struct domain_device *dev, int *phy_id,
1611 if (res) 1622 if (res)
1612 goto out; 1623 goto out;
1613 else if (phy_change_count != ex->ex_phy[i].phy_change_count) { 1624 else if (phy_change_count != ex->ex_phy[i].phy_change_count) {
1614 ex->ex_phy[i].phy_change_count = phy_change_count; 1625 if (update)
1626 ex->ex_phy[i].phy_change_count =
1627 phy_change_count;
1615 *phy_id = i; 1628 *phy_id = i;
1616 return 0; 1629 return 0;
1617 } 1630 }
@@ -1653,31 +1666,52 @@ out:
1653 kfree(rg_req); 1666 kfree(rg_req);
1654 return res; 1667 return res;
1655} 1668}
1669/**
1670 * sas_find_bcast_dev - find the device issue BROADCAST(CHANGE).
1671 * @dev:domain device to be detect.
1672 * @src_dev: the device which originated BROADCAST(CHANGE).
1673 *
1674 * Add self-configuration expander suport. Suppose two expander cascading,
1675 * when the first level expander is self-configuring, hotplug the disks in
1676 * second level expander, BROADCAST(CHANGE) will not only be originated
1677 * in the second level expander, but also be originated in the first level
1678 * expander (see SAS protocol SAS 2r-14, 7.11 for detail), it is to say,
1679 * expander changed count in two level expanders will all increment at least
1680 * once, but the phy which chang count has changed is the source device which
1681 * we concerned.
1682 */
1656 1683
1657static int sas_find_bcast_dev(struct domain_device *dev, 1684static int sas_find_bcast_dev(struct domain_device *dev,
1658 struct domain_device **src_dev) 1685 struct domain_device **src_dev)
1659{ 1686{
1660 struct expander_device *ex = &dev->ex_dev; 1687 struct expander_device *ex = &dev->ex_dev;
1661 int ex_change_count = -1; 1688 int ex_change_count = -1;
1689 int phy_id = -1;
1662 int res; 1690 int res;
1691 struct domain_device *ch;
1663 1692
1664 res = sas_get_ex_change_count(dev, &ex_change_count); 1693 res = sas_get_ex_change_count(dev, &ex_change_count);
1665 if (res) 1694 if (res)
1666 goto out; 1695 goto out;
1667 if (ex_change_count != -1 && 1696 if (ex_change_count != -1 && ex_change_count != ex->ex_change_count) {
1668 ex_change_count != ex->ex_change_count) { 1697 /* Just detect if this expander phys phy change count changed,
1669 *src_dev = dev; 1698 * in order to determine if this expander originate BROADCAST,
1670 ex->ex_change_count = ex_change_count; 1699 * and do not update phy change count field in our structure.
1671 } else { 1700 */
1672 struct domain_device *ch; 1701 res = sas_find_bcast_phy(dev, &phy_id, 0, false);
1673 1702 if (phy_id != -1) {
1674 list_for_each_entry(ch, &ex->children, siblings) { 1703 *src_dev = dev;
1675 if (ch->dev_type == EDGE_DEV || 1704 ex->ex_change_count = ex_change_count;
1676 ch->dev_type == FANOUT_DEV) { 1705 SAS_DPRINTK("Expander phy change count has changed\n");
1677 res = sas_find_bcast_dev(ch, src_dev); 1706 return res;
1678 if (src_dev) 1707 } else
1679 return res; 1708 SAS_DPRINTK("Expander phys DID NOT change\n");
1680 } 1709 }
1710 list_for_each_entry(ch, &ex->children, siblings) {
1711 if (ch->dev_type == EDGE_DEV || ch->dev_type == FANOUT_DEV) {
1712 res = sas_find_bcast_dev(ch, src_dev);
1713 if (src_dev)
1714 return res;
1681 } 1715 }
1682 } 1716 }
1683out: 1717out:
@@ -1700,24 +1734,26 @@ static void sas_unregister_ex_tree(struct domain_device *dev)
1700} 1734}
1701 1735
1702static void sas_unregister_devs_sas_addr(struct domain_device *parent, 1736static void sas_unregister_devs_sas_addr(struct domain_device *parent,
1703 int phy_id) 1737 int phy_id, bool last)
1704{ 1738{
1705 struct expander_device *ex_dev = &parent->ex_dev; 1739 struct expander_device *ex_dev = &parent->ex_dev;
1706 struct ex_phy *phy = &ex_dev->ex_phy[phy_id]; 1740 struct ex_phy *phy = &ex_dev->ex_phy[phy_id];
1707 struct domain_device *child, *n; 1741 struct domain_device *child, *n;
1708 1742 if (last) {
1709 list_for_each_entry_safe(child, n, &ex_dev->children, siblings) { 1743 list_for_each_entry_safe(child, n,
1710 if (SAS_ADDR(child->sas_addr) == 1744 &ex_dev->children, siblings) {
1711 SAS_ADDR(phy->attached_sas_addr)) { 1745 if (SAS_ADDR(child->sas_addr) ==
1712 if (child->dev_type == EDGE_DEV || 1746 SAS_ADDR(phy->attached_sas_addr)) {
1713 child->dev_type == FANOUT_DEV) 1747 if (child->dev_type == EDGE_DEV ||
1714 sas_unregister_ex_tree(child); 1748 child->dev_type == FANOUT_DEV)
1715 else 1749 sas_unregister_ex_tree(child);
1716 sas_unregister_dev(child); 1750 else
1717 break; 1751 sas_unregister_dev(child);
1752 break;
1753 }
1718 } 1754 }
1755 sas_disable_routing(parent, phy->attached_sas_addr);
1719 } 1756 }
1720 sas_disable_routing(parent, phy->attached_sas_addr);
1721 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE); 1757 memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
1722 sas_port_delete_phy(phy->port, phy->phy); 1758 sas_port_delete_phy(phy->port, phy->phy);
1723 if (phy->port->num_phys == 0) 1759 if (phy->port->num_phys == 0)
@@ -1770,15 +1806,31 @@ static int sas_discover_new(struct domain_device *dev, int phy_id)
1770{ 1806{
1771 struct ex_phy *ex_phy = &dev->ex_dev.ex_phy[phy_id]; 1807 struct ex_phy *ex_phy = &dev->ex_dev.ex_phy[phy_id];
1772 struct domain_device *child; 1808 struct domain_device *child;
1773 int res; 1809 bool found = false;
1810 int res, i;
1774 1811
1775 SAS_DPRINTK("ex %016llx phy%d new device attached\n", 1812 SAS_DPRINTK("ex %016llx phy%d new device attached\n",
1776 SAS_ADDR(dev->sas_addr), phy_id); 1813 SAS_ADDR(dev->sas_addr), phy_id);
1777 res = sas_ex_phy_discover(dev, phy_id); 1814 res = sas_ex_phy_discover(dev, phy_id);
1778 if (res) 1815 if (res)
1779 goto out; 1816 goto out;
1817 /* to support the wide port inserted */
1818 for (i = 0; i < dev->ex_dev.num_phys; i++) {
1819 struct ex_phy *ex_phy_temp = &dev->ex_dev.ex_phy[i];
1820 if (i == phy_id)
1821 continue;
1822 if (SAS_ADDR(ex_phy_temp->attached_sas_addr) ==
1823 SAS_ADDR(ex_phy->attached_sas_addr)) {
1824 found = true;
1825 break;
1826 }
1827 }
1828 if (found) {
1829 sas_ex_join_wide_port(dev, phy_id);
1830 return 0;
1831 }
1780 res = sas_ex_discover_devices(dev, phy_id); 1832 res = sas_ex_discover_devices(dev, phy_id);
1781 if (res) 1833 if (!res)
1782 goto out; 1834 goto out;
1783 list_for_each_entry(child, &dev->ex_dev.children, siblings) { 1835 list_for_each_entry(child, &dev->ex_dev.children, siblings) {
1784 if (SAS_ADDR(child->sas_addr) == 1836 if (SAS_ADDR(child->sas_addr) ==
@@ -1793,7 +1845,7 @@ out:
1793 return res; 1845 return res;
1794} 1846}
1795 1847
1796static int sas_rediscover_dev(struct domain_device *dev, int phy_id) 1848static int sas_rediscover_dev(struct domain_device *dev, int phy_id, bool last)
1797{ 1849{
1798 struct expander_device *ex = &dev->ex_dev; 1850 struct expander_device *ex = &dev->ex_dev;
1799 struct ex_phy *phy = &ex->ex_phy[phy_id]; 1851 struct ex_phy *phy = &ex->ex_phy[phy_id];
@@ -1804,11 +1856,11 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id)
1804 switch (res) { 1856 switch (res) {
1805 case SMP_RESP_NO_PHY: 1857 case SMP_RESP_NO_PHY:
1806 phy->phy_state = PHY_NOT_PRESENT; 1858 phy->phy_state = PHY_NOT_PRESENT;
1807 sas_unregister_devs_sas_addr(dev, phy_id); 1859 sas_unregister_devs_sas_addr(dev, phy_id, last);
1808 goto out; break; 1860 goto out; break;
1809 case SMP_RESP_PHY_VACANT: 1861 case SMP_RESP_PHY_VACANT:
1810 phy->phy_state = PHY_VACANT; 1862 phy->phy_state = PHY_VACANT;
1811 sas_unregister_devs_sas_addr(dev, phy_id); 1863 sas_unregister_devs_sas_addr(dev, phy_id, last);
1812 goto out; break; 1864 goto out; break;
1813 case SMP_RESP_FUNC_ACC: 1865 case SMP_RESP_FUNC_ACC:
1814 break; 1866 break;
@@ -1816,7 +1868,7 @@ static int sas_rediscover_dev(struct domain_device *dev, int phy_id)
1816 1868
1817 if (SAS_ADDR(attached_sas_addr) == 0) { 1869 if (SAS_ADDR(attached_sas_addr) == 0) {
1818 phy->phy_state = PHY_EMPTY; 1870 phy->phy_state = PHY_EMPTY;
1819 sas_unregister_devs_sas_addr(dev, phy_id); 1871 sas_unregister_devs_sas_addr(dev, phy_id, last);
1820 } else if (SAS_ADDR(attached_sas_addr) == 1872 } else if (SAS_ADDR(attached_sas_addr) ==
1821 SAS_ADDR(phy->attached_sas_addr)) { 1873 SAS_ADDR(phy->attached_sas_addr)) {
1822 SAS_DPRINTK("ex %016llx phy 0x%x broadcast flutter\n", 1874 SAS_DPRINTK("ex %016llx phy 0x%x broadcast flutter\n",
@@ -1828,12 +1880,27 @@ out:
1828 return res; 1880 return res;
1829} 1881}
1830 1882
1883/**
1884 * sas_rediscover - revalidate the domain.
1885 * @dev:domain device to be detect.
1886 * @phy_id: the phy id will be detected.
1887 *
1888 * NOTE: this process _must_ quit (return) as soon as any connection
1889 * errors are encountered. Connection recovery is done elsewhere.
1890 * Discover process only interrogates devices in order to discover the
1891 * domain.For plugging out, we un-register the device only when it is
1892 * the last phy in the port, for other phys in this port, we just delete it
1893 * from the port.For inserting, we do discovery when it is the
1894 * first phy,for other phys in this port, we add it to the port to
1895 * forming the wide-port.
1896 */
1831static int sas_rediscover(struct domain_device *dev, const int phy_id) 1897static int sas_rediscover(struct domain_device *dev, const int phy_id)
1832{ 1898{
1833 struct expander_device *ex = &dev->ex_dev; 1899 struct expander_device *ex = &dev->ex_dev;
1834 struct ex_phy *changed_phy = &ex->ex_phy[phy_id]; 1900 struct ex_phy *changed_phy = &ex->ex_phy[phy_id];
1835 int res = 0; 1901 int res = 0;
1836 int i; 1902 int i;
1903 bool last = true; /* is this the last phy of the port */
1837 1904
1838 SAS_DPRINTK("ex %016llx phy%d originated BROADCAST(CHANGE)\n", 1905 SAS_DPRINTK("ex %016llx phy%d originated BROADCAST(CHANGE)\n",
1839 SAS_ADDR(dev->sas_addr), phy_id); 1906 SAS_ADDR(dev->sas_addr), phy_id);
@@ -1848,13 +1915,13 @@ static int sas_rediscover(struct domain_device *dev, const int phy_id)
1848 SAS_ADDR(changed_phy->attached_sas_addr)) { 1915 SAS_ADDR(changed_phy->attached_sas_addr)) {
1849 SAS_DPRINTK("phy%d part of wide port with " 1916 SAS_DPRINTK("phy%d part of wide port with "
1850 "phy%d\n", phy_id, i); 1917 "phy%d\n", phy_id, i);
1851 goto out; 1918 last = false;
1919 break;
1852 } 1920 }
1853 } 1921 }
1854 res = sas_rediscover_dev(dev, phy_id); 1922 res = sas_rediscover_dev(dev, phy_id, last);
1855 } else 1923 } else
1856 res = sas_discover_new(dev, phy_id); 1924 res = sas_discover_new(dev, phy_id);
1857out:
1858 return res; 1925 return res;
1859} 1926}
1860 1927
@@ -1881,7 +1948,7 @@ int sas_ex_revalidate_domain(struct domain_device *port_dev)
1881 1948
1882 do { 1949 do {
1883 phy_id = -1; 1950 phy_id = -1;
1884 res = sas_find_bcast_phy(dev, &phy_id, i); 1951 res = sas_find_bcast_phy(dev, &phy_id, i, true);
1885 if (phy_id == -1) 1952 if (phy_id == -1)
1886 break; 1953 break;
1887 res = sas_rediscover(dev, phy_id); 1954 res = sas_rediscover(dev, phy_id);
diff --git a/drivers/scsi/libsas/sas_port.c b/drivers/scsi/libsas/sas_port.c
index e6ac59c023f1..fe8b74c706d2 100644
--- a/drivers/scsi/libsas/sas_port.c
+++ b/drivers/scsi/libsas/sas_port.c
@@ -56,7 +56,7 @@ static void sas_form_port(struct asd_sas_phy *phy)
56 } 56 }
57 } 57 }
58 58
59 /* find a port */ 59 /* see if the phy should be part of a wide port */
60 spin_lock_irqsave(&sas_ha->phy_port_lock, flags); 60 spin_lock_irqsave(&sas_ha->phy_port_lock, flags);
61 for (i = 0; i < sas_ha->num_phys; i++) { 61 for (i = 0; i < sas_ha->num_phys; i++) {
62 port = sas_ha->sas_port[i]; 62 port = sas_ha->sas_port[i];
@@ -69,12 +69,23 @@ static void sas_form_port(struct asd_sas_phy *phy)
69 SAS_DPRINTK("phy%d matched wide port%d\n", phy->id, 69 SAS_DPRINTK("phy%d matched wide port%d\n", phy->id,
70 port->id); 70 port->id);
71 break; 71 break;
72 } else if (*(u64 *) port->sas_addr == 0 && port->num_phys==0) {
73 memcpy(port->sas_addr, phy->sas_addr, SAS_ADDR_SIZE);
74 break;
75 } 72 }
76 spin_unlock(&port->phy_list_lock); 73 spin_unlock(&port->phy_list_lock);
77 } 74 }
75 /* The phy does not match any existing port, create a new one */
76 if (i == sas_ha->num_phys) {
77 for (i = 0; i < sas_ha->num_phys; i++) {
78 port = sas_ha->sas_port[i];
79 spin_lock(&port->phy_list_lock);
80 if (*(u64 *)port->sas_addr == 0
81 && port->num_phys == 0) {
82 memcpy(port->sas_addr, phy->sas_addr,
83 SAS_ADDR_SIZE);
84 break;
85 }
86 spin_unlock(&port->phy_list_lock);
87 }
88 }
78 89
79 if (i >= sas_ha->num_phys) { 90 if (i >= sas_ha->num_phys) {
80 printk(KERN_NOTICE "%s: couldn't find a free port, bug?\n", 91 printk(KERN_NOTICE "%s: couldn't find a free port, bug?\n",
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.c b/drivers/scsi/mpt2sas/mpt2sas_base.c
index f3da592f7bcc..35a13867495e 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.c
@@ -119,6 +119,64 @@ _base_fault_reset_work(struct work_struct *work)
119 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags); 119 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
120} 120}
121 121
122/**
123 * mpt2sas_base_start_watchdog - start the fault_reset_work_q
124 * @ioc: pointer to scsi command object
125 * Context: sleep.
126 *
127 * Return nothing.
128 */
129void
130mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc)
131{
132 unsigned long flags;
133
134 if (ioc->fault_reset_work_q)
135 return;
136
137 /* initialize fault polling */
138 INIT_DELAYED_WORK(&ioc->fault_reset_work, _base_fault_reset_work);
139 snprintf(ioc->fault_reset_work_q_name,
140 sizeof(ioc->fault_reset_work_q_name), "poll_%d_status", ioc->id);
141 ioc->fault_reset_work_q =
142 create_singlethread_workqueue(ioc->fault_reset_work_q_name);
143 if (!ioc->fault_reset_work_q) {
144 printk(MPT2SAS_ERR_FMT "%s: failed (line=%d)\n",
145 ioc->name, __func__, __LINE__);
146 return;
147 }
148 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
149 if (ioc->fault_reset_work_q)
150 queue_delayed_work(ioc->fault_reset_work_q,
151 &ioc->fault_reset_work,
152 msecs_to_jiffies(FAULT_POLLING_INTERVAL));
153 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
154}
155
156/**
157 * mpt2sas_base_stop_watchdog - stop the fault_reset_work_q
158 * @ioc: pointer to scsi command object
159 * Context: sleep.
160 *
161 * Return nothing.
162 */
163void
164mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc)
165{
166 unsigned long flags;
167 struct workqueue_struct *wq;
168
169 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
170 wq = ioc->fault_reset_work_q;
171 ioc->fault_reset_work_q = NULL;
172 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
173 if (wq) {
174 if (!cancel_delayed_work(&ioc->fault_reset_work))
175 flush_workqueue(wq);
176 destroy_workqueue(wq);
177 }
178}
179
122#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 180#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
123/** 181/**
124 * _base_sas_ioc_info - verbose translation of the ioc status 182 * _base_sas_ioc_info - verbose translation of the ioc status
@@ -440,6 +498,10 @@ _base_sas_log_info(struct MPT2SAS_ADAPTER *ioc , u32 log_info)
440 if (sas_loginfo.dw.bus_type != 3 /*SAS*/) 498 if (sas_loginfo.dw.bus_type != 3 /*SAS*/)
441 return; 499 return;
442 500
501 /* each nexus loss loginfo */
502 if (log_info == 0x31170000)
503 return;
504
443 /* eat the loginfos associated with task aborts */ 505 /* eat the loginfos associated with task aborts */
444 if (ioc->ignore_loginfos && (log_info == 30050000 || log_info == 506 if (ioc->ignore_loginfos && (log_info == 30050000 || log_info ==
445 0x31140000 || log_info == 0x31130000)) 507 0x31140000 || log_info == 0x31130000))
@@ -1109,7 +1171,6 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
1109 } 1171 }
1110 } 1172 }
1111 1173
1112 pci_set_drvdata(pdev, ioc->shost);
1113 _base_mask_interrupts(ioc); 1174 _base_mask_interrupts(ioc);
1114 r = _base_enable_msix(ioc); 1175 r = _base_enable_msix(ioc);
1115 if (r) 1176 if (r)
@@ -1132,7 +1193,6 @@ mpt2sas_base_map_resources(struct MPT2SAS_ADAPTER *ioc)
1132 ioc->pci_irq = -1; 1193 ioc->pci_irq = -1;
1133 pci_release_selected_regions(ioc->pdev, ioc->bars); 1194 pci_release_selected_regions(ioc->pdev, ioc->bars);
1134 pci_disable_device(pdev); 1195 pci_disable_device(pdev);
1135 pci_set_drvdata(pdev, NULL);
1136 return r; 1196 return r;
1137} 1197}
1138 1198
@@ -3191,7 +3251,6 @@ mpt2sas_base_free_resources(struct MPT2SAS_ADAPTER *ioc)
3191 ioc->chip_phys = 0; 3251 ioc->chip_phys = 0;
3192 pci_release_selected_regions(ioc->pdev, ioc->bars); 3252 pci_release_selected_regions(ioc->pdev, ioc->bars);
3193 pci_disable_device(pdev); 3253 pci_disable_device(pdev);
3194 pci_set_drvdata(pdev, NULL);
3195 return; 3254 return;
3196} 3255}
3197 3256
@@ -3205,7 +3264,6 @@ int
3205mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc) 3264mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3206{ 3265{
3207 int r, i; 3266 int r, i;
3208 unsigned long flags;
3209 3267
3210 dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, 3268 dinitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name,
3211 __func__)); 3269 __func__));
@@ -3214,6 +3272,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3214 if (r) 3272 if (r)
3215 return r; 3273 return r;
3216 3274
3275 pci_set_drvdata(ioc->pdev, ioc->shost);
3217 r = _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET); 3276 r = _base_make_ioc_ready(ioc, CAN_SLEEP, SOFT_RESET);
3218 if (r) 3277 if (r)
3219 goto out_free_resources; 3278 goto out_free_resources;
@@ -3288,23 +3347,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3288 if (r) 3347 if (r)
3289 goto out_free_resources; 3348 goto out_free_resources;
3290 3349
3291 /* initialize fault polling */ 3350 mpt2sas_base_start_watchdog(ioc);
3292 INIT_DELAYED_WORK(&ioc->fault_reset_work, _base_fault_reset_work);
3293 snprintf(ioc->fault_reset_work_q_name,
3294 sizeof(ioc->fault_reset_work_q_name), "poll_%d_status", ioc->id);
3295 ioc->fault_reset_work_q =
3296 create_singlethread_workqueue(ioc->fault_reset_work_q_name);
3297 if (!ioc->fault_reset_work_q) {
3298 printk(MPT2SAS_ERR_FMT "%s: failed (line=%d)\n",
3299 ioc->name, __func__, __LINE__);
3300 goto out_free_resources;
3301 }
3302 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags);
3303 if (ioc->fault_reset_work_q)
3304 queue_delayed_work(ioc->fault_reset_work_q,
3305 &ioc->fault_reset_work,
3306 msecs_to_jiffies(FAULT_POLLING_INTERVAL));
3307 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
3308 return 0; 3351 return 0;
3309 3352
3310 out_free_resources: 3353 out_free_resources:
@@ -3312,6 +3355,7 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3312 ioc->remove_host = 1; 3355 ioc->remove_host = 1;
3313 mpt2sas_base_free_resources(ioc); 3356 mpt2sas_base_free_resources(ioc);
3314 _base_release_memory_pools(ioc); 3357 _base_release_memory_pools(ioc);
3358 pci_set_drvdata(ioc->pdev, NULL);
3315 kfree(ioc->tm_cmds.reply); 3359 kfree(ioc->tm_cmds.reply);
3316 kfree(ioc->transport_cmds.reply); 3360 kfree(ioc->transport_cmds.reply);
3317 kfree(ioc->config_cmds.reply); 3361 kfree(ioc->config_cmds.reply);
@@ -3337,22 +3381,14 @@ mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc)
3337void 3381void
3338mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc) 3382mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc)
3339{ 3383{
3340 unsigned long flags;
3341 struct workqueue_struct *wq;
3342 3384
3343 dexitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name, 3385 dexitprintk(ioc, printk(MPT2SAS_DEBUG_FMT "%s\n", ioc->name,
3344 __func__)); 3386 __func__));
3345 3387
3346 spin_lock_irqsave(&ioc->ioc_reset_in_progress_lock, flags); 3388 mpt2sas_base_stop_watchdog(ioc);
3347 wq = ioc->fault_reset_work_q;
3348 ioc->fault_reset_work_q = NULL;
3349 spin_unlock_irqrestore(&ioc->ioc_reset_in_progress_lock, flags);
3350 if (!cancel_delayed_work(&ioc->fault_reset_work))
3351 flush_workqueue(wq);
3352 destroy_workqueue(wq);
3353
3354 mpt2sas_base_free_resources(ioc); 3389 mpt2sas_base_free_resources(ioc);
3355 _base_release_memory_pools(ioc); 3390 _base_release_memory_pools(ioc);
3391 pci_set_drvdata(ioc->pdev, NULL);
3356 kfree(ioc->pfacts); 3392 kfree(ioc->pfacts);
3357 kfree(ioc->ctl_cmds.reply); 3393 kfree(ioc->ctl_cmds.reply);
3358 kfree(ioc->base_cmds.reply); 3394 kfree(ioc->base_cmds.reply);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_base.h b/drivers/scsi/mpt2sas/mpt2sas_base.h
index 286c185fa9e4..acdcff150a35 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_base.h
+++ b/drivers/scsi/mpt2sas/mpt2sas_base.h
@@ -69,10 +69,10 @@
69#define MPT2SAS_DRIVER_NAME "mpt2sas" 69#define MPT2SAS_DRIVER_NAME "mpt2sas"
70#define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>" 70#define MPT2SAS_AUTHOR "LSI Corporation <DL-MPTFusionLinux@lsi.com>"
71#define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver" 71#define MPT2SAS_DESCRIPTION "LSI MPT Fusion SAS 2.0 Device Driver"
72#define MPT2SAS_DRIVER_VERSION "01.100.03.00" 72#define MPT2SAS_DRIVER_VERSION "01.100.04.00"
73#define MPT2SAS_MAJOR_VERSION 01 73#define MPT2SAS_MAJOR_VERSION 01
74#define MPT2SAS_MINOR_VERSION 100 74#define MPT2SAS_MINOR_VERSION 100
75#define MPT2SAS_BUILD_VERSION 03 75#define MPT2SAS_BUILD_VERSION 04
76#define MPT2SAS_RELEASE_VERSION 00 76#define MPT2SAS_RELEASE_VERSION 00
77 77
78/* 78/*
@@ -673,6 +673,8 @@ typedef void (*MPT_CALLBACK)(struct MPT2SAS_ADAPTER *ioc, u16 smid, u8 VF_ID,
673 673
674/* base shared API */ 674/* base shared API */
675extern struct list_head mpt2sas_ioc_list; 675extern struct list_head mpt2sas_ioc_list;
676void mpt2sas_base_start_watchdog(struct MPT2SAS_ADAPTER *ioc);
677void mpt2sas_base_stop_watchdog(struct MPT2SAS_ADAPTER *ioc);
676 678
677int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc); 679int mpt2sas_base_attach(struct MPT2SAS_ADAPTER *ioc);
678void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc); 680void mpt2sas_base_detach(struct MPT2SAS_ADAPTER *ioc);
diff --git a/drivers/scsi/mpt2sas/mpt2sas_config.c b/drivers/scsi/mpt2sas/mpt2sas_config.c
index 58cfb97846f7..6ddee161beb3 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_config.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_config.c
@@ -236,17 +236,25 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
236 Mpi2ConfigRequest_t *config_request; 236 Mpi2ConfigRequest_t *config_request;
237 int r; 237 int r;
238 u8 retry_count; 238 u8 retry_count;
239 u8 issue_reset; 239 u8 issue_host_reset = 0;
240 u16 wait_state_count; 240 u16 wait_state_count;
241 241
242 mutex_lock(&ioc->config_cmds.mutex);
242 if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) { 243 if (ioc->config_cmds.status != MPT2_CMD_NOT_USED) {
243 printk(MPT2SAS_ERR_FMT "%s: config_cmd in use\n", 244 printk(MPT2SAS_ERR_FMT "%s: config_cmd in use\n",
244 ioc->name, __func__); 245 ioc->name, __func__);
246 mutex_unlock(&ioc->config_cmds.mutex);
245 return -EAGAIN; 247 return -EAGAIN;
246 } 248 }
247 retry_count = 0; 249 retry_count = 0;
248 250
249 retry_config: 251 retry_config:
252 if (retry_count) {
253 if (retry_count > 2) /* attempt only 2 retries */
254 return -EFAULT;
255 printk(MPT2SAS_INFO_FMT "%s: attempting retry (%d)\n",
256 ioc->name, __func__, retry_count);
257 }
250 wait_state_count = 0; 258 wait_state_count = 0;
251 ioc_state = mpt2sas_base_get_iocstate(ioc, 1); 259 ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
252 while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) { 260 while (ioc_state != MPI2_IOC_STATE_OPERATIONAL) {
@@ -254,8 +262,8 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
254 printk(MPT2SAS_ERR_FMT 262 printk(MPT2SAS_ERR_FMT
255 "%s: failed due to ioc not operational\n", 263 "%s: failed due to ioc not operational\n",
256 ioc->name, __func__); 264 ioc->name, __func__);
257 ioc->config_cmds.status = MPT2_CMD_NOT_USED; 265 r = -EFAULT;
258 return -EFAULT; 266 goto out;
259 } 267 }
260 ssleep(1); 268 ssleep(1);
261 ioc_state = mpt2sas_base_get_iocstate(ioc, 1); 269 ioc_state = mpt2sas_base_get_iocstate(ioc, 1);
@@ -271,8 +279,8 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
271 if (!smid) { 279 if (!smid) {
272 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n", 280 printk(MPT2SAS_ERR_FMT "%s: failed obtaining a smid\n",
273 ioc->name, __func__); 281 ioc->name, __func__);
274 ioc->config_cmds.status = MPT2_CMD_NOT_USED; 282 r = -EAGAIN;
275 return -EAGAIN; 283 goto out;
276 } 284 }
277 285
278 r = 0; 286 r = 0;
@@ -292,9 +300,15 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
292 ioc->name, __func__); 300 ioc->name, __func__);
293 _debug_dump_mf(mpi_request, 301 _debug_dump_mf(mpi_request,
294 sizeof(Mpi2ConfigRequest_t)/4); 302 sizeof(Mpi2ConfigRequest_t)/4);
295 if (!(ioc->config_cmds.status & MPT2_CMD_RESET)) 303 retry_count++;
296 issue_reset = 1; 304 if (ioc->config_cmds.smid == smid)
297 goto issue_host_reset; 305 mpt2sas_base_free_smid(ioc, smid);
306 if ((ioc->shost_recovery) ||
307 (ioc->config_cmds.status & MPT2_CMD_RESET))
308 goto retry_config;
309 issue_host_reset = 1;
310 r = -EFAULT;
311 goto out;
298 } 312 }
299 if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID) 313 if (ioc->config_cmds.status & MPT2_CMD_REPLY_VALID)
300 memcpy(mpi_reply, ioc->config_cmds.reply, 314 memcpy(mpi_reply, ioc->config_cmds.reply,
@@ -302,21 +316,13 @@ _config_request(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigRequest_t
302 if (retry_count) 316 if (retry_count)
303 printk(MPT2SAS_INFO_FMT "%s: retry completed!!\n", 317 printk(MPT2SAS_INFO_FMT "%s: retry completed!!\n",
304 ioc->name, __func__); 318 ioc->name, __func__);
319out:
305 ioc->config_cmds.status = MPT2_CMD_NOT_USED; 320 ioc->config_cmds.status = MPT2_CMD_NOT_USED;
306 return r; 321 mutex_unlock(&ioc->config_cmds.mutex);
307 322 if (issue_host_reset)
308 issue_host_reset:
309 if (issue_reset)
310 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, 323 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP,
311 FORCE_BIG_HAMMER); 324 FORCE_BIG_HAMMER);
312 ioc->config_cmds.status = MPT2_CMD_NOT_USED; 325 return r;
313 if (!retry_count) {
314 printk(MPT2SAS_INFO_FMT "%s: attempting retry\n",
315 ioc->name, __func__);
316 retry_count++;
317 goto retry_config;
318 }
319 return -EFAULT;
320} 326}
321 327
322/** 328/**
@@ -375,7 +381,6 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
375 int r; 381 int r;
376 struct config_request mem; 382 struct config_request mem;
377 383
378 mutex_lock(&ioc->config_cmds.mutex);
379 memset(config_page, 0, sizeof(Mpi2ManufacturingPage0_t)); 384 memset(config_page, 0, sizeof(Mpi2ManufacturingPage0_t));
380 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 385 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
381 mpi_request.Function = MPI2_FUNCTION_CONFIG; 386 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -417,7 +422,6 @@ mpt2sas_config_get_manufacturing_pg0(struct MPT2SAS_ADAPTER *ioc,
417 _config_free_config_dma_memory(ioc, &mem); 422 _config_free_config_dma_memory(ioc, &mem);
418 423
419 out: 424 out:
420 mutex_unlock(&ioc->config_cmds.mutex);
421 return r; 425 return r;
422} 426}
423 427
@@ -438,7 +442,6 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc,
438 int r; 442 int r;
439 struct config_request mem; 443 struct config_request mem;
440 444
441 mutex_lock(&ioc->config_cmds.mutex);
442 memset(config_page, 0, sizeof(Mpi2BiosPage2_t)); 445 memset(config_page, 0, sizeof(Mpi2BiosPage2_t));
443 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 446 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
444 mpi_request.Function = MPI2_FUNCTION_CONFIG; 447 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -480,7 +483,6 @@ mpt2sas_config_get_bios_pg2(struct MPT2SAS_ADAPTER *ioc,
480 _config_free_config_dma_memory(ioc, &mem); 483 _config_free_config_dma_memory(ioc, &mem);
481 484
482 out: 485 out:
483 mutex_unlock(&ioc->config_cmds.mutex);
484 return r; 486 return r;
485} 487}
486 488
@@ -501,7 +503,6 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
501 int r; 503 int r;
502 struct config_request mem; 504 struct config_request mem;
503 505
504 mutex_lock(&ioc->config_cmds.mutex);
505 memset(config_page, 0, sizeof(Mpi2BiosPage3_t)); 506 memset(config_page, 0, sizeof(Mpi2BiosPage3_t));
506 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 507 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
507 mpi_request.Function = MPI2_FUNCTION_CONFIG; 508 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -543,7 +544,6 @@ mpt2sas_config_get_bios_pg3(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
543 _config_free_config_dma_memory(ioc, &mem); 544 _config_free_config_dma_memory(ioc, &mem);
544 545
545 out: 546 out:
546 mutex_unlock(&ioc->config_cmds.mutex);
547 return r; 547 return r;
548} 548}
549 549
@@ -564,7 +564,6 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc,
564 int r; 564 int r;
565 struct config_request mem; 565 struct config_request mem;
566 566
567 mutex_lock(&ioc->config_cmds.mutex);
568 memset(config_page, 0, sizeof(Mpi2IOUnitPage0_t)); 567 memset(config_page, 0, sizeof(Mpi2IOUnitPage0_t));
569 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 568 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
570 mpi_request.Function = MPI2_FUNCTION_CONFIG; 569 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -606,7 +605,6 @@ mpt2sas_config_get_iounit_pg0(struct MPT2SAS_ADAPTER *ioc,
606 _config_free_config_dma_memory(ioc, &mem); 605 _config_free_config_dma_memory(ioc, &mem);
607 606
608 out: 607 out:
609 mutex_unlock(&ioc->config_cmds.mutex);
610 return r; 608 return r;
611} 609}
612 610
@@ -627,7 +625,6 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
627 int r; 625 int r;
628 struct config_request mem; 626 struct config_request mem;
629 627
630 mutex_lock(&ioc->config_cmds.mutex);
631 memset(config_page, 0, sizeof(Mpi2IOUnitPage1_t)); 628 memset(config_page, 0, sizeof(Mpi2IOUnitPage1_t));
632 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 629 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
633 mpi_request.Function = MPI2_FUNCTION_CONFIG; 630 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -669,7 +666,6 @@ mpt2sas_config_get_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
669 _config_free_config_dma_memory(ioc, &mem); 666 _config_free_config_dma_memory(ioc, &mem);
670 667
671 out: 668 out:
672 mutex_unlock(&ioc->config_cmds.mutex);
673 return r; 669 return r;
674} 670}
675 671
@@ -690,7 +686,6 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
690 int r; 686 int r;
691 struct config_request mem; 687 struct config_request mem;
692 688
693 mutex_lock(&ioc->config_cmds.mutex);
694 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 689 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
695 mpi_request.Function = MPI2_FUNCTION_CONFIG; 690 mpi_request.Function = MPI2_FUNCTION_CONFIG;
696 mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; 691 mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
@@ -732,7 +727,6 @@ mpt2sas_config_set_iounit_pg1(struct MPT2SAS_ADAPTER *ioc,
732 _config_free_config_dma_memory(ioc, &mem); 727 _config_free_config_dma_memory(ioc, &mem);
733 728
734 out: 729 out:
735 mutex_unlock(&ioc->config_cmds.mutex);
736 return r; 730 return r;
737} 731}
738 732
@@ -753,7 +747,6 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc,
753 int r; 747 int r;
754 struct config_request mem; 748 struct config_request mem;
755 749
756 mutex_lock(&ioc->config_cmds.mutex);
757 memset(config_page, 0, sizeof(Mpi2IOCPage8_t)); 750 memset(config_page, 0, sizeof(Mpi2IOCPage8_t));
758 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 751 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
759 mpi_request.Function = MPI2_FUNCTION_CONFIG; 752 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -795,7 +788,6 @@ mpt2sas_config_get_ioc_pg8(struct MPT2SAS_ADAPTER *ioc,
795 _config_free_config_dma_memory(ioc, &mem); 788 _config_free_config_dma_memory(ioc, &mem);
796 789
797 out: 790 out:
798 mutex_unlock(&ioc->config_cmds.mutex);
799 return r; 791 return r;
800} 792}
801 793
@@ -818,7 +810,6 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
818 int r; 810 int r;
819 struct config_request mem; 811 struct config_request mem;
820 812
821 mutex_lock(&ioc->config_cmds.mutex);
822 memset(config_page, 0, sizeof(Mpi2SasDevicePage0_t)); 813 memset(config_page, 0, sizeof(Mpi2SasDevicePage0_t));
823 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 814 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
824 mpi_request.Function = MPI2_FUNCTION_CONFIG; 815 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -863,7 +854,6 @@ mpt2sas_config_get_sas_device_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
863 _config_free_config_dma_memory(ioc, &mem); 854 _config_free_config_dma_memory(ioc, &mem);
864 855
865 out: 856 out:
866 mutex_unlock(&ioc->config_cmds.mutex);
867 return r; 857 return r;
868} 858}
869 859
@@ -886,7 +876,6 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
886 int r; 876 int r;
887 struct config_request mem; 877 struct config_request mem;
888 878
889 mutex_lock(&ioc->config_cmds.mutex);
890 memset(config_page, 0, sizeof(Mpi2SasDevicePage1_t)); 879 memset(config_page, 0, sizeof(Mpi2SasDevicePage1_t));
891 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 880 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
892 mpi_request.Function = MPI2_FUNCTION_CONFIG; 881 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -931,7 +920,6 @@ mpt2sas_config_get_sas_device_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
931 _config_free_config_dma_memory(ioc, &mem); 920 _config_free_config_dma_memory(ioc, &mem);
932 921
933 out: 922 out:
934 mutex_unlock(&ioc->config_cmds.mutex);
935 return r; 923 return r;
936} 924}
937 925
@@ -953,7 +941,6 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys)
953 Mpi2ConfigReply_t mpi_reply; 941 Mpi2ConfigReply_t mpi_reply;
954 Mpi2SasIOUnitPage0_t config_page; 942 Mpi2SasIOUnitPage0_t config_page;
955 943
956 mutex_lock(&ioc->config_cmds.mutex);
957 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 944 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
958 mpi_request.Function = MPI2_FUNCTION_CONFIG; 945 mpi_request.Function = MPI2_FUNCTION_CONFIG;
959 mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER; 946 mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
@@ -1002,7 +989,6 @@ mpt2sas_config_get_number_hba_phys(struct MPT2SAS_ADAPTER *ioc, u8 *num_phys)
1002 _config_free_config_dma_memory(ioc, &mem); 989 _config_free_config_dma_memory(ioc, &mem);
1003 990
1004 out: 991 out:
1005 mutex_unlock(&ioc->config_cmds.mutex);
1006 return r; 992 return r;
1007} 993}
1008 994
@@ -1026,8 +1012,6 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1026 Mpi2ConfigRequest_t mpi_request; 1012 Mpi2ConfigRequest_t mpi_request;
1027 int r; 1013 int r;
1028 struct config_request mem; 1014 struct config_request mem;
1029
1030 mutex_lock(&ioc->config_cmds.mutex);
1031 memset(config_page, 0, sz); 1015 memset(config_page, 0, sz);
1032 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1016 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1033 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1017 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1070,7 +1054,6 @@ mpt2sas_config_get_sas_iounit_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1070 _config_free_config_dma_memory(ioc, &mem); 1054 _config_free_config_dma_memory(ioc, &mem);
1071 1055
1072 out: 1056 out:
1073 mutex_unlock(&ioc->config_cmds.mutex);
1074 return r; 1057 return r;
1075} 1058}
1076 1059
@@ -1095,7 +1078,6 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1095 int r; 1078 int r;
1096 struct config_request mem; 1079 struct config_request mem;
1097 1080
1098 mutex_lock(&ioc->config_cmds.mutex);
1099 memset(config_page, 0, sz); 1081 memset(config_page, 0, sz);
1100 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1082 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1101 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1083 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1138,7 +1120,6 @@ mpt2sas_config_get_sas_iounit_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1138 _config_free_config_dma_memory(ioc, &mem); 1120 _config_free_config_dma_memory(ioc, &mem);
1139 1121
1140 out: 1122 out:
1141 mutex_unlock(&ioc->config_cmds.mutex);
1142 return r; 1123 return r;
1143} 1124}
1144 1125
@@ -1161,7 +1142,6 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1161 int r; 1142 int r;
1162 struct config_request mem; 1143 struct config_request mem;
1163 1144
1164 mutex_lock(&ioc->config_cmds.mutex);
1165 memset(config_page, 0, sizeof(Mpi2ExpanderPage0_t)); 1145 memset(config_page, 0, sizeof(Mpi2ExpanderPage0_t));
1166 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1146 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1167 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1147 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1206,7 +1186,6 @@ mpt2sas_config_get_expander_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1206 _config_free_config_dma_memory(ioc, &mem); 1186 _config_free_config_dma_memory(ioc, &mem);
1207 1187
1208 out: 1188 out:
1209 mutex_unlock(&ioc->config_cmds.mutex);
1210 return r; 1189 return r;
1211} 1190}
1212 1191
@@ -1230,7 +1209,6 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1230 int r; 1209 int r;
1231 struct config_request mem; 1210 struct config_request mem;
1232 1211
1233 mutex_lock(&ioc->config_cmds.mutex);
1234 memset(config_page, 0, sizeof(Mpi2ExpanderPage1_t)); 1212 memset(config_page, 0, sizeof(Mpi2ExpanderPage1_t));
1235 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1213 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1236 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1214 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1277,7 +1255,6 @@ mpt2sas_config_get_expander_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1277 _config_free_config_dma_memory(ioc, &mem); 1255 _config_free_config_dma_memory(ioc, &mem);
1278 1256
1279 out: 1257 out:
1280 mutex_unlock(&ioc->config_cmds.mutex);
1281 return r; 1258 return r;
1282} 1259}
1283 1260
@@ -1300,7 +1277,6 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1300 int r; 1277 int r;
1301 struct config_request mem; 1278 struct config_request mem;
1302 1279
1303 mutex_lock(&ioc->config_cmds.mutex);
1304 memset(config_page, 0, sizeof(Mpi2SasEnclosurePage0_t)); 1280 memset(config_page, 0, sizeof(Mpi2SasEnclosurePage0_t));
1305 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1281 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1306 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1282 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1345,7 +1321,6 @@ mpt2sas_config_get_enclosure_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1345 _config_free_config_dma_memory(ioc, &mem); 1321 _config_free_config_dma_memory(ioc, &mem);
1346 1322
1347 out: 1323 out:
1348 mutex_unlock(&ioc->config_cmds.mutex);
1349 return r; 1324 return r;
1350} 1325}
1351 1326
@@ -1367,7 +1342,6 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1367 int r; 1342 int r;
1368 struct config_request mem; 1343 struct config_request mem;
1369 1344
1370 mutex_lock(&ioc->config_cmds.mutex);
1371 memset(config_page, 0, sizeof(Mpi2SasPhyPage0_t)); 1345 memset(config_page, 0, sizeof(Mpi2SasPhyPage0_t));
1372 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1346 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1373 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1347 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1413,7 +1387,6 @@ mpt2sas_config_get_phy_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1413 _config_free_config_dma_memory(ioc, &mem); 1387 _config_free_config_dma_memory(ioc, &mem);
1414 1388
1415 out: 1389 out:
1416 mutex_unlock(&ioc->config_cmds.mutex);
1417 return r; 1390 return r;
1418} 1391}
1419 1392
@@ -1435,7 +1408,6 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1435 int r; 1408 int r;
1436 struct config_request mem; 1409 struct config_request mem;
1437 1410
1438 mutex_lock(&ioc->config_cmds.mutex);
1439 memset(config_page, 0, sizeof(Mpi2SasPhyPage1_t)); 1411 memset(config_page, 0, sizeof(Mpi2SasPhyPage1_t));
1440 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1412 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1441 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1413 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1481,7 +1453,6 @@ mpt2sas_config_get_phy_pg1(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1481 _config_free_config_dma_memory(ioc, &mem); 1453 _config_free_config_dma_memory(ioc, &mem);
1482 1454
1483 out: 1455 out:
1484 mutex_unlock(&ioc->config_cmds.mutex);
1485 return r; 1456 return r;
1486} 1457}
1487 1458
@@ -1505,7 +1476,6 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc,
1505 int r; 1476 int r;
1506 struct config_request mem; 1477 struct config_request mem;
1507 1478
1508 mutex_lock(&ioc->config_cmds.mutex);
1509 memset(config_page, 0, sizeof(Mpi2RaidVolPage1_t)); 1479 memset(config_page, 0, sizeof(Mpi2RaidVolPage1_t));
1510 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1480 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1511 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1481 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1548,7 +1518,6 @@ mpt2sas_config_get_raid_volume_pg1(struct MPT2SAS_ADAPTER *ioc,
1548 _config_free_config_dma_memory(ioc, &mem); 1518 _config_free_config_dma_memory(ioc, &mem);
1549 1519
1550 out: 1520 out:
1551 mutex_unlock(&ioc->config_cmds.mutex);
1552 return r; 1521 return r;
1553} 1522}
1554 1523
@@ -1572,7 +1541,6 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle,
1572 struct config_request mem; 1541 struct config_request mem;
1573 u16 ioc_status; 1542 u16 ioc_status;
1574 1543
1575 mutex_lock(&ioc->config_cmds.mutex);
1576 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1544 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1577 *num_pds = 0; 1545 *num_pds = 0;
1578 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1546 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1620,7 +1588,6 @@ mpt2sas_config_get_number_pds(struct MPT2SAS_ADAPTER *ioc, u16 handle,
1620 _config_free_config_dma_memory(ioc, &mem); 1588 _config_free_config_dma_memory(ioc, &mem);
1621 1589
1622 out: 1590 out:
1623 mutex_unlock(&ioc->config_cmds.mutex);
1624 return r; 1591 return r;
1625} 1592}
1626 1593
@@ -1645,7 +1612,6 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc,
1645 int r; 1612 int r;
1646 struct config_request mem; 1613 struct config_request mem;
1647 1614
1648 mutex_lock(&ioc->config_cmds.mutex);
1649 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1615 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1650 memset(config_page, 0, sz); 1616 memset(config_page, 0, sz);
1651 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1617 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1687,7 +1653,6 @@ mpt2sas_config_get_raid_volume_pg0(struct MPT2SAS_ADAPTER *ioc,
1687 _config_free_config_dma_memory(ioc, &mem); 1653 _config_free_config_dma_memory(ioc, &mem);
1688 1654
1689 out: 1655 out:
1690 mutex_unlock(&ioc->config_cmds.mutex);
1691 return r; 1656 return r;
1692} 1657}
1693 1658
@@ -1711,7 +1676,6 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1711 int r; 1676 int r;
1712 struct config_request mem; 1677 struct config_request mem;
1713 1678
1714 mutex_lock(&ioc->config_cmds.mutex);
1715 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1679 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1716 memset(config_page, 0, sizeof(Mpi2RaidPhysDiskPage0_t)); 1680 memset(config_page, 0, sizeof(Mpi2RaidPhysDiskPage0_t));
1717 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1681 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1754,7 +1718,6 @@ mpt2sas_config_get_phys_disk_pg0(struct MPT2SAS_ADAPTER *ioc, Mpi2ConfigReply_t
1754 _config_free_config_dma_memory(ioc, &mem); 1718 _config_free_config_dma_memory(ioc, &mem);
1755 1719
1756 out: 1720 out:
1757 mutex_unlock(&ioc->config_cmds.mutex);
1758 return r; 1721 return r;
1759} 1722}
1760 1723
@@ -1778,7 +1741,6 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
1778 struct config_request mem; 1741 struct config_request mem;
1779 u16 ioc_status; 1742 u16 ioc_status;
1780 1743
1781 mutex_lock(&ioc->config_cmds.mutex);
1782 *volume_handle = 0; 1744 *volume_handle = 0;
1783 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t)); 1745 memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
1784 mpi_request.Function = MPI2_FUNCTION_CONFIG; 1746 mpi_request.Function = MPI2_FUNCTION_CONFIG;
@@ -1842,7 +1804,6 @@ mpt2sas_config_get_volume_handle(struct MPT2SAS_ADAPTER *ioc, u16 pd_handle,
1842 _config_free_config_dma_memory(ioc, &mem); 1804 _config_free_config_dma_memory(ioc, &mem);
1843 1805
1844 out: 1806 out:
1845 mutex_unlock(&ioc->config_cmds.mutex);
1846 return r; 1807 return r;
1847} 1808}
1848 1809
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 2a01a5f2a84d..2e9a4445596f 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -2767,6 +2767,10 @@ _scsih_scsi_ioc_info(struct MPT2SAS_ADAPTER *ioc, struct scsi_cmnd *scmd,
2767 char *desc_ioc_state = NULL; 2767 char *desc_ioc_state = NULL;
2768 char *desc_scsi_status = NULL; 2768 char *desc_scsi_status = NULL;
2769 char *desc_scsi_state = ioc->tmp_string; 2769 char *desc_scsi_state = ioc->tmp_string;
2770 u32 log_info = le32_to_cpu(mpi_reply->IOCLogInfo);
2771
2772 if (log_info == 0x31170000)
2773 return;
2770 2774
2771 switch (ioc_status) { 2775 switch (ioc_status) {
2772 case MPI2_IOCSTATUS_SUCCESS: 2776 case MPI2_IOCSTATUS_SUCCESS:
@@ -3426,7 +3430,7 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3426 __le64 sas_address; 3430 __le64 sas_address;
3427 int i; 3431 int i;
3428 unsigned long flags; 3432 unsigned long flags;
3429 struct _sas_port *mpt2sas_port; 3433 struct _sas_port *mpt2sas_port = NULL;
3430 int rc = 0; 3434 int rc = 0;
3431 3435
3432 if (!handle) 3436 if (!handle)
@@ -3518,12 +3522,20 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3518 &expander_pg1, i, handle))) { 3522 &expander_pg1, i, handle))) {
3519 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n", 3523 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
3520 ioc->name, __FILE__, __LINE__, __func__); 3524 ioc->name, __FILE__, __LINE__, __func__);
3521 continue; 3525 rc = -1;
3526 goto out_fail;
3522 } 3527 }
3523 sas_expander->phy[i].handle = handle; 3528 sas_expander->phy[i].handle = handle;
3524 sas_expander->phy[i].phy_id = i; 3529 sas_expander->phy[i].phy_id = i;
3525 mpt2sas_transport_add_expander_phy(ioc, &sas_expander->phy[i], 3530
3526 expander_pg1, sas_expander->parent_dev); 3531 if ((mpt2sas_transport_add_expander_phy(ioc,
3532 &sas_expander->phy[i], expander_pg1,
3533 sas_expander->parent_dev))) {
3534 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
3535 ioc->name, __FILE__, __LINE__, __func__);
3536 rc = -1;
3537 goto out_fail;
3538 }
3527 } 3539 }
3528 3540
3529 if (sas_expander->enclosure_handle) { 3541 if (sas_expander->enclosure_handle) {
@@ -3540,8 +3552,9 @@ _scsih_expander_add(struct MPT2SAS_ADAPTER *ioc, u16 handle)
3540 3552
3541 out_fail: 3553 out_fail:
3542 3554
3543 if (sas_expander) 3555 if (mpt2sas_port)
3544 kfree(sas_expander->phy); 3556 mpt2sas_transport_port_remove(ioc, sas_expander->sas_address,
3557 sas_expander->parent_handle);
3545 kfree(sas_expander); 3558 kfree(sas_expander);
3546 return rc; 3559 return rc;
3547} 3560}
@@ -3663,12 +3676,11 @@ _scsih_add_device(struct MPT2SAS_ADAPTER *ioc, u16 handle, u8 phy_num, u8 is_pd)
3663 sas_device->hidden_raid_component = is_pd; 3676 sas_device->hidden_raid_component = is_pd;
3664 3677
3665 /* get enclosure_logical_id */ 3678 /* get enclosure_logical_id */
3666 if (!(mpt2sas_config_get_enclosure_pg0(ioc, &mpi_reply, &enclosure_pg0, 3679 if (sas_device->enclosure_handle && !(mpt2sas_config_get_enclosure_pg0(
3667 MPI2_SAS_ENCLOS_PGAD_FORM_HANDLE, 3680 ioc, &mpi_reply, &enclosure_pg0, MPI2_SAS_ENCLOS_PGAD_FORM_HANDLE,
3668 sas_device->enclosure_handle))) { 3681 sas_device->enclosure_handle)))
3669 sas_device->enclosure_logical_id = 3682 sas_device->enclosure_logical_id =
3670 le64_to_cpu(enclosure_pg0.EnclosureLogicalID); 3683 le64_to_cpu(enclosure_pg0.EnclosureLogicalID);
3671 }
3672 3684
3673 /* get device name */ 3685 /* get device name */
3674 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName); 3686 sas_device->device_name = le64_to_cpu(sas_device_pg0.DeviceName);
@@ -4250,12 +4262,6 @@ _scsih_sas_volume_add(struct MPT2SAS_ADAPTER *ioc,
4250 u16 handle = le16_to_cpu(element->VolDevHandle); 4262 u16 handle = le16_to_cpu(element->VolDevHandle);
4251 int rc; 4263 int rc;
4252 4264
4253#if 0 /* RAID_HACKS */
4254 if (le32_to_cpu(event_data->Flags) &
4255 MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG)
4256 return;
4257#endif
4258
4259 mpt2sas_config_get_volume_wwid(ioc, handle, &wwid); 4265 mpt2sas_config_get_volume_wwid(ioc, handle, &wwid);
4260 if (!wwid) { 4266 if (!wwid) {
4261 printk(MPT2SAS_ERR_FMT 4267 printk(MPT2SAS_ERR_FMT
@@ -4310,12 +4316,6 @@ _scsih_sas_volume_delete(struct MPT2SAS_ADAPTER *ioc,
4310 unsigned long flags; 4316 unsigned long flags;
4311 struct MPT2SAS_TARGET *sas_target_priv_data; 4317 struct MPT2SAS_TARGET *sas_target_priv_data;
4312 4318
4313#if 0 /* RAID_HACKS */
4314 if (le32_to_cpu(event_data->Flags) &
4315 MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG)
4316 return;
4317#endif
4318
4319 spin_lock_irqsave(&ioc->raid_device_lock, flags); 4319 spin_lock_irqsave(&ioc->raid_device_lock, flags);
4320 raid_device = _scsih_raid_device_find_by_handle(ioc, handle); 4320 raid_device = _scsih_raid_device_find_by_handle(ioc, handle);
4321 spin_unlock_irqrestore(&ioc->raid_device_lock, flags); 4321 spin_unlock_irqrestore(&ioc->raid_device_lock, flags);
@@ -4428,14 +4428,38 @@ _scsih_sas_pd_add(struct MPT2SAS_ADAPTER *ioc,
4428 struct _sas_device *sas_device; 4428 struct _sas_device *sas_device;
4429 unsigned long flags; 4429 unsigned long flags;
4430 u16 handle = le16_to_cpu(element->PhysDiskDevHandle); 4430 u16 handle = le16_to_cpu(element->PhysDiskDevHandle);
4431 Mpi2ConfigReply_t mpi_reply;
4432 Mpi2SasDevicePage0_t sas_device_pg0;
4433 u32 ioc_status;
4431 4434
4432 spin_lock_irqsave(&ioc->sas_device_lock, flags); 4435 spin_lock_irqsave(&ioc->sas_device_lock, flags);
4433 sas_device = _scsih_sas_device_find_by_handle(ioc, handle); 4436 sas_device = _scsih_sas_device_find_by_handle(ioc, handle);
4434 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); 4437 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
4435 if (sas_device) 4438 if (sas_device) {
4436 sas_device->hidden_raid_component = 1; 4439 sas_device->hidden_raid_component = 1;
4437 else 4440 return;
4438 _scsih_add_device(ioc, handle, 0, 1); 4441 }
4442
4443 if ((mpt2sas_config_get_sas_device_pg0(ioc, &mpi_reply, &sas_device_pg0,
4444 MPI2_SAS_DEVICE_PGAD_FORM_HANDLE, handle))) {
4445 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
4446 ioc->name, __FILE__, __LINE__, __func__);
4447 return;
4448 }
4449
4450 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
4451 MPI2_IOCSTATUS_MASK;
4452 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
4453 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
4454 ioc->name, __FILE__, __LINE__, __func__);
4455 return;
4456 }
4457
4458 _scsih_link_change(ioc,
4459 le16_to_cpu(sas_device_pg0.ParentDevHandle),
4460 handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5);
4461
4462 _scsih_add_device(ioc, handle, 0, 1);
4439} 4463}
4440 4464
4441#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4465#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
@@ -4535,12 +4559,15 @@ _scsih_sas_ir_config_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4535{ 4559{
4536 Mpi2EventIrConfigElement_t *element; 4560 Mpi2EventIrConfigElement_t *element;
4537 int i; 4561 int i;
4562 u8 foreign_config;
4538 4563
4539#ifdef CONFIG_SCSI_MPT2SAS_LOGGING 4564#ifdef CONFIG_SCSI_MPT2SAS_LOGGING
4540 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK) 4565 if (ioc->logging_level & MPT_DEBUG_EVENT_WORK_TASK)
4541 _scsih_sas_ir_config_change_event_debug(ioc, event_data); 4566 _scsih_sas_ir_config_change_event_debug(ioc, event_data);
4542 4567
4543#endif 4568#endif
4569 foreign_config = (le32_to_cpu(event_data->Flags) &
4570 MPI2_EVENT_IR_CHANGE_FLAGS_FOREIGN_CONFIG) ? 1 : 0;
4544 4571
4545 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0]; 4572 element = (Mpi2EventIrConfigElement_t *)&event_data->ConfigElement[0];
4546 for (i = 0; i < event_data->NumElements; i++, element++) { 4573 for (i = 0; i < event_data->NumElements; i++, element++) {
@@ -4548,11 +4575,13 @@ _scsih_sas_ir_config_change_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4548 switch (element->ReasonCode) { 4575 switch (element->ReasonCode) {
4549 case MPI2_EVENT_IR_CHANGE_RC_VOLUME_CREATED: 4576 case MPI2_EVENT_IR_CHANGE_RC_VOLUME_CREATED:
4550 case MPI2_EVENT_IR_CHANGE_RC_ADDED: 4577 case MPI2_EVENT_IR_CHANGE_RC_ADDED:
4551 _scsih_sas_volume_add(ioc, element); 4578 if (!foreign_config)
4579 _scsih_sas_volume_add(ioc, element);
4552 break; 4580 break;
4553 case MPI2_EVENT_IR_CHANGE_RC_VOLUME_DELETED: 4581 case MPI2_EVENT_IR_CHANGE_RC_VOLUME_DELETED:
4554 case MPI2_EVENT_IR_CHANGE_RC_REMOVED: 4582 case MPI2_EVENT_IR_CHANGE_RC_REMOVED:
4555 _scsih_sas_volume_delete(ioc, element); 4583 if (!foreign_config)
4584 _scsih_sas_volume_delete(ioc, element);
4556 break; 4585 break;
4557 case MPI2_EVENT_IR_CHANGE_RC_PD_CREATED: 4586 case MPI2_EVENT_IR_CHANGE_RC_PD_CREATED:
4558 _scsih_sas_pd_hide(ioc, element); 4587 _scsih_sas_pd_hide(ioc, element);
@@ -4671,6 +4700,9 @@ _scsih_sas_ir_physical_disk_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4671 u32 state; 4700 u32 state;
4672 struct _sas_device *sas_device; 4701 struct _sas_device *sas_device;
4673 unsigned long flags; 4702 unsigned long flags;
4703 Mpi2ConfigReply_t mpi_reply;
4704 Mpi2SasDevicePage0_t sas_device_pg0;
4705 u32 ioc_status;
4674 4706
4675 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED) 4707 if (event_data->ReasonCode != MPI2_EVENT_IR_PHYSDISK_RC_STATE_CHANGED)
4676 return; 4708 return;
@@ -4687,22 +4719,40 @@ _scsih_sas_ir_physical_disk_event(struct MPT2SAS_ADAPTER *ioc, u8 VF_ID,
4687 spin_unlock_irqrestore(&ioc->sas_device_lock, flags); 4719 spin_unlock_irqrestore(&ioc->sas_device_lock, flags);
4688 4720
4689 switch (state) { 4721 switch (state) {
4690#if 0
4691 case MPI2_RAID_PD_STATE_OFFLINE:
4692 if (sas_device)
4693 _scsih_remove_device(ioc, handle);
4694 break;
4695#endif
4696 case MPI2_RAID_PD_STATE_ONLINE: 4722 case MPI2_RAID_PD_STATE_ONLINE:
4697 case MPI2_RAID_PD_STATE_DEGRADED: 4723 case MPI2_RAID_PD_STATE_DEGRADED:
4698 case MPI2_RAID_PD_STATE_REBUILDING: 4724 case MPI2_RAID_PD_STATE_REBUILDING:
4699 case MPI2_RAID_PD_STATE_OPTIMAL: 4725 case MPI2_RAID_PD_STATE_OPTIMAL:
4700 if (sas_device) 4726 if (sas_device) {
4701 sas_device->hidden_raid_component = 1; 4727 sas_device->hidden_raid_component = 1;
4702 else 4728 return;
4703 _scsih_add_device(ioc, handle, 0, 1); 4729 }
4730
4731 if ((mpt2sas_config_get_sas_device_pg0(ioc, &mpi_reply,
4732 &sas_device_pg0, MPI2_SAS_DEVICE_PGAD_FORM_HANDLE,
4733 handle))) {
4734 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
4735 ioc->name, __FILE__, __LINE__, __func__);
4736 return;
4737 }
4738
4739 ioc_status = le16_to_cpu(mpi_reply.IOCStatus) &
4740 MPI2_IOCSTATUS_MASK;
4741 if (ioc_status != MPI2_IOCSTATUS_SUCCESS) {
4742 printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
4743 ioc->name, __FILE__, __LINE__, __func__);
4744 return;
4745 }
4746
4747 _scsih_link_change(ioc,
4748 le16_to_cpu(sas_device_pg0.ParentDevHandle),
4749 handle, sas_device_pg0.PhyNum, MPI2_SAS_NEG_LINK_RATE_1_5);
4750
4751 _scsih_add_device(ioc, handle, 0, 1);
4752
4704 break; 4753 break;
4705 4754
4755 case MPI2_RAID_PD_STATE_OFFLINE:
4706 case MPI2_RAID_PD_STATE_NOT_CONFIGURED: 4756 case MPI2_RAID_PD_STATE_NOT_CONFIGURED:
4707 case MPI2_RAID_PD_STATE_NOT_COMPATIBLE: 4757 case MPI2_RAID_PD_STATE_NOT_COMPATIBLE:
4708 case MPI2_RAID_PD_STATE_HOT_SPARE: 4758 case MPI2_RAID_PD_STATE_HOT_SPARE:
@@ -5774,6 +5824,7 @@ _scsih_suspend(struct pci_dev *pdev, pm_message_t state)
5774 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost); 5824 struct MPT2SAS_ADAPTER *ioc = shost_priv(shost);
5775 u32 device_state; 5825 u32 device_state;
5776 5826
5827 mpt2sas_base_stop_watchdog(ioc);
5777 flush_scheduled_work(); 5828 flush_scheduled_work();
5778 scsi_block_requests(shost); 5829 scsi_block_requests(shost);
5779 device_state = pci_choose_state(pdev, state); 5830 device_state = pci_choose_state(pdev, state);
@@ -5816,6 +5867,7 @@ _scsih_resume(struct pci_dev *pdev)
5816 5867
5817 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, SOFT_RESET); 5868 mpt2sas_base_hard_reset_handler(ioc, CAN_SLEEP, SOFT_RESET);
5818 scsi_unblock_requests(shost); 5869 scsi_unblock_requests(shost);
5870 mpt2sas_base_start_watchdog(ioc);
5819 return 0; 5871 return 0;
5820} 5872}
5821#endif /* CONFIG_PM */ 5873#endif /* CONFIG_PM */
diff --git a/drivers/scsi/qla4xxx/ql4_dbg.c b/drivers/scsi/qla4xxx/ql4_dbg.c
index fcc184cd066d..cbceb0ebabf7 100644
--- a/drivers/scsi/qla4xxx/ql4_dbg.c
+++ b/drivers/scsi/qla4xxx/ql4_dbg.c
@@ -15,19 +15,18 @@ void qla4xxx_dump_buffer(void *b, uint32_t size)
15 uint32_t cnt; 15 uint32_t cnt;
16 uint8_t *c = b; 16 uint8_t *c = b;
17 17
18 printk(" 0 1 2 3 4 5 6 7 8 9 Ah Bh Ch Dh Eh " 18 printk(" 0 1 2 3 4 5 6 7 8 9 Ah Bh Ch Dh Eh "
19 "Fh\n"); 19 "Fh\n");
20 printk("------------------------------------------------------------" 20 printk("------------------------------------------------------------"
21 "--\n"); 21 "--\n");
22 for (cnt = 0; cnt < size; cnt++, c++) { 22 for (cnt = 0; cnt < size; c++) {
23 printk(KERN_DEBUG "%02x", *c); 23 printk(KERN_INFO "%02x", *c);
24 if (!(cnt % 16)) 24 if (!(++cnt % 16))
25 printk(KERN_DEBUG "\n"); 25 printk(KERN_INFO "\n");
26 26
27 else 27 else
28 printk(KERN_DEBUG " "); 28 printk(KERN_INFO " ");
29 } 29 }
30 if (cnt % 16) 30 printk(KERN_INFO "\n");
31 printk(KERN_DEBUG "\n");
32} 31}
33 32
diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
index b586f27c3bd4..81b5f29254e2 100644
--- a/drivers/scsi/qla4xxx/ql4_def.h
+++ b/drivers/scsi/qla4xxx/ql4_def.h
@@ -100,7 +100,6 @@
100#define MAX_SRBS MAX_CMDS_TO_RISC 100#define MAX_SRBS MAX_CMDS_TO_RISC
101#define MBOX_AEN_REG_COUNT 5 101#define MBOX_AEN_REG_COUNT 5
102#define MAX_INIT_RETRIES 5 102#define MAX_INIT_RETRIES 5
103#define IOCB_HIWAT_CUSHION 16
104 103
105/* 104/*
106 * Buffer sizes 105 * Buffer sizes
@@ -184,6 +183,11 @@ struct srb {
184 uint16_t cc_stat; 183 uint16_t cc_stat;
185 u_long r_start; /* Time we recieve a cmd from OS */ 184 u_long r_start; /* Time we recieve a cmd from OS */
186 u_long u_start; /* Time when we handed the cmd to F/W */ 185 u_long u_start; /* Time when we handed the cmd to F/W */
186
187 /* Used for extended sense / status continuation */
188 uint8_t *req_sense_ptr;
189 uint16_t req_sense_len;
190 uint16_t reserved2;
187}; 191};
188 192
189/* 193/*
@@ -302,7 +306,6 @@ struct scsi_qla_host {
302 uint32_t tot_ddbs; 306 uint32_t tot_ddbs;
303 307
304 uint16_t iocb_cnt; 308 uint16_t iocb_cnt;
305 uint16_t iocb_hiwat;
306 309
307 /* SRB cache. */ 310 /* SRB cache. */
308#define SRB_MIN_REQ 128 311#define SRB_MIN_REQ 128
@@ -436,6 +439,8 @@ struct scsi_qla_host {
436 /* Map ddb_list entry by FW ddb index */ 439 /* Map ddb_list entry by FW ddb index */
437 struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES]; 440 struct ddb_entry *fw_ddb_index_map[MAX_DDB_ENTRIES];
438 441
442 /* Saved srb for status continuation entry processing */
443 struct srb *status_srb;
439}; 444};
440 445
441static inline int is_qla4010(struct scsi_qla_host *ha) 446static inline int is_qla4010(struct scsi_qla_host *ha)
diff --git a/drivers/scsi/qla4xxx/ql4_fw.h b/drivers/scsi/qla4xxx/ql4_fw.h
index 1b667a70cffa..9cd7a608df38 100644
--- a/drivers/scsi/qla4xxx/ql4_fw.h
+++ b/drivers/scsi/qla4xxx/ql4_fw.h
@@ -572,6 +572,7 @@ struct conn_event_log_entry {
572 *************************************************************************/ 572 *************************************************************************/
573#define IOCB_MAX_CDB_LEN 16 /* Bytes in a CBD */ 573#define IOCB_MAX_CDB_LEN 16 /* Bytes in a CBD */
574#define IOCB_MAX_SENSEDATA_LEN 32 /* Bytes of sense data */ 574#define IOCB_MAX_SENSEDATA_LEN 32 /* Bytes of sense data */
575#define IOCB_MAX_EXT_SENSEDATA_LEN 60 /* Bytes of extended sense data */
575 576
576/* IOCB header structure */ 577/* IOCB header structure */
577struct qla4_header { 578struct qla4_header {
@@ -733,6 +734,12 @@ struct status_entry {
733 734
734}; 735};
735 736
737/* Status Continuation entry */
738struct status_cont_entry {
739 struct qla4_header hdr; /* 00-03 */
740 uint8_t ext_sense_data[IOCB_MAX_EXT_SENSEDATA_LEN]; /* 04-63 */
741};
742
736struct passthru0 { 743struct passthru0 {
737 struct qla4_header hdr; /* 00-03 */ 744 struct qla4_header hdr; /* 00-03 */
738 uint32_t handle; /* 04-07 */ 745 uint32_t handle; /* 04-07 */
diff --git a/drivers/scsi/qla4xxx/ql4_iocb.c b/drivers/scsi/qla4xxx/ql4_iocb.c
index 912a67494adf..e0c32159749c 100644
--- a/drivers/scsi/qla4xxx/ql4_iocb.c
+++ b/drivers/scsi/qla4xxx/ql4_iocb.c
@@ -10,9 +10,42 @@
10#include "ql4_dbg.h" 10#include "ql4_dbg.h"
11#include "ql4_inline.h" 11#include "ql4_inline.h"
12 12
13
14#include <scsi/scsi_tcq.h> 13#include <scsi/scsi_tcq.h>
15 14
15static int
16qla4xxx_space_in_req_ring(struct scsi_qla_host *ha, uint16_t req_cnt)
17{
18 uint16_t cnt;
19
20 /* Calculate number of free request entries. */
21 if ((req_cnt + 2) >= ha->req_q_count) {
22 cnt = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out);
23 if (ha->request_in < cnt)
24 ha->req_q_count = cnt - ha->request_in;
25 else
26 ha->req_q_count = REQUEST_QUEUE_DEPTH -
27 (ha->request_in - cnt);
28 }
29
30 /* Check if room for request in request ring. */
31 if ((req_cnt + 2) < ha->req_q_count)
32 return 1;
33 else
34 return 0;
35}
36
37static void qla4xxx_advance_req_ring_ptr(struct scsi_qla_host *ha)
38{
39 /* Advance request queue pointer */
40 if (ha->request_in == (REQUEST_QUEUE_DEPTH - 1)) {
41 ha->request_in = 0;
42 ha->request_ptr = ha->request_ring;
43 } else {
44 ha->request_in++;
45 ha->request_ptr++;
46 }
47}
48
16/** 49/**
17 * qla4xxx_get_req_pkt - returns a valid entry in request queue. 50 * qla4xxx_get_req_pkt - returns a valid entry in request queue.
18 * @ha: Pointer to host adapter structure. 51 * @ha: Pointer to host adapter structure.
@@ -26,35 +59,18 @@
26static int qla4xxx_get_req_pkt(struct scsi_qla_host *ha, 59static int qla4xxx_get_req_pkt(struct scsi_qla_host *ha,
27 struct queue_entry **queue_entry) 60 struct queue_entry **queue_entry)
28{ 61{
29 uint16_t request_in; 62 uint16_t req_cnt = 1;
30 uint8_t status = QLA_SUCCESS;
31
32 *queue_entry = ha->request_ptr;
33 63
34 /* get the latest request_in and request_out index */ 64 if (qla4xxx_space_in_req_ring(ha, req_cnt)) {
35 request_in = ha->request_in; 65 *queue_entry = ha->request_ptr;
36 ha->request_out = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out);
37
38 /* Advance request queue pointer and check for queue full */
39 if (request_in == (REQUEST_QUEUE_DEPTH - 1)) {
40 request_in = 0;
41 ha->request_ptr = ha->request_ring;
42 } else {
43 request_in++;
44 ha->request_ptr++;
45 }
46
47 /* request queue is full, try again later */
48 if ((ha->iocb_cnt + 1) >= ha->iocb_hiwat) {
49 /* restore request pointer */
50 ha->request_ptr = *queue_entry;
51 status = QLA_ERROR;
52 } else {
53 ha->request_in = request_in;
54 memset(*queue_entry, 0, sizeof(**queue_entry)); 66 memset(*queue_entry, 0, sizeof(**queue_entry));
67
68 qla4xxx_advance_req_ring_ptr(ha);
69 ha->req_q_count -= req_cnt;
70 return QLA_SUCCESS;
55 } 71 }
56 72
57 return status; 73 return QLA_ERROR;
58} 74}
59 75
60/** 76/**
@@ -100,21 +116,14 @@ exit_send_marker:
100 return status; 116 return status;
101} 117}
102 118
103static struct continuation_t1_entry* qla4xxx_alloc_cont_entry( 119static struct continuation_t1_entry *
104 struct scsi_qla_host *ha) 120qla4xxx_alloc_cont_entry(struct scsi_qla_host *ha)
105{ 121{
106 struct continuation_t1_entry *cont_entry; 122 struct continuation_t1_entry *cont_entry;
107 123
108 cont_entry = (struct continuation_t1_entry *)ha->request_ptr; 124 cont_entry = (struct continuation_t1_entry *)ha->request_ptr;
109 125
110 /* Advance request queue pointer */ 126 qla4xxx_advance_req_ring_ptr(ha);
111 if (ha->request_in == (REQUEST_QUEUE_DEPTH - 1)) {
112 ha->request_in = 0;
113 ha->request_ptr = ha->request_ring;
114 } else {
115 ha->request_in++;
116 ha->request_ptr++;
117 }
118 127
119 /* Load packet defaults */ 128 /* Load packet defaults */
120 cont_entry->hdr.entryType = ET_CONTINUE; 129 cont_entry->hdr.entryType = ET_CONTINUE;
@@ -197,13 +206,10 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb)
197 struct scsi_cmnd *cmd = srb->cmd; 206 struct scsi_cmnd *cmd = srb->cmd;
198 struct ddb_entry *ddb_entry; 207 struct ddb_entry *ddb_entry;
199 struct command_t3_entry *cmd_entry; 208 struct command_t3_entry *cmd_entry;
200
201 int nseg; 209 int nseg;
202 uint16_t tot_dsds; 210 uint16_t tot_dsds;
203 uint16_t req_cnt; 211 uint16_t req_cnt;
204
205 unsigned long flags; 212 unsigned long flags;
206 uint16_t cnt;
207 uint32_t index; 213 uint32_t index;
208 char tag[2]; 214 char tag[2];
209 215
@@ -217,6 +223,19 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb)
217 223
218 index = (uint32_t)cmd->request->tag; 224 index = (uint32_t)cmd->request->tag;
219 225
226 /*
227 * Check to see if adapter is online before placing request on
228 * request queue. If a reset occurs and a request is in the queue,
229 * the firmware will still attempt to process the request, retrieving
230 * garbage for pointers.
231 */
232 if (!test_bit(AF_ONLINE, &ha->flags)) {
233 DEBUG2(printk("scsi%ld: %s: Adapter OFFLINE! "
234 "Do not issue command.\n",
235 ha->host_no, __func__));
236 goto queuing_error;
237 }
238
220 /* Calculate the number of request entries needed. */ 239 /* Calculate the number of request entries needed. */
221 nseg = scsi_dma_map(cmd); 240 nseg = scsi_dma_map(cmd);
222 if (nseg < 0) 241 if (nseg < 0)
@@ -224,17 +243,7 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb)
224 tot_dsds = nseg; 243 tot_dsds = nseg;
225 244
226 req_cnt = qla4xxx_calc_request_entries(tot_dsds); 245 req_cnt = qla4xxx_calc_request_entries(tot_dsds);
227 246 if (!qla4xxx_space_in_req_ring(ha, req_cnt))
228 if (ha->req_q_count < (req_cnt + 2)) {
229 cnt = (uint16_t) le32_to_cpu(ha->shadow_regs->req_q_out);
230 if (ha->request_in < cnt)
231 ha->req_q_count = cnt - ha->request_in;
232 else
233 ha->req_q_count = REQUEST_QUEUE_DEPTH -
234 (ha->request_in - cnt);
235 }
236
237 if (ha->req_q_count < (req_cnt + 2))
238 goto queuing_error; 247 goto queuing_error;
239 248
240 /* total iocbs active */ 249 /* total iocbs active */
@@ -286,32 +295,10 @@ int qla4xxx_send_command_to_isp(struct scsi_qla_host *ha, struct srb * srb)
286 break; 295 break;
287 } 296 }
288 297
289 298 qla4xxx_advance_req_ring_ptr(ha);
290 /* Advance request queue pointer */
291 ha->request_in++;
292 if (ha->request_in == REQUEST_QUEUE_DEPTH) {
293 ha->request_in = 0;
294 ha->request_ptr = ha->request_ring;
295 } else
296 ha->request_ptr++;
297
298
299 qla4xxx_build_scsi_iocbs(srb, cmd_entry, tot_dsds); 299 qla4xxx_build_scsi_iocbs(srb, cmd_entry, tot_dsds);
300 wmb(); 300 wmb();
301 301
302 /*
303 * Check to see if adapter is online before placing request on
304 * request queue. If a reset occurs and a request is in the queue,
305 * the firmware will still attempt to process the request, retrieving
306 * garbage for pointers.
307 */
308 if (!test_bit(AF_ONLINE, &ha->flags)) {
309 DEBUG2(printk("scsi%ld: %s: Adapter OFFLINE! "
310 "Do not issue command.\n",
311 ha->host_no, __func__));
312 goto queuing_error;
313 }
314
315 srb->cmd->host_scribble = (unsigned char *)srb; 302 srb->cmd->host_scribble = (unsigned char *)srb;
316 303
317 /* update counters */ 304 /* update counters */
diff --git a/drivers/scsi/qla4xxx/ql4_isr.c b/drivers/scsi/qla4xxx/ql4_isr.c
index 799120fcb9be..8025ee16588e 100644
--- a/drivers/scsi/qla4xxx/ql4_isr.c
+++ b/drivers/scsi/qla4xxx/ql4_isr.c
@@ -11,6 +11,98 @@
11#include "ql4_inline.h" 11#include "ql4_inline.h"
12 12
13/** 13/**
14 * qla4xxx_copy_sense - copy sense data into cmd sense buffer
15 * @ha: Pointer to host adapter structure.
16 * @sts_entry: Pointer to status entry structure.
17 * @srb: Pointer to srb structure.
18 **/
19static void qla4xxx_copy_sense(struct scsi_qla_host *ha,
20 struct status_entry *sts_entry,
21 struct srb *srb)
22{
23 struct scsi_cmnd *cmd = srb->cmd;
24 uint16_t sense_len;
25
26 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
27 sense_len = le16_to_cpu(sts_entry->senseDataByteCnt);
28 if (sense_len == 0)
29 return;
30
31 /* Save total available sense length,
32 * not to exceed cmd's sense buffer size */
33 sense_len = min_t(uint16_t, sense_len, SCSI_SENSE_BUFFERSIZE);
34 srb->req_sense_ptr = cmd->sense_buffer;
35 srb->req_sense_len = sense_len;
36
37 /* Copy sense from sts_entry pkt */
38 sense_len = min_t(uint16_t, sense_len, IOCB_MAX_SENSEDATA_LEN);
39 memcpy(cmd->sense_buffer, sts_entry->senseData, sense_len);
40
41 DEBUG2(printk(KERN_INFO "scsi%ld:%d:%d:%d: %s: sense key = %x, "
42 "ASL= %02x, ASC/ASCQ = %02x/%02x\n", ha->host_no,
43 cmd->device->channel, cmd->device->id,
44 cmd->device->lun, __func__,
45 sts_entry->senseData[2] & 0x0f,
46 sts_entry->senseData[7],
47 sts_entry->senseData[12],
48 sts_entry->senseData[13]));
49
50 DEBUG5(qla4xxx_dump_buffer(cmd->sense_buffer, sense_len));
51 srb->flags |= SRB_GOT_SENSE;
52
53 /* Update srb, in case a sts_cont pkt follows */
54 srb->req_sense_ptr += sense_len;
55 srb->req_sense_len -= sense_len;
56 if (srb->req_sense_len != 0)
57 ha->status_srb = srb;
58 else
59 ha->status_srb = NULL;
60}
61
62/**
63 * qla4xxx_status_cont_entry - Process a Status Continuations entry.
64 * @ha: SCSI driver HA context
65 * @sts_cont: Entry pointer
66 *
67 * Extended sense data.
68 */
69static void
70qla4xxx_status_cont_entry(struct scsi_qla_host *ha,
71 struct status_cont_entry *sts_cont)
72{
73 struct srb *srb = ha->status_srb;
74 struct scsi_cmnd *cmd;
75 uint8_t sense_len;
76
77 if (srb == NULL)
78 return;
79
80 cmd = srb->cmd;
81 if (cmd == NULL) {
82 DEBUG2(printk(KERN_INFO "scsi%ld: %s: Cmd already returned "
83 "back to OS srb=%p srb->state:%d\n", ha->host_no,
84 __func__, srb, srb->state));
85 ha->status_srb = NULL;
86 return;
87 }
88
89 /* Copy sense data. */
90 sense_len = min_t(uint16_t, srb->req_sense_len,
91 IOCB_MAX_EXT_SENSEDATA_LEN);
92 memcpy(srb->req_sense_ptr, sts_cont->ext_sense_data, sense_len);
93 DEBUG5(qla4xxx_dump_buffer(srb->req_sense_ptr, sense_len));
94
95 srb->req_sense_ptr += sense_len;
96 srb->req_sense_len -= sense_len;
97
98 /* Place command on done queue. */
99 if (srb->req_sense_len == 0) {
100 qla4xxx_srb_compl(ha, srb);
101 ha->status_srb = NULL;
102 }
103}
104
105/**
14 * qla4xxx_status_entry - processes status IOCBs 106 * qla4xxx_status_entry - processes status IOCBs
15 * @ha: Pointer to host adapter structure. 107 * @ha: Pointer to host adapter structure.
16 * @sts_entry: Pointer to status entry structure. 108 * @sts_entry: Pointer to status entry structure.
@@ -23,7 +115,6 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
23 struct srb *srb; 115 struct srb *srb;
24 struct ddb_entry *ddb_entry; 116 struct ddb_entry *ddb_entry;
25 uint32_t residual; 117 uint32_t residual;
26 uint16_t sensebytecnt;
27 118
28 srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle)); 119 srb = qla4xxx_del_from_active_array(ha, le32_to_cpu(sts_entry->handle));
29 if (!srb) { 120 if (!srb) {
@@ -92,24 +183,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
92 break; 183 break;
93 184
94 /* Copy Sense Data into sense buffer. */ 185 /* Copy Sense Data into sense buffer. */
95 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 186 qla4xxx_copy_sense(ha, sts_entry, srb);
96
97 sensebytecnt = le16_to_cpu(sts_entry->senseDataByteCnt);
98 if (sensebytecnt == 0)
99 break;
100
101 memcpy(cmd->sense_buffer, sts_entry->senseData,
102 min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE));
103
104 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
105 "ASC/ASCQ = %02x/%02x\n", ha->host_no,
106 cmd->device->channel, cmd->device->id,
107 cmd->device->lun, __func__,
108 sts_entry->senseData[2] & 0x0f,
109 sts_entry->senseData[12],
110 sts_entry->senseData[13]));
111
112 srb->flags |= SRB_GOT_SENSE;
113 break; 187 break;
114 188
115 case SCS_INCOMPLETE: 189 case SCS_INCOMPLETE:
@@ -176,23 +250,7 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
176 break; 250 break;
177 251
178 /* Copy Sense Data into sense buffer. */ 252 /* Copy Sense Data into sense buffer. */
179 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); 253 qla4xxx_copy_sense(ha, sts_entry, srb);
180
181 sensebytecnt =
182 le16_to_cpu(sts_entry->senseDataByteCnt);
183 if (sensebytecnt == 0)
184 break;
185
186 memcpy(cmd->sense_buffer, sts_entry->senseData,
187 min_t(uint16_t, sensebytecnt, SCSI_SENSE_BUFFERSIZE));
188
189 DEBUG2(printk("scsi%ld:%d:%d:%d: %s: sense key = %x, "
190 "ASC/ASCQ = %02x/%02x\n", ha->host_no,
191 cmd->device->channel, cmd->device->id,
192 cmd->device->lun, __func__,
193 sts_entry->senseData[2] & 0x0f,
194 sts_entry->senseData[12],
195 sts_entry->senseData[13]));
196 } else { 254 } else {
197 /* 255 /*
198 * If RISC reports underrun and target does not 256 * If RISC reports underrun and target does not
@@ -268,9 +326,10 @@ static void qla4xxx_status_entry(struct scsi_qla_host *ha,
268 326
269status_entry_exit: 327status_entry_exit:
270 328
271 /* complete the request */ 329 /* complete the request, if not waiting for status_continuation pkt */
272 srb->cc_stat = sts_entry->completionStatus; 330 srb->cc_stat = sts_entry->completionStatus;
273 qla4xxx_srb_compl(ha, srb); 331 if (ha->status_srb == NULL)
332 qla4xxx_srb_compl(ha, srb);
274} 333}
275 334
276/** 335/**
@@ -305,10 +364,7 @@ static void qla4xxx_process_response_queue(struct scsi_qla_host * ha)
305 /* process entry */ 364 /* process entry */
306 switch (sts_entry->hdr.entryType) { 365 switch (sts_entry->hdr.entryType) {
307 case ET_STATUS: 366 case ET_STATUS:
308 /* 367 /* Common status */
309 * Common status - Single completion posted in single
310 * IOSB.
311 */
312 qla4xxx_status_entry(ha, sts_entry); 368 qla4xxx_status_entry(ha, sts_entry);
313 break; 369 break;
314 370
@@ -316,9 +372,8 @@ static void qla4xxx_process_response_queue(struct scsi_qla_host * ha)
316 break; 372 break;
317 373
318 case ET_STATUS_CONTINUATION: 374 case ET_STATUS_CONTINUATION:
319 /* Just throw away the status continuation entries */ 375 qla4xxx_status_cont_entry(ha,
320 DEBUG2(printk("scsi%ld: %s: Status Continuation entry " 376 (struct status_cont_entry *) sts_entry);
321 "- ignoring\n", ha->host_no, __func__));
322 break; 377 break;
323 378
324 case ET_COMMAND: 379 case ET_COMMAND:
diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c
index 051b0f5e8c8e..09d6d4b76f39 100644
--- a/drivers/scsi/qla4xxx/ql4_mbx.c
+++ b/drivers/scsi/qla4xxx/ql4_mbx.c
@@ -385,16 +385,6 @@ int qla4xxx_get_firmware_status(struct scsi_qla_host * ha)
385 mbox_sts[0])); 385 mbox_sts[0]));
386 return QLA_ERROR; 386 return QLA_ERROR;
387 } 387 }
388
389 /* High-water mark of IOCBs */
390 ha->iocb_hiwat = mbox_sts[2];
391 if (ha->iocb_hiwat > IOCB_HIWAT_CUSHION)
392 ha->iocb_hiwat -= IOCB_HIWAT_CUSHION;
393 else
394 dev_info(&ha->pdev->dev, "WARNING!!! You have less than %d "
395 "firmware IOCBs available (%d).\n",
396 IOCB_HIWAT_CUSHION, ha->iocb_hiwat);
397
398 return QLA_SUCCESS; 388 return QLA_SUCCESS;
399} 389}
400 390
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index ec9da6ce8489..40e3cafb3a9c 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -66,6 +66,7 @@ static int qla4xxx_sess_get_param(struct iscsi_cls_session *sess,
66static int qla4xxx_host_get_param(struct Scsi_Host *shost, 66static int qla4xxx_host_get_param(struct Scsi_Host *shost,
67 enum iscsi_host_param param, char *buf); 67 enum iscsi_host_param param, char *buf);
68static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session); 68static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session);
69static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc);
69 70
70/* 71/*
71 * SCSI host template entry points 72 * SCSI host template entry points
@@ -89,6 +90,7 @@ static struct scsi_host_template qla4xxx_driver_template = {
89 .eh_device_reset_handler = qla4xxx_eh_device_reset, 90 .eh_device_reset_handler = qla4xxx_eh_device_reset,
90 .eh_target_reset_handler = qla4xxx_eh_target_reset, 91 .eh_target_reset_handler = qla4xxx_eh_target_reset,
91 .eh_host_reset_handler = qla4xxx_eh_host_reset, 92 .eh_host_reset_handler = qla4xxx_eh_host_reset,
93 .eh_timed_out = qla4xxx_eh_cmd_timed_out,
92 94
93 .slave_configure = qla4xxx_slave_configure, 95 .slave_configure = qla4xxx_slave_configure,
94 .slave_alloc = qla4xxx_slave_alloc, 96 .slave_alloc = qla4xxx_slave_alloc,
@@ -124,6 +126,21 @@ static struct iscsi_transport qla4xxx_iscsi_transport = {
124 126
125static struct scsi_transport_template *qla4xxx_scsi_transport; 127static struct scsi_transport_template *qla4xxx_scsi_transport;
126 128
129static enum blk_eh_timer_return qla4xxx_eh_cmd_timed_out(struct scsi_cmnd *sc)
130{
131 struct iscsi_cls_session *session;
132 struct ddb_entry *ddb_entry;
133
134 session = starget_to_session(scsi_target(sc->device));
135 ddb_entry = session->dd_data;
136
137 /* if we are not logged in then the LLD is going to clean up the cmd */
138 if (atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE)
139 return BLK_EH_RESET_TIMER;
140 else
141 return BLK_EH_NOT_HANDLED;
142}
143
127static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session) 144static void qla4xxx_recovery_timedout(struct iscsi_cls_session *session)
128{ 145{
129 struct ddb_entry *ddb_entry = session->dd_data; 146 struct ddb_entry *ddb_entry = session->dd_data;
@@ -904,18 +921,17 @@ static int qla4xxx_recover_adapter(struct scsi_qla_host *ha,
904 /* Flush any pending ddb changed AENs */ 921 /* Flush any pending ddb changed AENs */
905 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); 922 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
906 923
924 qla4xxx_flush_active_srbs(ha);
925
907 /* Reset the firmware. If successful, function 926 /* Reset the firmware. If successful, function
908 * returns with ISP interrupts enabled. 927 * returns with ISP interrupts enabled.
909 */ 928 */
910 if (status == QLA_SUCCESS) { 929 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n",
911 DEBUG2(printk("scsi%ld: %s - Performing soft reset..\n", 930 ha->host_no, __func__));
912 ha->host_no, __func__)); 931 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS)
913 qla4xxx_flush_active_srbs(ha); 932 status = qla4xxx_soft_reset(ha);
914 if (ql4xxx_lock_drvr_wait(ha) == QLA_SUCCESS) 933 else
915 status = qla4xxx_soft_reset(ha); 934 status = QLA_ERROR;
916 else
917 status = QLA_ERROR;
918 }
919 935
920 /* Flush any pending ddb changed AENs */ 936 /* Flush any pending ddb changed AENs */
921 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS); 937 qla4xxx_process_aen(ha, FLUSH_DDB_CHANGED_AENS);
@@ -1527,11 +1543,9 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
1527{ 1543{
1528 struct scsi_qla_host *ha = to_qla_host(cmd->device->host); 1544 struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
1529 struct ddb_entry *ddb_entry = cmd->device->hostdata; 1545 struct ddb_entry *ddb_entry = cmd->device->hostdata;
1530 struct srb *sp;
1531 int ret = FAILED, stat; 1546 int ret = FAILED, stat;
1532 1547
1533 sp = (struct srb *) cmd->SCp.ptr; 1548 if (!ddb_entry)
1534 if (!sp || !ddb_entry)
1535 return ret; 1549 return ret;
1536 1550
1537 dev_info(&ha->pdev->dev, 1551 dev_info(&ha->pdev->dev,
@@ -1644,7 +1658,7 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
1644 ha = (struct scsi_qla_host *) cmd->device->host->hostdata; 1658 ha = (struct scsi_qla_host *) cmd->device->host->hostdata;
1645 1659
1646 dev_info(&ha->pdev->dev, 1660 dev_info(&ha->pdev->dev,
1647 "scsi(%ld:%d:%d:%d): ADAPTER RESET ISSUED.\n", ha->host_no, 1661 "scsi(%ld:%d:%d:%d): HOST RESET ISSUED.\n", ha->host_no,
1648 cmd->device->channel, cmd->device->id, cmd->device->lun); 1662 cmd->device->channel, cmd->device->id, cmd->device->lun);
1649 1663
1650 if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) { 1664 if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
diff --git a/drivers/scsi/qla4xxx/ql4_version.h b/drivers/scsi/qla4xxx/ql4_version.h
index ab984cb89cea..6980cb279c81 100644
--- a/drivers/scsi/qla4xxx/ql4_version.h
+++ b/drivers/scsi/qla4xxx/ql4_version.h
@@ -5,5 +5,5 @@
5 * See LICENSE.qla4xxx for copyright and licensing details. 5 * See LICENSE.qla4xxx for copyright and licensing details.
6 */ 6 */
7 7
8#define QLA4XXX_DRIVER_VERSION "5.01.00-k8" 8#define QLA4XXX_DRIVER_VERSION "5.01.00-k9"
9 9
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 783e33c65eb7..b47240ca4b19 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -990,7 +990,7 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,
990 struct iscsi_uevent *ev; 990 struct iscsi_uevent *ev;
991 int len = NLMSG_SPACE(sizeof(*ev) + data_size); 991 int len = NLMSG_SPACE(sizeof(*ev) + data_size);
992 992
993 skb = alloc_skb(len, GFP_NOIO); 993 skb = alloc_skb(len, GFP_ATOMIC);
994 if (!skb) { 994 if (!skb) {
995 printk(KERN_ERR "can not deliver iscsi offload message:OOM\n"); 995 printk(KERN_ERR "can not deliver iscsi offload message:OOM\n");
996 return -ENOMEM; 996 return -ENOMEM;
@@ -1012,7 +1012,7 @@ int iscsi_offload_mesg(struct Scsi_Host *shost,
1012 1012
1013 memcpy((char *)ev + sizeof(*ev), data, data_size); 1013 memcpy((char *)ev + sizeof(*ev), data, data_size);
1014 1014
1015 return iscsi_multicast_skb(skb, ISCSI_NL_GRP_UIP, GFP_NOIO); 1015 return iscsi_multicast_skb(skb, ISCSI_NL_GRP_UIP, GFP_ATOMIC);
1016} 1016}
1017EXPORT_SYMBOL_GPL(iscsi_offload_mesg); 1017EXPORT_SYMBOL_GPL(iscsi_offload_mesg);
1018 1018
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 5616cd780ff3..b7b9fec67a98 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1840,6 +1840,18 @@ static void sd_read_block_characteristics(struct scsi_disk *sdkp)
1840 kfree(buffer); 1840 kfree(buffer);
1841} 1841}
1842 1842
1843static int sd_try_extended_inquiry(struct scsi_device *sdp)
1844{
1845 /*
1846 * Although VPD inquiries can go to SCSI-2 type devices,
1847 * some USB ones crash on receiving them, and the pages
1848 * we currently ask for are for SPC-3 and beyond
1849 */
1850 if (sdp->scsi_level > SCSI_SPC_2)
1851 return 1;
1852 return 0;
1853}
1854
1843/** 1855/**
1844 * sd_revalidate_disk - called the first time a new disk is seen, 1856 * sd_revalidate_disk - called the first time a new disk is seen,
1845 * performs disk spin up, read_capacity, etc. 1857 * performs disk spin up, read_capacity, etc.
@@ -1877,8 +1889,12 @@ static int sd_revalidate_disk(struct gendisk *disk)
1877 */ 1889 */
1878 if (sdkp->media_present) { 1890 if (sdkp->media_present) {
1879 sd_read_capacity(sdkp, buffer); 1891 sd_read_capacity(sdkp, buffer);
1880 sd_read_block_limits(sdkp); 1892
1881 sd_read_block_characteristics(sdkp); 1893 if (sd_try_extended_inquiry(sdp)) {
1894 sd_read_block_limits(sdkp);
1895 sd_read_block_characteristics(sdkp);
1896 }
1897
1882 sd_read_write_protect_flag(sdkp, buffer); 1898 sd_read_write_protect_flag(sdkp, buffer);
1883 sd_read_cache_type(sdkp, buffer); 1899 sd_read_cache_type(sdkp, buffer);
1884 sd_read_app_tag_own(sdkp, buffer); 1900 sd_read_app_tag_own(sdkp, buffer);
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index cdd552d33a78..03422ce878cf 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -527,7 +527,7 @@ config SERIAL_S3C24A0
527 527
528config SERIAL_S3C6400 528config SERIAL_S3C6400
529 tristate "Samsung S3C6400/S3C6410 Serial port support" 529 tristate "Samsung S3C6400/S3C6410 Serial port support"
530 depends on SERIAL_SAMSUNG && (CPU_S3C600 || CPU_S3C6410) 530 depends on SERIAL_SAMSUNG && (CPU_S3C6400 || CPU_S3C6410)
531 default y 531 default y
532 help 532 help
533 Serial port support for the Samsung S3C6400 and S3C6410 533 Serial port support for the Samsung S3C6400 and S3C6410
diff --git a/drivers/serial/s3c2400.c b/drivers/serial/s3c2400.c
index fb00ed5296e6..fed1a9a1ffb4 100644
--- a/drivers/serial/s3c2400.c
+++ b/drivers/serial/s3c2400.c
@@ -76,7 +76,7 @@ static int s3c2400_serial_probe(struct platform_device *dev)
76 return s3c24xx_serial_probe(dev, &s3c2400_uart_inf); 76 return s3c24xx_serial_probe(dev, &s3c2400_uart_inf);
77} 77}
78 78
79static struct platform_driver s3c2400_serial_drv = { 79static struct platform_driver s3c2400_serial_driver = {
80 .probe = s3c2400_serial_probe, 80 .probe = s3c2400_serial_probe,
81 .remove = __devexit_p(s3c24xx_serial_remove), 81 .remove = __devexit_p(s3c24xx_serial_remove),
82 .driver = { 82 .driver = {
@@ -85,16 +85,16 @@ static struct platform_driver s3c2400_serial_drv = {
85 }, 85 },
86}; 86};
87 87
88s3c24xx_console_init(&s3c2400_serial_drv, &s3c2400_uart_inf); 88s3c24xx_console_init(&s3c2400_serial_driver, &s3c2400_uart_inf);
89 89
90static inline int s3c2400_serial_init(void) 90static inline int s3c2400_serial_init(void)
91{ 91{
92 return s3c24xx_serial_init(&s3c2400_serial_drv, &s3c2400_uart_inf); 92 return s3c24xx_serial_init(&s3c2400_serial_driver, &s3c2400_uart_inf);
93} 93}
94 94
95static inline void s3c2400_serial_exit(void) 95static inline void s3c2400_serial_exit(void)
96{ 96{
97 platform_driver_unregister(&s3c2400_serial_drv); 97 platform_driver_unregister(&s3c2400_serial_driver);
98} 98}
99 99
100module_init(s3c2400_serial_init); 100module_init(s3c2400_serial_init);
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index b5d7cbcba2ae..c99f0821cae3 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -88,7 +88,7 @@ static int s3c2410_serial_probe(struct platform_device *dev)
88 return s3c24xx_serial_probe(dev, &s3c2410_uart_inf); 88 return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
89} 89}
90 90
91static struct platform_driver s3c2410_serial_drv = { 91static struct platform_driver s3c2410_serial_driver = {
92 .probe = s3c2410_serial_probe, 92 .probe = s3c2410_serial_probe,
93 .remove = __devexit_p(s3c24xx_serial_remove), 93 .remove = __devexit_p(s3c24xx_serial_remove),
94 .driver = { 94 .driver = {
@@ -97,16 +97,16 @@ static struct platform_driver s3c2410_serial_drv = {
97 }, 97 },
98}; 98};
99 99
100s3c24xx_console_init(&s3c2410_serial_drv, &s3c2410_uart_inf); 100s3c24xx_console_init(&s3c2410_serial_driver, &s3c2410_uart_inf);
101 101
102static int __init s3c2410_serial_init(void) 102static int __init s3c2410_serial_init(void)
103{ 103{
104 return s3c24xx_serial_init(&s3c2410_serial_drv, &s3c2410_uart_inf); 104 return s3c24xx_serial_init(&s3c2410_serial_driver, &s3c2410_uart_inf);
105} 105}
106 106
107static void __exit s3c2410_serial_exit(void) 107static void __exit s3c2410_serial_exit(void)
108{ 108{
109 platform_driver_unregister(&s3c2410_serial_drv); 109 platform_driver_unregister(&s3c2410_serial_driver);
110} 110}
111 111
112module_init(s3c2410_serial_init); 112module_init(s3c2410_serial_init);
diff --git a/drivers/serial/s3c2412.c b/drivers/serial/s3c2412.c
index 11dcb90bdfef..6e057d8809d3 100644
--- a/drivers/serial/s3c2412.c
+++ b/drivers/serial/s3c2412.c
@@ -121,7 +121,7 @@ static int s3c2412_serial_probe(struct platform_device *dev)
121 return s3c24xx_serial_probe(dev, &s3c2412_uart_inf); 121 return s3c24xx_serial_probe(dev, &s3c2412_uart_inf);
122} 122}
123 123
124static struct platform_driver s3c2412_serial_drv = { 124static struct platform_driver s3c2412_serial_driver = {
125 .probe = s3c2412_serial_probe, 125 .probe = s3c2412_serial_probe,
126 .remove = __devexit_p(s3c24xx_serial_remove), 126 .remove = __devexit_p(s3c24xx_serial_remove),
127 .driver = { 127 .driver = {
@@ -130,16 +130,16 @@ static struct platform_driver s3c2412_serial_drv = {
130 }, 130 },
131}; 131};
132 132
133s3c24xx_console_init(&s3c2412_serial_drv, &s3c2412_uart_inf); 133s3c24xx_console_init(&s3c2412_serial_driver, &s3c2412_uart_inf);
134 134
135static inline int s3c2412_serial_init(void) 135static inline int s3c2412_serial_init(void)
136{ 136{
137 return s3c24xx_serial_init(&s3c2412_serial_drv, &s3c2412_uart_inf); 137 return s3c24xx_serial_init(&s3c2412_serial_driver, &s3c2412_uart_inf);
138} 138}
139 139
140static inline void s3c2412_serial_exit(void) 140static inline void s3c2412_serial_exit(void)
141{ 141{
142 platform_driver_unregister(&s3c2412_serial_drv); 142 platform_driver_unregister(&s3c2412_serial_driver);
143} 143}
144 144
145module_init(s3c2412_serial_init); 145module_init(s3c2412_serial_init);
diff --git a/drivers/serial/s3c2440.c b/drivers/serial/s3c2440.c
index 06c5b0cc47a3..69ff5d340f04 100644
--- a/drivers/serial/s3c2440.c
+++ b/drivers/serial/s3c2440.c
@@ -151,7 +151,7 @@ static int s3c2440_serial_probe(struct platform_device *dev)
151 return s3c24xx_serial_probe(dev, &s3c2440_uart_inf); 151 return s3c24xx_serial_probe(dev, &s3c2440_uart_inf);
152} 152}
153 153
154static struct platform_driver s3c2440_serial_drv = { 154static struct platform_driver s3c2440_serial_driver = {
155 .probe = s3c2440_serial_probe, 155 .probe = s3c2440_serial_probe,
156 .remove = __devexit_p(s3c24xx_serial_remove), 156 .remove = __devexit_p(s3c24xx_serial_remove),
157 .driver = { 157 .driver = {
@@ -160,16 +160,16 @@ static struct platform_driver s3c2440_serial_drv = {
160 }, 160 },
161}; 161};
162 162
163s3c24xx_console_init(&s3c2440_serial_drv, &s3c2440_uart_inf); 163s3c24xx_console_init(&s3c2440_serial_driver, &s3c2440_uart_inf);
164 164
165static int __init s3c2440_serial_init(void) 165static int __init s3c2440_serial_init(void)
166{ 166{
167 return s3c24xx_serial_init(&s3c2440_serial_drv, &s3c2440_uart_inf); 167 return s3c24xx_serial_init(&s3c2440_serial_driver, &s3c2440_uart_inf);
168} 168}
169 169
170static void __exit s3c2440_serial_exit(void) 170static void __exit s3c2440_serial_exit(void)
171{ 171{
172 platform_driver_unregister(&s3c2440_serial_drv); 172 platform_driver_unregister(&s3c2440_serial_driver);
173} 173}
174 174
175module_init(s3c2440_serial_init); 175module_init(s3c2440_serial_init);
diff --git a/drivers/serial/s3c24a0.c b/drivers/serial/s3c24a0.c
index 786a067d62ac..26c49e18bdd1 100644
--- a/drivers/serial/s3c24a0.c
+++ b/drivers/serial/s3c24a0.c
@@ -92,7 +92,7 @@ static int s3c24a0_serial_probe(struct platform_device *dev)
92 return s3c24xx_serial_probe(dev, &s3c24a0_uart_inf); 92 return s3c24xx_serial_probe(dev, &s3c24a0_uart_inf);
93} 93}
94 94
95static struct platform_driver s3c24a0_serial_drv = { 95static struct platform_driver s3c24a0_serial_driver = {
96 .probe = s3c24a0_serial_probe, 96 .probe = s3c24a0_serial_probe,
97 .remove = __devexit_p(s3c24xx_serial_remove), 97 .remove = __devexit_p(s3c24xx_serial_remove),
98 .driver = { 98 .driver = {
@@ -101,16 +101,16 @@ static struct platform_driver s3c24a0_serial_drv = {
101 }, 101 },
102}; 102};
103 103
104s3c24xx_console_init(&s3c24a0_serial_drv, &s3c24a0_uart_inf); 104s3c24xx_console_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
105 105
106static int __init s3c24a0_serial_init(void) 106static int __init s3c24a0_serial_init(void)
107{ 107{
108 return s3c24xx_serial_init(&s3c24a0_serial_drv, &s3c24a0_uart_inf); 108 return s3c24xx_serial_init(&s3c24a0_serial_driver, &s3c24a0_uart_inf);
109} 109}
110 110
111static void __exit s3c24a0_serial_exit(void) 111static void __exit s3c24a0_serial_exit(void)
112{ 112{
113 platform_driver_unregister(&s3c24a0_serial_drv); 113 platform_driver_unregister(&s3c24a0_serial_driver);
114} 114}
115 115
116module_init(s3c24a0_serial_init); 116module_init(s3c24a0_serial_init);
diff --git a/drivers/serial/s3c6400.c b/drivers/serial/s3c6400.c
index 48f1a3781f0d..4be92ab50058 100644
--- a/drivers/serial/s3c6400.c
+++ b/drivers/serial/s3c6400.c
@@ -122,7 +122,7 @@ static int s3c6400_serial_probe(struct platform_device *dev)
122 return s3c24xx_serial_probe(dev, &s3c6400_uart_inf); 122 return s3c24xx_serial_probe(dev, &s3c6400_uart_inf);
123} 123}
124 124
125static struct platform_driver s3c6400_serial_drv = { 125static struct platform_driver s3c6400_serial_driver = {
126 .probe = s3c6400_serial_probe, 126 .probe = s3c6400_serial_probe,
127 .remove = __devexit_p(s3c24xx_serial_remove), 127 .remove = __devexit_p(s3c24xx_serial_remove),
128 .driver = { 128 .driver = {
@@ -131,16 +131,16 @@ static struct platform_driver s3c6400_serial_drv = {
131 }, 131 },
132}; 132};
133 133
134s3c24xx_console_init(&s3c6400_serial_drv, &s3c6400_uart_inf); 134s3c24xx_console_init(&s3c6400_serial_driver, &s3c6400_uart_inf);
135 135
136static int __init s3c6400_serial_init(void) 136static int __init s3c6400_serial_init(void)
137{ 137{
138 return s3c24xx_serial_init(&s3c6400_serial_drv, &s3c6400_uart_inf); 138 return s3c24xx_serial_init(&s3c6400_serial_driver, &s3c6400_uart_inf);
139} 139}
140 140
141static void __exit s3c6400_serial_exit(void) 141static void __exit s3c6400_serial_exit(void)
142{ 142{
143 platform_driver_unregister(&s3c6400_serial_drv); 143 platform_driver_unregister(&s3c6400_serial_driver);
144} 144}
145 145
146module_init(s3c6400_serial_init); 146module_init(s3c6400_serial_init);
diff --git a/drivers/serial/serial_ks8695.c b/drivers/serial/serial_ks8695.c
index 998e89dc5aaf..52db5cc3f900 100644
--- a/drivers/serial/serial_ks8695.c
+++ b/drivers/serial/serial_ks8695.c
@@ -110,7 +110,11 @@ static struct console ks8695_console;
110static void ks8695uart_stop_tx(struct uart_port *port) 110static void ks8695uart_stop_tx(struct uart_port *port)
111{ 111{
112 if (tx_enabled(port)) { 112 if (tx_enabled(port)) {
113 disable_irq(KS8695_IRQ_UART_TX); 113 /* use disable_irq_nosync() and not disable_irq() to avoid self
114 * imposed deadlock by not waiting for irq handler to end,
115 * since this ks8695uart_stop_tx() is called from interrupt context.
116 */
117 disable_irq_nosync(KS8695_IRQ_UART_TX);
114 tx_enable(port, 0); 118 tx_enable(port, 0);
115 } 119 }
116} 120}
@@ -549,7 +553,7 @@ static struct uart_port ks8695uart_ports[SERIAL_KS8695_NR] = {
549 .mapbase = KS8695_UART_VA, 553 .mapbase = KS8695_UART_VA,
550 .iotype = SERIAL_IO_MEM, 554 .iotype = SERIAL_IO_MEM,
551 .irq = KS8695_IRQ_UART_TX, 555 .irq = KS8695_IRQ_UART_TX,
552 .uartclk = CLOCK_TICK_RATE * 16, 556 .uartclk = KS8695_CLOCK_RATE * 16,
553 .fifosize = 16, 557 .fifosize = 16,
554 .ops = &ks8695uart_pops, 558 .ops = &ks8695uart_pops,
555 .flags = ASYNC_BOOT_AUTOCONF, 559 .flags = ASYNC_BOOT_AUTOCONF,
diff --git a/drivers/spi/spi_s3c24xx.c b/drivers/spi/spi_s3c24xx.c
index e0d44af4745a..3f3119d760db 100644
--- a/drivers/spi/spi_s3c24xx.c
+++ b/drivers/spi/spi_s3c24xx.c
@@ -111,29 +111,32 @@ static int s3c24xx_spi_setupxfer(struct spi_device *spi,
111 unsigned int bpw; 111 unsigned int bpw;
112 unsigned int hz; 112 unsigned int hz;
113 unsigned int div; 113 unsigned int div;
114 unsigned long clk;
114 115
115 bpw = t ? t->bits_per_word : spi->bits_per_word; 116 bpw = t ? t->bits_per_word : spi->bits_per_word;
116 hz = t ? t->speed_hz : spi->max_speed_hz; 117 hz = t ? t->speed_hz : spi->max_speed_hz;
117 118
119 if (!bpw)
120 bpw = 8;
121
122 if (!hz)
123 hz = spi->max_speed_hz;
124
118 if (bpw != 8) { 125 if (bpw != 8) {
119 dev_err(&spi->dev, "invalid bits-per-word (%d)\n", bpw); 126 dev_err(&spi->dev, "invalid bits-per-word (%d)\n", bpw);
120 return -EINVAL; 127 return -EINVAL;
121 } 128 }
122 129
123 div = clk_get_rate(hw->clk) / hz; 130 clk = clk_get_rate(hw->clk);
124 131 div = DIV_ROUND_UP(clk, hz * 2) - 1;
125 /* is clk = pclk / (2 * (pre+1)), or is it
126 * clk = (pclk * 2) / ( pre + 1) */
127
128 div /= 2;
129
130 if (div > 0)
131 div -= 1;
132 132
133 if (div > 255) 133 if (div > 255)
134 div = 255; 134 div = 255;
135 135
136 dev_dbg(&spi->dev, "setting pre-scaler to %d (hz %d)\n", div, hz); 136 dev_dbg(&spi->dev, "setting pre-scaler to %d (wanted %d, got %ld)\n",
137 div, hz, clk / (2 * (div + 1)));
138
139
137 writeb(div, hw->regs + S3C2410_SPPRE); 140 writeb(div, hw->regs + S3C2410_SPPRE);
138 141
139 spin_lock(&hw->bitbang.lock); 142 spin_lock(&hw->bitbang.lock);
diff --git a/drivers/staging/b3dfg/Kconfig b/drivers/staging/b3dfg/Kconfig
index 524231047de5..9e6573cf97d3 100644
--- a/drivers/staging/b3dfg/Kconfig
+++ b/drivers/staging/b3dfg/Kconfig
@@ -1,5 +1,6 @@
1config B3DFG 1config B3DFG
2 tristate "Brontes 3d Frame Framegrabber" 2 tristate "Brontes 3d Frame Framegrabber"
3 depends on PCI
3 default n 4 default n
4 ---help--- 5 ---help---
5 This driver provides support for the Brontes 3d Framegrabber 6 This driver provides support for the Brontes 3d Framegrabber
diff --git a/drivers/staging/heci/Kconfig b/drivers/staging/heci/Kconfig
index ae8d588d3a27..c7206f8bcd93 100644
--- a/drivers/staging/heci/Kconfig
+++ b/drivers/staging/heci/Kconfig
@@ -1,5 +1,6 @@
1config HECI 1config HECI
2 tristate "Intel Management Engine Interface (MEI) Support" 2 tristate "Intel Management Engine Interface (MEI) Support"
3 depends on PCI
3 ---help--- 4 ---help---
4 The Intel Management Engine Interface (Intel MEI) driver allows 5 The Intel Management Engine Interface (Intel MEI) driver allows
5 applications to access the Active Management Technology 6 applications to access the Active Management Technology
diff --git a/drivers/staging/rspiusb/rspiusb.c b/drivers/staging/rspiusb/rspiusb.c
index 2f8155c1968b..04e2f92c0f62 100644
--- a/drivers/staging/rspiusb/rspiusb.c
+++ b/drivers/staging/rspiusb/rspiusb.c
@@ -716,6 +716,8 @@ static int MapUserBuffer(struct ioctl_struct *io, struct device_extension *pdx)
716 pdx->PixelUrb[frameInfo][i]->transfer_flags = 716 pdx->PixelUrb[frameInfo][i]->transfer_flags =
717 URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT; 717 URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT;
718 } 718 }
719 if (i == 0)
720 return -EINVAL;
719 /* only interrupt when last URB completes */ 721 /* only interrupt when last URB completes */
720 pdx->PixelUrb[frameInfo][--i]->transfer_flags &= ~URB_NO_INTERRUPT; 722 pdx->PixelUrb[frameInfo][--i]->transfer_flags &= ~URB_NO_INTERRUPT;
721 pdx->pendedPixelUrbs[frameInfo] = 723 pdx->pendedPixelUrbs[frameInfo] =
diff --git a/drivers/staging/rt2860/rt_linux.h b/drivers/staging/rt2860/rt_linux.h
index 85175c182432..25b53ac3f820 100644
--- a/drivers/staging/rt2860/rt_linux.h
+++ b/drivers/staging/rt2860/rt_linux.h
@@ -43,9 +43,6 @@
43#include "rtmp_type.h" 43#include "rtmp_type.h"
44#include <linux/module.h> 44#include <linux/module.h>
45#include <linux/kernel.h> 45#include <linux/kernel.h>
46#if !defined(RT2860) && !defined(RT30xx)
47#include <linux/kthread.h>
48#endif
49 46
50#include <linux/spinlock.h> 47#include <linux/spinlock.h>
51#include <linux/init.h> 48#include <linux/init.h>
@@ -166,9 +163,7 @@ typedef int (*HARD_START_XMIT_FUNC)(struct sk_buff *skb, struct net_device *net_
166 163
167#ifndef RT30xx 164#ifndef RT30xx
168typedef struct pid * THREAD_PID; 165typedef struct pid * THREAD_PID;
169#ifdef RT2860
170#define THREAD_PID_INIT_VALUE NULL 166#define THREAD_PID_INIT_VALUE NULL
171#endif
172#define GET_PID(_v) find_get_pid(_v) 167#define GET_PID(_v) find_get_pid(_v)
173#define GET_PID_NUMBER(_v) pid_nr(_v) 168#define GET_PID_NUMBER(_v) pid_nr(_v)
174#define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0) 169#define CHECK_PID_LEGALITY(_pid) if (pid_nr(_pid) >= 0)
@@ -188,12 +183,12 @@ struct os_cookie {
188 dma_addr_t pAd_pa; 183 dma_addr_t pAd_pa;
189#endif 184#endif
190#ifdef RT2870 185#ifdef RT2870
191 struct usb_device *pUsb_Dev; 186 struct usb_device *pUsb_Dev;
192 187
193#ifndef RT30xx 188#ifndef RT30xx
194 struct task_struct *MLMEThr_task; 189 THREAD_PID MLMEThr_pid;
195 struct task_struct *RTUSBCmdThr_task; 190 THREAD_PID RTUSBCmdThr_pid;
196 struct task_struct *TimerQThr_task; 191 THREAD_PID TimerQThr_pid;
197#endif 192#endif
198#ifdef RT30xx 193#ifdef RT30xx
199 struct pid *MLMEThr_pid; 194 struct pid *MLMEThr_pid;
diff --git a/drivers/staging/rt2870/2870_main_dev.c b/drivers/staging/rt2870/2870_main_dev.c
index dd01c64fbf61..a4e8696ca39c 100644
--- a/drivers/staging/rt2870/2870_main_dev.c
+++ b/drivers/staging/rt2870/2870_main_dev.c
@@ -235,7 +235,7 @@ INT MlmeThread(
235 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); 235 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
236 236
237#ifndef RT30xx 237#ifndef RT30xx
238 pObj->MLMEThr_task = NULL; 238 pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE;
239#endif 239#endif
240#ifdef RT30xx 240#ifdef RT30xx
241 pObj->MLMEThr_pid = NULL; 241 pObj->MLMEThr_pid = NULL;
@@ -348,7 +348,7 @@ INT RTUSBCmdThread(
348 DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n")); 348 DBGPRINT(RT_DEBUG_TRACE,( "<---RTUSBCmdThread\n"));
349 349
350#ifndef RT30xx 350#ifndef RT30xx
351 pObj->RTUSBCmdThr_task = NULL; 351 pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE;
352#endif 352#endif
353#ifdef RT30xx 353#ifdef RT30xx
354 pObj->RTUSBCmdThr_pid = NULL; 354 pObj->RTUSBCmdThr_pid = NULL;
@@ -447,7 +447,7 @@ INT TimerQThread(
447 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__)); 447 DBGPRINT(RT_DEBUG_TRACE,( "<---%s\n",__func__));
448 448
449#ifndef RT30xx 449#ifndef RT30xx
450 pObj->TimerQThr_task = NULL; 450 pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE;
451#endif 451#endif
452#ifdef RT30xx 452#ifdef RT30xx
453 pObj->TimerQThr_pid = NULL; 453 pObj->TimerQThr_pid = NULL;
@@ -883,46 +883,69 @@ VOID RT28xxThreadTerminate(
883 883
884 // Terminate Threads 884 // Terminate Threads
885#ifndef RT30xx 885#ifndef RT30xx
886 BUG_ON(pObj->TimerQThr_task == NULL); 886 CHECK_PID_LEGALITY(pObj->TimerQThr_pid)
887 CHECK_PID_LEGALITY(task_pid(pObj->TimerQThr_task))
888 { 887 {
889 POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie; 888 POS_COOKIE pObj = (POS_COOKIE)pAd->OS_Cookie;
890 889
891 printk(KERN_DEBUG "Terminate the TimerQThr pid=%d!\n", 890 printk("Terminate the TimerQThr_pid=%d!\n", GET_PID_NUMBER(pObj->TimerQThr_pid));
892 pid_nr(task_pid(pObj->TimerQThr_task)));
893 mb(); 891 mb();
894 pAd->TimerFunc_kill = 1; 892 pAd->TimerFunc_kill = 1;
895 mb(); 893 mb();
896 kthread_stop(pObj->TimerQThr_task); 894 ret = KILL_THREAD_PID(pObj->TimerQThr_pid, SIGTERM, 1);
897 pObj->TimerQThr_task = NULL; 895 if (ret)
896 {
897 printk(KERN_WARNING "%s: unable to stop TimerQThread, pid=%d, ret=%d!\n",
898 pAd->net_dev->name, GET_PID_NUMBER(pObj->TimerQThr_pid), ret);
899 }
900 else
901 {
902 wait_for_completion(&pAd->TimerQComplete);
903 pObj->TimerQThr_pid = THREAD_PID_INIT_VALUE;
904 }
898 } 905 }
899 906
900 BUG_ON(pObj->MLMEThr_task == NULL); 907 CHECK_PID_LEGALITY(pObj->MLMEThr_pid)
901 CHECK_PID_LEGALITY(task_pid(pObj->MLMEThr_task))
902 { 908 {
903 printk(KERN_DEBUG "Terminate the MLMEThr pid=%d!\n", 909 printk("Terminate the MLMEThr_pid=%d!\n", GET_PID_NUMBER(pObj->MLMEThr_pid));
904 pid_nr(task_pid(pObj->MLMEThr_task)));
905 mb(); 910 mb();
906 pAd->mlme_kill = 1; 911 pAd->mlme_kill = 1;
907 //RT28XX_MLME_HANDLER(pAd); 912 //RT28XX_MLME_HANDLER(pAd);
908 mb(); 913 mb();
909 kthread_stop(pObj->MLMEThr_task); 914 ret = KILL_THREAD_PID(pObj->MLMEThr_pid, SIGTERM, 1);
910 pObj->MLMEThr_task = NULL; 915 if (ret)
916 {
917 printk (KERN_WARNING "%s: unable to Mlme thread, pid=%d, ret=%d!\n",
918 pAd->net_dev->name, GET_PID_NUMBER(pObj->MLMEThr_pid), ret);
919 }
920 else
921 {
922 //wait_for_completion (&pAd->notify);
923 wait_for_completion (&pAd->mlmeComplete);
924 pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE;
925 }
911 } 926 }
912 927
913 BUG_ON(pObj->RTUSBCmdThr_task == NULL); 928 CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid)
914 CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task))
915 { 929 {
916 printk(KERN_DEBUG "Terminate the RTUSBCmdThr pid=%d!\n", 930 printk("Terminate the RTUSBCmdThr_pid=%d!\n", GET_PID_NUMBER(pObj->RTUSBCmdThr_pid));
917 pid_nr(task_pid(pObj->RTUSBCmdThr_task)));
918 mb(); 931 mb();
919 NdisAcquireSpinLock(&pAd->CmdQLock); 932 NdisAcquireSpinLock(&pAd->CmdQLock);
920 pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED; 933 pAd->CmdQ.CmdQState = RT2870_THREAD_STOPED;
921 NdisReleaseSpinLock(&pAd->CmdQLock); 934 NdisReleaseSpinLock(&pAd->CmdQLock);
922 mb(); 935 mb();
923 //RTUSBCMDUp(pAd); 936 //RTUSBCMDUp(pAd);
924 kthread_stop(pObj->RTUSBCmdThr_task); 937 ret = KILL_THREAD_PID(pObj->RTUSBCmdThr_pid, SIGTERM, 1);
925 pObj->RTUSBCmdThr_task = NULL; 938 if (ret)
939 {
940 printk(KERN_WARNING "%s: unable to RTUSBCmd thread, pid=%d, ret=%d!\n",
941 pAd->net_dev->name, GET_PID_NUMBER(pObj->RTUSBCmdThr_pid), ret);
942 }
943 else
944 {
945 //wait_for_completion (&pAd->notify);
946 wait_for_completion (&pAd->CmdQComplete);
947 pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE;
948 }
926 } 949 }
927#endif 950#endif
928#ifdef RT30xx 951#ifdef RT30xx
@@ -1045,7 +1068,7 @@ BOOLEAN RT28XXChipsetCheck(
1045 dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct) 1068 dev_p->descriptor.idProduct == rtusb_usb_id[i].idProduct)
1046 { 1069 {
1047#ifndef RT30xx 1070#ifndef RT30xx
1048 printk(KERN_DEBUG "rt2870: idVendor = 0x%x, idProduct = 0x%x\n", 1071 printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
1049#endif 1072#endif
1050#ifdef RT30xx 1073#ifdef RT30xx
1051 printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n", 1074 printk("rt2870: idVendor = 0x%x, idProduct = 0x%x\n",
diff --git a/drivers/staging/rt2870/common/2870_rtmp_init.c b/drivers/staging/rt2870/common/2870_rtmp_init.c
index 0f4c8af97e47..80909e9ab5ae 100644
--- a/drivers/staging/rt2870/common/2870_rtmp_init.c
+++ b/drivers/staging/rt2870/common/2870_rtmp_init.c
@@ -700,8 +700,8 @@ NDIS_STATUS AdapterBlockAllocateMemory(
700 usb_dev = pObj->pUsb_Dev; 700 usb_dev = pObj->pUsb_Dev;
701 701
702#ifndef RT30xx 702#ifndef RT30xx
703 pObj->MLMEThr_task = NULL; 703 pObj->MLMEThr_pid = THREAD_PID_INIT_VALUE;
704 pObj->RTUSBCmdThr_task = NULL; 704 pObj->RTUSBCmdThr_pid = THREAD_PID_INIT_VALUE;
705#endif 705#endif
706#ifdef RT30xx 706#ifdef RT30xx
707 pObj->MLMEThr_pid = NULL; 707 pObj->MLMEThr_pid = NULL;
@@ -743,7 +743,7 @@ NDIS_STATUS CreateThreads(
743 PRTMP_ADAPTER pAd = net_dev->ml_priv; 743 PRTMP_ADAPTER pAd = net_dev->ml_priv;
744 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; 744 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
745#ifndef RT30xx 745#ifndef RT30xx
746 struct task_struct *tsk; 746 pid_t pid_number = -1;
747#endif 747#endif
748#ifdef RT30xx 748#ifdef RT30xx
749 pid_t pid_number; 749 pid_t pid_number;
@@ -762,10 +762,10 @@ NDIS_STATUS CreateThreads(
762 762
763 // Creat MLME Thread 763 // Creat MLME Thread
764#ifndef RT30xx 764#ifndef RT30xx
765 pObj->MLMEThr_task = NULL; 765 pObj->MLMEThr_pid= THREAD_PID_INIT_VALUE;
766 tsk = kthread_run(MlmeThread, pAd, "%s", pAd->net_dev->name); 766 pid_number = kernel_thread(MlmeThread, pAd, CLONE_VM);
767 767 if (pid_number < 0)
768 if (IS_ERR(tsk)) { 768 {
769#endif 769#endif
770#ifdef RT30xx 770#ifdef RT30xx
771 pObj->MLMEThr_pid = NULL; 771 pObj->MLMEThr_pid = NULL;
@@ -778,7 +778,7 @@ NDIS_STATUS CreateThreads(
778 } 778 }
779 779
780#ifndef RT30xx 780#ifndef RT30xx
781 pObj->MLMEThr_task = tsk; 781 pObj->MLMEThr_pid = GET_PID(pid_number);
782#endif 782#endif
783#ifdef RT30xx 783#ifdef RT30xx
784 pObj->MLMEThr_pid = find_get_pid(pid_number); 784 pObj->MLMEThr_pid = find_get_pid(pid_number);
@@ -788,10 +788,9 @@ NDIS_STATUS CreateThreads(
788 788
789 // Creat Command Thread 789 // Creat Command Thread
790#ifndef RT30xx 790#ifndef RT30xx
791 pObj->RTUSBCmdThr_task = NULL; 791 pObj->RTUSBCmdThr_pid= THREAD_PID_INIT_VALUE;
792 tsk = kthread_run(RTUSBCmdThread, pAd, "%s", pAd->net_dev->name); 792 pid_number = kernel_thread(RTUSBCmdThread, pAd, CLONE_VM);
793 793 if (pid_number < 0)
794 if (IS_ERR(tsk) < 0)
795#endif 794#endif
796#ifdef RT30xx 795#ifdef RT30xx
797 pObj->RTUSBCmdThr_pid = NULL; 796 pObj->RTUSBCmdThr_pid = NULL;
@@ -804,7 +803,7 @@ NDIS_STATUS CreateThreads(
804 } 803 }
805 804
806#ifndef RT30xx 805#ifndef RT30xx
807 pObj->RTUSBCmdThr_task = tsk; 806 pObj->RTUSBCmdThr_pid = GET_PID(pid_number);
808#endif 807#endif
809#ifdef RT30xx 808#ifdef RT30xx
810 pObj->RTUSBCmdThr_pid = find_get_pid(pid_number); 809 pObj->RTUSBCmdThr_pid = find_get_pid(pid_number);
@@ -812,9 +811,9 @@ NDIS_STATUS CreateThreads(
812 wait_for_completion(&(pAd->CmdQComplete)); 811 wait_for_completion(&(pAd->CmdQComplete));
813 812
814#ifndef RT30xx 813#ifndef RT30xx
815 pObj->TimerQThr_task = NULL; 814 pObj->TimerQThr_pid= THREAD_PID_INIT_VALUE;
816 tsk = kthread_run(TimerQThread, pAd, "%s", pAd->net_dev->name); 815 pid_number = kernel_thread(TimerQThread, pAd, CLONE_VM);
817 if (IS_ERR(tsk) < 0) 816 if (pid_number < 0)
818#endif 817#endif
819#ifdef RT30xx 818#ifdef RT30xx
820 pObj->TimerQThr_pid = NULL; 819 pObj->TimerQThr_pid = NULL;
@@ -826,7 +825,7 @@ NDIS_STATUS CreateThreads(
826 return NDIS_STATUS_FAILURE; 825 return NDIS_STATUS_FAILURE;
827 } 826 }
828#ifndef RT30xx 827#ifndef RT30xx
829 pObj->TimerQThr_task = tsk; 828 pObj->TimerQThr_pid = GET_PID(pid_number);
830#endif 829#endif
831#ifdef RT30xx 830#ifdef RT30xx
832 pObj->TimerQThr_pid = find_get_pid(pid_number); 831 pObj->TimerQThr_pid = find_get_pid(pid_number);
diff --git a/drivers/staging/rt2870/common/rtusb_io.c b/drivers/staging/rt2870/common/rtusb_io.c
index fd1b0c18f2a0..704b5c2d5091 100644
--- a/drivers/staging/rt2870/common/rtusb_io.c
+++ b/drivers/staging/rt2870/common/rtusb_io.c
@@ -984,8 +984,7 @@ NDIS_STATUS RTUSBEnqueueCmdFromNdis(
984 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; 984 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie;
985 985
986#ifndef RT30xx 986#ifndef RT30xx
987 BUG_ON(pObj->RTUSBCmdThr_task == NULL); 987 CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid)
988 CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task))
989#endif 988#endif
990#ifdef RT30xx 989#ifdef RT30xx
991 if (pObj->RTUSBCmdThr_pid < 0) 990 if (pObj->RTUSBCmdThr_pid < 0)
diff --git a/drivers/staging/rt2870/rt2870.h b/drivers/staging/rt2870/rt2870.h
index 29e3b53e52a1..2b8872b2fd9d 100644
--- a/drivers/staging/rt2870/rt2870.h
+++ b/drivers/staging/rt2870/rt2870.h
@@ -79,6 +79,7 @@
79{ \ 79{ \
80 {USB_DEVICE(0x148F,0x2770)}, /* Ralink */ \ 80 {USB_DEVICE(0x148F,0x2770)}, /* Ralink */ \
81 {USB_DEVICE(0x1737,0x0071)}, /* Linksys WUSB600N */ \ 81 {USB_DEVICE(0x1737,0x0071)}, /* Linksys WUSB600N */ \
82 {USB_DEVICE(0x1737,0x0070)}, /* Linksys */ \
82 {USB_DEVICE(0x148F,0x2870)}, /* Ralink */ \ 83 {USB_DEVICE(0x148F,0x2870)}, /* Ralink */ \
83 {USB_DEVICE(0x148F,0x3070)}, /* Ralink */ \ 84 {USB_DEVICE(0x148F,0x3070)}, /* Ralink */ \
84 {USB_DEVICE(0x0B05,0x1731)}, /* Asus */ \ 85 {USB_DEVICE(0x0B05,0x1731)}, /* Asus */ \
@@ -93,12 +94,14 @@
93 {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \ 94 {USB_DEVICE(0x14B2,0x3C06)}, /* Conceptronic */ \
94 {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \ 95 {USB_DEVICE(0x14B2,0x3C28)}, /* Conceptronic */ \
95 {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \ 96 {USB_DEVICE(0x2019,0xED06)}, /* Planex Communications, Inc. */ \
97 {USB_DEVICE(0x2019,0xED14)}, /* Planex Communications, Inc. */ \
96 {USB_DEVICE(0x2019,0xAB25)}, /* Planex Communications, Inc. RT3070 */ \ 98 {USB_DEVICE(0x2019,0xAB25)}, /* Planex Communications, Inc. RT3070 */ \
97 {USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */ \ 99 {USB_DEVICE(0x07D1,0x3C09)}, /* D-Link */ \
98 {USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */ \ 100 {USB_DEVICE(0x07D1,0x3C11)}, /* D-Link */ \
99 {USB_DEVICE(0x14B2,0x3C07)}, /* AL */ \ 101 {USB_DEVICE(0x14B2,0x3C07)}, /* AL */ \
100 {USB_DEVICE(0x14B2,0x3C12)}, /* AL */ \ 102 {USB_DEVICE(0x14B2,0x3C12)}, /* AL */ \
101 {USB_DEVICE(0x050D,0x8053)}, /* Belkin */ \ 103 {USB_DEVICE(0x050D,0x8053)}, /* Belkin */ \
104 {USB_DEVICE(0x050D,0x815C)}, /* Belkin */ \
102 {USB_DEVICE(0x14B2,0x3C23)}, /* Airlink */ \ 105 {USB_DEVICE(0x14B2,0x3C23)}, /* Airlink */ \
103 {USB_DEVICE(0x14B2,0x3C27)}, /* Airlink */ \ 106 {USB_DEVICE(0x14B2,0x3C27)}, /* Airlink */ \
104 {USB_DEVICE(0x07AA,0x002F)}, /* Corega */ \ 107 {USB_DEVICE(0x07AA,0x002F)}, /* Corega */ \
@@ -587,16 +590,14 @@ VOID RTUSBBulkRxComplete(purbb_t pUrb, struct pt_regs *pt_regs);
587#define RTUSBMlmeUp(pAd) \ 590#define RTUSBMlmeUp(pAd) \
588{ \ 591{ \
589 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ 592 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
590 BUG_ON(pObj->MLMEThr_task == NULL); \ 593 CHECK_PID_LEGALITY(pObj->MLMEThr_pid) \
591 CHECK_PID_LEGALITY(task_pid(pObj->MLMEThr_task)) \
592 up(&(pAd->mlme_semaphore)); \ 594 up(&(pAd->mlme_semaphore)); \
593} 595}
594 596
595#define RTUSBCMDUp(pAd) \ 597#define RTUSBCMDUp(pAd) \
596{ \ 598{ \
597 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \ 599 POS_COOKIE pObj = (POS_COOKIE) pAd->OS_Cookie; \
598 BUG_ON(pObj->RTUSBCmdThr_task == NULL); \ 600 CHECK_PID_LEGALITY(pObj->RTUSBCmdThr_pid) \
599 CHECK_PID_LEGALITY(task_pid(pObj->RTUSBCmdThr_task)) \
600 up(&(pAd->RTUSBCmd_semaphore)); \ 601 up(&(pAd->RTUSBCmd_semaphore)); \
601} 602}
602#endif 603#endif
diff --git a/drivers/staging/rtl8192su/ieee80211.h b/drivers/staging/rtl8192su/ieee80211.h
index 0edb09a536f9..ea9739318037 100644
--- a/drivers/staging/rtl8192su/ieee80211.h
+++ b/drivers/staging/rtl8192su/ieee80211.h
@@ -2645,7 +2645,7 @@ extern int ieee80211_encrypt_fragment(
2645 struct sk_buff *frag, 2645 struct sk_buff *frag,
2646 int hdr_len); 2646 int hdr_len);
2647 2647
2648extern int ieee80211_xmit(struct sk_buff *skb, 2648extern int rtl8192_ieee80211_xmit(struct sk_buff *skb,
2649 struct net_device *dev); 2649 struct net_device *dev);
2650extern void ieee80211_txb_free(struct ieee80211_txb *); 2650extern void ieee80211_txb_free(struct ieee80211_txb *);
2651 2651
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211.h b/drivers/staging/rtl8192su/ieee80211/ieee80211.h
index 720bfcbfadc1..5e3a2cbed2b1 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211.h
@@ -2645,7 +2645,7 @@ extern int ieee80211_encrypt_fragment(
2645 struct sk_buff *frag, 2645 struct sk_buff *frag,
2646 int hdr_len); 2646 int hdr_len);
2647 2647
2648extern int ieee80211_xmit(struct sk_buff *skb, 2648extern int rtl8192_ieee80211_xmit(struct sk_buff *skb,
2649 struct net_device *dev); 2649 struct net_device *dev);
2650extern void ieee80211_txb_free(struct ieee80211_txb *); 2650extern void ieee80211_txb_free(struct ieee80211_txb *);
2651 2651
diff --git a/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
index 7294572b990f..cba12b84be5c 100644
--- a/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192su/ieee80211/ieee80211_tx.c
@@ -618,7 +618,7 @@ void ieee80211_query_seqnum(struct ieee80211_device*ieee, struct sk_buff* skb, u
618 } 618 }
619} 619}
620 620
621int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) 621int rtl8192_ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
622{ 622{
623#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)) 623#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0))
624 struct ieee80211_device *ieee = netdev_priv(dev); 624 struct ieee80211_device *ieee = netdev_priv(dev);
@@ -943,5 +943,6 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
943 return 1; 943 return 1;
944 944
945} 945}
946EXPORT_SYMBOL(rtl8192_ieee80211_xmit);
946 947
947EXPORT_SYMBOL(ieee80211_txb_free); 948EXPORT_SYMBOL(ieee80211_txb_free);
diff --git a/drivers/staging/rtl8192su/r8192U_core.c b/drivers/staging/rtl8192su/r8192U_core.c
index 4ab250743e81..70f81a8f1291 100644
--- a/drivers/staging/rtl8192su/r8192U_core.c
+++ b/drivers/staging/rtl8192su/r8192U_core.c
@@ -12142,7 +12142,7 @@ static const struct net_device_ops rtl8192_netdev_ops = {
12142 .ndo_set_mac_address = r8192_set_mac_adr, 12142 .ndo_set_mac_address = r8192_set_mac_adr,
12143 .ndo_validate_addr = eth_validate_addr, 12143 .ndo_validate_addr = eth_validate_addr,
12144 .ndo_change_mtu = eth_change_mtu, 12144 .ndo_change_mtu = eth_change_mtu,
12145 .ndo_start_xmit = ieee80211_xmit, 12145 .ndo_start_xmit = rtl8192_ieee80211_xmit,
12146}; 12146};
12147 12147
12148#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0) 12148#if LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 0a69672097a8..4e83c297ec9e 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -953,7 +953,12 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
953 953
954 mutex_lock(&tz->lock); 954 mutex_lock(&tz->lock);
955 955
956 tz->ops->get_temp(tz, &temp); 956 if (tz->ops->get_temp(tz, &temp)) {
957 /* get_temp failed - retry it later */
958 printk(KERN_WARNING PREFIX "failed to read out thermal zone "
959 "%d\n", tz->id);
960 goto leave;
961 }
957 962
958 for (count = 0; count < tz->trips; count++) { 963 for (count = 0; count < tz->trips; count++) {
959 tz->ops->get_trip_type(tz, count, &trip_type); 964 tz->ops->get_trip_type(tz, count, &trip_type);
@@ -1005,6 +1010,8 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
1005 THERMAL_TRIPS_NONE); 1010 THERMAL_TRIPS_NONE);
1006 1011
1007 tz->last_temperature = temp; 1012 tz->last_temperature = temp;
1013
1014 leave:
1008 if (tz->passive) 1015 if (tz->passive)
1009 thermal_zone_device_set_polling(tz, tz->passive_delay); 1016 thermal_zone_device_set_polling(tz, tz->passive_delay);
1010 else if (tz->polling_delay) 1017 else if (tz->polling_delay)
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index e1f89416ef8c..2bfc41ece0e1 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -387,7 +387,6 @@ static void acm_rx_tasklet(unsigned long _acm)
387 struct acm_ru *rcv; 387 struct acm_ru *rcv;
388 unsigned long flags; 388 unsigned long flags;
389 unsigned char throttled; 389 unsigned char throttled;
390 struct usb_host_endpoint *ep;
391 390
392 dbg("Entering acm_rx_tasklet"); 391 dbg("Entering acm_rx_tasklet");
393 392
@@ -463,14 +462,12 @@ urbs:
463 462
464 rcv->buffer = buf; 463 rcv->buffer = buf;
465 464
466 ep = (usb_pipein(acm->rx_endpoint) ? acm->dev->ep_in : acm->dev->ep_out) 465 if (acm->is_int_ep)
467 [usb_pipeendpoint(acm->rx_endpoint)];
468 if (usb_endpoint_xfer_int(&ep->desc))
469 usb_fill_int_urb(rcv->urb, acm->dev, 466 usb_fill_int_urb(rcv->urb, acm->dev,
470 acm->rx_endpoint, 467 acm->rx_endpoint,
471 buf->base, 468 buf->base,
472 acm->readsize, 469 acm->readsize,
473 acm_read_bulk, rcv, ep->desc.bInterval); 470 acm_read_bulk, rcv, acm->bInterval);
474 else 471 else
475 usb_fill_bulk_urb(rcv->urb, acm->dev, 472 usb_fill_bulk_urb(rcv->urb, acm->dev,
476 acm->rx_endpoint, 473 acm->rx_endpoint,
@@ -1183,6 +1180,9 @@ made_compressed_probe:
1183 spin_lock_init(&acm->read_lock); 1180 spin_lock_init(&acm->read_lock);
1184 mutex_init(&acm->mutex); 1181 mutex_init(&acm->mutex);
1185 acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress); 1182 acm->rx_endpoint = usb_rcvbulkpipe(usb_dev, epread->bEndpointAddress);
1183 acm->is_int_ep = usb_endpoint_xfer_int(epread);
1184 if (acm->is_int_ep)
1185 acm->bInterval = epread->bInterval;
1186 tty_port_init(&acm->port); 1186 tty_port_init(&acm->port);
1187 acm->port.ops = &acm_port_ops; 1187 acm->port.ops = &acm_port_ops;
1188 1188
diff --git a/drivers/usb/class/cdc-acm.h b/drivers/usb/class/cdc-acm.h
index 1602324808ba..c4a0ee8ffccf 100644
--- a/drivers/usb/class/cdc-acm.h
+++ b/drivers/usb/class/cdc-acm.h
@@ -126,6 +126,8 @@ struct acm {
126 unsigned int ctrl_caps; /* control capabilities from the class specific header */ 126 unsigned int ctrl_caps; /* control capabilities from the class specific header */
127 unsigned int susp_count; /* number of suspended interfaces */ 127 unsigned int susp_count; /* number of suspended interfaces */
128 int combined_interfaces:1; /* control and data collapsed */ 128 int combined_interfaces:1; /* control and data collapsed */
129 int is_int_ep:1; /* interrupt endpoints contrary to spec used */
130 u8 bInterval;
129 struct acm_wb *delayed_wb; /* write queued for a device about to be woken */ 131 struct acm_wb *delayed_wb; /* write queued for a device about to be woken */
130}; 132};
131 133
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
index 38b8bce782d6..4247eccf858c 100644
--- a/drivers/usb/core/devio.c
+++ b/drivers/usb/core/devio.c
@@ -595,7 +595,7 @@ static int usbdev_open(struct inode *inode, struct file *file)
595 if (!ps) 595 if (!ps)
596 goto out; 596 goto out;
597 597
598 ret = -ENOENT; 598 ret = -ENODEV;
599 599
600 /* usbdev device-node */ 600 /* usbdev device-node */
601 if (imajor(inode) == USB_DEVICE_MAJOR) 601 if (imajor(inode) == USB_DEVICE_MAJOR)
@@ -1321,7 +1321,8 @@ static int get_urb32(struct usbdevfs_urb *kurb,
1321 struct usbdevfs_urb32 __user *uurb) 1321 struct usbdevfs_urb32 __user *uurb)
1322{ 1322{
1323 __u32 uptr; 1323 __u32 uptr;
1324 if (get_user(kurb->type, &uurb->type) || 1324 if (!access_ok(VERIFY_READ, uurb, sizeof(*uurb)) ||
1325 __get_user(kurb->type, &uurb->type) ||
1325 __get_user(kurb->endpoint, &uurb->endpoint) || 1326 __get_user(kurb->endpoint, &uurb->endpoint) ||
1326 __get_user(kurb->status, &uurb->status) || 1327 __get_user(kurb->status, &uurb->status) ||
1327 __get_user(kurb->flags, &uurb->flags) || 1328 __get_user(kurb->flags, &uurb->flags) ||
@@ -1536,8 +1537,9 @@ static int proc_ioctl_compat(struct dev_state *ps, compat_uptr_t arg)
1536 u32 udata; 1537 u32 udata;
1537 1538
1538 uioc = compat_ptr((long)arg); 1539 uioc = compat_ptr((long)arg);
1539 if (get_user(ctrl.ifno, &uioc->ifno) || 1540 if (!access_ok(VERIFY_READ, uioc, sizeof(*uioc)) ||
1540 get_user(ctrl.ioctl_code, &uioc->ioctl_code) || 1541 __get_user(ctrl.ifno, &uioc->ifno) ||
1542 __get_user(ctrl.ioctl_code, &uioc->ioctl_code) ||
1541 __get_user(udata, &uioc->data)) 1543 __get_user(udata, &uioc->data))
1542 return -EFAULT; 1544 return -EFAULT;
1543 ctrl.data = compat_ptr(udata); 1545 ctrl.data = compat_ptr(udata);
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 7d03549c3339..11c627ce6022 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -903,7 +903,8 @@ static int ehci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
903 /* already started */ 903 /* already started */
904 break; 904 break;
905 case QH_STATE_IDLE: 905 case QH_STATE_IDLE:
906 WARN_ON(1); 906 /* QH might be waiting for a Clear-TT-Buffer */
907 qh_completions(ehci, qh);
907 break; 908 break;
908 } 909 }
909 break; 910 break;
diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c
index 9a1384747f3b..7673554fa64d 100644
--- a/drivers/usb/host/ehci-q.c
+++ b/drivers/usb/host/ehci-q.c
@@ -375,12 +375,11 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh)
375 */ 375 */
376 if ((token & QTD_STS_XACT) && 376 if ((token & QTD_STS_XACT) &&
377 QTD_CERR(token) == 0 && 377 QTD_CERR(token) == 0 &&
378 --qh->xacterrs > 0 && 378 ++qh->xacterrs < QH_XACTERR_MAX &&
379 !urb->unlinked) { 379 !urb->unlinked) {
380 ehci_dbg(ehci, 380 ehci_dbg(ehci,
381 "detected XactErr len %zu/%zu retry %d\n", 381 "detected XactErr len %zu/%zu retry %d\n",
382 qtd->length - QTD_LENGTH(token), qtd->length, 382 qtd->length - QTD_LENGTH(token), qtd->length, qh->xacterrs);
383 QH_XACTERR_MAX - qh->xacterrs);
384 383
385 /* reset the token in the qtd and the 384 /* reset the token in the qtd and the
386 * qh overlay (which still contains 385 * qh overlay (which still contains
@@ -494,7 +493,7 @@ halt:
494 last = qtd; 493 last = qtd;
495 494
496 /* reinit the xacterr counter for the next qtd */ 495 /* reinit the xacterr counter for the next qtd */
497 qh->xacterrs = QH_XACTERR_MAX; 496 qh->xacterrs = 0;
498 } 497 }
499 498
500 /* last urb's completion might still need calling */ 499 /* last urb's completion might still need calling */
@@ -940,7 +939,8 @@ static void qh_link_async (struct ehci_hcd *ehci, struct ehci_qh *qh)
940 head->qh_next.qh = qh; 939 head->qh_next.qh = qh;
941 head->hw_next = dma; 940 head->hw_next = dma;
942 941
943 qh->xacterrs = QH_XACTERR_MAX; 942 qh_get(qh);
943 qh->xacterrs = 0;
944 qh->qh_state = QH_STATE_LINKED; 944 qh->qh_state = QH_STATE_LINKED;
945 /* qtd completions reported later by interrupt */ 945 /* qtd completions reported later by interrupt */
946} 946}
@@ -1080,7 +1080,7 @@ submit_async (
1080 * the HC and TT handle it when the TT has a buffer ready. 1080 * the HC and TT handle it when the TT has a buffer ready.
1081 */ 1081 */
1082 if (likely (qh->qh_state == QH_STATE_IDLE)) 1082 if (likely (qh->qh_state == QH_STATE_IDLE))
1083 qh_link_async (ehci, qh_get (qh)); 1083 qh_link_async(ehci, qh);
1084 done: 1084 done:
1085 spin_unlock_irqrestore (&ehci->lock, flags); 1085 spin_unlock_irqrestore (&ehci->lock, flags);
1086 if (unlikely (qh == NULL)) 1086 if (unlikely (qh == NULL))
@@ -1115,8 +1115,6 @@ static void end_unlink_async (struct ehci_hcd *ehci)
1115 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state)) 1115 && HC_IS_RUNNING (ehci_to_hcd(ehci)->state))
1116 qh_link_async (ehci, qh); 1116 qh_link_async (ehci, qh);
1117 else { 1117 else {
1118 qh_put (qh); // refcount from async list
1119
1120 /* it's not free to turn the async schedule on/off; leave it 1118 /* it's not free to turn the async schedule on/off; leave it
1121 * active but idle for a while once it empties. 1119 * active but idle for a while once it empties.
1122 */ 1120 */
@@ -1124,6 +1122,7 @@ static void end_unlink_async (struct ehci_hcd *ehci)
1124 && ehci->async->qh_next.qh == NULL) 1122 && ehci->async->qh_next.qh == NULL)
1125 timer_action (ehci, TIMER_ASYNC_OFF); 1123 timer_action (ehci, TIMER_ASYNC_OFF);
1126 } 1124 }
1125 qh_put(qh); /* refcount from async list */
1127 1126
1128 if (next) { 1127 if (next) {
1129 ehci->reclaim = NULL; 1128 ehci->reclaim = NULL;
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c
index 74f7f83b29ad..edd61ee90323 100644
--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -542,6 +542,7 @@ static int qh_link_periodic (struct ehci_hcd *ehci, struct ehci_qh *qh)
542 } 542 }
543 } 543 }
544 qh->qh_state = QH_STATE_LINKED; 544 qh->qh_state = QH_STATE_LINKED;
545 qh->xacterrs = 0;
545 qh_get (qh); 546 qh_get (qh);
546 547
547 /* update per-qh bandwidth for usbfs */ 548 /* update per-qh bandwidth for usbfs */
diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig
index 70073b157f0a..803adcb5ac1d 100644
--- a/drivers/usb/musb/Kconfig
+++ b/drivers/usb/musb/Kconfig
@@ -12,6 +12,7 @@ config USB_MUSB_HDRC
12 depends on !SUPERH 12 depends on !SUPERH
13 select NOP_USB_XCEIV if ARCH_DAVINCI 13 select NOP_USB_XCEIV if ARCH_DAVINCI
14 select TWL4030_USB if MACH_OMAP_3430SDP 14 select TWL4030_USB if MACH_OMAP_3430SDP
15 select NOP_USB_XCEIV if MACH_OMAP3EVM
15 select USB_OTG_UTILS 16 select USB_OTG_UTILS
16 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)' 17 tristate 'Inventra Highspeed Dual Role Controller (TI, ADI, ...)'
17 help 18 help
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c
index b574878c78b2..8fec5d4455c9 100644
--- a/drivers/usb/serial/ftdi_sio.c
+++ b/drivers/usb/serial/ftdi_sio.c
@@ -699,6 +699,9 @@ static struct usb_device_id id_table_combined [] = {
699 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, 699 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
700 { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) }, 700 { USB_DEVICE(LARSENBRUSGAARD_VID, LB_ALTITRACK_PID) },
701 { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) }, 701 { USB_DEVICE(GN_OTOMETRICS_VID, AURICAL_USB_PID) },
702 { USB_DEVICE(BAYER_VID, BAYER_CONTOUR_CABLE_PID) },
703 { USB_DEVICE(FTDI_VID, MARVELL_OPENRD_PID),
704 .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk },
702 { }, /* Optional parameter entry */ 705 { }, /* Optional parameter entry */
703 { } /* Terminating entry */ 706 { } /* Terminating entry */
704}; 707};
diff --git a/drivers/usb/serial/ftdi_sio.h b/drivers/usb/serial/ftdi_sio.h
index 24dbd99e87d7..8c92b88166ae 100644
--- a/drivers/usb/serial/ftdi_sio.h
+++ b/drivers/usb/serial/ftdi_sio.h
@@ -954,6 +954,20 @@
954#define AURICAL_USB_PID 0x0010 /* Aurical USB Audiometer */ 954#define AURICAL_USB_PID 0x0010 /* Aurical USB Audiometer */
955 955
956/* 956/*
957 * Bayer Ascensia Contour blood glucose meter USB-converter cable.
958 * http://winglucofacts.com/cables/
959 */
960#define BAYER_VID 0x1A79
961#define BAYER_CONTOUR_CABLE_PID 0x6001
962
963/*
964 * Marvell OpenRD Base, Client
965 * http://www.open-rd.org
966 * OpenRD Base, Client use VID 0x0403
967 */
968#define MARVELL_OPENRD_PID 0x9e90
969
970/*
957 * BmRequestType: 1100 0000b 971 * BmRequestType: 1100 0000b
958 * bRequest: FTDI_E2_READ 972 * bRequest: FTDI_E2_READ
959 * wValue: 0 973 * wValue: 0
diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c
index 7d15bfa7c2db..3e86815b2705 100644
--- a/drivers/usb/serial/pl2303.c
+++ b/drivers/usb/serial/pl2303.c
@@ -95,6 +95,7 @@ static struct usb_device_id id_table [] = {
95 { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) }, 95 { USB_DEVICE(SUPERIAL_VENDOR_ID, SUPERIAL_PRODUCT_ID) },
96 { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) }, 96 { USB_DEVICE(HP_VENDOR_ID, HP_LD220_PRODUCT_ID) },
97 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) }, 97 { USB_DEVICE(CRESSI_VENDOR_ID, CRESSI_EDY_PRODUCT_ID) },
98 { USB_DEVICE(SONY_VENDOR_ID, SONY_QN3USB_PRODUCT_ID) },
98 { } /* Terminating entry */ 99 { } /* Terminating entry */
99}; 100};
100 101
diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h
index 12aac7d2462d..ee9505e1dd92 100644
--- a/drivers/usb/serial/pl2303.h
+++ b/drivers/usb/serial/pl2303.h
@@ -126,3 +126,7 @@
126/* Cressi Edy (diving computer) PC interface */ 126/* Cressi Edy (diving computer) PC interface */
127#define CRESSI_VENDOR_ID 0x04b8 127#define CRESSI_VENDOR_ID 0x04b8
128#define CRESSI_EDY_PRODUCT_ID 0x0521 128#define CRESSI_EDY_PRODUCT_ID 0x0521
129
130/* Sony, USB data cable for CMD-Jxx mobile phones */
131#define SONY_VENDOR_ID 0x054c
132#define SONY_QN3USB_PRODUCT_ID 0x0437
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index 1b9c5dd0fb27..7477d411959f 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -838,6 +838,13 @@ UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001,
838 US_SC_DEVICE, US_PR_DEVICE, NULL, 838 US_SC_DEVICE, US_PR_DEVICE, NULL,
839 US_FL_FIX_CAPACITY ), 839 US_FL_FIX_CAPACITY ),
840 840
841/* Reported by Rogerio Brito <rbrito@ime.usp.br> */
842UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001,
843 "Prolific Technology, Inc.",
844 "Mass Storage Device",
845 US_SC_DEVICE, US_PR_DEVICE, NULL,
846 US_FL_NOT_LOCKABLE ),
847
841/* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */ 848/* Reported by Richard -=[]=- <micro_flyer@hotmail.com> */
842/* Change to bcdDeviceMin (0x0100 to 0x0001) reported by 849/* Change to bcdDeviceMin (0x0100 to 0x0001) reported by
843 * Thomas Bartosik <tbartdev@gmx-topmail.de> */ 850 * Thomas Bartosik <tbartdev@gmx-topmail.de> */
diff --git a/drivers/video/console/fbcon.c b/drivers/video/console/fbcon.c
index 471a9a60376a..3a44695b9c09 100644
--- a/drivers/video/console/fbcon.c
+++ b/drivers/video/console/fbcon.c
@@ -1082,7 +1082,6 @@ static void fbcon_init(struct vc_data *vc, int init)
1082 new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres); 1082 new_rows = FBCON_SWAP(ops->rotate, info->var.yres, info->var.xres);
1083 new_cols /= vc->vc_font.width; 1083 new_cols /= vc->vc_font.width;
1084 new_rows /= vc->vc_font.height; 1084 new_rows /= vc->vc_font.height;
1085 vc_resize(vc, new_cols, new_rows);
1086 1085
1087 /* 1086 /*
1088 * We must always set the mode. The mode of the previous console 1087 * We must always set the mode. The mode of the previous console
@@ -1111,10 +1110,11 @@ static void fbcon_init(struct vc_data *vc, int init)
1111 * vc_{cols,rows}, but we must not set those if we are only 1110 * vc_{cols,rows}, but we must not set those if we are only
1112 * resizing the console. 1111 * resizing the console.
1113 */ 1112 */
1114 if (!init) { 1113 if (init) {
1115 vc->vc_cols = new_cols; 1114 vc->vc_cols = new_cols;
1116 vc->vc_rows = new_rows; 1115 vc->vc_rows = new_rows;
1117 } 1116 } else
1117 vc_resize(vc, new_cols, new_rows);
1118 1118
1119 if (logo) 1119 if (logo)
1120 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows); 1120 fbcon_prepare_logo(vc, info, cols, rows, new_cols, new_rows);
diff --git a/drivers/video/console/fbcon_rotate.h b/drivers/video/console/fbcon_rotate.h
index 75be5ce53dc5..e233444cda66 100644
--- a/drivers/video/console/fbcon_rotate.h
+++ b/drivers/video/console/fbcon_rotate.h
@@ -45,7 +45,7 @@ static inline void rotate_ud(const char *in, char *out, u32 width, u32 height)
45 width = (width + 7) & ~7; 45 width = (width + 7) & ~7;
46 46
47 for (i = 0; i < height; i++) { 47 for (i = 0; i < height; i++) {
48 for (j = 0; j < width; j++) { 48 for (j = 0; j < width - shift; j++) {
49 if (pattern_test_bit(j, i, width, in)) 49 if (pattern_test_bit(j, i, width, in))
50 pattern_set_bit(width - (1 + j + shift), 50 pattern_set_bit(width - (1 + j + shift),
51 height - (1 + i), 51 height - (1 + i),
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c
index ef7870f5ea08..857b3668b3ba 100644
--- a/drivers/video/console/sticore.c
+++ b/drivers/video/console/sticore.c
@@ -957,9 +957,14 @@ static int __devinit sticore_pci_init(struct pci_dev *pd,
957#ifdef CONFIG_PCI 957#ifdef CONFIG_PCI
958 unsigned long fb_base, rom_base; 958 unsigned long fb_base, rom_base;
959 unsigned int fb_len, rom_len; 959 unsigned int fb_len, rom_len;
960 int err;
960 struct sti_struct *sti; 961 struct sti_struct *sti;
961 962
962 pci_enable_device(pd); 963 err = pci_enable_device(pd);
964 if (err < 0) {
965 dev_err(&pd->dev, "Cannot enable PCI device\n");
966 return err;
967 }
963 968
964 fb_base = pci_resource_start(pd, 0); 969 fb_base = pci_resource_start(pd, 0);
965 fb_len = pci_resource_len(pd, 0); 970 fb_len = pci_resource_len(pd, 0);
@@ -1048,7 +1053,7 @@ static void __devinit sti_init_roms(void)
1048 1053
1049 /* Register drivers for native & PCI cards */ 1054 /* Register drivers for native & PCI cards */
1050 register_parisc_driver(&pa_sti_driver); 1055 register_parisc_driver(&pa_sti_driver);
1051 pci_register_driver(&pci_sti_driver); 1056 WARN_ON(pci_register_driver(&pci_sti_driver));
1052 1057
1053 /* if we didn't find the given default sti, take the first one */ 1058 /* if we didn't find the given default sti, take the first one */
1054 if (!default_sti) 1059 if (!default_sti)
diff --git a/drivers/video/mx3fb.c b/drivers/video/mx3fb.c
index f8778cde2183..054ef29be479 100644
--- a/drivers/video/mx3fb.c
+++ b/drivers/video/mx3fb.c
@@ -669,7 +669,8 @@ static uint32_t bpp_to_pixfmt(int bpp)
669} 669}
670 670
671static int mx3fb_blank(int blank, struct fb_info *fbi); 671static int mx3fb_blank(int blank, struct fb_info *fbi);
672static int mx3fb_map_video_memory(struct fb_info *fbi, unsigned int mem_len); 672static int mx3fb_map_video_memory(struct fb_info *fbi, unsigned int mem_len,
673 bool lock);
673static int mx3fb_unmap_video_memory(struct fb_info *fbi); 674static int mx3fb_unmap_video_memory(struct fb_info *fbi);
674 675
675/** 676/**
@@ -711,12 +712,7 @@ static void mx3fb_dma_done(void *arg)
711 complete(&mx3_fbi->flip_cmpl); 712 complete(&mx3_fbi->flip_cmpl);
712} 713}
713 714
714/** 715static int __set_par(struct fb_info *fbi, bool lock)
715 * mx3fb_set_par() - set framebuffer parameters and change the operating mode.
716 * @fbi: framebuffer information pointer.
717 * @return: 0 on success or negative error code on failure.
718 */
719static int mx3fb_set_par(struct fb_info *fbi)
720{ 716{
721 u32 mem_len; 717 u32 mem_len;
722 struct ipu_di_signal_cfg sig_cfg; 718 struct ipu_di_signal_cfg sig_cfg;
@@ -727,10 +723,6 @@ static int mx3fb_set_par(struct fb_info *fbi)
727 struct idmac_video_param *video = &ichan->params.video; 723 struct idmac_video_param *video = &ichan->params.video;
728 struct scatterlist *sg = mx3_fbi->sg; 724 struct scatterlist *sg = mx3_fbi->sg;
729 725
730 dev_dbg(mx3fb->dev, "%s [%c]\n", __func__, list_empty(&ichan->queue) ? '-' : '+');
731
732 mutex_lock(&mx3_fbi->mutex);
733
734 /* Total cleanup */ 726 /* Total cleanup */
735 if (mx3_fbi->txd) 727 if (mx3_fbi->txd)
736 sdc_disable_channel(mx3_fbi); 728 sdc_disable_channel(mx3_fbi);
@@ -742,10 +734,8 @@ static int mx3fb_set_par(struct fb_info *fbi)
742 if (fbi->fix.smem_start) 734 if (fbi->fix.smem_start)
743 mx3fb_unmap_video_memory(fbi); 735 mx3fb_unmap_video_memory(fbi);
744 736
745 if (mx3fb_map_video_memory(fbi, mem_len) < 0) { 737 if (mx3fb_map_video_memory(fbi, mem_len, lock) < 0)
746 mutex_unlock(&mx3_fbi->mutex);
747 return -ENOMEM; 738 return -ENOMEM;
748 }
749 } 739 }
750 740
751 sg_init_table(&sg[0], 1); 741 sg_init_table(&sg[0], 1);
@@ -791,7 +781,6 @@ static int mx3fb_set_par(struct fb_info *fbi)
791 fbi->var.vsync_len, 781 fbi->var.vsync_len,
792 fbi->var.lower_margin + 782 fbi->var.lower_margin +
793 fbi->var.vsync_len, sig_cfg) != 0) { 783 fbi->var.vsync_len, sig_cfg) != 0) {
794 mutex_unlock(&mx3_fbi->mutex);
795 dev_err(fbi->device, 784 dev_err(fbi->device,
796 "mx3fb: Error initializing panel.\n"); 785 "mx3fb: Error initializing panel.\n");
797 return -EINVAL; 786 return -EINVAL;
@@ -810,9 +799,30 @@ static int mx3fb_set_par(struct fb_info *fbi)
810 if (mx3_fbi->blank == FB_BLANK_UNBLANK) 799 if (mx3_fbi->blank == FB_BLANK_UNBLANK)
811 sdc_enable_channel(mx3_fbi); 800 sdc_enable_channel(mx3_fbi);
812 801
802 return 0;
803}
804
805/**
806 * mx3fb_set_par() - set framebuffer parameters and change the operating mode.
807 * @fbi: framebuffer information pointer.
808 * @return: 0 on success or negative error code on failure.
809 */
810static int mx3fb_set_par(struct fb_info *fbi)
811{
812 struct mx3fb_info *mx3_fbi = fbi->par;
813 struct mx3fb_data *mx3fb = mx3_fbi->mx3fb;
814 struct idmac_channel *ichan = mx3_fbi->idmac_channel;
815 int ret;
816
817 dev_dbg(mx3fb->dev, "%s [%c]\n", __func__, list_empty(&ichan->queue) ? '-' : '+');
818
819 mutex_lock(&mx3_fbi->mutex);
820
821 ret = __set_par(fbi, true);
822
813 mutex_unlock(&mx3_fbi->mutex); 823 mutex_unlock(&mx3_fbi->mutex);
814 824
815 return 0; 825 return ret;
816} 826}
817 827
818/** 828/**
@@ -966,21 +976,11 @@ static int mx3fb_setcolreg(unsigned int regno, unsigned int red,
966 return ret; 976 return ret;
967} 977}
968 978
969/** 979static void __blank(int blank, struct fb_info *fbi)
970 * mx3fb_blank() - blank the display.
971 */
972static int mx3fb_blank(int blank, struct fb_info *fbi)
973{ 980{
974 struct mx3fb_info *mx3_fbi = fbi->par; 981 struct mx3fb_info *mx3_fbi = fbi->par;
975 struct mx3fb_data *mx3fb = mx3_fbi->mx3fb; 982 struct mx3fb_data *mx3fb = mx3_fbi->mx3fb;
976 983
977 dev_dbg(fbi->device, "%s, blank = %d, base %p, len %u\n", __func__,
978 blank, fbi->screen_base, fbi->fix.smem_len);
979
980 if (mx3_fbi->blank == blank)
981 return 0;
982
983 mutex_lock(&mx3_fbi->mutex);
984 mx3_fbi->blank = blank; 984 mx3_fbi->blank = blank;
985 985
986 switch (blank) { 986 switch (blank) {
@@ -999,6 +999,23 @@ static int mx3fb_blank(int blank, struct fb_info *fbi)
999 sdc_set_brightness(mx3fb, mx3fb->backlight_level); 999 sdc_set_brightness(mx3fb, mx3fb->backlight_level);
1000 break; 1000 break;
1001 } 1001 }
1002}
1003
1004/**
1005 * mx3fb_blank() - blank the display.
1006 */
1007static int mx3fb_blank(int blank, struct fb_info *fbi)
1008{
1009 struct mx3fb_info *mx3_fbi = fbi->par;
1010
1011 dev_dbg(fbi->device, "%s, blank = %d, base %p, len %u\n", __func__,
1012 blank, fbi->screen_base, fbi->fix.smem_len);
1013
1014 if (mx3_fbi->blank == blank)
1015 return 0;
1016
1017 mutex_lock(&mx3_fbi->mutex);
1018 __blank(blank, fbi);
1002 mutex_unlock(&mx3_fbi->mutex); 1019 mutex_unlock(&mx3_fbi->mutex);
1003 1020
1004 return 0; 1021 return 0;
@@ -1198,6 +1215,7 @@ static int mx3fb_resume(struct platform_device *pdev)
1198 * mx3fb_map_video_memory() - allocates the DRAM memory for the frame buffer. 1215 * mx3fb_map_video_memory() - allocates the DRAM memory for the frame buffer.
1199 * @fbi: framebuffer information pointer 1216 * @fbi: framebuffer information pointer
1200 * @mem_len: length of mapped memory 1217 * @mem_len: length of mapped memory
1218 * @lock: do not lock during initialisation
1201 * @return: Error code indicating success or failure 1219 * @return: Error code indicating success or failure
1202 * 1220 *
1203 * This buffer is remapped into a non-cached, non-buffered, memory region to 1221 * This buffer is remapped into a non-cached, non-buffered, memory region to
@@ -1205,7 +1223,8 @@ static int mx3fb_resume(struct platform_device *pdev)
1205 * area is remapped, all virtual memory access to the video memory should occur 1223 * area is remapped, all virtual memory access to the video memory should occur
1206 * at the new region. 1224 * at the new region.
1207 */ 1225 */
1208static int mx3fb_map_video_memory(struct fb_info *fbi, unsigned int mem_len) 1226static int mx3fb_map_video_memory(struct fb_info *fbi, unsigned int mem_len,
1227 bool lock)
1209{ 1228{
1210 int retval = 0; 1229 int retval = 0;
1211 dma_addr_t addr; 1230 dma_addr_t addr;
@@ -1221,10 +1240,12 @@ static int mx3fb_map_video_memory(struct fb_info *fbi, unsigned int mem_len)
1221 goto err0; 1240 goto err0;
1222 } 1241 }
1223 1242
1224 mutex_lock(&fbi->mm_lock); 1243 if (lock)
1244 mutex_lock(&fbi->mm_lock);
1225 fbi->fix.smem_start = addr; 1245 fbi->fix.smem_start = addr;
1226 fbi->fix.smem_len = mem_len; 1246 fbi->fix.smem_len = mem_len;
1227 mutex_unlock(&fbi->mm_lock); 1247 if (lock)
1248 mutex_unlock(&fbi->mm_lock);
1228 1249
1229 dev_dbg(fbi->device, "allocated fb @ p=0x%08x, v=0x%p, size=%d.\n", 1250 dev_dbg(fbi->device, "allocated fb @ p=0x%08x, v=0x%p, size=%d.\n",
1230 (uint32_t) fbi->fix.smem_start, fbi->screen_base, fbi->fix.smem_len); 1251 (uint32_t) fbi->fix.smem_start, fbi->screen_base, fbi->fix.smem_len);
@@ -1365,6 +1386,11 @@ static int init_fb_chan(struct mx3fb_data *mx3fb, struct idmac_channel *ichan)
1365 init_completion(&mx3fbi->flip_cmpl); 1386 init_completion(&mx3fbi->flip_cmpl);
1366 disable_irq(ichan->eof_irq); 1387 disable_irq(ichan->eof_irq);
1367 dev_dbg(mx3fb->dev, "disabling irq %d\n", ichan->eof_irq); 1388 dev_dbg(mx3fb->dev, "disabling irq %d\n", ichan->eof_irq);
1389 ret = __set_par(fbi, false);
1390 if (ret < 0)
1391 goto esetpar;
1392
1393 __blank(FB_BLANK_UNBLANK, fbi);
1368 1394
1369 dev_info(dev, "registered, using mode %s\n", fb_mode); 1395 dev_info(dev, "registered, using mode %s\n", fb_mode);
1370 1396
diff --git a/drivers/video/sh_mobile_lcdcfb.c b/drivers/video/sh_mobile_lcdcfb.c
index 8f24564f77b0..07f22b625632 100644
--- a/drivers/video/sh_mobile_lcdcfb.c
+++ b/drivers/video/sh_mobile_lcdcfb.c
@@ -481,6 +481,9 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
481 /* tell the board code to enable the panel */ 481 /* tell the board code to enable the panel */
482 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { 482 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
483 ch = &priv->ch[k]; 483 ch = &priv->ch[k];
484 if (!ch->enabled)
485 continue;
486
484 board_cfg = &ch->cfg.board_cfg; 487 board_cfg = &ch->cfg.board_cfg;
485 if (board_cfg->display_on) 488 if (board_cfg->display_on)
486 board_cfg->display_on(board_cfg->board_data); 489 board_cfg->display_on(board_cfg->board_data);
@@ -498,6 +501,8 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
498 /* clean up deferred io and ask board code to disable panel */ 501 /* clean up deferred io and ask board code to disable panel */
499 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) { 502 for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
500 ch = &priv->ch[k]; 503 ch = &priv->ch[k];
504 if (!ch->enabled)
505 continue;
501 506
502 /* deferred io mode: 507 /* deferred io mode:
503 * flush frame, and wait for frame end interrupt 508 * flush frame, and wait for frame end interrupt
diff --git a/drivers/video/via/hw.c b/drivers/video/via/hw.c
index fcd53ceb88fa..c8960003f47d 100644
--- a/drivers/video/via/hw.c
+++ b/drivers/video/via/hw.c
@@ -2407,14 +2407,14 @@ int viafb_setmode(int vmode_index, int hor_res, int ver_res, int video_bpp,
2407 viafb_dvi_set_mode(viafb_get_mode_index 2407 viafb_dvi_set_mode(viafb_get_mode_index
2408 (viaparinfo->tmds_setting_info->h_active, 2408 (viaparinfo->tmds_setting_info->h_active,
2409 viaparinfo->tmds_setting_info-> 2409 viaparinfo->tmds_setting_info->
2410 v_active, 1), 2410 v_active),
2411 video_bpp1, viaparinfo-> 2411 video_bpp1, viaparinfo->
2412 tmds_setting_info->iga_path); 2412 tmds_setting_info->iga_path);
2413 } else { 2413 } else {
2414 viafb_dvi_set_mode(viafb_get_mode_index 2414 viafb_dvi_set_mode(viafb_get_mode_index
2415 (viaparinfo->tmds_setting_info->h_active, 2415 (viaparinfo->tmds_setting_info->h_active,
2416 viaparinfo-> 2416 viaparinfo->
2417 tmds_setting_info->v_active, 0), 2417 tmds_setting_info->v_active),
2418 video_bpp, viaparinfo-> 2418 video_bpp, viaparinfo->
2419 tmds_setting_info->iga_path); 2419 tmds_setting_info->iga_path);
2420 } 2420 }
diff --git a/drivers/video/via/lcd.c b/drivers/video/via/lcd.c
index 6c7290a6a447..78c6b3387947 100644
--- a/drivers/video/via/lcd.c
+++ b/drivers/video/via/lcd.c
@@ -580,10 +580,7 @@ static void load_lcd_k400_patch_tbl(int set_hres, int set_vres,
580 int reg_num = 0; 580 int reg_num = 0;
581 struct io_reg *lcd_patch_reg = NULL; 581 struct io_reg *lcd_patch_reg = NULL;
582 582
583 if (viaparinfo->lvds_setting_info->iga_path == IGA2) 583 vmode_index = viafb_get_mode_index(set_hres, set_vres);
584 vmode_index = viafb_get_mode_index(set_hres, set_vres, 1);
585 else
586 vmode_index = viafb_get_mode_index(set_hres, set_vres, 0);
587 switch (panel_id) { 584 switch (panel_id) {
588 /* LCD 800x600 */ 585 /* LCD 800x600 */
589 case LCD_PANEL_ID1_800X600: 586 case LCD_PANEL_ID1_800X600:
@@ -761,10 +758,7 @@ static void load_lcd_p880_patch_tbl(int set_hres, int set_vres,
761 int reg_num = 0; 758 int reg_num = 0;
762 struct io_reg *lcd_patch_reg = NULL; 759 struct io_reg *lcd_patch_reg = NULL;
763 760
764 if (viaparinfo->lvds_setting_info->iga_path == IGA2) 761 vmode_index = viafb_get_mode_index(set_hres, set_vres);
765 vmode_index = viafb_get_mode_index(set_hres, set_vres, 1);
766 else
767 vmode_index = viafb_get_mode_index(set_hres, set_vres, 0);
768 762
769 switch (panel_id) { 763 switch (panel_id) {
770 case LCD_PANEL_ID5_1400X1050: 764 case LCD_PANEL_ID5_1400X1050:
@@ -832,10 +826,7 @@ static void load_lcd_patch_regs(int set_hres, int set_vres,
832{ 826{
833 int vmode_index; 827 int vmode_index;
834 828
835 if (viaparinfo->lvds_setting_info->iga_path == IGA2) 829 vmode_index = viafb_get_mode_index(set_hres, set_vres);
836 vmode_index = viafb_get_mode_index(set_hres, set_vres, 1);
837 else
838 vmode_index = viafb_get_mode_index(set_hres, set_vres, 0);
839 830
840 viafb_unlock_crt(); 831 viafb_unlock_crt();
841 832
diff --git a/drivers/video/via/viafbdev.c b/drivers/video/via/viafbdev.c
index a0fec298216e..72833f3334b5 100644
--- a/drivers/video/via/viafbdev.c
+++ b/drivers/video/via/viafbdev.c
@@ -32,7 +32,6 @@ static u32 pseudo_pal[17];
32/* video mode */ 32/* video mode */
33static char *viafb_mode = "640x480"; 33static char *viafb_mode = "640x480";
34static char *viafb_mode1 = "640x480"; 34static char *viafb_mode1 = "640x480";
35static int viafb_resMode = VIA_RES_640X480;
36 35
37/* Added for specifying active devices.*/ 36/* Added for specifying active devices.*/
38char *viafb_active_dev = ""; 37char *viafb_active_dev = "";
@@ -56,47 +55,47 @@ static void viafb_get_video_device(u32 *video_dev_info);
56 55
57/* Mode information */ 56/* Mode information */
58static const struct viafb_modeinfo viafb_modentry[] = { 57static const struct viafb_modeinfo viafb_modentry[] = {
59 {480, 640, VIA_RES_480X640, "480x640"}, 58 {480, 640, VIA_RES_480X640},
60 {640, 480, VIA_RES_640X480, "640x480"}, 59 {640, 480, VIA_RES_640X480},
61 {800, 480, VIA_RES_800X480, "800x480"}, 60 {800, 480, VIA_RES_800X480},
62 {800, 600, VIA_RES_800X600, "800x600"}, 61 {800, 600, VIA_RES_800X600},
63 {1024, 768, VIA_RES_1024X768, "1024x768"}, 62 {1024, 768, VIA_RES_1024X768},
64 {1152, 864, VIA_RES_1152X864, "1152x864"}, 63 {1152, 864, VIA_RES_1152X864},
65 {1280, 1024, VIA_RES_1280X1024, "1280x1024"}, 64 {1280, 1024, VIA_RES_1280X1024},
66 {1600, 1200, VIA_RES_1600X1200, "1600x1200"}, 65 {1600, 1200, VIA_RES_1600X1200},
67 {1440, 1050, VIA_RES_1440X1050, "1440x1050"}, 66 {1440, 1050, VIA_RES_1440X1050},
68 {1280, 768, VIA_RES_1280X768, "1280x768"}, 67 {1280, 768, VIA_RES_1280X768,},
69 {1280, 800, VIA_RES_1280X800, "1280x800"}, 68 {1280, 800, VIA_RES_1280X800},
70 {1280, 960, VIA_RES_1280X960, "1280x960"}, 69 {1280, 960, VIA_RES_1280X960},
71 {1920, 1440, VIA_RES_1920X1440, "1920x1440"}, 70 {1920, 1440, VIA_RES_1920X1440},
72 {848, 480, VIA_RES_848X480, "848x480"}, 71 {848, 480, VIA_RES_848X480},
73 {1400, 1050, VIA_RES_1400X1050, "1400x1050"}, 72 {1400, 1050, VIA_RES_1400X1050},
74 {720, 480, VIA_RES_720X480, "720x480"}, 73 {720, 480, VIA_RES_720X480},
75 {720, 576, VIA_RES_720X576, "720x576"}, 74 {720, 576, VIA_RES_720X576},
76 {1024, 512, VIA_RES_1024X512, "1024x512"}, 75 {1024, 512, VIA_RES_1024X512},
77 {1024, 576, VIA_RES_1024X576, "1024x576"}, 76 {1024, 576, VIA_RES_1024X576},
78 {1024, 600, VIA_RES_1024X600, "1024x600"}, 77 {1024, 600, VIA_RES_1024X600},
79 {1280, 720, VIA_RES_1280X720, "1280x720"}, 78 {1280, 720, VIA_RES_1280X720},
80 {1920, 1080, VIA_RES_1920X1080, "1920x1080"}, 79 {1920, 1080, VIA_RES_1920X1080},
81 {1366, 768, VIA_RES_1368X768, "1368x768"}, 80 {1366, 768, VIA_RES_1368X768},
82 {1680, 1050, VIA_RES_1680X1050, "1680x1050"}, 81 {1680, 1050, VIA_RES_1680X1050},
83 {960, 600, VIA_RES_960X600, "960x600"}, 82 {960, 600, VIA_RES_960X600},
84 {1000, 600, VIA_RES_1000X600, "1000x600"}, 83 {1000, 600, VIA_RES_1000X600},
85 {1024, 576, VIA_RES_1024X576, "1024x576"}, 84 {1024, 576, VIA_RES_1024X576},
86 {1024, 600, VIA_RES_1024X600, "1024x600"}, 85 {1024, 600, VIA_RES_1024X600},
87 {1088, 612, VIA_RES_1088X612, "1088x612"}, 86 {1088, 612, VIA_RES_1088X612},
88 {1152, 720, VIA_RES_1152X720, "1152x720"}, 87 {1152, 720, VIA_RES_1152X720},
89 {1200, 720, VIA_RES_1200X720, "1200x720"}, 88 {1200, 720, VIA_RES_1200X720},
90 {1280, 600, VIA_RES_1280X600, "1280x600"}, 89 {1280, 600, VIA_RES_1280X600},
91 {1360, 768, VIA_RES_1360X768, "1360x768"}, 90 {1360, 768, VIA_RES_1360X768},
92 {1440, 900, VIA_RES_1440X900, "1440x900"}, 91 {1440, 900, VIA_RES_1440X900},
93 {1600, 900, VIA_RES_1600X900, "1600x900"}, 92 {1600, 900, VIA_RES_1600X900},
94 {1600, 1024, VIA_RES_1600X1024, "1600x1024"}, 93 {1600, 1024, VIA_RES_1600X1024},
95 {1792, 1344, VIA_RES_1792X1344, "1792x1344"}, 94 {1792, 1344, VIA_RES_1792X1344},
96 {1856, 1392, VIA_RES_1856X1392, "1856x1392"}, 95 {1856, 1392, VIA_RES_1856X1392},
97 {1920, 1200, VIA_RES_1920X1200, "1920x1200"}, 96 {1920, 1200, VIA_RES_1920X1200},
98 {2048, 1536, VIA_RES_2048X1536, "2048x1536"}, 97 {2048, 1536, VIA_RES_2048X1536},
99 {0, 0, VIA_RES_INVALID, "640x480"} 98 {0, 0, VIA_RES_INVALID}
100}; 99};
101 100
102static struct fb_ops viafb_ops; 101static struct fb_ops viafb_ops;
@@ -177,7 +176,7 @@ static int viafb_check_var(struct fb_var_screeninfo *var,
177 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE) 176 if (var->vmode & FB_VMODE_INTERLACED || var->vmode & FB_VMODE_DOUBLE)
178 return -EINVAL; 177 return -EINVAL;
179 178
180 vmode_index = viafb_get_mode_index(var->xres, var->yres, 0); 179 vmode_index = viafb_get_mode_index(var->xres, var->yres);
181 if (vmode_index == VIA_RES_INVALID) { 180 if (vmode_index == VIA_RES_INVALID) {
182 DEBUG_MSG(KERN_INFO 181 DEBUG_MSG(KERN_INFO
183 "viafb: Mode %dx%dx%d not supported!!\n", 182 "viafb: Mode %dx%dx%d not supported!!\n",
@@ -233,14 +232,14 @@ static int viafb_set_par(struct fb_info *info)
233 viafb_update_device_setting(info->var.xres, info->var.yres, 232 viafb_update_device_setting(info->var.xres, info->var.yres,
234 info->var.bits_per_pixel, viafb_refresh, 0); 233 info->var.bits_per_pixel, viafb_refresh, 0);
235 234
236 vmode_index = viafb_get_mode_index(info->var.xres, info->var.yres, 0); 235 vmode_index = viafb_get_mode_index(info->var.xres, info->var.yres);
237 236
238 if (viafb_SAMM_ON == 1) { 237 if (viafb_SAMM_ON == 1) {
239 DEBUG_MSG(KERN_INFO 238 DEBUG_MSG(KERN_INFO
240 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n", 239 "viafb_second_xres = %d, viafb_second_yres = %d, bpp = %d\n",
241 viafb_second_xres, viafb_second_yres, viafb_bpp1); 240 viafb_second_xres, viafb_second_yres, viafb_bpp1);
242 vmode_index1 = viafb_get_mode_index(viafb_second_xres, 241 vmode_index1 = viafb_get_mode_index(viafb_second_xres,
243 viafb_second_yres, 1); 242 viafb_second_yres);
244 DEBUG_MSG(KERN_INFO "->viafb_SAMM_ON: index=%d\n", 243 DEBUG_MSG(KERN_INFO "->viafb_SAMM_ON: index=%d\n",
245 vmode_index1); 244 vmode_index1);
246 245
@@ -1262,7 +1261,7 @@ static int viafb_sync(struct fb_info *info)
1262 return 0; 1261 return 0;
1263} 1262}
1264 1263
1265int viafb_get_mode_index(int hres, int vres, int flag) 1264int viafb_get_mode_index(int hres, int vres)
1266{ 1265{
1267 u32 i; 1266 u32 i;
1268 DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n"); 1267 DEBUG_MSG(KERN_INFO "viafb_get_mode_index!\n");
@@ -1272,13 +1271,7 @@ int viafb_get_mode_index(int hres, int vres, int flag)
1272 viafb_modentry[i].yres == vres) 1271 viafb_modentry[i].yres == vres)
1273 break; 1272 break;
1274 1273
1275 viafb_resMode = viafb_modentry[i].mode_index; 1274 return viafb_modentry[i].mode_index;
1276 if (flag)
1277 viafb_mode1 = viafb_modentry[i].mode_res;
1278 else
1279 viafb_mode = viafb_modentry[i].mode_res;
1280
1281 return viafb_resMode;
1282} 1275}
1283 1276
1284static void check_available_device_to_enable(int device_id) 1277static void check_available_device_to_enable(int device_id)
@@ -2199,7 +2192,7 @@ static int __devinit via_pci_probe(void)
2199 strict_strtoul(tmpc, 0, &default_xres); 2192 strict_strtoul(tmpc, 0, &default_xres);
2200 strict_strtoul(tmpm, 0, &default_yres); 2193 strict_strtoul(tmpm, 0, &default_yres);
2201 2194
2202 vmode_index = viafb_get_mode_index(default_xres, default_yres, 0); 2195 vmode_index = viafb_get_mode_index(default_xres, default_yres);
2203 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index); 2196 DEBUG_MSG(KERN_INFO "0->index=%d\n", vmode_index);
2204 2197
2205 if (viafb_SAMM_ON == 1) { 2198 if (viafb_SAMM_ON == 1) {
diff --git a/drivers/video/via/viafbdev.h b/drivers/video/via/viafbdev.h
index a4158e872878..227b000feb38 100644
--- a/drivers/video/via/viafbdev.h
+++ b/drivers/video/via/viafbdev.h
@@ -81,7 +81,6 @@ struct viafb_modeinfo {
81 u32 xres; 81 u32 xres;
82 u32 yres; 82 u32 yres;
83 int mode_index; 83 int mode_index;
84 char *mode_res;
85}; 84};
86extern unsigned int viafb_second_virtual_yres; 85extern unsigned int viafb_second_virtual_yres;
87extern unsigned int viafb_second_virtual_xres; 86extern unsigned int viafb_second_virtual_xres;
@@ -102,7 +101,7 @@ extern int strict_strtoul(const char *cp, unsigned int base,
102void viafb_memory_pitch_patch(struct fb_info *info); 101void viafb_memory_pitch_patch(struct fb_info *info);
103void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh, 102void viafb_fill_var_timing_info(struct fb_var_screeninfo *var, int refresh,
104 int mode_index); 103 int mode_index);
105int viafb_get_mode_index(int hres, int vres, int flag); 104int viafb_get_mode_index(int hres, int vres);
106u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information 105u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
107 *plvds_setting_info, struct lvds_chip_information 106 *plvds_setting_info, struct lvds_chip_information
108 *plvds_chip_info, u8 index); 107 *plvds_chip_info, u8 index);
diff --git a/drivers/video/xen-fbfront.c b/drivers/video/xen-fbfront.c
index 15502d5e3641..54cd91610174 100644
--- a/drivers/video/xen-fbfront.c
+++ b/drivers/video/xen-fbfront.c
@@ -454,6 +454,10 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
454 454
455 xenfb_init_shared_page(info, fb_info); 455 xenfb_init_shared_page(info, fb_info);
456 456
457 ret = xenfb_connect_backend(dev, info);
458 if (ret < 0)
459 goto error;
460
457 ret = register_framebuffer(fb_info); 461 ret = register_framebuffer(fb_info);
458 if (ret) { 462 if (ret) {
459 fb_deferred_io_cleanup(fb_info); 463 fb_deferred_io_cleanup(fb_info);
@@ -464,10 +468,6 @@ static int __devinit xenfb_probe(struct xenbus_device *dev,
464 } 468 }
465 info->fb_info = fb_info; 469 info->fb_info = fb_info;
466 470
467 ret = xenfb_connect_backend(dev, info);
468 if (ret < 0)
469 goto error;
470
471 xenfb_make_preferred_console(); 471 xenfb_make_preferred_console();
472 return 0; 472 return 0;
473 473
diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
index a7e3b706b9d3..0d92969404c3 100644
--- a/drivers/w1/masters/omap_hdq.c
+++ b/drivers/w1/masters/omap_hdq.c
@@ -687,6 +687,7 @@ static int omap_hdq_remove(struct platform_device *pdev)
687 687
688 if (hdq_data->hdq_usecount) { 688 if (hdq_data->hdq_usecount) {
689 dev_dbg(&pdev->dev, "removed when use count is not zero\n"); 689 dev_dbg(&pdev->dev, "removed when use count is not zero\n");
690 mutex_unlock(&hdq_data->hdq_mutex);
690 return -EBUSY; 691 return -EBUSY;
691 } 692 }
692 693
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c
index 3fe9742c23ca..2f8643efe92c 100644
--- a/drivers/watchdog/ar7_wdt.c
+++ b/drivers/watchdog/ar7_wdt.c
@@ -37,7 +37,7 @@
37#include <linux/uaccess.h> 37#include <linux/uaccess.h>
38 38
39#include <asm/addrspace.h> 39#include <asm/addrspace.h>
40#include <asm/ar7/ar7.h> 40#include <asm/mach-ar7/ar7.h>
41 41
42#define DRVNAME "ar7_wdt" 42#define DRVNAME "ar7_wdt"
43#define LONGNAME "TI AR7 Watchdog Timer" 43#define LONGNAME "TI AR7 Watchdog Timer"
diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index fecb307d28e9..aec7cefdef21 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -18,6 +18,7 @@
18#include <linux/bitops.h> 18#include <linux/bitops.h>
19#include <linux/uaccess.h> 19#include <linux/uaccess.h>
20#include <linux/clk.h> 20#include <linux/clk.h>
21#include <linux/delay.h>
21 22
22#define DRV_NAME "WDOG COH 901 327" 23#define DRV_NAME "WDOG COH 901 327"
23 24
@@ -92,6 +93,8 @@ static struct clk *clk;
92static void coh901327_enable(u16 timeout) 93static void coh901327_enable(u16 timeout)
93{ 94{
94 u16 val; 95 u16 val;
96 unsigned long freq;
97 unsigned long delay_ns;
95 98
96 clk_enable(clk); 99 clk_enable(clk);
97 /* Restart timer if it is disabled */ 100 /* Restart timer if it is disabled */
@@ -102,6 +105,14 @@ static void coh901327_enable(u16 timeout)
102 /* Acknowledge any pending interrupt so it doesn't just fire off */ 105 /* Acknowledge any pending interrupt so it doesn't just fire off */
103 writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE, 106 writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE,
104 virtbase + U300_WDOG_IER); 107 virtbase + U300_WDOG_IER);
108 /*
109 * The interrupt is cleared in the 32 kHz clock domain.
110 * Wait 3 32 kHz cycles for it to take effect
111 */
112 freq = clk_get_rate(clk);
113 delay_ns = (1000000000 + freq - 1) / freq; /* Freq to ns and round up */
114 delay_ns = 3 * delay_ns; /* Wait 3 cycles */
115 ndelay(delay_ns);
105 /* Enable the watchdog interrupt */ 116 /* Enable the watchdog interrupt */
106 writew(U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE, virtbase + U300_WDOG_IMR); 117 writew(U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE, virtbase + U300_WDOG_IMR);
107 /* Activate the watchdog timer */ 118 /* Activate the watchdog timer */
diff --git a/drivers/watchdog/ks8695_wdt.c b/drivers/watchdog/ks8695_wdt.c
index 00b03eb43bf0..e1c82769b08e 100644
--- a/drivers/watchdog/ks8695_wdt.c
+++ b/drivers/watchdog/ks8695_wdt.c
@@ -66,7 +66,7 @@ static inline void ks8695_wdt_stop(void)
66static inline void ks8695_wdt_start(void) 66static inline void ks8695_wdt_start(void)
67{ 67{
68 unsigned long tmcon; 68 unsigned long tmcon;
69 unsigned long tval = wdt_time * CLOCK_TICK_RATE; 69 unsigned long tval = wdt_time * KS8695_CLOCK_RATE;
70 70
71 spin_lock(&ks8695_lock); 71 spin_lock(&ks8695_lock);
72 /* disable timer0 */ 72 /* disable timer0 */
@@ -103,7 +103,7 @@ static inline void ks8695_wdt_reload(void)
103static int ks8695_wdt_settimeout(int new_time) 103static int ks8695_wdt_settimeout(int new_time)
104{ 104{
105 /* 105 /*
106 * All counting occurs at SLOW_CLOCK / 128 = 0.256 Hz 106 * All counting occurs at KS8695_CLOCK_RATE / 128 = 0.256 Hz
107 * 107 *
108 * Since WDV is a 16-bit counter, the maximum period is 108 * Since WDV is a 16-bit counter, the maximum period is
109 * 65536 / 0.256 = 256 seconds. 109 * 65536 / 0.256 = 256 seconds.
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index 332b5ff02fec..f7003cfac63d 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -76,7 +76,7 @@ static const match_table_t tokens = {
76 * Return 0 upon success, -ERRNO upon failure. 76 * Return 0 upon success, -ERRNO upon failure.
77 */ 77 */
78 78
79static int v9fs_parse_options(struct v9fs_session_info *v9ses) 79static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
80{ 80{
81 char *options; 81 char *options;
82 substring_t args[MAX_OPT_ARGS]; 82 substring_t args[MAX_OPT_ARGS];
@@ -90,10 +90,10 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses)
90 v9ses->debug = 0; 90 v9ses->debug = 0;
91 v9ses->cache = 0; 91 v9ses->cache = 0;
92 92
93 if (!v9ses->options) 93 if (!opts)
94 return 0; 94 return 0;
95 95
96 options = kstrdup(v9ses->options, GFP_KERNEL); 96 options = kstrdup(opts, GFP_KERNEL);
97 if (!options) { 97 if (!options) {
98 P9_DPRINTK(P9_DEBUG_ERROR, 98 P9_DPRINTK(P9_DEBUG_ERROR,
99 "failed to allocate copy of option string\n"); 99 "failed to allocate copy of option string\n");
@@ -206,24 +206,14 @@ struct p9_fid *v9fs_session_init(struct v9fs_session_info *v9ses,
206 v9ses->uid = ~0; 206 v9ses->uid = ~0;
207 v9ses->dfltuid = V9FS_DEFUID; 207 v9ses->dfltuid = V9FS_DEFUID;
208 v9ses->dfltgid = V9FS_DEFGID; 208 v9ses->dfltgid = V9FS_DEFGID;
209 if (data) {
210 v9ses->options = kstrdup(data, GFP_KERNEL);
211 if (!v9ses->options) {
212 P9_DPRINTK(P9_DEBUG_ERROR,
213 "failed to allocate copy of option string\n");
214 retval = -ENOMEM;
215 goto error;
216 }
217 }
218 209
219 rc = v9fs_parse_options(v9ses); 210 rc = v9fs_parse_options(v9ses, data);
220 if (rc < 0) { 211 if (rc < 0) {
221 retval = rc; 212 retval = rc;
222 goto error; 213 goto error;
223 } 214 }
224 215
225 v9ses->clnt = p9_client_create(dev_name, v9ses->options); 216 v9ses->clnt = p9_client_create(dev_name, data);
226
227 if (IS_ERR(v9ses->clnt)) { 217 if (IS_ERR(v9ses->clnt)) {
228 retval = PTR_ERR(v9ses->clnt); 218 retval = PTR_ERR(v9ses->clnt);
229 v9ses->clnt = NULL; 219 v9ses->clnt = NULL;
@@ -280,7 +270,6 @@ void v9fs_session_close(struct v9fs_session_info *v9ses)
280 270
281 __putname(v9ses->uname); 271 __putname(v9ses->uname);
282 __putname(v9ses->aname); 272 __putname(v9ses->aname);
283 kfree(v9ses->options);
284} 273}
285 274
286/** 275/**
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index a7d567192998..38762bf102a9 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -85,7 +85,6 @@ struct v9fs_session_info {
85 unsigned int afid; 85 unsigned int afid;
86 unsigned int cache; 86 unsigned int cache;
87 87
88 char *options; /* copy of mount options */
89 char *uname; /* user name to mount as */ 88 char *uname; /* user name to mount as */
90 char *aname; /* name of remote hierarchy being mounted */ 89 char *aname; /* name of remote hierarchy being mounted */
91 unsigned int maxdata; /* max data for client interface */ 90 unsigned int maxdata; /* max data for client interface */
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 81f8bbf12f9f..06a223d50a81 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -171,7 +171,6 @@ int v9fs_uflags2omode(int uflags, int extended)
171 171
172/** 172/**
173 * v9fs_blank_wstat - helper function to setup a 9P stat structure 173 * v9fs_blank_wstat - helper function to setup a 9P stat structure
174 * @v9ses: 9P session info (for determining extended mode)
175 * @wstat: structure to initialize 174 * @wstat: structure to initialize
176 * 175 *
177 */ 176 */
@@ -207,65 +206,72 @@ v9fs_blank_wstat(struct p9_wstat *wstat)
207 206
208struct inode *v9fs_get_inode(struct super_block *sb, int mode) 207struct inode *v9fs_get_inode(struct super_block *sb, int mode)
209{ 208{
209 int err;
210 struct inode *inode; 210 struct inode *inode;
211 struct v9fs_session_info *v9ses = sb->s_fs_info; 211 struct v9fs_session_info *v9ses = sb->s_fs_info;
212 212
213 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode); 213 P9_DPRINTK(P9_DEBUG_VFS, "super block: %p mode: %o\n", sb, mode);
214 214
215 inode = new_inode(sb); 215 inode = new_inode(sb);
216 if (inode) { 216 if (!inode) {
217 inode->i_mode = mode;
218 inode->i_uid = current_fsuid();
219 inode->i_gid = current_fsgid();
220 inode->i_blocks = 0;
221 inode->i_rdev = 0;
222 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
223 inode->i_mapping->a_ops = &v9fs_addr_operations;
224
225 switch (mode & S_IFMT) {
226 case S_IFIFO:
227 case S_IFBLK:
228 case S_IFCHR:
229 case S_IFSOCK:
230 if (!v9fs_extended(v9ses)) {
231 P9_DPRINTK(P9_DEBUG_ERROR,
232 "special files without extended mode\n");
233 return ERR_PTR(-EINVAL);
234 }
235 init_special_inode(inode, inode->i_mode,
236 inode->i_rdev);
237 break;
238 case S_IFREG:
239 inode->i_op = &v9fs_file_inode_operations;
240 inode->i_fop = &v9fs_file_operations;
241 break;
242 case S_IFLNK:
243 if (!v9fs_extended(v9ses)) {
244 P9_DPRINTK(P9_DEBUG_ERROR,
245 "extended modes used w/o 9P2000.u\n");
246 return ERR_PTR(-EINVAL);
247 }
248 inode->i_op = &v9fs_symlink_inode_operations;
249 break;
250 case S_IFDIR:
251 inc_nlink(inode);
252 if (v9fs_extended(v9ses))
253 inode->i_op = &v9fs_dir_inode_operations_ext;
254 else
255 inode->i_op = &v9fs_dir_inode_operations;
256 inode->i_fop = &v9fs_dir_operations;
257 break;
258 default:
259 P9_DPRINTK(P9_DEBUG_ERROR,
260 "BAD mode 0x%x S_IFMT 0x%x\n",
261 mode, mode & S_IFMT);
262 return ERR_PTR(-EINVAL);
263 }
264 } else {
265 P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n"); 217 P9_EPRINTK(KERN_WARNING, "Problem allocating inode\n");
266 return ERR_PTR(-ENOMEM); 218 return ERR_PTR(-ENOMEM);
267 } 219 }
220
221 inode->i_mode = mode;
222 inode->i_uid = current_fsuid();
223 inode->i_gid = current_fsgid();
224 inode->i_blocks = 0;
225 inode->i_rdev = 0;
226 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
227 inode->i_mapping->a_ops = &v9fs_addr_operations;
228
229 switch (mode & S_IFMT) {
230 case S_IFIFO:
231 case S_IFBLK:
232 case S_IFCHR:
233 case S_IFSOCK:
234 if (!v9fs_extended(v9ses)) {
235 P9_DPRINTK(P9_DEBUG_ERROR,
236 "special files without extended mode\n");
237 err = -EINVAL;
238 goto error;
239 }
240 init_special_inode(inode, inode->i_mode, inode->i_rdev);
241 break;
242 case S_IFREG:
243 inode->i_op = &v9fs_file_inode_operations;
244 inode->i_fop = &v9fs_file_operations;
245 break;
246 case S_IFLNK:
247 if (!v9fs_extended(v9ses)) {
248 P9_DPRINTK(P9_DEBUG_ERROR,
249 "extended modes used w/o 9P2000.u\n");
250 err = -EINVAL;
251 goto error;
252 }
253 inode->i_op = &v9fs_symlink_inode_operations;
254 break;
255 case S_IFDIR:
256 inc_nlink(inode);
257 if (v9fs_extended(v9ses))
258 inode->i_op = &v9fs_dir_inode_operations_ext;
259 else
260 inode->i_op = &v9fs_dir_inode_operations;
261 inode->i_fop = &v9fs_dir_operations;
262 break;
263 default:
264 P9_DPRINTK(P9_DEBUG_ERROR, "BAD mode 0x%x S_IFMT 0x%x\n",
265 mode, mode & S_IFMT);
266 err = -EINVAL;
267 goto error;
268 }
269
268 return inode; 270 return inode;
271
272error:
273 iput(inode);
274 return ERR_PTR(err);
269} 275}
270 276
271/* 277/*
@@ -338,30 +344,25 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid,
338 344
339 ret = NULL; 345 ret = NULL;
340 st = p9_client_stat(fid); 346 st = p9_client_stat(fid);
341 if (IS_ERR(st)) { 347 if (IS_ERR(st))
342 err = PTR_ERR(st); 348 return ERR_CAST(st);
343 st = NULL;
344 goto error;
345 }
346 349
347 umode = p9mode2unixmode(v9ses, st->mode); 350 umode = p9mode2unixmode(v9ses, st->mode);
348 ret = v9fs_get_inode(sb, umode); 351 ret = v9fs_get_inode(sb, umode);
349 if (IS_ERR(ret)) { 352 if (IS_ERR(ret)) {
350 err = PTR_ERR(ret); 353 err = PTR_ERR(ret);
351 ret = NULL;
352 goto error; 354 goto error;
353 } 355 }
354 356
355 v9fs_stat2inode(st, ret, sb); 357 v9fs_stat2inode(st, ret, sb);
356 ret->i_ino = v9fs_qid2ino(&st->qid); 358 ret->i_ino = v9fs_qid2ino(&st->qid);
359 p9stat_free(st);
357 kfree(st); 360 kfree(st);
358 return ret; 361 return ret;
359 362
360error: 363error:
364 p9stat_free(st);
361 kfree(st); 365 kfree(st);
362 if (ret)
363 iput(ret);
364
365 return ERR_PTR(err); 366 return ERR_PTR(err);
366} 367}
367 368
@@ -403,9 +404,9 @@ v9fs_open_created(struct inode *inode, struct file *file)
403 * @v9ses: session information 404 * @v9ses: session information
404 * @dir: directory that dentry is being created in 405 * @dir: directory that dentry is being created in
405 * @dentry: dentry that is being created 406 * @dentry: dentry that is being created
407 * @extension: 9p2000.u extension string to support devices, etc.
406 * @perm: create permissions 408 * @perm: create permissions
407 * @mode: open mode 409 * @mode: open mode
408 * @extension: 9p2000.u extension string to support devices, etc.
409 * 410 *
410 */ 411 */
411static struct p9_fid * 412static struct p9_fid *
@@ -470,7 +471,10 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
470 dentry->d_op = &v9fs_dentry_operations; 471 dentry->d_op = &v9fs_dentry_operations;
471 472
472 d_instantiate(dentry, inode); 473 d_instantiate(dentry, inode);
473 v9fs_fid_add(dentry, fid); 474 err = v9fs_fid_add(dentry, fid);
475 if (err < 0)
476 goto error;
477
474 return ofid; 478 return ofid;
475 479
476error: 480error:
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c
index 38d695d66a0b..8961f1a8f668 100644
--- a/fs/9p/vfs_super.c
+++ b/fs/9p/vfs_super.c
@@ -81,7 +81,7 @@ static int v9fs_set_super(struct super_block *s, void *data)
81 81
82static void 82static void
83v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses, 83v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
84 int flags) 84 int flags, void *data)
85{ 85{
86 sb->s_maxbytes = MAX_LFS_FILESIZE; 86 sb->s_maxbytes = MAX_LFS_FILESIZE;
87 sb->s_blocksize_bits = fls(v9ses->maxdata - 1); 87 sb->s_blocksize_bits = fls(v9ses->maxdata - 1);
@@ -91,6 +91,8 @@ v9fs_fill_super(struct super_block *sb, struct v9fs_session_info *v9ses,
91 91
92 sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC | 92 sb->s_flags = flags | MS_ACTIVE | MS_SYNCHRONOUS | MS_DIRSYNC |
93 MS_NOATIME; 93 MS_NOATIME;
94
95 save_mount_options(sb, data);
94} 96}
95 97
96/** 98/**
@@ -113,14 +115,11 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
113 struct v9fs_session_info *v9ses = NULL; 115 struct v9fs_session_info *v9ses = NULL;
114 struct p9_wstat *st = NULL; 116 struct p9_wstat *st = NULL;
115 int mode = S_IRWXUGO | S_ISVTX; 117 int mode = S_IRWXUGO | S_ISVTX;
116 uid_t uid = current_fsuid();
117 gid_t gid = current_fsgid();
118 struct p9_fid *fid; 118 struct p9_fid *fid;
119 int retval = 0; 119 int retval = 0;
120 120
121 P9_DPRINTK(P9_DEBUG_VFS, " \n"); 121 P9_DPRINTK(P9_DEBUG_VFS, " \n");
122 122
123 st = NULL;
124 v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL); 123 v9ses = kzalloc(sizeof(struct v9fs_session_info), GFP_KERNEL);
125 if (!v9ses) 124 if (!v9ses)
126 return -ENOMEM; 125 return -ENOMEM;
@@ -142,7 +141,7 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
142 retval = PTR_ERR(sb); 141 retval = PTR_ERR(sb);
143 goto free_stat; 142 goto free_stat;
144 } 143 }
145 v9fs_fill_super(sb, v9ses, flags); 144 v9fs_fill_super(sb, v9ses, flags, data);
146 145
147 inode = v9fs_get_inode(sb, S_IFDIR | mode); 146 inode = v9fs_get_inode(sb, S_IFDIR | mode);
148 if (IS_ERR(inode)) { 147 if (IS_ERR(inode)) {
@@ -150,9 +149,6 @@ static int v9fs_get_sb(struct file_system_type *fs_type, int flags,
150 goto release_sb; 149 goto release_sb;
151 } 150 }
152 151
153 inode->i_uid = uid;
154 inode->i_gid = gid;
155
156 root = d_alloc_root(inode); 152 root = d_alloc_root(inode);
157 if (!root) { 153 if (!root) {
158 iput(inode); 154 iput(inode);
@@ -173,10 +169,8 @@ P9_DPRINTK(P9_DEBUG_VFS, " simple set mount, return 0\n");
173 simple_set_mnt(mnt, sb); 169 simple_set_mnt(mnt, sb);
174 return 0; 170 return 0;
175 171
176release_sb:
177 deactivate_locked_super(sb);
178
179free_stat: 172free_stat:
173 p9stat_free(st);
180 kfree(st); 174 kfree(st);
181 175
182clunk_fid: 176clunk_fid:
@@ -185,7 +179,12 @@ clunk_fid:
185close_session: 179close_session:
186 v9fs_session_close(v9ses); 180 v9fs_session_close(v9ses);
187 kfree(v9ses); 181 kfree(v9ses);
182 return retval;
188 183
184release_sb:
185 p9stat_free(st);
186 kfree(st);
187 deactivate_locked_super(sb);
189 return retval; 188 return retval;
190} 189}
191 190
@@ -207,24 +206,10 @@ static void v9fs_kill_super(struct super_block *s)
207 206
208 v9fs_session_close(v9ses); 207 v9fs_session_close(v9ses);
209 kfree(v9ses); 208 kfree(v9ses);
209 s->s_fs_info = NULL;
210 P9_DPRINTK(P9_DEBUG_VFS, "exiting kill_super\n"); 210 P9_DPRINTK(P9_DEBUG_VFS, "exiting kill_super\n");
211} 211}
212 212
213/**
214 * v9fs_show_options - Show mount options in /proc/mounts
215 * @m: seq_file to write to
216 * @mnt: mount descriptor
217 *
218 */
219
220static int v9fs_show_options(struct seq_file *m, struct vfsmount *mnt)
221{
222 struct v9fs_session_info *v9ses = mnt->mnt_sb->s_fs_info;
223
224 seq_printf(m, "%s", v9ses->options);
225 return 0;
226}
227
228static void 213static void
229v9fs_umount_begin(struct super_block *sb) 214v9fs_umount_begin(struct super_block *sb)
230{ 215{
@@ -237,7 +222,7 @@ v9fs_umount_begin(struct super_block *sb)
237static const struct super_operations v9fs_super_ops = { 222static const struct super_operations v9fs_super_ops = {
238 .statfs = simple_statfs, 223 .statfs = simple_statfs,
239 .clear_inode = v9fs_clear_inode, 224 .clear_inode = v9fs_clear_inode,
240 .show_options = v9fs_show_options, 225 .show_options = generic_show_options,
241 .umount_begin = v9fs_umount_begin, 226 .umount_begin = v9fs_umount_begin,
242}; 227};
243 228
diff --git a/fs/afs/file.c b/fs/afs/file.c
index 0149dab365e7..681c2a7b013f 100644
--- a/fs/afs/file.c
+++ b/fs/afs/file.c
@@ -134,9 +134,16 @@ static int afs_readpage(struct file *file, struct page *page)
134 134
135 inode = page->mapping->host; 135 inode = page->mapping->host;
136 136
137 ASSERT(file != NULL); 137 if (file) {
138 key = file->private_data; 138 key = file->private_data;
139 ASSERT(key != NULL); 139 ASSERT(key != NULL);
140 } else {
141 key = afs_request_key(AFS_FS_S(inode->i_sb)->volume->cell);
142 if (IS_ERR(key)) {
143 ret = PTR_ERR(key);
144 goto error_nokey;
145 }
146 }
140 147
141 _enter("{%x},{%lu},{%lu}", key_serial(key), inode->i_ino, page->index); 148 _enter("{%x},{%lu},{%lu}", key_serial(key), inode->i_ino, page->index);
142 149
@@ -207,12 +214,17 @@ static int afs_readpage(struct file *file, struct page *page)
207 unlock_page(page); 214 unlock_page(page);
208 } 215 }
209 216
217 if (!file)
218 key_put(key);
210 _leave(" = 0"); 219 _leave(" = 0");
211 return 0; 220 return 0;
212 221
213error: 222error:
214 SetPageError(page); 223 SetPageError(page);
215 unlock_page(page); 224 unlock_page(page);
225 if (!file)
226 key_put(key);
227error_nokey:
216 _leave(" = %d", ret); 228 _leave(" = %d", ret);
217 return ret; 229 return ret;
218} 230}
diff --git a/fs/autofs4/expire.c b/fs/autofs4/expire.c
index aa39ae83f019..3da18d453488 100644
--- a/fs/autofs4/expire.c
+++ b/fs/autofs4/expire.c
@@ -77,7 +77,7 @@ static int autofs4_mount_busy(struct vfsmount *mnt, struct dentry *dentry)
77 } 77 }
78 78
79 /* Update the expiry counter if fs is busy */ 79 /* Update the expiry counter if fs is busy */
80 if (!may_umount_tree(mnt)) { 80 if (!may_umount_tree(path.mnt)) {
81 struct autofs_info *ino = autofs4_dentry_ino(top); 81 struct autofs_info *ino = autofs4_dentry_ino(top);
82 ino->last_used = jiffies; 82 ino->last_used = jiffies;
83 goto done; 83 goto done;
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index 697f6b5f1313..e92f229e3c6e 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -828,15 +828,22 @@ static int load_flat_shared_library(int id, struct lib_info *libs)
828 if (IS_ERR(bprm.file)) 828 if (IS_ERR(bprm.file))
829 return res; 829 return res;
830 830
831 bprm.cred = prepare_exec_creds();
832 res = -ENOMEM;
833 if (!bprm.cred)
834 goto out;
835
831 res = prepare_binprm(&bprm); 836 res = prepare_binprm(&bprm);
832 837
833 if (res <= (unsigned long)-4096) 838 if (res <= (unsigned long)-4096)
834 res = load_flat_file(&bprm, libs, id, NULL); 839 res = load_flat_file(&bprm, libs, id, NULL);
835 if (bprm.file) { 840
836 allow_write_access(bprm.file); 841 abort_creds(bprm.cred);
837 fput(bprm.file); 842
838 bprm.file = NULL; 843out:
839 } 844 allow_write_access(bprm.file);
845 fput(bprm.file);
846
840 return(res); 847 return(res);
841} 848}
842 849
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index dc84daee6bc4..72a2b9c28e9f 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -265,10 +265,6 @@ static int caching_kthread(void *data)
265 265
266 atomic_inc(&block_group->space_info->caching_threads); 266 atomic_inc(&block_group->space_info->caching_threads);
267 last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET); 267 last = max_t(u64, block_group->key.objectid, BTRFS_SUPER_INFO_OFFSET);
268again:
269 /* need to make sure the commit_root doesn't disappear */
270 down_read(&fs_info->extent_commit_sem);
271
272 /* 268 /*
273 * We don't want to deadlock with somebody trying to allocate a new 269 * We don't want to deadlock with somebody trying to allocate a new
274 * extent for the extent root while also trying to search the extent 270 * extent for the extent root while also trying to search the extent
@@ -282,6 +278,10 @@ again:
282 key.objectid = last; 278 key.objectid = last;
283 key.offset = 0; 279 key.offset = 0;
284 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); 280 btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY);
281again:
282 /* need to make sure the commit_root doesn't disappear */
283 down_read(&fs_info->extent_commit_sem);
284
285 ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0); 285 ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0);
286 if (ret < 0) 286 if (ret < 0)
287 goto err; 287 goto err;
@@ -304,6 +304,19 @@ again:
304 304
305 if (need_resched() || 305 if (need_resched() ||
306 btrfs_transaction_in_commit(fs_info)) { 306 btrfs_transaction_in_commit(fs_info)) {
307 leaf = path->nodes[0];
308
309 /* this shouldn't happen, but if the
310 * leaf is empty just move on.
311 */
312 if (btrfs_header_nritems(leaf) == 0)
313 break;
314 /*
315 * we need to copy the key out so that
316 * we are sure the next search advances
317 * us forward in the btree.
318 */
319 btrfs_item_key_to_cpu(leaf, &key, 0);
307 btrfs_release_path(fs_info->extent_root, path); 320 btrfs_release_path(fs_info->extent_root, path);
308 up_read(&fs_info->extent_commit_sem); 321 up_read(&fs_info->extent_commit_sem);
309 schedule_timeout(1); 322 schedule_timeout(1);
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index af99b78b288e..5edcee3a617f 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -414,11 +414,29 @@ static noinline int remove_from_bitmap(struct btrfs_block_group_cache *block_gro
414 u64 *offset, u64 *bytes) 414 u64 *offset, u64 *bytes)
415{ 415{
416 u64 end; 416 u64 end;
417 u64 search_start, search_bytes;
418 int ret;
417 419
418again: 420again:
419 end = bitmap_info->offset + 421 end = bitmap_info->offset +
420 (u64)(BITS_PER_BITMAP * block_group->sectorsize) - 1; 422 (u64)(BITS_PER_BITMAP * block_group->sectorsize) - 1;
421 423
424 /*
425 * XXX - this can go away after a few releases.
426 *
427 * since the only user of btrfs_remove_free_space is the tree logging
428 * stuff, and the only way to test that is under crash conditions, we
429 * want to have this debug stuff here just in case somethings not
430 * working. Search the bitmap for the space we are trying to use to
431 * make sure its actually there. If its not there then we need to stop
432 * because something has gone wrong.
433 */
434 search_start = *offset;
435 search_bytes = *bytes;
436 ret = search_bitmap(block_group, bitmap_info, &search_start,
437 &search_bytes);
438 BUG_ON(ret < 0 || search_start != *offset);
439
422 if (*offset > bitmap_info->offset && *offset + *bytes > end) { 440 if (*offset > bitmap_info->offset && *offset + *bytes > end) {
423 bitmap_clear_bits(block_group, bitmap_info, *offset, 441 bitmap_clear_bits(block_group, bitmap_info, *offset,
424 end - *offset + 1); 442 end - *offset + 1);
@@ -430,6 +448,7 @@ again:
430 } 448 }
431 449
432 if (*bytes) { 450 if (*bytes) {
451 struct rb_node *next = rb_next(&bitmap_info->offset_index);
433 if (!bitmap_info->bytes) { 452 if (!bitmap_info->bytes) {
434 unlink_free_space(block_group, bitmap_info); 453 unlink_free_space(block_group, bitmap_info);
435 kfree(bitmap_info->bitmap); 454 kfree(bitmap_info->bitmap);
@@ -438,16 +457,36 @@ again:
438 recalculate_thresholds(block_group); 457 recalculate_thresholds(block_group);
439 } 458 }
440 459
441 bitmap_info = tree_search_offset(block_group, 460 /*
442 offset_to_bitmap(block_group, 461 * no entry after this bitmap, but we still have bytes to
443 *offset), 462 * remove, so something has gone wrong.
444 1, 0); 463 */
445 if (!bitmap_info) 464 if (!next)
446 return -EINVAL; 465 return -EINVAL;
447 466
467 bitmap_info = rb_entry(next, struct btrfs_free_space,
468 offset_index);
469
470 /*
471 * if the next entry isn't a bitmap we need to return to let the
472 * extent stuff do its work.
473 */
448 if (!bitmap_info->bitmap) 474 if (!bitmap_info->bitmap)
449 return -EAGAIN; 475 return -EAGAIN;
450 476
477 /*
478 * Ok the next item is a bitmap, but it may not actually hold
479 * the information for the rest of this free space stuff, so
480 * look for it, and if we don't find it return so we can try
481 * everything over again.
482 */
483 search_start = *offset;
484 search_bytes = *bytes;
485 ret = search_bitmap(block_group, bitmap_info, &search_start,
486 &search_bytes);
487 if (ret < 0 || search_start != *offset)
488 return -EAGAIN;
489
451 goto again; 490 goto again;
452 } else if (!bitmap_info->bytes) { 491 } else if (!bitmap_info->bytes) {
453 unlink_free_space(block_group, bitmap_info); 492 unlink_free_space(block_group, bitmap_info);
@@ -644,8 +683,17 @@ int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
644again: 683again:
645 info = tree_search_offset(block_group, offset, 0, 0); 684 info = tree_search_offset(block_group, offset, 0, 0);
646 if (!info) { 685 if (!info) {
647 WARN_ON(1); 686 /*
648 goto out_lock; 687 * oops didn't find an extent that matched the space we wanted
688 * to remove, look for a bitmap instead
689 */
690 info = tree_search_offset(block_group,
691 offset_to_bitmap(block_group, offset),
692 1, 0);
693 if (!info) {
694 WARN_ON(1);
695 goto out_lock;
696 }
649 } 697 }
650 698
651 if (info->bytes < bytes && rb_next(&info->offset_index)) { 699 if (info->bytes < bytes && rb_next(&info->offset_index)) {
@@ -957,8 +1005,15 @@ static u64 btrfs_alloc_from_bitmap(struct btrfs_block_group_cache *block_group,
957 if (cluster->block_group != block_group) 1005 if (cluster->block_group != block_group)
958 goto out; 1006 goto out;
959 1007
960 entry = tree_search_offset(block_group, search_start, 0, 0); 1008 /*
961 1009 * search_start is the beginning of the bitmap, but at some point it may
1010 * be a good idea to point to the actual start of the free area in the
1011 * bitmap, so do the offset_to_bitmap trick anyway, and set bitmap_only
1012 * to 1 to make sure we get the bitmap entry
1013 */
1014 entry = tree_search_offset(block_group,
1015 offset_to_bitmap(block_group, search_start),
1016 1, 0);
962 if (!entry || !entry->bitmap) 1017 if (!entry || !entry->bitmap)
963 goto out; 1018 goto out;
964 1019
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 56fe83fa60c4..59cba180fe83 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3099,8 +3099,12 @@ static void inode_tree_add(struct inode *inode)
3099{ 3099{
3100 struct btrfs_root *root = BTRFS_I(inode)->root; 3100 struct btrfs_root *root = BTRFS_I(inode)->root;
3101 struct btrfs_inode *entry; 3101 struct btrfs_inode *entry;
3102 struct rb_node **p = &root->inode_tree.rb_node; 3102 struct rb_node **p;
3103 struct rb_node *parent = NULL; 3103 struct rb_node *parent;
3104
3105again:
3106 p = &root->inode_tree.rb_node;
3107 parent = NULL;
3104 3108
3105 spin_lock(&root->inode_lock); 3109 spin_lock(&root->inode_lock);
3106 while (*p) { 3110 while (*p) {
@@ -3108,13 +3112,16 @@ static void inode_tree_add(struct inode *inode)
3108 entry = rb_entry(parent, struct btrfs_inode, rb_node); 3112 entry = rb_entry(parent, struct btrfs_inode, rb_node);
3109 3113
3110 if (inode->i_ino < entry->vfs_inode.i_ino) 3114 if (inode->i_ino < entry->vfs_inode.i_ino)
3111 p = &(*p)->rb_left; 3115 p = &parent->rb_left;
3112 else if (inode->i_ino > entry->vfs_inode.i_ino) 3116 else if (inode->i_ino > entry->vfs_inode.i_ino)
3113 p = &(*p)->rb_right; 3117 p = &parent->rb_right;
3114 else { 3118 else {
3115 WARN_ON(!(entry->vfs_inode.i_state & 3119 WARN_ON(!(entry->vfs_inode.i_state &
3116 (I_WILL_FREE | I_FREEING | I_CLEAR))); 3120 (I_WILL_FREE | I_FREEING | I_CLEAR)));
3117 break; 3121 rb_erase(parent, &root->inode_tree);
3122 RB_CLEAR_NODE(parent);
3123 spin_unlock(&root->inode_lock);
3124 goto again;
3118 } 3125 }
3119 } 3126 }
3120 rb_link_node(&BTRFS_I(inode)->rb_node, parent, p); 3127 rb_link_node(&BTRFS_I(inode)->rb_node, parent, p);
@@ -3126,12 +3133,12 @@ static void inode_tree_del(struct inode *inode)
3126{ 3133{
3127 struct btrfs_root *root = BTRFS_I(inode)->root; 3134 struct btrfs_root *root = BTRFS_I(inode)->root;
3128 3135
3136 spin_lock(&root->inode_lock);
3129 if (!RB_EMPTY_NODE(&BTRFS_I(inode)->rb_node)) { 3137 if (!RB_EMPTY_NODE(&BTRFS_I(inode)->rb_node)) {
3130 spin_lock(&root->inode_lock);
3131 rb_erase(&BTRFS_I(inode)->rb_node, &root->inode_tree); 3138 rb_erase(&BTRFS_I(inode)->rb_node, &root->inode_tree);
3132 spin_unlock(&root->inode_lock);
3133 RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node); 3139 RB_CLEAR_NODE(&BTRFS_I(inode)->rb_node);
3134 } 3140 }
3141 spin_unlock(&root->inode_lock);
3135} 3142}
3136 3143
3137static noinline void init_btrfs_i(struct inode *inode) 3144static noinline void init_btrfs_i(struct inode *inode)
@@ -4785,8 +4792,7 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
4785 * and the replacement file is large. Start IO on it now so 4792 * and the replacement file is large. Start IO on it now so
4786 * we don't add too much work to the end of the transaction 4793 * we don't add too much work to the end of the transaction
4787 */ 4794 */
4788 if (new_inode && old_inode && S_ISREG(old_inode->i_mode) && 4795 if (new_inode && S_ISREG(old_inode->i_mode) && new_inode->i_size &&
4789 new_inode->i_size &&
4790 old_inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT) 4796 old_inode->i_size > BTRFS_ORDERED_OPERATIONS_FLUSH_LIMIT)
4791 filemap_flush(old_inode->i_mapping); 4797 filemap_flush(old_inode->i_mapping);
4792 4798
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index e71264d1c2c9..c04f7f212602 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2553,8 +2553,13 @@ int relocate_inode_pages(struct inode *inode, u64 start, u64 len)
2553 last_index = (start + len - 1) >> PAGE_CACHE_SHIFT; 2553 last_index = (start + len - 1) >> PAGE_CACHE_SHIFT;
2554 2554
2555 /* make sure the dirty trick played by the caller work */ 2555 /* make sure the dirty trick played by the caller work */
2556 ret = invalidate_inode_pages2_range(inode->i_mapping, 2556 while (1) {
2557 first_index, last_index); 2557 ret = invalidate_inode_pages2_range(inode->i_mapping,
2558 first_index, last_index);
2559 if (ret != -EBUSY)
2560 break;
2561 schedule_timeout(HZ/10);
2562 }
2558 if (ret) 2563 if (ret)
2559 goto out_unlock; 2564 goto out_unlock;
2560 2565
diff --git a/fs/btrfs/zlib.c b/fs/btrfs/zlib.c
index ecfbce836d32..3e2b90eaa239 100644
--- a/fs/btrfs/zlib.c
+++ b/fs/btrfs/zlib.c
@@ -208,7 +208,7 @@ int btrfs_zlib_compress_pages(struct address_space *mapping,
208 *total_in = 0; 208 *total_in = 0;
209 209
210 workspace = find_zlib_workspace(); 210 workspace = find_zlib_workspace();
211 if (!workspace) 211 if (IS_ERR(workspace))
212 return -1; 212 return -1;
213 213
214 if (Z_OK != zlib_deflateInit(&workspace->def_strm, 3)) { 214 if (Z_OK != zlib_deflateInit(&workspace->def_strm, 3)) {
@@ -366,7 +366,7 @@ int btrfs_zlib_decompress_biovec(struct page **pages_in,
366 char *kaddr; 366 char *kaddr;
367 367
368 workspace = find_zlib_workspace(); 368 workspace = find_zlib_workspace();
369 if (!workspace) 369 if (IS_ERR(workspace))
370 return -ENOMEM; 370 return -ENOMEM;
371 371
372 data_in = kmap(pages_in[page_in_index]); 372 data_in = kmap(pages_in[page_in_index]);
@@ -547,7 +547,7 @@ int btrfs_zlib_decompress(unsigned char *data_in,
547 return -ENOMEM; 547 return -ENOMEM;
548 548
549 workspace = find_zlib_workspace(); 549 workspace = find_zlib_workspace();
550 if (!workspace) 550 if (IS_ERR(workspace))
551 return -ENOMEM; 551 return -ENOMEM;
552 552
553 workspace->inf_strm.next_in = data_in; 553 workspace->inf_strm.next_in = data_in;
diff --git a/fs/buffer.c b/fs/buffer.c
index a3ef091a45bd..28f320fac4d4 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1165,8 +1165,11 @@ void mark_buffer_dirty(struct buffer_head *bh)
1165 1165
1166 if (!test_set_buffer_dirty(bh)) { 1166 if (!test_set_buffer_dirty(bh)) {
1167 struct page *page = bh->b_page; 1167 struct page *page = bh->b_page;
1168 if (!TestSetPageDirty(page)) 1168 if (!TestSetPageDirty(page)) {
1169 __set_page_dirty(page, page_mapping(page), 0); 1169 struct address_space *mapping = page_mapping(page);
1170 if (mapping)
1171 __set_page_dirty(page, mapping, 0);
1172 }
1170 } 1173 }
1171} 1174}
1172 1175
diff --git a/fs/cifs/CHANGES b/fs/cifs/CHANGES
index 92888aa90749..e85b1e4389e0 100644
--- a/fs/cifs/CHANGES
+++ b/fs/cifs/CHANGES
@@ -1,3 +1,10 @@
1Version 1.60
2-------------
3Fix memory leak in reconnect. Fix oops in DFS mount error path.
4Set s_maxbytes to smaller (the max that vfs can handle) so that
5sendfile will now work over cifs mounts again. Add noforcegid
6and noforceuid mount parameters.
7
1Version 1.59 8Version 1.59
2------------ 9------------
3Client uses server inode numbers (which are persistent) rather than 10Client uses server inode numbers (which are persistent) rather than
diff --git a/fs/cifs/README b/fs/cifs/README
index ad92921dbde4..79c1a93400be 100644
--- a/fs/cifs/README
+++ b/fs/cifs/README
@@ -262,11 +262,11 @@ A partial list of the supported mount options follows:
262 mount. 262 mount.
263 domain Set the SMB/CIFS workgroup name prepended to the 263 domain Set the SMB/CIFS workgroup name prepended to the
264 username during CIFS session establishment 264 username during CIFS session establishment
265 forceuid Set the default uid for inodes based on the uid 265 forceuid Set the default uid for inodes to the uid
266 passed in. For mounts to servers 266 passed in on mount. For mounts to servers
267 which do support the CIFS Unix extensions, such as a 267 which do support the CIFS Unix extensions, such as a
268 properly configured Samba server, the server provides 268 properly configured Samba server, the server provides
269 the uid, gid and mode so this parameter should not be 269 the uid, gid and mode so this parameter should not be
270 specified unless the server and clients uid and gid 270 specified unless the server and clients uid and gid
271 numbering differ. If the server and client are in the 271 numbering differ. If the server and client are in the
272 same domain (e.g. running winbind or nss_ldap) and 272 same domain (e.g. running winbind or nss_ldap) and
@@ -278,11 +278,7 @@ A partial list of the supported mount options follows:
278 of existing files will be the uid (gid) of the person 278 of existing files will be the uid (gid) of the person
279 who executed the mount (root, except when mount.cifs 279 who executed the mount (root, except when mount.cifs
280 is configured setuid for user mounts) unless the "uid=" 280 is configured setuid for user mounts) unless the "uid="
281 (gid) mount option is specified. For the uid (gid) of newly 281 (gid) mount option is specified. Also note that permission
282 created files and directories, ie files created since
283 the last mount of the server share, the expected uid
284 (gid) is cached as long as the inode remains in
285 memory on the client. Also note that permission
286 checks (authorization checks) on accesses to a file occur 282 checks (authorization checks) on accesses to a file occur
287 at the server, but there are cases in which an administrator 283 at the server, but there are cases in which an administrator
288 may want to restrict at the client as well. For those 284 may want to restrict at the client as well. For those
@@ -290,12 +286,15 @@ A partial list of the supported mount options follows:
290 (such as Windows), permissions can also be checked at the 286 (such as Windows), permissions can also be checked at the
291 client, and a crude form of client side permission checking 287 client, and a crude form of client side permission checking
292 can be enabled by specifying file_mode and dir_mode on 288 can be enabled by specifying file_mode and dir_mode on
293 the client. Note that the mount.cifs helper must be 289 the client. (default)
294 at version 1.10 or higher to support specifying the uid 290 forcegid (similar to above but for the groupid instead of uid) (default)
295 (or gid) in non-numeric form. 291 noforceuid Fill in file owner information (uid) by requesting it from
296 forcegid (similar to above but for the groupid instead of uid) 292 the server if possible. With this option, the value given in
293 the uid= option (on mount) will only be used if the server
294 can not support returning uids on inodes.
295 noforcegid (similar to above but for the group owner, gid, instead of uid)
297 uid Set the default uid for inodes, and indicate to the 296 uid Set the default uid for inodes, and indicate to the
298 cifs kernel driver which local user mounted . If the server 297 cifs kernel driver which local user mounted. If the server
299 supports the unix extensions the default uid is 298 supports the unix extensions the default uid is
300 not used to fill in the owner fields of inodes (files) 299 not used to fill in the owner fields of inodes (files)
301 unless the "forceuid" parameter is specified. 300 unless the "forceuid" parameter is specified.
diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c
index 3bb11be8b6a8..606912d8f2a8 100644
--- a/fs/cifs/cifs_dfs_ref.c
+++ b/fs/cifs/cifs_dfs_ref.c
@@ -55,7 +55,7 @@ void cifs_dfs_release_automount_timer(void)
55 * i.e. strips from UNC trailing path that is not part of share 55 * i.e. strips from UNC trailing path that is not part of share
56 * name and fixup missing '\' in the begining of DFS node refferal 56 * name and fixup missing '\' in the begining of DFS node refferal
57 * if neccessary. 57 * if neccessary.
58 * Returns pointer to share name on success or NULL on error. 58 * Returns pointer to share name on success or ERR_PTR on error.
59 * Caller is responsible for freeing returned string. 59 * Caller is responsible for freeing returned string.
60 */ 60 */
61static char *cifs_get_share_name(const char *node_name) 61static char *cifs_get_share_name(const char *node_name)
@@ -68,7 +68,7 @@ static char *cifs_get_share_name(const char *node_name)
68 UNC = kmalloc(len+2 /*for term null and additional \ if it's missed */, 68 UNC = kmalloc(len+2 /*for term null and additional \ if it's missed */,
69 GFP_KERNEL); 69 GFP_KERNEL);
70 if (!UNC) 70 if (!UNC)
71 return NULL; 71 return ERR_PTR(-ENOMEM);
72 72
73 /* get share name and server name */ 73 /* get share name and server name */
74 if (node_name[1] != '\\') { 74 if (node_name[1] != '\\') {
@@ -87,7 +87,7 @@ static char *cifs_get_share_name(const char *node_name)
87 cERROR(1, ("%s: no server name end in node name: %s", 87 cERROR(1, ("%s: no server name end in node name: %s",
88 __func__, node_name)); 88 __func__, node_name));
89 kfree(UNC); 89 kfree(UNC);
90 return NULL; 90 return ERR_PTR(-EINVAL);
91 } 91 }
92 92
93 /* find sharename end */ 93 /* find sharename end */
@@ -133,6 +133,12 @@ char *cifs_compose_mount_options(const char *sb_mountdata,
133 return ERR_PTR(-EINVAL); 133 return ERR_PTR(-EINVAL);
134 134
135 *devname = cifs_get_share_name(ref->node_name); 135 *devname = cifs_get_share_name(ref->node_name);
136 if (IS_ERR(*devname)) {
137 rc = PTR_ERR(*devname);
138 *devname = NULL;
139 goto compose_mount_options_err;
140 }
141
136 rc = dns_resolve_server_name_to_ip(*devname, &srvIP); 142 rc = dns_resolve_server_name_to_ip(*devname, &srvIP);
137 if (rc != 0) { 143 if (rc != 0) {
138 cERROR(1, ("%s: Failed to resolve server part of %s to IP: %d", 144 cERROR(1, ("%s: Failed to resolve server part of %s to IP: %d",
diff --git a/fs/cifs/cifs_unicode.c b/fs/cifs/cifs_unicode.c
index 60e3c4253de0..714a542cbafc 100644
--- a/fs/cifs/cifs_unicode.c
+++ b/fs/cifs/cifs_unicode.c
@@ -44,7 +44,7 @@ cifs_ucs2_bytes(const __le16 *from, int maxbytes,
44 int maxwords = maxbytes / 2; 44 int maxwords = maxbytes / 2;
45 char tmp[NLS_MAX_CHARSET_SIZE]; 45 char tmp[NLS_MAX_CHARSET_SIZE];
46 46
47 for (i = 0; from[i] && i < maxwords; i++) { 47 for (i = 0; i < maxwords && from[i]; i++) {
48 charlen = codepage->uni2char(le16_to_cpu(from[i]), tmp, 48 charlen = codepage->uni2char(le16_to_cpu(from[i]), tmp,
49 NLS_MAX_CHARSET_SIZE); 49 NLS_MAX_CHARSET_SIZE);
50 if (charlen > 0) 50 if (charlen > 0)
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index 44f30504b82d..84b75253b05a 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -376,10 +376,14 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
376 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid); 376 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
377 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 377 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
378 seq_printf(s, ",forceuid"); 378 seq_printf(s, ",forceuid");
379 else
380 seq_printf(s, ",noforceuid");
379 381
380 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid); 382 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
381 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) 383 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
382 seq_printf(s, ",forcegid"); 384 seq_printf(s, ",forcegid");
385 else
386 seq_printf(s, ",noforcegid");
383 387
384 cifs_show_address(s, tcon->ses->server); 388 cifs_show_address(s, tcon->ses->server);
385 389
diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index fc44d316d0bb..1f3345d7fa79 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -803,6 +803,10 @@ cifs_parse_mount_options(char *options, const char *devname,
803 char *data; 803 char *data;
804 unsigned int temp_len, i, j; 804 unsigned int temp_len, i, j;
805 char separator[2]; 805 char separator[2];
806 short int override_uid = -1;
807 short int override_gid = -1;
808 bool uid_specified = false;
809 bool gid_specified = false;
806 810
807 separator[0] = ','; 811 separator[0] = ',';
808 separator[1] = 0; 812 separator[1] = 0;
@@ -1093,18 +1097,20 @@ cifs_parse_mount_options(char *options, const char *devname,
1093 "too long.\n"); 1097 "too long.\n");
1094 return 1; 1098 return 1;
1095 } 1099 }
1096 } else if (strnicmp(data, "uid", 3) == 0) { 1100 } else if (!strnicmp(data, "uid", 3) && value && *value) {
1097 if (value && *value) 1101 vol->linux_uid = simple_strtoul(value, &value, 0);
1098 vol->linux_uid = 1102 uid_specified = true;
1099 simple_strtoul(value, &value, 0); 1103 } else if (!strnicmp(data, "forceuid", 8)) {
1100 } else if (strnicmp(data, "forceuid", 8) == 0) { 1104 override_uid = 1;
1101 vol->override_uid = 1; 1105 } else if (!strnicmp(data, "noforceuid", 10)) {
1102 } else if (strnicmp(data, "gid", 3) == 0) { 1106 override_uid = 0;
1103 if (value && *value) 1107 } else if (!strnicmp(data, "gid", 3) && value && *value) {
1104 vol->linux_gid = 1108 vol->linux_gid = simple_strtoul(value, &value, 0);
1105 simple_strtoul(value, &value, 0); 1109 gid_specified = true;
1106 } else if (strnicmp(data, "forcegid", 8) == 0) { 1110 } else if (!strnicmp(data, "forcegid", 8)) {
1107 vol->override_gid = 1; 1111 override_gid = 1;
1112 } else if (!strnicmp(data, "noforcegid", 10)) {
1113 override_gid = 0;
1108 } else if (strnicmp(data, "file_mode", 4) == 0) { 1114 } else if (strnicmp(data, "file_mode", 4) == 0) {
1109 if (value && *value) { 1115 if (value && *value) {
1110 vol->file_mode = 1116 vol->file_mode =
@@ -1355,6 +1361,18 @@ cifs_parse_mount_options(char *options, const char *devname,
1355 if (vol->UNCip == NULL) 1361 if (vol->UNCip == NULL)
1356 vol->UNCip = &vol->UNC[2]; 1362 vol->UNCip = &vol->UNC[2];
1357 1363
1364 if (uid_specified)
1365 vol->override_uid = override_uid;
1366 else if (override_uid == 1)
1367 printk(KERN_NOTICE "CIFS: ignoring forceuid mount option "
1368 "specified with no uid= option.\n");
1369
1370 if (gid_specified)
1371 vol->override_gid = override_gid;
1372 else if (override_gid == 1)
1373 printk(KERN_NOTICE "CIFS: ignoring forcegid mount option "
1374 "specified with no gid= option.\n");
1375
1358 return 0; 1376 return 0;
1359} 1377}
1360 1378
@@ -2544,11 +2562,20 @@ remote_path_check:
2544 2562
2545 if (mount_data != mount_data_global) 2563 if (mount_data != mount_data_global)
2546 kfree(mount_data); 2564 kfree(mount_data);
2565
2547 mount_data = cifs_compose_mount_options( 2566 mount_data = cifs_compose_mount_options(
2548 cifs_sb->mountdata, full_path + 1, 2567 cifs_sb->mountdata, full_path + 1,
2549 referrals, &fake_devname); 2568 referrals, &fake_devname);
2550 kfree(fake_devname); 2569
2551 free_dfs_info_array(referrals, num_referrals); 2570 free_dfs_info_array(referrals, num_referrals);
2571 kfree(fake_devname);
2572 kfree(full_path);
2573
2574 if (IS_ERR(mount_data)) {
2575 rc = PTR_ERR(mount_data);
2576 mount_data = NULL;
2577 goto mount_fail_check;
2578 }
2552 2579
2553 if (tcon) 2580 if (tcon)
2554 cifs_put_tcon(tcon); 2581 cifs_put_tcon(tcon);
@@ -2556,8 +2583,6 @@ remote_path_check:
2556 cifs_put_smb_ses(pSesInfo); 2583 cifs_put_smb_ses(pSesInfo);
2557 2584
2558 cleanup_volume_info(&volume_info); 2585 cleanup_volume_info(&volume_info);
2559 FreeXid(xid);
2560 kfree(full_path);
2561 referral_walks_count++; 2586 referral_walks_count++;
2562 goto try_mount_again; 2587 goto try_mount_again;
2563 } 2588 }
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index f28f070a60fc..f91fd51b32e3 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1905,6 +1905,7 @@ COMPATIBLE_IOCTL(FIONCLEX)
1905COMPATIBLE_IOCTL(FIOASYNC) 1905COMPATIBLE_IOCTL(FIOASYNC)
1906COMPATIBLE_IOCTL(FIONBIO) 1906COMPATIBLE_IOCTL(FIONBIO)
1907COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */ 1907COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
1908COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
1908/* 0x00 */ 1909/* 0x00 */
1909COMPATIBLE_IOCTL(FIBMAP) 1910COMPATIBLE_IOCTL(FIBMAP)
1910COMPATIBLE_IOCTL(FIGETBSZ) 1911COMPATIBLE_IOCTL(FIGETBSZ)
diff --git a/fs/exec.c b/fs/exec.c
index 4a8849e45b21..fb4f3cdda78c 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -678,8 +678,8 @@ exit:
678} 678}
679EXPORT_SYMBOL(open_exec); 679EXPORT_SYMBOL(open_exec);
680 680
681int kernel_read(struct file *file, unsigned long offset, 681int kernel_read(struct file *file, loff_t offset,
682 char *addr, unsigned long count) 682 char *addr, unsigned long count)
683{ 683{
684 mm_segment_t old_fs; 684 mm_segment_t old_fs;
685 loff_t pos = offset; 685 loff_t pos = offset;
diff --git a/fs/ext3/Kconfig b/fs/ext3/Kconfig
index fb3c1a21b135..522b15498f45 100644
--- a/fs/ext3/Kconfig
+++ b/fs/ext3/Kconfig
@@ -29,23 +29,25 @@ config EXT3_FS
29 module will be called ext3. 29 module will be called ext3.
30 30
31config EXT3_DEFAULTS_TO_ORDERED 31config EXT3_DEFAULTS_TO_ORDERED
32 bool "Default to 'data=ordered' in ext3 (legacy option)" 32 bool "Default to 'data=ordered' in ext3"
33 depends on EXT3_FS 33 depends on EXT3_FS
34 help 34 help
35 If a filesystem does not explicitly specify a data ordering 35 The journal mode options for ext3 have different tradeoffs
36 mode, and the journal capability allowed it, ext3 used to 36 between when data is guaranteed to be on disk and
37 historically default to 'data=ordered'. 37 performance. The use of "data=writeback" can cause
38 38 unwritten data to appear in files after an system crash or
39 That was a rather unfortunate choice, because it leads to all 39 power failure, which can be a security issue. However,
40 kinds of latency problems, and the 'data=writeback' mode is more 40 "data=ordered" mode can also result in major performance
41 appropriate these days. 41 problems, including seconds-long delays before an fsync()
42 42 call returns. For details, see:
43 You should probably always answer 'n' here, and if you really 43
44 want to use 'data=ordered' mode, set it in the filesystem itself 44 http://ext4.wiki.kernel.org/index.php/Ext3_data_mode_tradeoffs
45 with 'tune2fs -o journal_data_ordered'. 45
46 46 If you have been historically happy with ext3's performance,
47 But if you really want to enable the legacy default, you can do 47 data=ordered mode will be a safe choice and you should
48 so by answering 'y' to this question. 48 answer 'y' here. If you understand the reliability and data
49 privacy issues of data=writeback and are willing to make
50 that trade off, answer 'n'.
49 51
50config EXT3_FS_XATTR 52config EXT3_FS_XATTR
51 bool "Ext3 extended attributes" 53 bool "Ext3 extended attributes"
diff --git a/fs/ext3/super.c b/fs/ext3/super.c
index 524b349c6299..a8d80a7f1105 100644
--- a/fs/ext3/super.c
+++ b/fs/ext3/super.c
@@ -543,6 +543,19 @@ static inline void ext3_show_quota_options(struct seq_file *seq, struct super_bl
543#endif 543#endif
544} 544}
545 545
546static char *data_mode_string(unsigned long mode)
547{
548 switch (mode) {
549 case EXT3_MOUNT_JOURNAL_DATA:
550 return "journal";
551 case EXT3_MOUNT_ORDERED_DATA:
552 return "ordered";
553 case EXT3_MOUNT_WRITEBACK_DATA:
554 return "writeback";
555 }
556 return "unknown";
557}
558
546/* 559/*
547 * Show an option if 560 * Show an option if
548 * - it's set to a non-default value OR 561 * - it's set to a non-default value OR
@@ -616,13 +629,8 @@ static int ext3_show_options(struct seq_file *seq, struct vfsmount *vfs)
616 if (test_opt(sb, NOBH)) 629 if (test_opt(sb, NOBH))
617 seq_puts(seq, ",nobh"); 630 seq_puts(seq, ",nobh");
618 631
619 if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA) 632 seq_printf(seq, ",data=%s", data_mode_string(sbi->s_mount_opt &
620 seq_puts(seq, ",data=journal"); 633 EXT3_MOUNT_DATA_FLAGS));
621 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA)
622 seq_puts(seq, ",data=ordered");
623 else if (test_opt(sb, DATA_FLAGS) == EXT3_MOUNT_WRITEBACK_DATA)
624 seq_puts(seq, ",data=writeback");
625
626 if (test_opt(sb, DATA_ERR_ABORT)) 634 if (test_opt(sb, DATA_ERR_ABORT))
627 seq_puts(seq, ",data_err=abort"); 635 seq_puts(seq, ",data_err=abort");
628 636
@@ -1024,12 +1032,18 @@ static int parse_options (char *options, struct super_block *sb,
1024 datacheck: 1032 datacheck:
1025 if (is_remount) { 1033 if (is_remount) {
1026 if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS) 1034 if ((sbi->s_mount_opt & EXT3_MOUNT_DATA_FLAGS)
1027 != data_opt) { 1035 == data_opt)
1028 printk(KERN_ERR 1036 break;
1029 "EXT3-fs: cannot change data " 1037 printk(KERN_ERR
1030 "mode on remount\n"); 1038 "EXT3-fs (device %s): Cannot change "
1031 return 0; 1039 "data mode on remount. The filesystem "
1032 } 1040 "is mounted in data=%s mode and you "
1041 "try to remount it in data=%s mode.\n",
1042 sb->s_id,
1043 data_mode_string(sbi->s_mount_opt &
1044 EXT3_MOUNT_DATA_FLAGS),
1045 data_mode_string(data_opt));
1046 return 0;
1033 } else { 1047 } else {
1034 sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS; 1048 sbi->s_mount_opt &= ~EXT3_MOUNT_DATA_FLAGS;
1035 sbi->s_mount_opt |= data_opt; 1049 sbi->s_mount_opt |= data_opt;
diff --git a/fs/gfs2/sys.c b/fs/gfs2/sys.c
index 23419dc3027b..a7cbfbd340c7 100644
--- a/fs/gfs2/sys.c
+++ b/fs/gfs2/sys.c
@@ -386,16 +386,16 @@ static ssize_t jid_show(struct gfs2_sbd *sdp, char *buf)
386#define GDLM_ATTR(_name,_mode,_show,_store) \ 386#define GDLM_ATTR(_name,_mode,_show,_store) \
387static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store) 387static struct gfs2_attr gdlm_attr_##_name = __ATTR(_name,_mode,_show,_store)
388 388
389GDLM_ATTR(proto_name, 0444, proto_name_show, NULL); 389GDLM_ATTR(proto_name, 0444, proto_name_show, NULL);
390GDLM_ATTR(block, 0644, block_show, block_store); 390GDLM_ATTR(block, 0644, block_show, block_store);
391GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store); 391GDLM_ATTR(withdraw, 0644, withdraw_show, withdraw_store);
392GDLM_ATTR(id, 0444, lkid_show, NULL); 392GDLM_ATTR(id, 0444, lkid_show, NULL);
393GDLM_ATTR(jid, 0444, jid_show, NULL); 393GDLM_ATTR(jid, 0444, jid_show, NULL);
394GDLM_ATTR(first, 0444, lkfirst_show, NULL); 394GDLM_ATTR(first, 0444, lkfirst_show, NULL);
395GDLM_ATTR(first_done, 0444, first_done_show, NULL); 395GDLM_ATTR(first_done, 0444, first_done_show, NULL);
396GDLM_ATTR(recover, 0200, NULL, recover_store); 396GDLM_ATTR(recover, 0600, NULL, recover_store);
397GDLM_ATTR(recover_done, 0444, recover_done_show, NULL); 397GDLM_ATTR(recover_done, 0444, recover_done_show, NULL);
398GDLM_ATTR(recover_status, 0444, recover_status_show, NULL); 398GDLM_ATTR(recover_status, 0444, recover_status_show, NULL);
399 399
400static struct attribute *lock_module_attrs[] = { 400static struct attribute *lock_module_attrs[] = {
401 &gdlm_attr_proto_name.attr, 401 &gdlm_attr_proto_name.attr,
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 941c8425c10b..cb88dac8ccaa 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -935,26 +935,28 @@ static int can_do_hugetlb_shm(void)
935 return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group); 935 return capable(CAP_IPC_LOCK) || in_group_p(sysctl_hugetlb_shm_group);
936} 936}
937 937
938struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag) 938struct file *hugetlb_file_setup(const char *name, size_t size, int acctflag,
939 struct user_struct **user)
939{ 940{
940 int error = -ENOMEM; 941 int error = -ENOMEM;
941 int unlock_shm = 0;
942 struct file *file; 942 struct file *file;
943 struct inode *inode; 943 struct inode *inode;
944 struct dentry *dentry, *root; 944 struct dentry *dentry, *root;
945 struct qstr quick_string; 945 struct qstr quick_string;
946 struct user_struct *user = current_user();
947 946
947 *user = NULL;
948 if (!hugetlbfs_vfsmount) 948 if (!hugetlbfs_vfsmount)
949 return ERR_PTR(-ENOENT); 949 return ERR_PTR(-ENOENT);
950 950
951 if (!can_do_hugetlb_shm()) { 951 if (!can_do_hugetlb_shm()) {
952 if (user_shm_lock(size, user)) { 952 *user = current_user();
953 unlock_shm = 1; 953 if (user_shm_lock(size, *user)) {
954 WARN_ONCE(1, 954 WARN_ONCE(1,
955 "Using mlock ulimits for SHM_HUGETLB deprecated\n"); 955 "Using mlock ulimits for SHM_HUGETLB deprecated\n");
956 } else 956 } else {
957 *user = NULL;
957 return ERR_PTR(-EPERM); 958 return ERR_PTR(-EPERM);
959 }
958 } 960 }
959 961
960 root = hugetlbfs_vfsmount->mnt_root; 962 root = hugetlbfs_vfsmount->mnt_root;
@@ -996,8 +998,10 @@ out_inode:
996out_dentry: 998out_dentry:
997 dput(dentry); 999 dput(dentry);
998out_shm_unlock: 1000out_shm_unlock:
999 if (unlock_shm) 1001 if (*user) {
1000 user_shm_unlock(size, user); 1002 user_shm_unlock(size, *user);
1003 *user = NULL;
1004 }
1001 return ERR_PTR(error); 1005 return ERR_PTR(error);
1002} 1006}
1003 1007
diff --git a/fs/inode.c b/fs/inode.c
index 901bad1e5f12..ae7b67e48661 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -120,12 +120,11 @@ static void wake_up_inode(struct inode *inode)
120 * These are initializations that need to be done on every inode 120 * These are initializations that need to be done on every inode
121 * allocation as the fields are not initialised by slab allocation. 121 * allocation as the fields are not initialised by slab allocation.
122 */ 122 */
123struct inode *inode_init_always(struct super_block *sb, struct inode *inode) 123int inode_init_always(struct super_block *sb, struct inode *inode)
124{ 124{
125 static const struct address_space_operations empty_aops; 125 static const struct address_space_operations empty_aops;
126 static struct inode_operations empty_iops; 126 static struct inode_operations empty_iops;
127 static const struct file_operations empty_fops; 127 static const struct file_operations empty_fops;
128
129 struct address_space *const mapping = &inode->i_data; 128 struct address_space *const mapping = &inode->i_data;
130 129
131 inode->i_sb = sb; 130 inode->i_sb = sb;
@@ -152,7 +151,7 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode)
152 inode->dirtied_when = 0; 151 inode->dirtied_when = 0;
153 152
154 if (security_inode_alloc(inode)) 153 if (security_inode_alloc(inode))
155 goto out_free_inode; 154 goto out;
156 155
157 /* allocate and initialize an i_integrity */ 156 /* allocate and initialize an i_integrity */
158 if (ima_inode_alloc(inode)) 157 if (ima_inode_alloc(inode))
@@ -198,16 +197,12 @@ struct inode *inode_init_always(struct super_block *sb, struct inode *inode)
198 inode->i_fsnotify_mask = 0; 197 inode->i_fsnotify_mask = 0;
199#endif 198#endif
200 199
201 return inode; 200 return 0;
202 201
203out_free_security: 202out_free_security:
204 security_inode_free(inode); 203 security_inode_free(inode);
205out_free_inode: 204out:
206 if (inode->i_sb->s_op->destroy_inode) 205 return -ENOMEM;
207 inode->i_sb->s_op->destroy_inode(inode);
208 else
209 kmem_cache_free(inode_cachep, (inode));
210 return NULL;
211} 206}
212EXPORT_SYMBOL(inode_init_always); 207EXPORT_SYMBOL(inode_init_always);
213 208
@@ -220,12 +215,21 @@ static struct inode *alloc_inode(struct super_block *sb)
220 else 215 else
221 inode = kmem_cache_alloc(inode_cachep, GFP_KERNEL); 216 inode = kmem_cache_alloc(inode_cachep, GFP_KERNEL);
222 217
223 if (inode) 218 if (!inode)
224 return inode_init_always(sb, inode); 219 return NULL;
225 return NULL; 220
221 if (unlikely(inode_init_always(sb, inode))) {
222 if (inode->i_sb->s_op->destroy_inode)
223 inode->i_sb->s_op->destroy_inode(inode);
224 else
225 kmem_cache_free(inode_cachep, inode);
226 return NULL;
227 }
228
229 return inode;
226} 230}
227 231
228void destroy_inode(struct inode *inode) 232void __destroy_inode(struct inode *inode)
229{ 233{
230 BUG_ON(inode_has_buffers(inode)); 234 BUG_ON(inode_has_buffers(inode));
231 ima_inode_free(inode); 235 ima_inode_free(inode);
@@ -237,13 +241,17 @@ void destroy_inode(struct inode *inode)
237 if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED) 241 if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED)
238 posix_acl_release(inode->i_default_acl); 242 posix_acl_release(inode->i_default_acl);
239#endif 243#endif
244}
245EXPORT_SYMBOL(__destroy_inode);
246
247void destroy_inode(struct inode *inode)
248{
249 __destroy_inode(inode);
240 if (inode->i_sb->s_op->destroy_inode) 250 if (inode->i_sb->s_op->destroy_inode)
241 inode->i_sb->s_op->destroy_inode(inode); 251 inode->i_sb->s_op->destroy_inode(inode);
242 else 252 else
243 kmem_cache_free(inode_cachep, (inode)); 253 kmem_cache_free(inode_cachep, (inode));
244} 254}
245EXPORT_SYMBOL(destroy_inode);
246
247 255
248/* 256/*
249 * These are initializations that only need to be done 257 * These are initializations that only need to be done
diff --git a/fs/jffs2/file.c b/fs/jffs2/file.c
index 5edc2bf20581..23c947539864 100644
--- a/fs/jffs2/file.c
+++ b/fs/jffs2/file.c
@@ -99,7 +99,7 @@ static int jffs2_do_readpage_nolock (struct inode *inode, struct page *pg)
99 kunmap(pg); 99 kunmap(pg);
100 100
101 D2(printk(KERN_DEBUG "readpage finished\n")); 101 D2(printk(KERN_DEBUG "readpage finished\n"));
102 return 0; 102 return ret;
103} 103}
104 104
105int jffs2_do_readpage_unlock(struct inode *inode, struct page *pg) 105int jffs2_do_readpage_unlock(struct inode *inode, struct page *pg)
diff --git a/fs/libfs.c b/fs/libfs.c
index ddfa89948c3f..dcec3d3ea64f 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -217,7 +217,7 @@ int get_sb_pseudo(struct file_system_type *fs_type, char *name,
217 return PTR_ERR(s); 217 return PTR_ERR(s);
218 218
219 s->s_flags = MS_NOUSER; 219 s->s_flags = MS_NOUSER;
220 s->s_maxbytes = ~0ULL; 220 s->s_maxbytes = MAX_LFS_FILESIZE;
221 s->s_blocksize = PAGE_SIZE; 221 s->s_blocksize = PAGE_SIZE;
222 s->s_blocksize_bits = PAGE_SHIFT; 222 s->s_blocksize_bits = PAGE_SHIFT;
223 s->s_magic = magic; 223 s->s_magic = magic;
diff --git a/fs/namespace.c b/fs/namespace.c
index 277c28a63ead..7230787d18b0 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -316,7 +316,8 @@ EXPORT_SYMBOL_GPL(mnt_clone_write);
316 */ 316 */
317int mnt_want_write_file(struct file *file) 317int mnt_want_write_file(struct file *file)
318{ 318{
319 if (!(file->f_mode & FMODE_WRITE)) 319 struct inode *inode = file->f_dentry->d_inode;
320 if (!(file->f_mode & FMODE_WRITE) || special_file(inode->i_mode))
320 return mnt_want_write(file->f_path.mnt); 321 return mnt_want_write(file->f_path.mnt);
321 else 322 else
322 return mnt_clone_write(file->f_path.mnt); 323 return mnt_clone_write(file->f_path.mnt);
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 489fc01a3204..e4e089a8f294 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -255,7 +255,7 @@ static void nfs_direct_read_release(void *calldata)
255 255
256 if (put_dreq(dreq)) 256 if (put_dreq(dreq))
257 nfs_direct_complete(dreq); 257 nfs_direct_complete(dreq);
258 nfs_readdata_release(calldata); 258 nfs_readdata_free(data);
259} 259}
260 260
261static const struct rpc_call_ops nfs_read_direct_ops = { 261static const struct rpc_call_ops nfs_read_direct_ops = {
@@ -314,14 +314,14 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
314 data->npages, 1, 0, data->pagevec, NULL); 314 data->npages, 1, 0, data->pagevec, NULL);
315 up_read(&current->mm->mmap_sem); 315 up_read(&current->mm->mmap_sem);
316 if (result < 0) { 316 if (result < 0) {
317 nfs_readdata_release(data); 317 nfs_readdata_free(data);
318 break; 318 break;
319 } 319 }
320 if ((unsigned)result < data->npages) { 320 if ((unsigned)result < data->npages) {
321 bytes = result * PAGE_SIZE; 321 bytes = result * PAGE_SIZE;
322 if (bytes <= pgbase) { 322 if (bytes <= pgbase) {
323 nfs_direct_release_pages(data->pagevec, result); 323 nfs_direct_release_pages(data->pagevec, result);
324 nfs_readdata_release(data); 324 nfs_readdata_free(data);
325 break; 325 break;
326 } 326 }
327 bytes -= pgbase; 327 bytes -= pgbase;
@@ -334,7 +334,7 @@ static ssize_t nfs_direct_read_schedule_segment(struct nfs_direct_req *dreq,
334 data->inode = inode; 334 data->inode = inode;
335 data->cred = msg.rpc_cred; 335 data->cred = msg.rpc_cred;
336 data->args.fh = NFS_FH(inode); 336 data->args.fh = NFS_FH(inode);
337 data->args.context = get_nfs_open_context(ctx); 337 data->args.context = ctx;
338 data->args.offset = pos; 338 data->args.offset = pos;
339 data->args.pgbase = pgbase; 339 data->args.pgbase = pgbase;
340 data->args.pages = data->pagevec; 340 data->args.pages = data->pagevec;
@@ -441,7 +441,7 @@ static void nfs_direct_free_writedata(struct nfs_direct_req *dreq)
441 struct nfs_write_data *data = list_entry(dreq->rewrite_list.next, struct nfs_write_data, pages); 441 struct nfs_write_data *data = list_entry(dreq->rewrite_list.next, struct nfs_write_data, pages);
442 list_del(&data->pages); 442 list_del(&data->pages);
443 nfs_direct_release_pages(data->pagevec, data->npages); 443 nfs_direct_release_pages(data->pagevec, data->npages);
444 nfs_writedata_release(data); 444 nfs_writedata_free(data);
445 } 445 }
446} 446}
447 447
@@ -534,7 +534,7 @@ static void nfs_direct_commit_release(void *calldata)
534 534
535 dprintk("NFS: %5u commit returned %d\n", data->task.tk_pid, status); 535 dprintk("NFS: %5u commit returned %d\n", data->task.tk_pid, status);
536 nfs_direct_write_complete(dreq, data->inode); 536 nfs_direct_write_complete(dreq, data->inode);
537 nfs_commitdata_release(calldata); 537 nfs_commit_free(data);
538} 538}
539 539
540static const struct rpc_call_ops nfs_commit_direct_ops = { 540static const struct rpc_call_ops nfs_commit_direct_ops = {
@@ -570,7 +570,7 @@ static void nfs_direct_commit_schedule(struct nfs_direct_req *dreq)
570 data->args.fh = NFS_FH(data->inode); 570 data->args.fh = NFS_FH(data->inode);
571 data->args.offset = 0; 571 data->args.offset = 0;
572 data->args.count = 0; 572 data->args.count = 0;
573 data->args.context = get_nfs_open_context(dreq->ctx); 573 data->args.context = dreq->ctx;
574 data->res.count = 0; 574 data->res.count = 0;
575 data->res.fattr = &data->fattr; 575 data->res.fattr = &data->fattr;
576 data->res.verf = &data->verf; 576 data->res.verf = &data->verf;
@@ -734,14 +734,14 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
734 data->npages, 0, 0, data->pagevec, NULL); 734 data->npages, 0, 0, data->pagevec, NULL);
735 up_read(&current->mm->mmap_sem); 735 up_read(&current->mm->mmap_sem);
736 if (result < 0) { 736 if (result < 0) {
737 nfs_writedata_release(data); 737 nfs_writedata_free(data);
738 break; 738 break;
739 } 739 }
740 if ((unsigned)result < data->npages) { 740 if ((unsigned)result < data->npages) {
741 bytes = result * PAGE_SIZE; 741 bytes = result * PAGE_SIZE;
742 if (bytes <= pgbase) { 742 if (bytes <= pgbase) {
743 nfs_direct_release_pages(data->pagevec, result); 743 nfs_direct_release_pages(data->pagevec, result);
744 nfs_writedata_release(data); 744 nfs_writedata_free(data);
745 break; 745 break;
746 } 746 }
747 bytes -= pgbase; 747 bytes -= pgbase;
@@ -756,7 +756,7 @@ static ssize_t nfs_direct_write_schedule_segment(struct nfs_direct_req *dreq,
756 data->inode = inode; 756 data->inode = inode;
757 data->cred = msg.rpc_cred; 757 data->cred = msg.rpc_cred;
758 data->args.fh = NFS_FH(inode); 758 data->args.fh = NFS_FH(inode);
759 data->args.context = get_nfs_open_context(ctx); 759 data->args.context = ctx;
760 data->args.offset = pos; 760 data->args.offset = pos;
761 data->args.pgbase = pgbase; 761 data->args.pgbase = pgbase;
762 data->args.pages = data->pagevec; 762 data->args.pages = data->pagevec;
diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 65ca8c18476f..1434080aefeb 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1250,8 +1250,8 @@ static void nfs4_state_manager(struct nfs_client *clp)
1250 continue; 1250 continue;
1251 } 1251 }
1252 /* Initialize or reset the session */ 1252 /* Initialize or reset the session */
1253 if (nfs4_has_session(clp) && 1253 if (test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)
1254 test_and_clear_bit(NFS4CLNT_SESSION_SETUP, &clp->cl_state)) { 1254 && nfs4_has_session(clp)) {
1255 if (clp->cl_cons_state == NFS_CS_SESSION_INITING) 1255 if (clp->cl_cons_state == NFS_CS_SESSION_INITING)
1256 status = nfs4_initialize_session(clp); 1256 status = nfs4_initialize_session(clp);
1257 else 1257 else
diff --git a/fs/nfs/read.c b/fs/nfs/read.c
index 73ea5e8d66ce..12c9e66d3f1d 100644
--- a/fs/nfs/read.c
+++ b/fs/nfs/read.c
@@ -60,17 +60,15 @@ struct nfs_read_data *nfs_readdata_alloc(unsigned int pagecount)
60 return p; 60 return p;
61} 61}
62 62
63static void nfs_readdata_free(struct nfs_read_data *p) 63void nfs_readdata_free(struct nfs_read_data *p)
64{ 64{
65 if (p && (p->pagevec != &p->page_array[0])) 65 if (p && (p->pagevec != &p->page_array[0]))
66 kfree(p->pagevec); 66 kfree(p->pagevec);
67 mempool_free(p, nfs_rdata_mempool); 67 mempool_free(p, nfs_rdata_mempool);
68} 68}
69 69
70void nfs_readdata_release(void *data) 70static void nfs_readdata_release(struct nfs_read_data *rdata)
71{ 71{
72 struct nfs_read_data *rdata = data;
73
74 put_nfs_open_context(rdata->args.context); 72 put_nfs_open_context(rdata->args.context);
75 nfs_readdata_free(rdata); 73 nfs_readdata_free(rdata);
76} 74}
diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 0a0a2ff767c3..a34fae21fe10 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -87,17 +87,15 @@ struct nfs_write_data *nfs_writedata_alloc(unsigned int pagecount)
87 return p; 87 return p;
88} 88}
89 89
90static void nfs_writedata_free(struct nfs_write_data *p) 90void nfs_writedata_free(struct nfs_write_data *p)
91{ 91{
92 if (p && (p->pagevec != &p->page_array[0])) 92 if (p && (p->pagevec != &p->page_array[0]))
93 kfree(p->pagevec); 93 kfree(p->pagevec);
94 mempool_free(p, nfs_wdata_mempool); 94 mempool_free(p, nfs_wdata_mempool);
95} 95}
96 96
97void nfs_writedata_release(void *data) 97static void nfs_writedata_release(struct nfs_write_data *wdata)
98{ 98{
99 struct nfs_write_data *wdata = data;
100
101 put_nfs_open_context(wdata->args.context); 99 put_nfs_open_context(wdata->args.context);
102 nfs_writedata_free(wdata); 100 nfs_writedata_free(wdata);
103} 101}
diff --git a/fs/nilfs2/mdt.c b/fs/nilfs2/mdt.c
index 3d3ddb3f5177..2dfd47714ae5 100644
--- a/fs/nilfs2/mdt.c
+++ b/fs/nilfs2/mdt.c
@@ -412,8 +412,10 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)
412 return 0; /* Do not request flush for shadow page cache */ 412 return 0; /* Do not request flush for shadow page cache */
413 if (!sb) { 413 if (!sb) {
414 writer = nilfs_get_writer(NILFS_MDT(inode)->mi_nilfs); 414 writer = nilfs_get_writer(NILFS_MDT(inode)->mi_nilfs);
415 if (!writer) 415 if (!writer) {
416 nilfs_put_writer(NILFS_MDT(inode)->mi_nilfs);
416 return -EROFS; 417 return -EROFS;
418 }
417 sb = writer->s_super; 419 sb = writer->s_super;
418 } 420 }
419 421
diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
index 8b5e4778cf28..51ff3d0a4ee2 100644
--- a/fs/nilfs2/segment.c
+++ b/fs/nilfs2/segment.c
@@ -1859,12 +1859,26 @@ static void nilfs_end_page_io(struct page *page, int err)
1859 if (!page) 1859 if (!page)
1860 return; 1860 return;
1861 1861
1862 if (buffer_nilfs_node(page_buffers(page)) && !PageWriteback(page)) 1862 if (buffer_nilfs_node(page_buffers(page)) && !PageWriteback(page)) {
1863 /* 1863 /*
1864 * For b-tree node pages, this function may be called twice 1864 * For b-tree node pages, this function may be called twice
1865 * or more because they might be split in a segment. 1865 * or more because they might be split in a segment.
1866 */ 1866 */
1867 if (PageDirty(page)) {
1868 /*
1869 * For pages holding split b-tree node buffers, dirty
1870 * flag on the buffers may be cleared discretely.
1871 * In that case, the page is once redirtied for
1872 * remaining buffers, and it must be cancelled if
1873 * all the buffers get cleaned later.
1874 */
1875 lock_page(page);
1876 if (nilfs_page_buffers_clean(page))
1877 __nilfs_clear_page_dirty(page);
1878 unlock_page(page);
1879 }
1867 return; 1880 return;
1881 }
1868 1882
1869 __nilfs_end_page_io(page, err); 1883 __nilfs_end_page_io(page, err);
1870} 1884}
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 8e2ec43b18f4..151964f0de4c 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -416,8 +416,10 @@ int nilfs_attach_checkpoint(struct nilfs_sb_info *sbi, __u64 cno)
416 if (unlikely(err)) 416 if (unlikely(err))
417 goto failed; 417 goto failed;
418 418
419 down_read(&nilfs->ns_segctor_sem);
419 err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp, 420 err = nilfs_cpfile_get_checkpoint(nilfs->ns_cpfile, cno, 0, &raw_cp,
420 &bh_cp); 421 &bh_cp);
422 up_read(&nilfs->ns_segctor_sem);
421 if (unlikely(err)) { 423 if (unlikely(err)) {
422 if (err == -ENOENT || err == -EINVAL) { 424 if (err == -ENOENT || err == -EINVAL) {
423 printk(KERN_ERR 425 printk(KERN_ERR
diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h
index e8adbffc626f..1b9caafb8662 100644
--- a/fs/nilfs2/the_nilfs.h
+++ b/fs/nilfs2/the_nilfs.h
@@ -253,7 +253,7 @@ nilfs_detach_writer(struct the_nilfs *nilfs, struct nilfs_sb_info *sbi)
253 253
254static inline void nilfs_put_sbinfo(struct nilfs_sb_info *sbi) 254static inline void nilfs_put_sbinfo(struct nilfs_sb_info *sbi)
255{ 255{
256 if (!atomic_dec_and_test(&sbi->s_count)) 256 if (atomic_dec_and_test(&sbi->s_count))
257 kfree(sbi); 257 kfree(sbi);
258} 258}
259 259
diff --git a/fs/notify/inotify/inotify_fsnotify.c b/fs/notify/inotify/inotify_fsnotify.c
index 47cd258fd24d..c9ee67b442e1 100644
--- a/fs/notify/inotify/inotify_fsnotify.c
+++ b/fs/notify/inotify/inotify_fsnotify.c
@@ -62,13 +62,14 @@ static int inotify_handle_event(struct fsnotify_group *group, struct fsnotify_ev
62 event_priv->wd = wd; 62 event_priv->wd = wd;
63 63
64 ret = fsnotify_add_notify_event(group, event, fsn_event_priv); 64 ret = fsnotify_add_notify_event(group, event, fsn_event_priv);
65 /* EEXIST is not an error */ 65 if (ret) {
66 if (ret == -EEXIST)
67 ret = 0;
68
69 /* did event_priv get attached? */
70 if (list_empty(&fsn_event_priv->event_list))
71 inotify_free_event_priv(fsn_event_priv); 66 inotify_free_event_priv(fsn_event_priv);
67 /* EEXIST says we tail matched, EOVERFLOW isn't something
68 * to report up the stack. */
69 if ((ret == -EEXIST) ||
70 (ret == -EOVERFLOW))
71 ret = 0;
72 }
72 73
73 /* 74 /*
74 * If we hold the entry until after the event is on the queue 75 * If we hold the entry until after the event is on the queue
@@ -104,16 +105,45 @@ static bool inotify_should_send_event(struct fsnotify_group *group, struct inode
104 return send; 105 return send;
105} 106}
106 107
108/*
109 * This is NEVER supposed to be called. Inotify marks should either have been
110 * removed from the idr when the watch was removed or in the
111 * fsnotify_destroy_mark_by_group() call when the inotify instance was being
112 * torn down. This is only called if the idr is about to be freed but there
113 * are still marks in it.
114 */
107static int idr_callback(int id, void *p, void *data) 115static int idr_callback(int id, void *p, void *data)
108{ 116{
109 BUG(); 117 struct fsnotify_mark_entry *entry;
118 struct inotify_inode_mark_entry *ientry;
119 static bool warned = false;
120
121 if (warned)
122 return 0;
123
124 warned = false;
125 entry = p;
126 ientry = container_of(entry, struct inotify_inode_mark_entry, fsn_entry);
127
128 WARN(1, "inotify closing but id=%d for entry=%p in group=%p still in "
129 "idr. Probably leaking memory\n", id, p, data);
130
131 /*
132 * I'm taking the liberty of assuming that the mark in question is a
133 * valid address and I'm dereferencing it. This might help to figure
134 * out why we got here and the panic is no worse than the original
135 * BUG() that was here.
136 */
137 if (entry)
138 printk(KERN_WARNING "entry->group=%p inode=%p wd=%d\n",
139 entry->group, entry->inode, ientry->wd);
110 return 0; 140 return 0;
111} 141}
112 142
113static void inotify_free_group_priv(struct fsnotify_group *group) 143static void inotify_free_group_priv(struct fsnotify_group *group)
114{ 144{
115 /* ideally the idr is empty and we won't hit the BUG in teh callback */ 145 /* ideally the idr is empty and we won't hit the BUG in teh callback */
116 idr_for_each(&group->inotify_data.idr, idr_callback, NULL); 146 idr_for_each(&group->inotify_data.idr, idr_callback, group);
117 idr_remove_all(&group->inotify_data.idr); 147 idr_remove_all(&group->inotify_data.idr);
118 idr_destroy(&group->inotify_data.idr); 148 idr_destroy(&group->inotify_data.idr);
119} 149}
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index f30d9bbc2e1b..dcd2040d330c 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -47,9 +47,6 @@
47 47
48static struct vfsmount *inotify_mnt __read_mostly; 48static struct vfsmount *inotify_mnt __read_mostly;
49 49
50/* this just sits here and wastes global memory. used to just pad userspace messages with zeros */
51static struct inotify_event nul_inotify_event;
52
53/* these are configurable via /proc/sys/fs/inotify/ */ 50/* these are configurable via /proc/sys/fs/inotify/ */
54static int inotify_max_user_instances __read_mostly; 51static int inotify_max_user_instances __read_mostly;
55static int inotify_max_queued_events __read_mostly; 52static int inotify_max_queued_events __read_mostly;
@@ -157,7 +154,8 @@ static struct fsnotify_event *get_one_event(struct fsnotify_group *group,
157 154
158 event = fsnotify_peek_notify_event(group); 155 event = fsnotify_peek_notify_event(group);
159 156
160 event_size += roundup(event->name_len, event_size); 157 if (event->name_len)
158 event_size += roundup(event->name_len + 1, event_size);
161 159
162 if (event_size > count) 160 if (event_size > count)
163 return ERR_PTR(-EINVAL); 161 return ERR_PTR(-EINVAL);
@@ -183,7 +181,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
183 struct fsnotify_event_private_data *fsn_priv; 181 struct fsnotify_event_private_data *fsn_priv;
184 struct inotify_event_private_data *priv; 182 struct inotify_event_private_data *priv;
185 size_t event_size = sizeof(struct inotify_event); 183 size_t event_size = sizeof(struct inotify_event);
186 size_t name_len; 184 size_t name_len = 0;
187 185
188 /* we get the inotify watch descriptor from the event private data */ 186 /* we get the inotify watch descriptor from the event private data */
189 spin_lock(&event->lock); 187 spin_lock(&event->lock);
@@ -199,8 +197,12 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
199 inotify_free_event_priv(fsn_priv); 197 inotify_free_event_priv(fsn_priv);
200 } 198 }
201 199
202 /* round up event->name_len so it is a multiple of event_size */ 200 /*
203 name_len = roundup(event->name_len, event_size); 201 * round up event->name_len so it is a multiple of event_size
202 * plus an extra byte for the terminating '\0'.
203 */
204 if (event->name_len)
205 name_len = roundup(event->name_len + 1, event_size);
204 inotify_event.len = name_len; 206 inotify_event.len = name_len;
205 207
206 inotify_event.mask = inotify_mask_to_arg(event->mask); 208 inotify_event.mask = inotify_mask_to_arg(event->mask);
@@ -224,8 +226,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
224 return -EFAULT; 226 return -EFAULT;
225 buf += event->name_len; 227 buf += event->name_len;
226 228
227 /* fill userspace with 0's from nul_inotify_event */ 229 /* fill userspace with 0's */
228 if (copy_to_user(buf, &nul_inotify_event, len_to_zero)) 230 if (clear_user(buf, len_to_zero))
229 return -EFAULT; 231 return -EFAULT;
230 buf += len_to_zero; 232 buf += len_to_zero;
231 event_size += name_len; 233 event_size += name_len;
@@ -326,8 +328,9 @@ static long inotify_ioctl(struct file *file, unsigned int cmd,
326 list_for_each_entry(holder, &group->notification_list, event_list) { 328 list_for_each_entry(holder, &group->notification_list, event_list) {
327 event = holder->event; 329 event = holder->event;
328 send_len += sizeof(struct inotify_event); 330 send_len += sizeof(struct inotify_event);
329 send_len += roundup(event->name_len, 331 if (event->name_len)
330 sizeof(struct inotify_event)); 332 send_len += roundup(event->name_len + 1,
333 sizeof(struct inotify_event));
331 } 334 }
332 mutex_unlock(&group->notification_mutex); 335 mutex_unlock(&group->notification_mutex);
333 ret = put_user(send_len, (int __user *) p); 336 ret = put_user(send_len, (int __user *) p);
@@ -364,20 +367,53 @@ static int inotify_find_inode(const char __user *dirname, struct path *path, uns
364 return error; 367 return error;
365} 368}
366 369
370/*
371 * Remove the mark from the idr (if present) and drop the reference
372 * on the mark because it was in the idr.
373 */
367static void inotify_remove_from_idr(struct fsnotify_group *group, 374static void inotify_remove_from_idr(struct fsnotify_group *group,
368 struct inotify_inode_mark_entry *ientry) 375 struct inotify_inode_mark_entry *ientry)
369{ 376{
370 struct idr *idr; 377 struct idr *idr;
378 struct fsnotify_mark_entry *entry;
379 struct inotify_inode_mark_entry *found_ientry;
380 int wd;
371 381
372 spin_lock(&group->inotify_data.idr_lock); 382 spin_lock(&group->inotify_data.idr_lock);
373 idr = &group->inotify_data.idr; 383 idr = &group->inotify_data.idr;
374 idr_remove(idr, ientry->wd); 384 wd = ientry->wd;
375 spin_unlock(&group->inotify_data.idr_lock); 385
386 if (wd == -1)
387 goto out;
388
389 entry = idr_find(&group->inotify_data.idr, wd);
390 if (unlikely(!entry))
391 goto out;
392
393 found_ientry = container_of(entry, struct inotify_inode_mark_entry, fsn_entry);
394 if (unlikely(found_ientry != ientry)) {
395 /* We found an entry in the idr with the right wd, but it's
396 * not the entry we were told to remove. eparis seriously
397 * fucked up somewhere. */
398 WARN_ON(1);
399 ientry->wd = -1;
400 goto out;
401 }
402
403 /* One ref for being in the idr, one ref held by the caller */
404 BUG_ON(atomic_read(&entry->refcnt) < 2);
405
406 idr_remove(idr, wd);
376 ientry->wd = -1; 407 ientry->wd = -1;
408
409 /* removed from the idr, drop that ref */
410 fsnotify_put_mark(entry);
411out:
412 spin_unlock(&group->inotify_data.idr_lock);
377} 413}
414
378/* 415/*
379 * Send IN_IGNORED for this wd, remove this wd from the idr, and drop the 416 * Send IN_IGNORED for this wd, remove this wd from the idr.
380 * internal reference help on the mark because it is in the idr.
381 */ 417 */
382void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry, 418void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry,
383 struct fsnotify_group *group) 419 struct fsnotify_group *group)
@@ -386,6 +422,7 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry,
386 struct fsnotify_event *ignored_event; 422 struct fsnotify_event *ignored_event;
387 struct inotify_event_private_data *event_priv; 423 struct inotify_event_private_data *event_priv;
388 struct fsnotify_event_private_data *fsn_event_priv; 424 struct fsnotify_event_private_data *fsn_event_priv;
425 int ret;
389 426
390 ignored_event = fsnotify_create_event(NULL, FS_IN_IGNORED, NULL, 427 ignored_event = fsnotify_create_event(NULL, FS_IN_IGNORED, NULL,
391 FSNOTIFY_EVENT_NONE, NULL, 0, 428 FSNOTIFY_EVENT_NONE, NULL, 0,
@@ -404,10 +441,8 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark_entry *entry,
404 fsn_event_priv->group = group; 441 fsn_event_priv->group = group;
405 event_priv->wd = ientry->wd; 442 event_priv->wd = ientry->wd;
406 443
407 fsnotify_add_notify_event(group, ignored_event, fsn_event_priv); 444 ret = fsnotify_add_notify_event(group, ignored_event, fsn_event_priv);
408 445 if (ret)
409 /* did the private data get added? */
410 if (list_empty(&fsn_event_priv->event_list))
411 inotify_free_event_priv(fsn_event_priv); 446 inotify_free_event_priv(fsn_event_priv);
412 447
413skip_send_ignore: 448skip_send_ignore:
@@ -418,9 +453,6 @@ skip_send_ignore:
418 /* remove this entry from the idr */ 453 /* remove this entry from the idr */
419 inotify_remove_from_idr(group, ientry); 454 inotify_remove_from_idr(group, ientry);
420 455
421 /* removed from idr, drop that reference */
422 fsnotify_put_mark(entry);
423
424 atomic_dec(&group->inotify_data.user->inotify_watches); 456 atomic_dec(&group->inotify_data.user->inotify_watches);
425} 457}
426 458
@@ -432,80 +464,29 @@ static void inotify_free_mark(struct fsnotify_mark_entry *entry)
432 kmem_cache_free(inotify_inode_mark_cachep, ientry); 464 kmem_cache_free(inotify_inode_mark_cachep, ientry);
433} 465}
434 466
435static int inotify_update_watch(struct fsnotify_group *group, struct inode *inode, u32 arg) 467static int inotify_update_existing_watch(struct fsnotify_group *group,
468 struct inode *inode,
469 u32 arg)
436{ 470{
437 struct fsnotify_mark_entry *entry = NULL; 471 struct fsnotify_mark_entry *entry;
438 struct inotify_inode_mark_entry *ientry; 472 struct inotify_inode_mark_entry *ientry;
439 struct inotify_inode_mark_entry *tmp_ientry;
440 int ret = 0;
441 int add = (arg & IN_MASK_ADD);
442 __u32 mask;
443 __u32 old_mask, new_mask; 473 __u32 old_mask, new_mask;
474 __u32 mask;
475 int add = (arg & IN_MASK_ADD);
476 int ret;
444 477
445 /* don't allow invalid bits: we don't want flags set */ 478 /* don't allow invalid bits: we don't want flags set */
446 mask = inotify_arg_to_mask(arg); 479 mask = inotify_arg_to_mask(arg);
447 if (unlikely(!mask)) 480 if (unlikely(!mask))
448 return -EINVAL; 481 return -EINVAL;
449 482
450 tmp_ientry = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL);
451 if (unlikely(!tmp_ientry))
452 return -ENOMEM;
453 /* we set the mask at the end after attaching it */
454 fsnotify_init_mark(&tmp_ientry->fsn_entry, inotify_free_mark);
455 tmp_ientry->wd = -1;
456
457find_entry:
458 spin_lock(&inode->i_lock); 483 spin_lock(&inode->i_lock);
459 entry = fsnotify_find_mark_entry(group, inode); 484 entry = fsnotify_find_mark_entry(group, inode);
460 spin_unlock(&inode->i_lock); 485 spin_unlock(&inode->i_lock);
461 if (entry) { 486 if (!entry)
462 ientry = container_of(entry, struct inotify_inode_mark_entry, fsn_entry); 487 return -ENOENT;
463 } else {
464 ret = -ENOSPC;
465 if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches)
466 goto out_err;
467retry:
468 ret = -ENOMEM;
469 if (unlikely(!idr_pre_get(&group->inotify_data.idr, GFP_KERNEL)))
470 goto out_err;
471
472 spin_lock(&group->inotify_data.idr_lock);
473 ret = idr_get_new_above(&group->inotify_data.idr, &tmp_ientry->fsn_entry,
474 group->inotify_data.last_wd,
475 &tmp_ientry->wd);
476 spin_unlock(&group->inotify_data.idr_lock);
477 if (ret) {
478 if (ret == -EAGAIN)
479 goto retry;
480 goto out_err;
481 }
482 488
483 ret = fsnotify_add_mark(&tmp_ientry->fsn_entry, group, inode); 489 ientry = container_of(entry, struct inotify_inode_mark_entry, fsn_entry);
484 if (ret) {
485 inotify_remove_from_idr(group, tmp_ientry);
486 if (ret == -EEXIST)
487 goto find_entry;
488 goto out_err;
489 }
490
491 /* tmp_ientry has been added to the inode, so we are all set up.
492 * now we just need to make sure tmp_ientry doesn't get freed and
493 * we need to set up entry and ientry so the generic code can
494 * do its thing. */
495 ientry = tmp_ientry;
496 entry = &ientry->fsn_entry;
497 tmp_ientry = NULL;
498
499 atomic_inc(&group->inotify_data.user->inotify_watches);
500
501 /* update the idr hint */
502 group->inotify_data.last_wd = ientry->wd;
503
504 /* we put the mark on the idr, take a reference */
505 fsnotify_get_mark(entry);
506 }
507
508 ret = ientry->wd;
509 490
510 spin_lock(&entry->lock); 491 spin_lock(&entry->lock);
511 492
@@ -537,18 +518,107 @@ retry:
537 fsnotify_recalc_group_mask(group); 518 fsnotify_recalc_group_mask(group);
538 } 519 }
539 520
540 /* this either matches fsnotify_find_mark_entry, or init_mark_entry 521 /* return the wd */
541 * depending on which path we took... */ 522 ret = ientry->wd;
523
524 /* match the get from fsnotify_find_mark_entry() */
542 fsnotify_put_mark(entry); 525 fsnotify_put_mark(entry);
543 526
527 return ret;
528}
529
530static int inotify_new_watch(struct fsnotify_group *group,
531 struct inode *inode,
532 u32 arg)
533{
534 struct inotify_inode_mark_entry *tmp_ientry;
535 __u32 mask;
536 int ret;
537
538 /* don't allow invalid bits: we don't want flags set */
539 mask = inotify_arg_to_mask(arg);
540 if (unlikely(!mask))
541 return -EINVAL;
542
543 tmp_ientry = kmem_cache_alloc(inotify_inode_mark_cachep, GFP_KERNEL);
544 if (unlikely(!tmp_ientry))
545 return -ENOMEM;
546
547 fsnotify_init_mark(&tmp_ientry->fsn_entry, inotify_free_mark);
548 tmp_ientry->fsn_entry.mask = mask;
549 tmp_ientry->wd = -1;
550
551 ret = -ENOSPC;
552 if (atomic_read(&group->inotify_data.user->inotify_watches) >= inotify_max_user_watches)
553 goto out_err;
554retry:
555 ret = -ENOMEM;
556 if (unlikely(!idr_pre_get(&group->inotify_data.idr, GFP_KERNEL)))
557 goto out_err;
558
559 spin_lock(&group->inotify_data.idr_lock);
560 ret = idr_get_new_above(&group->inotify_data.idr, &tmp_ientry->fsn_entry,
561 group->inotify_data.last_wd,
562 &tmp_ientry->wd);
563 spin_unlock(&group->inotify_data.idr_lock);
564 if (ret) {
565 /* idr was out of memory allocate and try again */
566 if (ret == -EAGAIN)
567 goto retry;
568 goto out_err;
569 }
570
571 /* we put the mark on the idr, take a reference */
572 fsnotify_get_mark(&tmp_ientry->fsn_entry);
573
574 /* we are on the idr, now get on the inode */
575 ret = fsnotify_add_mark(&tmp_ientry->fsn_entry, group, inode);
576 if (ret) {
577 /* we failed to get on the inode, get off the idr */
578 inotify_remove_from_idr(group, tmp_ientry);
579 goto out_err;
580 }
581
582 /* update the idr hint, who cares about races, it's just a hint */
583 group->inotify_data.last_wd = tmp_ientry->wd;
584
585 /* increment the number of watches the user has */
586 atomic_inc(&group->inotify_data.user->inotify_watches);
587
588 /* return the watch descriptor for this new entry */
589 ret = tmp_ientry->wd;
590
591 /* match the ref from fsnotify_init_markentry() */
592 fsnotify_put_mark(&tmp_ientry->fsn_entry);
593
594 /* if this mark added a new event update the group mask */
595 if (mask & ~group->mask)
596 fsnotify_recalc_group_mask(group);
597
544out_err: 598out_err:
545 /* could be an error, could be that we found an existing mark */ 599 if (ret < 0)
546 if (tmp_ientry) {
547 /* on the idr but didn't make it on the inode */
548 if (tmp_ientry->wd != -1)
549 inotify_remove_from_idr(group, tmp_ientry);
550 kmem_cache_free(inotify_inode_mark_cachep, tmp_ientry); 600 kmem_cache_free(inotify_inode_mark_cachep, tmp_ientry);
551 } 601
602 return ret;
603}
604
605static int inotify_update_watch(struct fsnotify_group *group, struct inode *inode, u32 arg)
606{
607 int ret = 0;
608
609retry:
610 /* try to update and existing watch with the new arg */
611 ret = inotify_update_existing_watch(group, inode, arg);
612 /* no mark present, try to add a new one */
613 if (ret == -ENOENT)
614 ret = inotify_new_watch(group, inode, arg);
615 /*
616 * inotify_new_watch could race with another thread which did an
617 * inotify_new_watch between the update_existing and the add watch
618 * here, go back and try to update an existing mark again.
619 */
620 if (ret == -EEXIST)
621 goto retry;
552 622
553 return ret; 623 return ret;
554} 624}
@@ -568,7 +638,7 @@ static struct fsnotify_group *inotify_new_group(struct user_struct *user, unsign
568 638
569 spin_lock_init(&group->inotify_data.idr_lock); 639 spin_lock_init(&group->inotify_data.idr_lock);
570 idr_init(&group->inotify_data.idr); 640 idr_init(&group->inotify_data.idr);
571 group->inotify_data.last_wd = 0; 641 group->inotify_data.last_wd = 1;
572 group->inotify_data.user = user; 642 group->inotify_data.user = user;
573 group->inotify_data.fa = NULL; 643 group->inotify_data.fa = NULL;
574 644
diff --git a/fs/notify/notification.c b/fs/notify/notification.c
index 521368574e97..3816d5750dd5 100644
--- a/fs/notify/notification.c
+++ b/fs/notify/notification.c
@@ -153,6 +153,10 @@ static bool event_compare(struct fsnotify_event *old, struct fsnotify_event *new
153 return true; 153 return true;
154 break; 154 break;
155 case (FSNOTIFY_EVENT_NONE): 155 case (FSNOTIFY_EVENT_NONE):
156 if (old->mask & FS_Q_OVERFLOW)
157 return true;
158 else if (old->mask & FS_IN_IGNORED)
159 return false;
156 return false; 160 return false;
157 }; 161 };
158 } 162 }
@@ -171,9 +175,7 @@ int fsnotify_add_notify_event(struct fsnotify_group *group, struct fsnotify_even
171 struct list_head *list = &group->notification_list; 175 struct list_head *list = &group->notification_list;
172 struct fsnotify_event_holder *last_holder; 176 struct fsnotify_event_holder *last_holder;
173 struct fsnotify_event *last_event; 177 struct fsnotify_event *last_event;
174 178 int ret = 0;
175 /* easy to tell if priv was attached to the event */
176 INIT_LIST_HEAD(&priv->event_list);
177 179
178 /* 180 /*
179 * There is one fsnotify_event_holder embedded inside each fsnotify_event. 181 * There is one fsnotify_event_holder embedded inside each fsnotify_event.
@@ -194,6 +196,7 @@ alloc_holder:
194 196
195 if (group->q_len >= group->max_events) { 197 if (group->q_len >= group->max_events) {
196 event = &q_overflow_event; 198 event = &q_overflow_event;
199 ret = -EOVERFLOW;
197 /* sorry, no private data on the overflow event */ 200 /* sorry, no private data on the overflow event */
198 priv = NULL; 201 priv = NULL;
199 } 202 }
@@ -235,7 +238,7 @@ alloc_holder:
235 mutex_unlock(&group->notification_mutex); 238 mutex_unlock(&group->notification_mutex);
236 239
237 wake_up(&group->notification_waitq); 240 wake_up(&group->notification_waitq);
238 return 0; 241 return ret;
239} 242}
240 243
241/* 244/*
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 9edcde4974aa..ab513ddaeff2 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -1914,7 +1914,8 @@ static void ocfs2_adjust_adjacent_records(struct ocfs2_extent_rec *left_rec,
1914 * immediately to their right. 1914 * immediately to their right.
1915 */ 1915 */
1916 left_clusters = le32_to_cpu(right_child_el->l_recs[0].e_cpos); 1916 left_clusters = le32_to_cpu(right_child_el->l_recs[0].e_cpos);
1917 if (ocfs2_is_empty_extent(&right_child_el->l_recs[0])) { 1917 if (!ocfs2_rec_clusters(right_child_el, &right_child_el->l_recs[0])) {
1918 BUG_ON(right_child_el->l_tree_depth);
1918 BUG_ON(le16_to_cpu(right_child_el->l_next_free_rec) <= 1); 1919 BUG_ON(le16_to_cpu(right_child_el->l_next_free_rec) <= 1);
1919 left_clusters = le32_to_cpu(right_child_el->l_recs[1].e_cpos); 1920 left_clusters = le32_to_cpu(right_child_el->l_recs[1].e_cpos);
1920 } 1921 }
@@ -2476,15 +2477,37 @@ out_ret_path:
2476 return ret; 2477 return ret;
2477} 2478}
2478 2479
2479static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle, 2480static int ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
2480 struct ocfs2_path *path) 2481 int subtree_index, struct ocfs2_path *path)
2481{ 2482{
2482 int i, idx; 2483 int i, idx, ret;
2483 struct ocfs2_extent_rec *rec; 2484 struct ocfs2_extent_rec *rec;
2484 struct ocfs2_extent_list *el; 2485 struct ocfs2_extent_list *el;
2485 struct ocfs2_extent_block *eb; 2486 struct ocfs2_extent_block *eb;
2486 u32 range; 2487 u32 range;
2487 2488
2489 /*
2490 * In normal tree rotation process, we will never touch the
2491 * tree branch above subtree_index and ocfs2_extend_rotate_transaction
2492 * doesn't reserve the credits for them either.
2493 *
2494 * But we do have a special case here which will update the rightmost
2495 * records for all the bh in the path.
2496 * So we have to allocate extra credits and access them.
2497 */
2498 ret = ocfs2_extend_trans(handle,
2499 handle->h_buffer_credits + subtree_index);
2500 if (ret) {
2501 mlog_errno(ret);
2502 goto out;
2503 }
2504
2505 ret = ocfs2_journal_access_path(inode, handle, path);
2506 if (ret) {
2507 mlog_errno(ret);
2508 goto out;
2509 }
2510
2488 /* Path should always be rightmost. */ 2511 /* Path should always be rightmost. */
2489 eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data; 2512 eb = (struct ocfs2_extent_block *)path_leaf_bh(path)->b_data;
2490 BUG_ON(eb->h_next_leaf_blk != 0ULL); 2513 BUG_ON(eb->h_next_leaf_blk != 0ULL);
@@ -2505,6 +2528,8 @@ static void ocfs2_update_edge_lengths(struct inode *inode, handle_t *handle,
2505 2528
2506 ocfs2_journal_dirty(handle, path->p_node[i].bh); 2529 ocfs2_journal_dirty(handle, path->p_node[i].bh);
2507 } 2530 }
2531out:
2532 return ret;
2508} 2533}
2509 2534
2510static void ocfs2_unlink_path(struct inode *inode, handle_t *handle, 2535static void ocfs2_unlink_path(struct inode *inode, handle_t *handle,
@@ -2717,7 +2742,12 @@ static int ocfs2_rotate_subtree_left(struct inode *inode, handle_t *handle,
2717 if (del_right_subtree) { 2742 if (del_right_subtree) {
2718 ocfs2_unlink_subtree(inode, handle, left_path, right_path, 2743 ocfs2_unlink_subtree(inode, handle, left_path, right_path,
2719 subtree_index, dealloc); 2744 subtree_index, dealloc);
2720 ocfs2_update_edge_lengths(inode, handle, left_path); 2745 ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
2746 left_path);
2747 if (ret) {
2748 mlog_errno(ret);
2749 goto out;
2750 }
2721 2751
2722 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; 2752 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
2723 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); 2753 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
@@ -3034,7 +3064,12 @@ static int ocfs2_remove_rightmost_path(struct inode *inode, handle_t *handle,
3034 3064
3035 ocfs2_unlink_subtree(inode, handle, left_path, path, 3065 ocfs2_unlink_subtree(inode, handle, left_path, path,
3036 subtree_index, dealloc); 3066 subtree_index, dealloc);
3037 ocfs2_update_edge_lengths(inode, handle, left_path); 3067 ret = ocfs2_update_edge_lengths(inode, handle, subtree_index,
3068 left_path);
3069 if (ret) {
3070 mlog_errno(ret);
3071 goto out;
3072 }
3038 3073
3039 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data; 3074 eb = (struct ocfs2_extent_block *)path_leaf_bh(left_path)->b_data;
3040 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno)); 3075 ocfs2_et_set_last_eb_blk(et, le64_to_cpu(eb->h_blkno));
@@ -6816,7 +6851,7 @@ static int ocfs2_do_truncate(struct ocfs2_super *osb,
6816 } 6851 }
6817 status = 0; 6852 status = 0;
6818bail: 6853bail:
6819 6854 brelse(last_eb_bh);
6820 mlog_exit(status); 6855 mlog_exit(status);
6821 return status; 6856 return status;
6822} 6857}
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index b2c52b3a1484..b401654011a2 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -193,6 +193,7 @@ static int ocfs2_get_block(struct inode *inode, sector_t iblock,
193 (unsigned long long)OCFS2_I(inode)->ip_blkno); 193 (unsigned long long)OCFS2_I(inode)->ip_blkno);
194 mlog(ML_ERROR, "Size %llu, clusters %u\n", (unsigned long long)i_size_read(inode), OCFS2_I(inode)->ip_clusters); 194 mlog(ML_ERROR, "Size %llu, clusters %u\n", (unsigned long long)i_size_read(inode), OCFS2_I(inode)->ip_clusters);
195 dump_stack(); 195 dump_stack();
196 goto bail;
196 } 197 }
197 198
198 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode)); 199 past_eof = ocfs2_blocks_for_bytes(inode->i_sb, i_size_read(inode));
@@ -894,18 +895,17 @@ struct ocfs2_write_cluster_desc {
894 */ 895 */
895 unsigned c_new; 896 unsigned c_new;
896 unsigned c_unwritten; 897 unsigned c_unwritten;
898 unsigned c_needs_zero;
897}; 899};
898 900
899static inline int ocfs2_should_zero_cluster(struct ocfs2_write_cluster_desc *d)
900{
901 return d->c_new || d->c_unwritten;
902}
903
904struct ocfs2_write_ctxt { 901struct ocfs2_write_ctxt {
905 /* Logical cluster position / len of write */ 902 /* Logical cluster position / len of write */
906 u32 w_cpos; 903 u32 w_cpos;
907 u32 w_clen; 904 u32 w_clen;
908 905
906 /* First cluster allocated in a nonsparse extend */
907 u32 w_first_new_cpos;
908
909 struct ocfs2_write_cluster_desc w_desc[OCFS2_MAX_CLUSTERS_PER_PAGE]; 909 struct ocfs2_write_cluster_desc w_desc[OCFS2_MAX_CLUSTERS_PER_PAGE];
910 910
911 /* 911 /*
@@ -983,6 +983,7 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp,
983 return -ENOMEM; 983 return -ENOMEM;
984 984
985 wc->w_cpos = pos >> osb->s_clustersize_bits; 985 wc->w_cpos = pos >> osb->s_clustersize_bits;
986 wc->w_first_new_cpos = UINT_MAX;
986 cend = (pos + len - 1) >> osb->s_clustersize_bits; 987 cend = (pos + len - 1) >> osb->s_clustersize_bits;
987 wc->w_clen = cend - wc->w_cpos + 1; 988 wc->w_clen = cend - wc->w_cpos + 1;
988 get_bh(di_bh); 989 get_bh(di_bh);
@@ -1217,20 +1218,18 @@ out:
1217 */ 1218 */
1218static int ocfs2_write_cluster(struct address_space *mapping, 1219static int ocfs2_write_cluster(struct address_space *mapping,
1219 u32 phys, unsigned int unwritten, 1220 u32 phys, unsigned int unwritten,
1221 unsigned int should_zero,
1220 struct ocfs2_alloc_context *data_ac, 1222 struct ocfs2_alloc_context *data_ac,
1221 struct ocfs2_alloc_context *meta_ac, 1223 struct ocfs2_alloc_context *meta_ac,
1222 struct ocfs2_write_ctxt *wc, u32 cpos, 1224 struct ocfs2_write_ctxt *wc, u32 cpos,
1223 loff_t user_pos, unsigned user_len) 1225 loff_t user_pos, unsigned user_len)
1224{ 1226{
1225 int ret, i, new, should_zero = 0; 1227 int ret, i, new;
1226 u64 v_blkno, p_blkno; 1228 u64 v_blkno, p_blkno;
1227 struct inode *inode = mapping->host; 1229 struct inode *inode = mapping->host;
1228 struct ocfs2_extent_tree et; 1230 struct ocfs2_extent_tree et;
1229 1231
1230 new = phys == 0 ? 1 : 0; 1232 new = phys == 0 ? 1 : 0;
1231 if (new || unwritten)
1232 should_zero = 1;
1233
1234 if (new) { 1233 if (new) {
1235 u32 tmp_pos; 1234 u32 tmp_pos;
1236 1235
@@ -1301,7 +1300,7 @@ static int ocfs2_write_cluster(struct address_space *mapping,
1301 if (tmpret) { 1300 if (tmpret) {
1302 mlog_errno(tmpret); 1301 mlog_errno(tmpret);
1303 if (ret == 0) 1302 if (ret == 0)
1304 tmpret = ret; 1303 ret = tmpret;
1305 } 1304 }
1306 } 1305 }
1307 1306
@@ -1341,7 +1340,9 @@ static int ocfs2_write_cluster_by_desc(struct address_space *mapping,
1341 local_len = osb->s_clustersize - cluster_off; 1340 local_len = osb->s_clustersize - cluster_off;
1342 1341
1343 ret = ocfs2_write_cluster(mapping, desc->c_phys, 1342 ret = ocfs2_write_cluster(mapping, desc->c_phys,
1344 desc->c_unwritten, data_ac, meta_ac, 1343 desc->c_unwritten,
1344 desc->c_needs_zero,
1345 data_ac, meta_ac,
1345 wc, desc->c_cpos, pos, local_len); 1346 wc, desc->c_cpos, pos, local_len);
1346 if (ret) { 1347 if (ret) {
1347 mlog_errno(ret); 1348 mlog_errno(ret);
@@ -1391,14 +1392,14 @@ static void ocfs2_set_target_boundaries(struct ocfs2_super *osb,
1391 * newly allocated cluster. 1392 * newly allocated cluster.
1392 */ 1393 */
1393 desc = &wc->w_desc[0]; 1394 desc = &wc->w_desc[0];
1394 if (ocfs2_should_zero_cluster(desc)) 1395 if (desc->c_needs_zero)
1395 ocfs2_figure_cluster_boundaries(osb, 1396 ocfs2_figure_cluster_boundaries(osb,
1396 desc->c_cpos, 1397 desc->c_cpos,
1397 &wc->w_target_from, 1398 &wc->w_target_from,
1398 NULL); 1399 NULL);
1399 1400
1400 desc = &wc->w_desc[wc->w_clen - 1]; 1401 desc = &wc->w_desc[wc->w_clen - 1];
1401 if (ocfs2_should_zero_cluster(desc)) 1402 if (desc->c_needs_zero)
1402 ocfs2_figure_cluster_boundaries(osb, 1403 ocfs2_figure_cluster_boundaries(osb,
1403 desc->c_cpos, 1404 desc->c_cpos,
1404 NULL, 1405 NULL,
@@ -1466,13 +1467,28 @@ static int ocfs2_populate_write_desc(struct inode *inode,
1466 phys++; 1467 phys++;
1467 } 1468 }
1468 1469
1470 /*
1471 * If w_first_new_cpos is < UINT_MAX, we have a non-sparse
1472 * file that got extended. w_first_new_cpos tells us
1473 * where the newly allocated clusters are so we can
1474 * zero them.
1475 */
1476 if (desc->c_cpos >= wc->w_first_new_cpos) {
1477 BUG_ON(phys == 0);
1478 desc->c_needs_zero = 1;
1479 }
1480
1469 desc->c_phys = phys; 1481 desc->c_phys = phys;
1470 if (phys == 0) { 1482 if (phys == 0) {
1471 desc->c_new = 1; 1483 desc->c_new = 1;
1484 desc->c_needs_zero = 1;
1472 *clusters_to_alloc = *clusters_to_alloc + 1; 1485 *clusters_to_alloc = *clusters_to_alloc + 1;
1473 } 1486 }
1474 if (ext_flags & OCFS2_EXT_UNWRITTEN) 1487
1488 if (ext_flags & OCFS2_EXT_UNWRITTEN) {
1475 desc->c_unwritten = 1; 1489 desc->c_unwritten = 1;
1490 desc->c_needs_zero = 1;
1491 }
1476 1492
1477 num_clusters--; 1493 num_clusters--;
1478 } 1494 }
@@ -1632,10 +1648,13 @@ static int ocfs2_expand_nonsparse_inode(struct inode *inode, loff_t pos,
1632 if (newsize <= i_size_read(inode)) 1648 if (newsize <= i_size_read(inode))
1633 return 0; 1649 return 0;
1634 1650
1635 ret = ocfs2_extend_no_holes(inode, newsize, newsize - len); 1651 ret = ocfs2_extend_no_holes(inode, newsize, pos);
1636 if (ret) 1652 if (ret)
1637 mlog_errno(ret); 1653 mlog_errno(ret);
1638 1654
1655 wc->w_first_new_cpos =
1656 ocfs2_clusters_for_bytes(inode->i_sb, i_size_read(inode));
1657
1639 return ret; 1658 return ret;
1640} 1659}
1641 1660
@@ -1644,7 +1663,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1644 struct page **pagep, void **fsdata, 1663 struct page **pagep, void **fsdata,
1645 struct buffer_head *di_bh, struct page *mmap_page) 1664 struct buffer_head *di_bh, struct page *mmap_page)
1646{ 1665{
1647 int ret, credits = OCFS2_INODE_UPDATE_CREDITS; 1666 int ret, cluster_of_pages, credits = OCFS2_INODE_UPDATE_CREDITS;
1648 unsigned int clusters_to_alloc, extents_to_split; 1667 unsigned int clusters_to_alloc, extents_to_split;
1649 struct ocfs2_write_ctxt *wc; 1668 struct ocfs2_write_ctxt *wc;
1650 struct inode *inode = mapping->host; 1669 struct inode *inode = mapping->host;
@@ -1722,8 +1741,19 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1722 1741
1723 } 1742 }
1724 1743
1725 ocfs2_set_target_boundaries(osb, wc, pos, len, 1744 /*
1726 clusters_to_alloc + extents_to_split); 1745 * We have to zero sparse allocated clusters, unwritten extent clusters,
1746 * and non-sparse clusters we just extended. For non-sparse writes,
1747 * we know zeros will only be needed in the first and/or last cluster.
1748 */
1749 if (clusters_to_alloc || extents_to_split ||
1750 wc->w_desc[0].c_needs_zero ||
1751 wc->w_desc[wc->w_clen - 1].c_needs_zero)
1752 cluster_of_pages = 1;
1753 else
1754 cluster_of_pages = 0;
1755
1756 ocfs2_set_target_boundaries(osb, wc, pos, len, cluster_of_pages);
1727 1757
1728 handle = ocfs2_start_trans(osb, credits); 1758 handle = ocfs2_start_trans(osb, credits);
1729 if (IS_ERR(handle)) { 1759 if (IS_ERR(handle)) {
@@ -1756,8 +1786,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
1756 * extent. 1786 * extent.
1757 */ 1787 */
1758 ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos, 1788 ret = ocfs2_grab_pages_for_write(mapping, wc, wc->w_cpos, pos,
1759 clusters_to_alloc + extents_to_split, 1789 cluster_of_pages, mmap_page);
1760 mmap_page);
1761 if (ret) { 1790 if (ret) {
1762 mlog_errno(ret); 1791 mlog_errno(ret);
1763 goto out_quota; 1792 goto out_quota;
diff --git a/fs/ocfs2/dcache.c b/fs/ocfs2/dcache.c
index b574431a031d..2f28b7de2c8d 100644
--- a/fs/ocfs2/dcache.c
+++ b/fs/ocfs2/dcache.c
@@ -310,22 +310,19 @@ out_attach:
310 return ret; 310 return ret;
311} 311}
312 312
313static DEFINE_SPINLOCK(dentry_list_lock); 313DEFINE_SPINLOCK(dentry_list_lock);
314 314
315/* We limit the number of dentry locks to drop in one go. We have 315/* We limit the number of dentry locks to drop in one go. We have
316 * this limit so that we don't starve other users of ocfs2_wq. */ 316 * this limit so that we don't starve other users of ocfs2_wq. */
317#define DL_INODE_DROP_COUNT 64 317#define DL_INODE_DROP_COUNT 64
318 318
319/* Drop inode references from dentry locks */ 319/* Drop inode references from dentry locks */
320void ocfs2_drop_dl_inodes(struct work_struct *work) 320static void __ocfs2_drop_dl_inodes(struct ocfs2_super *osb, int drop_count)
321{ 321{
322 struct ocfs2_super *osb = container_of(work, struct ocfs2_super,
323 dentry_lock_work);
324 struct ocfs2_dentry_lock *dl; 322 struct ocfs2_dentry_lock *dl;
325 int drop_count = DL_INODE_DROP_COUNT;
326 323
327 spin_lock(&dentry_list_lock); 324 spin_lock(&dentry_list_lock);
328 while (osb->dentry_lock_list && drop_count--) { 325 while (osb->dentry_lock_list && (drop_count < 0 || drop_count--)) {
329 dl = osb->dentry_lock_list; 326 dl = osb->dentry_lock_list;
330 osb->dentry_lock_list = dl->dl_next; 327 osb->dentry_lock_list = dl->dl_next;
331 spin_unlock(&dentry_list_lock); 328 spin_unlock(&dentry_list_lock);
@@ -333,11 +330,32 @@ void ocfs2_drop_dl_inodes(struct work_struct *work)
333 kfree(dl); 330 kfree(dl);
334 spin_lock(&dentry_list_lock); 331 spin_lock(&dentry_list_lock);
335 } 332 }
336 if (osb->dentry_lock_list) 333 spin_unlock(&dentry_list_lock);
334}
335
336void ocfs2_drop_dl_inodes(struct work_struct *work)
337{
338 struct ocfs2_super *osb = container_of(work, struct ocfs2_super,
339 dentry_lock_work);
340
341 __ocfs2_drop_dl_inodes(osb, DL_INODE_DROP_COUNT);
342 /*
343 * Don't queue dropping if umount is in progress. We flush the
344 * list in ocfs2_dismount_volume
345 */
346 spin_lock(&dentry_list_lock);
347 if (osb->dentry_lock_list &&
348 !ocfs2_test_osb_flag(osb, OCFS2_OSB_DROP_DENTRY_LOCK_IMMED))
337 queue_work(ocfs2_wq, &osb->dentry_lock_work); 349 queue_work(ocfs2_wq, &osb->dentry_lock_work);
338 spin_unlock(&dentry_list_lock); 350 spin_unlock(&dentry_list_lock);
339} 351}
340 352
353/* Flush the whole work queue */
354void ocfs2_drop_all_dl_inodes(struct ocfs2_super *osb)
355{
356 __ocfs2_drop_dl_inodes(osb, -1);
357}
358
341/* 359/*
342 * ocfs2_dentry_iput() and friends. 360 * ocfs2_dentry_iput() and friends.
343 * 361 *
@@ -368,7 +386,8 @@ static void ocfs2_drop_dentry_lock(struct ocfs2_super *osb,
368 /* We leave dropping of inode reference to ocfs2_wq as that can 386 /* We leave dropping of inode reference to ocfs2_wq as that can
369 * possibly lead to inode deletion which gets tricky */ 387 * possibly lead to inode deletion which gets tricky */
370 spin_lock(&dentry_list_lock); 388 spin_lock(&dentry_list_lock);
371 if (!osb->dentry_lock_list) 389 if (!osb->dentry_lock_list &&
390 !ocfs2_test_osb_flag(osb, OCFS2_OSB_DROP_DENTRY_LOCK_IMMED))
372 queue_work(ocfs2_wq, &osb->dentry_lock_work); 391 queue_work(ocfs2_wq, &osb->dentry_lock_work);
373 dl->dl_next = osb->dentry_lock_list; 392 dl->dl_next = osb->dentry_lock_list;
374 osb->dentry_lock_list = dl; 393 osb->dentry_lock_list = dl;
diff --git a/fs/ocfs2/dcache.h b/fs/ocfs2/dcache.h
index faa12e75f98d..f5dd1789acf1 100644
--- a/fs/ocfs2/dcache.h
+++ b/fs/ocfs2/dcache.h
@@ -49,10 +49,13 @@ struct ocfs2_dentry_lock {
49int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode, 49int ocfs2_dentry_attach_lock(struct dentry *dentry, struct inode *inode,
50 u64 parent_blkno); 50 u64 parent_blkno);
51 51
52extern spinlock_t dentry_list_lock;
53
52void ocfs2_dentry_lock_put(struct ocfs2_super *osb, 54void ocfs2_dentry_lock_put(struct ocfs2_super *osb,
53 struct ocfs2_dentry_lock *dl); 55 struct ocfs2_dentry_lock *dl);
54 56
55void ocfs2_drop_dl_inodes(struct work_struct *work); 57void ocfs2_drop_dl_inodes(struct work_struct *work);
58void ocfs2_drop_all_dl_inodes(struct ocfs2_super *osb);
56 59
57struct dentry *ocfs2_find_local_alias(struct inode *inode, u64 parent_blkno, 60struct dentry *ocfs2_find_local_alias(struct inode *inode, u64 parent_blkno,
58 int skip_unhashed); 61 int skip_unhashed);
diff --git a/fs/ocfs2/dlm/dlmast.c b/fs/ocfs2/dlm/dlmast.c
index d07ddbe4b283..81eff8e58322 100644
--- a/fs/ocfs2/dlm/dlmast.c
+++ b/fs/ocfs2/dlm/dlmast.c
@@ -103,7 +103,6 @@ static void __dlm_queue_ast(struct dlm_ctxt *dlm, struct dlm_lock *lock)
103 lock->ast_pending, lock->ml.type); 103 lock->ast_pending, lock->ml.type);
104 BUG(); 104 BUG();
105 } 105 }
106 BUG_ON(!list_empty(&lock->ast_list));
107 if (lock->ast_pending) 106 if (lock->ast_pending)
108 mlog(0, "lock has an ast getting flushed right now\n"); 107 mlog(0, "lock has an ast getting flushed right now\n");
109 108
diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index bcb9260c3735..43e6e3280569 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1118,7 +1118,7 @@ static int dlm_send_mig_lockres_msg(struct dlm_ctxt *dlm,
1118 1118
1119 mlog(0, "%s:%.*s: sending mig lockres (%s) to %u\n", 1119 mlog(0, "%s:%.*s: sending mig lockres (%s) to %u\n",
1120 dlm->name, res->lockname.len, res->lockname.name, 1120 dlm->name, res->lockname.len, res->lockname.name,
1121 orig_flags & DLM_MRES_MIGRATION ? "migrate" : "recovery", 1121 orig_flags & DLM_MRES_MIGRATION ? "migration" : "recovery",
1122 send_to); 1122 send_to);
1123 1123
1124 /* send it */ 1124 /* send it */
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index fcf879ed6930..756f5b0998e0 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -122,7 +122,7 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
122 * that still has AST's pending... */ 122 * that still has AST's pending... */
123 in_use = !list_empty(&lock->ast_list); 123 in_use = !list_empty(&lock->ast_list);
124 spin_unlock(&dlm->ast_lock); 124 spin_unlock(&dlm->ast_lock);
125 if (in_use) { 125 if (in_use && !(flags & LKM_CANCEL)) {
126 mlog(ML_ERROR, "lockres %.*s: Someone is calling dlmunlock " 126 mlog(ML_ERROR, "lockres %.*s: Someone is calling dlmunlock "
127 "while waiting for an ast!", res->lockname.len, 127 "while waiting for an ast!", res->lockname.len,
128 res->lockname.name); 128 res->lockname.name);
@@ -131,7 +131,7 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
131 131
132 spin_lock(&res->spinlock); 132 spin_lock(&res->spinlock);
133 if (res->state & DLM_LOCK_RES_IN_PROGRESS) { 133 if (res->state & DLM_LOCK_RES_IN_PROGRESS) {
134 if (master_node) { 134 if (master_node && !(flags & LKM_CANCEL)) {
135 mlog(ML_ERROR, "lockres in progress!\n"); 135 mlog(ML_ERROR, "lockres in progress!\n");
136 spin_unlock(&res->spinlock); 136 spin_unlock(&res->spinlock);
137 return DLM_FORWARD; 137 return DLM_FORWARD;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 62442e413a00..aa501d3f93f1 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1851,6 +1851,7 @@ relock:
1851 if (ret) 1851 if (ret)
1852 goto out_dio; 1852 goto out_dio;
1853 1853
1854 count = ocount;
1854 ret = generic_write_checks(file, ppos, &count, 1855 ret = generic_write_checks(file, ppos, &count,
1855 S_ISBLK(inode->i_mode)); 1856 S_ISBLK(inode->i_mode));
1856 if (ret) 1857 if (ret)
@@ -1918,8 +1919,10 @@ out_sems:
1918 1919
1919 mutex_unlock(&inode->i_mutex); 1920 mutex_unlock(&inode->i_mutex);
1920 1921
1922 if (written)
1923 ret = written;
1921 mlog_exit(ret); 1924 mlog_exit(ret);
1922 return written ? written : ret; 1925 return ret;
1923} 1926}
1924 1927
1925static int ocfs2_splice_to_file(struct pipe_inode_info *pipe, 1928static int ocfs2_splice_to_file(struct pipe_inode_info *pipe,
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index f033760ecbea..c48b93ac6b65 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -1954,10 +1954,16 @@ void ocfs2_orphan_scan_init(struct ocfs2_super *osb)
1954 os->os_osb = osb; 1954 os->os_osb = osb;
1955 os->os_count = 0; 1955 os->os_count = 0;
1956 os->os_seqno = 0; 1956 os->os_seqno = 0;
1957 os->os_scantime = CURRENT_TIME;
1958 mutex_init(&os->os_lock); 1957 mutex_init(&os->os_lock);
1959 INIT_DELAYED_WORK(&os->os_orphan_scan_work, ocfs2_orphan_scan_work); 1958 INIT_DELAYED_WORK(&os->os_orphan_scan_work, ocfs2_orphan_scan_work);
1959}
1960 1960
1961void ocfs2_orphan_scan_start(struct ocfs2_super *osb)
1962{
1963 struct ocfs2_orphan_scan *os;
1964
1965 os = &osb->osb_orphan_scan;
1966 os->os_scantime = CURRENT_TIME;
1961 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb)) 1967 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
1962 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE); 1968 atomic_set(&os->os_state, ORPHAN_SCAN_INACTIVE);
1963 else { 1969 else {
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 5432c7f79cc6..2c3222aec622 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -145,6 +145,7 @@ static inline void ocfs2_inode_set_new(struct ocfs2_super *osb,
145 145
146/* Exported only for the journal struct init code in super.c. Do not call. */ 146/* Exported only for the journal struct init code in super.c. Do not call. */
147void ocfs2_orphan_scan_init(struct ocfs2_super *osb); 147void ocfs2_orphan_scan_init(struct ocfs2_super *osb);
148void ocfs2_orphan_scan_start(struct ocfs2_super *osb);
148void ocfs2_orphan_scan_stop(struct ocfs2_super *osb); 149void ocfs2_orphan_scan_stop(struct ocfs2_super *osb);
149void ocfs2_orphan_scan_exit(struct ocfs2_super *osb); 150void ocfs2_orphan_scan_exit(struct ocfs2_super *osb);
150 151
@@ -329,20 +330,27 @@ int ocfs2_journal_dirty(handle_t *handle,
329/* extended attribute block update */ 330/* extended attribute block update */
330#define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1 331#define OCFS2_XATTR_BLOCK_UPDATE_CREDITS 1
331 332
333/* Update of a single quota block */
334#define OCFS2_QUOTA_BLOCK_UPDATE_CREDITS 1
335
332/* global quotafile inode update, data block */ 336/* global quotafile inode update, data block */
333#define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) 337#define OCFS2_QINFO_WRITE_CREDITS (OCFS2_INODE_UPDATE_CREDITS + \
338 OCFS2_QUOTA_BLOCK_UPDATE_CREDITS)
334 339
340#define OCFS2_LOCAL_QINFO_WRITE_CREDITS OCFS2_QUOTA_BLOCK_UPDATE_CREDITS
335/* 341/*
336 * The two writes below can accidentally see global info dirty due 342 * The two writes below can accidentally see global info dirty due
337 * to set_info() quotactl so make them prepared for the writes. 343 * to set_info() quotactl so make them prepared for the writes.
338 */ 344 */
339/* quota data block, global info */ 345/* quota data block, global info */
340/* Write to local quota file */ 346/* Write to local quota file */
341#define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + 1) 347#define OCFS2_QWRITE_CREDITS (OCFS2_QINFO_WRITE_CREDITS + \
348 OCFS2_QUOTA_BLOCK_UPDATE_CREDITS)
342 349
343/* global quota data block, local quota data block, global quota inode, 350/* global quota data block, local quota data block, global quota inode,
344 * global quota info */ 351 * global quota info */
345#define OCFS2_QSYNC_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 3) 352#define OCFS2_QSYNC_CREDITS (OCFS2_QINFO_WRITE_CREDITS + \
353 2 * OCFS2_QUOTA_BLOCK_UPDATE_CREDITS)
346 354
347static inline int ocfs2_quota_trans_credits(struct super_block *sb) 355static inline int ocfs2_quota_trans_credits(struct super_block *sb)
348{ 356{
@@ -355,11 +363,6 @@ static inline int ocfs2_quota_trans_credits(struct super_block *sb)
355 return credits; 363 return credits;
356} 364}
357 365
358/* Number of credits needed for removing quota structure from file */
359int ocfs2_calc_qdel_credits(struct super_block *sb, int type);
360/* Number of credits needed for initialization of new quota structure */
361int ocfs2_calc_qinit_credits(struct super_block *sb, int type);
362
363/* group extend. inode update and last group update. */ 366/* group extend. inode update and last group update. */
364#define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1) 367#define OCFS2_GROUP_EXTEND_CREDITS (OCFS2_INODE_UPDATE_CREDITS + 1)
365 368
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index c9345ebb8493..39e1d5a39505 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -224,10 +224,12 @@ enum ocfs2_mount_options
224 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */ 224 OCFS2_MOUNT_GRPQUOTA = 1 << 10, /* We support group quotas */
225}; 225};
226 226
227#define OCFS2_OSB_SOFT_RO 0x0001 227#define OCFS2_OSB_SOFT_RO 0x0001
228#define OCFS2_OSB_HARD_RO 0x0002 228#define OCFS2_OSB_HARD_RO 0x0002
229#define OCFS2_OSB_ERROR_FS 0x0004 229#define OCFS2_OSB_ERROR_FS 0x0004
230#define OCFS2_DEFAULT_ATIME_QUANTUM 60 230#define OCFS2_OSB_DROP_DENTRY_LOCK_IMMED 0x0008
231
232#define OCFS2_DEFAULT_ATIME_QUANTUM 60
231 233
232struct ocfs2_journal; 234struct ocfs2_journal;
233struct ocfs2_slot_info; 235struct ocfs2_slot_info;
@@ -490,6 +492,18 @@ static inline void ocfs2_set_osb_flag(struct ocfs2_super *osb,
490 spin_unlock(&osb->osb_lock); 492 spin_unlock(&osb->osb_lock);
491} 493}
492 494
495
496static inline unsigned long ocfs2_test_osb_flag(struct ocfs2_super *osb,
497 unsigned long flag)
498{
499 unsigned long ret;
500
501 spin_lock(&osb->osb_lock);
502 ret = osb->osb_flags & flag;
503 spin_unlock(&osb->osb_lock);
504 return ret;
505}
506
493static inline void ocfs2_set_ro_flag(struct ocfs2_super *osb, 507static inline void ocfs2_set_ro_flag(struct ocfs2_super *osb,
494 int hard) 508 int hard)
495{ 509{
diff --git a/fs/ocfs2/ocfs2_lockid.h b/fs/ocfs2/ocfs2_lockid.h
index fcdba091af3d..c212cf5a2bdf 100644
--- a/fs/ocfs2/ocfs2_lockid.h
+++ b/fs/ocfs2/ocfs2_lockid.h
@@ -108,6 +108,7 @@ static char *ocfs2_lock_type_strings[] = {
108 [OCFS2_LOCK_TYPE_OPEN] = "Open", 108 [OCFS2_LOCK_TYPE_OPEN] = "Open",
109 [OCFS2_LOCK_TYPE_FLOCK] = "Flock", 109 [OCFS2_LOCK_TYPE_FLOCK] = "Flock",
110 [OCFS2_LOCK_TYPE_QINFO] = "Quota", 110 [OCFS2_LOCK_TYPE_QINFO] = "Quota",
111 [OCFS2_LOCK_TYPE_NFS_SYNC] = "NFSSync",
111 [OCFS2_LOCK_TYPE_ORPHAN_SCAN] = "OrphanScan", 112 [OCFS2_LOCK_TYPE_ORPHAN_SCAN] = "OrphanScan",
112}; 113};
113 114
diff --git a/fs/ocfs2/quota.h b/fs/ocfs2/quota.h
index 7365e2e08706..3fb96fcd4c81 100644
--- a/fs/ocfs2/quota.h
+++ b/fs/ocfs2/quota.h
@@ -50,7 +50,6 @@ struct ocfs2_mem_dqinfo {
50 unsigned int dqi_chunks; /* Number of chunks in local quota file */ 50 unsigned int dqi_chunks; /* Number of chunks in local quota file */
51 unsigned int dqi_blocks; /* Number of blocks allocated for local quota file */ 51 unsigned int dqi_blocks; /* Number of blocks allocated for local quota file */
52 unsigned int dqi_syncms; /* How often should we sync with other nodes */ 52 unsigned int dqi_syncms; /* How often should we sync with other nodes */
53 unsigned int dqi_syncjiff; /* Precomputed dqi_syncms in jiffies */
54 struct list_head dqi_chunk; /* List of chunks */ 53 struct list_head dqi_chunk; /* List of chunks */
55 struct inode *dqi_gqinode; /* Global quota file inode */ 54 struct inode *dqi_gqinode; /* Global quota file inode */
56 struct ocfs2_lock_res dqi_gqlock; /* Lock protecting quota information structure */ 55 struct ocfs2_lock_res dqi_gqlock; /* Lock protecting quota information structure */
diff --git a/fs/ocfs2/quota_global.c b/fs/ocfs2/quota_global.c
index edfa60cd155c..44f2a5e1d042 100644
--- a/fs/ocfs2/quota_global.c
+++ b/fs/ocfs2/quota_global.c
@@ -23,6 +23,7 @@
23#include "sysfile.h" 23#include "sysfile.h"
24#include "dlmglue.h" 24#include "dlmglue.h"
25#include "uptodate.h" 25#include "uptodate.h"
26#include "super.h"
26#include "quota.h" 27#include "quota.h"
27 28
28static struct workqueue_struct *ocfs2_quota_wq = NULL; 29static struct workqueue_struct *ocfs2_quota_wq = NULL;
@@ -69,6 +70,7 @@ static void ocfs2_global_mem2diskdqb(void *dp, struct dquot *dquot)
69 d->dqb_curspace = cpu_to_le64(m->dqb_curspace); 70 d->dqb_curspace = cpu_to_le64(m->dqb_curspace);
70 d->dqb_btime = cpu_to_le64(m->dqb_btime); 71 d->dqb_btime = cpu_to_le64(m->dqb_btime);
71 d->dqb_itime = cpu_to_le64(m->dqb_itime); 72 d->dqb_itime = cpu_to_le64(m->dqb_itime);
73 d->dqb_pad1 = d->dqb_pad2 = 0;
72} 74}
73 75
74static int ocfs2_global_is_id(void *dp, struct dquot *dquot) 76static int ocfs2_global_is_id(void *dp, struct dquot *dquot)
@@ -113,6 +115,15 @@ int ocfs2_read_quota_block(struct inode *inode, u64 v_block,
113 int rc = 0; 115 int rc = 0;
114 struct buffer_head *tmp = *bh; 116 struct buffer_head *tmp = *bh;
115 117
118 if (i_size_read(inode) >> inode->i_sb->s_blocksize_bits <= v_block) {
119 ocfs2_error(inode->i_sb,
120 "Quota file %llu is probably corrupted! Requested "
121 "to read block %Lu but file has size only %Lu\n",
122 (unsigned long long)OCFS2_I(inode)->ip_blkno,
123 (unsigned long long)v_block,
124 (unsigned long long)i_size_read(inode));
125 return -EIO;
126 }
116 rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0, 127 rc = ocfs2_read_virt_blocks(inode, v_block, 1, &tmp, 0,
117 ocfs2_validate_quota_block); 128 ocfs2_validate_quota_block);
118 if (rc) 129 if (rc)
@@ -211,14 +222,13 @@ ssize_t ocfs2_quota_write(struct super_block *sb, int type,
211 222
212 mutex_lock_nested(&gqinode->i_mutex, I_MUTEX_QUOTA); 223 mutex_lock_nested(&gqinode->i_mutex, I_MUTEX_QUOTA);
213 if (gqinode->i_size < off + len) { 224 if (gqinode->i_size < off + len) {
214 down_write(&OCFS2_I(gqinode)->ip_alloc_sem); 225 loff_t rounded_end =
215 err = ocfs2_extend_no_holes(gqinode, off + len, off); 226 ocfs2_align_bytes_to_blocks(sb, off + len);
216 up_write(&OCFS2_I(gqinode)->ip_alloc_sem); 227
217 if (err < 0) 228 /* Space is already allocated in ocfs2_global_read_dquot() */
218 goto out;
219 err = ocfs2_simple_size_update(gqinode, 229 err = ocfs2_simple_size_update(gqinode,
220 oinfo->dqi_gqi_bh, 230 oinfo->dqi_gqi_bh,
221 off + len); 231 rounded_end);
222 if (err < 0) 232 if (err < 0)
223 goto out; 233 goto out;
224 new = 1; 234 new = 1;
@@ -234,7 +244,7 @@ ssize_t ocfs2_quota_write(struct super_block *sb, int type,
234 } 244 }
235 if (err) { 245 if (err) {
236 mlog_errno(err); 246 mlog_errno(err);
237 return err; 247 goto out;
238 } 248 }
239 lock_buffer(bh); 249 lock_buffer(bh);
240 if (new) 250 if (new)
@@ -342,7 +352,6 @@ int ocfs2_global_read_info(struct super_block *sb, int type)
342 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace); 352 info->dqi_bgrace = le32_to_cpu(dinfo.dqi_bgrace);
343 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace); 353 info->dqi_igrace = le32_to_cpu(dinfo.dqi_igrace);
344 oinfo->dqi_syncms = le32_to_cpu(dinfo.dqi_syncms); 354 oinfo->dqi_syncms = le32_to_cpu(dinfo.dqi_syncms);
345 oinfo->dqi_syncjiff = msecs_to_jiffies(oinfo->dqi_syncms);
346 oinfo->dqi_gi.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks); 355 oinfo->dqi_gi.dqi_blocks = le32_to_cpu(dinfo.dqi_blocks);
347 oinfo->dqi_gi.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk); 356 oinfo->dqi_gi.dqi_free_blk = le32_to_cpu(dinfo.dqi_free_blk);
348 oinfo->dqi_gi.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry); 357 oinfo->dqi_gi.dqi_free_entry = le32_to_cpu(dinfo.dqi_free_entry);
@@ -352,7 +361,7 @@ int ocfs2_global_read_info(struct super_block *sb, int type)
352 oinfo->dqi_gi.dqi_qtree_depth = qtree_depth(&oinfo->dqi_gi); 361 oinfo->dqi_gi.dqi_qtree_depth = qtree_depth(&oinfo->dqi_gi);
353 INIT_DELAYED_WORK(&oinfo->dqi_sync_work, qsync_work_fn); 362 INIT_DELAYED_WORK(&oinfo->dqi_sync_work, qsync_work_fn);
354 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work, 363 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
355 oinfo->dqi_syncjiff); 364 msecs_to_jiffies(oinfo->dqi_syncms));
356 365
357out_err: 366out_err:
358 mlog_exit(status); 367 mlog_exit(status);
@@ -402,13 +411,36 @@ int ocfs2_global_write_info(struct super_block *sb, int type)
402 return err; 411 return err;
403} 412}
404 413
414static int ocfs2_global_qinit_alloc(struct super_block *sb, int type)
415{
416 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
417
418 /*
419 * We may need to allocate tree blocks and a leaf block but not the
420 * root block
421 */
422 return oinfo->dqi_gi.dqi_qtree_depth;
423}
424
425static int ocfs2_calc_global_qinit_credits(struct super_block *sb, int type)
426{
427 /* We modify all the allocated blocks, tree root, and info block */
428 return (ocfs2_global_qinit_alloc(sb, type) + 2) *
429 OCFS2_QUOTA_BLOCK_UPDATE_CREDITS;
430}
431
405/* Read in information from global quota file and acquire a reference to it. 432/* Read in information from global quota file and acquire a reference to it.
406 * dquot_acquire() has already started the transaction and locked quota file */ 433 * dquot_acquire() has already started the transaction and locked quota file */
407int ocfs2_global_read_dquot(struct dquot *dquot) 434int ocfs2_global_read_dquot(struct dquot *dquot)
408{ 435{
409 int err, err2, ex = 0; 436 int err, err2, ex = 0;
410 struct ocfs2_mem_dqinfo *info = 437 struct super_block *sb = dquot->dq_sb;
411 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 438 int type = dquot->dq_type;
439 struct ocfs2_mem_dqinfo *info = sb_dqinfo(sb, type)->dqi_priv;
440 struct ocfs2_super *osb = OCFS2_SB(sb);
441 struct inode *gqinode = info->dqi_gqinode;
442 int need_alloc = ocfs2_global_qinit_alloc(sb, type);
443 handle_t *handle = NULL;
412 444
413 err = ocfs2_qinfo_lock(info, 0); 445 err = ocfs2_qinfo_lock(info, 0);
414 if (err < 0) 446 if (err < 0)
@@ -419,14 +451,33 @@ int ocfs2_global_read_dquot(struct dquot *dquot)
419 OCFS2_DQUOT(dquot)->dq_use_count++; 451 OCFS2_DQUOT(dquot)->dq_use_count++;
420 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace; 452 OCFS2_DQUOT(dquot)->dq_origspace = dquot->dq_dqb.dqb_curspace;
421 OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes; 453 OCFS2_DQUOT(dquot)->dq_originodes = dquot->dq_dqb.dqb_curinodes;
454 ocfs2_qinfo_unlock(info, 0);
455
422 if (!dquot->dq_off) { /* No real quota entry? */ 456 if (!dquot->dq_off) { /* No real quota entry? */
423 /* Upgrade to exclusive lock for allocation */
424 ocfs2_qinfo_unlock(info, 0);
425 err = ocfs2_qinfo_lock(info, 1);
426 if (err < 0)
427 goto out_qlock;
428 ex = 1; 457 ex = 1;
458 /*
459 * Add blocks to quota file before we start a transaction since
460 * locking allocators ranks above a transaction start
461 */
462 WARN_ON(journal_current_handle());
463 down_write(&OCFS2_I(gqinode)->ip_alloc_sem);
464 err = ocfs2_extend_no_holes(gqinode,
465 gqinode->i_size + (need_alloc << sb->s_blocksize_bits),
466 gqinode->i_size);
467 up_write(&OCFS2_I(gqinode)->ip_alloc_sem);
468 if (err < 0)
469 goto out;
429 } 470 }
471
472 handle = ocfs2_start_trans(osb,
473 ocfs2_calc_global_qinit_credits(sb, type));
474 if (IS_ERR(handle)) {
475 err = PTR_ERR(handle);
476 goto out;
477 }
478 err = ocfs2_qinfo_lock(info, ex);
479 if (err < 0)
480 goto out_trans;
430 err = qtree_write_dquot(&info->dqi_gi, dquot); 481 err = qtree_write_dquot(&info->dqi_gi, dquot);
431 if (ex && info_dirty(sb_dqinfo(dquot->dq_sb, dquot->dq_type))) { 482 if (ex && info_dirty(sb_dqinfo(dquot->dq_sb, dquot->dq_type))) {
432 err2 = __ocfs2_global_write_info(dquot->dq_sb, dquot->dq_type); 483 err2 = __ocfs2_global_write_info(dquot->dq_sb, dquot->dq_type);
@@ -438,6 +489,9 @@ out_qlock:
438 ocfs2_qinfo_unlock(info, 1); 489 ocfs2_qinfo_unlock(info, 1);
439 else 490 else
440 ocfs2_qinfo_unlock(info, 0); 491 ocfs2_qinfo_unlock(info, 0);
492out_trans:
493 if (handle)
494 ocfs2_commit_trans(osb, handle);
441out: 495out:
442 if (err < 0) 496 if (err < 0)
443 mlog_errno(err); 497 mlog_errno(err);
@@ -607,7 +661,7 @@ static void qsync_work_fn(struct work_struct *work)
607 661
608 dquot_scan_active(sb, ocfs2_sync_dquot_helper, oinfo->dqi_type); 662 dquot_scan_active(sb, ocfs2_sync_dquot_helper, oinfo->dqi_type);
609 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work, 663 queue_delayed_work(ocfs2_quota_wq, &oinfo->dqi_sync_work,
610 oinfo->dqi_syncjiff); 664 msecs_to_jiffies(oinfo->dqi_syncms));
611} 665}
612 666
613/* 667/*
@@ -635,20 +689,18 @@ out:
635 return status; 689 return status;
636} 690}
637 691
638int ocfs2_calc_qdel_credits(struct super_block *sb, int type) 692static int ocfs2_calc_qdel_credits(struct super_block *sb, int type)
639{ 693{
640 struct ocfs2_mem_dqinfo *oinfo; 694 struct ocfs2_mem_dqinfo *oinfo = sb_dqinfo(sb, type)->dqi_priv;
641 int features[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA, 695 /*
642 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA }; 696 * We modify tree, leaf block, global info, local chunk header,
643 697 * global and local inode; OCFS2_QINFO_WRITE_CREDITS already
644 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, features[type])) 698 * accounts for inode update
645 return 0; 699 */
646 700 return (oinfo->dqi_gi.dqi_qtree_depth + 2) *
647 oinfo = sb_dqinfo(sb, type)->dqi_priv; 701 OCFS2_QUOTA_BLOCK_UPDATE_CREDITS +
648 /* We modify tree, leaf block, global info, local chunk header, 702 OCFS2_QINFO_WRITE_CREDITS +
649 * global and local inode */ 703 OCFS2_INODE_UPDATE_CREDITS;
650 return oinfo->dqi_gi.dqi_qtree_depth + 2 + 1 +
651 2 * OCFS2_INODE_UPDATE_CREDITS;
652} 704}
653 705
654static int ocfs2_release_dquot(struct dquot *dquot) 706static int ocfs2_release_dquot(struct dquot *dquot)
@@ -680,33 +732,10 @@ out:
680 return status; 732 return status;
681} 733}
682 734
683int ocfs2_calc_qinit_credits(struct super_block *sb, int type)
684{
685 struct ocfs2_mem_dqinfo *oinfo;
686 int features[MAXQUOTAS] = { OCFS2_FEATURE_RO_COMPAT_USRQUOTA,
687 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA };
688 struct ocfs2_dinode *lfe, *gfe;
689
690 if (!OCFS2_HAS_RO_COMPAT_FEATURE(sb, features[type]))
691 return 0;
692
693 oinfo = sb_dqinfo(sb, type)->dqi_priv;
694 gfe = (struct ocfs2_dinode *)oinfo->dqi_gqi_bh->b_data;
695 lfe = (struct ocfs2_dinode *)oinfo->dqi_lqi_bh->b_data;
696 /* We can extend local file + global file. In local file we
697 * can modify info, chunk header block and dquot block. In
698 * global file we can modify info, tree and leaf block */
699 return ocfs2_calc_extend_credits(sb, &lfe->id2.i_list, 0) +
700 ocfs2_calc_extend_credits(sb, &gfe->id2.i_list, 0) +
701 3 + oinfo->dqi_gi.dqi_qtree_depth + 2;
702}
703
704static int ocfs2_acquire_dquot(struct dquot *dquot) 735static int ocfs2_acquire_dquot(struct dquot *dquot)
705{ 736{
706 handle_t *handle;
707 struct ocfs2_mem_dqinfo *oinfo = 737 struct ocfs2_mem_dqinfo *oinfo =
708 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv; 738 sb_dqinfo(dquot->dq_sb, dquot->dq_type)->dqi_priv;
709 struct ocfs2_super *osb = OCFS2_SB(dquot->dq_sb);
710 int status = 0; 739 int status = 0;
711 740
712 mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type); 741 mlog_entry("id=%u, type=%d", dquot->dq_id, dquot->dq_type);
@@ -715,16 +744,7 @@ static int ocfs2_acquire_dquot(struct dquot *dquot)
715 status = ocfs2_lock_global_qf(oinfo, 1); 744 status = ocfs2_lock_global_qf(oinfo, 1);
716 if (status < 0) 745 if (status < 0)
717 goto out; 746 goto out;
718 handle = ocfs2_start_trans(osb,
719 ocfs2_calc_qinit_credits(dquot->dq_sb, dquot->dq_type));
720 if (IS_ERR(handle)) {
721 status = PTR_ERR(handle);
722 mlog_errno(status);
723 goto out_ilock;
724 }
725 status = dquot_acquire(dquot); 747 status = dquot_acquire(dquot);
726 ocfs2_commit_trans(osb, handle);
727out_ilock:
728 ocfs2_unlock_global_qf(oinfo, 1); 748 ocfs2_unlock_global_qf(oinfo, 1);
729out: 749out:
730 mlog_exit(status); 750 mlog_exit(status);
diff --git a/fs/ocfs2/quota_local.c b/fs/ocfs2/quota_local.c
index 5a460fa82553..bdb09cb6e1fe 100644
--- a/fs/ocfs2/quota_local.c
+++ b/fs/ocfs2/quota_local.c
@@ -20,6 +20,7 @@
20#include "sysfile.h" 20#include "sysfile.h"
21#include "dlmglue.h" 21#include "dlmglue.h"
22#include "quota.h" 22#include "quota.h"
23#include "uptodate.h"
23 24
24/* Number of local quota structures per block */ 25/* Number of local quota structures per block */
25static inline unsigned int ol_quota_entries_per_block(struct super_block *sb) 26static inline unsigned int ol_quota_entries_per_block(struct super_block *sb)
@@ -100,7 +101,8 @@ static int ocfs2_modify_bh(struct inode *inode, struct buffer_head *bh,
100 handle_t *handle; 101 handle_t *handle;
101 int status; 102 int status;
102 103
103 handle = ocfs2_start_trans(OCFS2_SB(sb), 1); 104 handle = ocfs2_start_trans(OCFS2_SB(sb),
105 OCFS2_QUOTA_BLOCK_UPDATE_CREDITS);
104 if (IS_ERR(handle)) { 106 if (IS_ERR(handle)) {
105 status = PTR_ERR(handle); 107 status = PTR_ERR(handle);
106 mlog_errno(status); 108 mlog_errno(status);
@@ -610,7 +612,8 @@ int ocfs2_finish_quota_recovery(struct ocfs2_super *osb,
610 goto out_bh; 612 goto out_bh;
611 /* Mark quota file as clean if we are recovering quota file of 613 /* Mark quota file as clean if we are recovering quota file of
612 * some other node. */ 614 * some other node. */
613 handle = ocfs2_start_trans(osb, 1); 615 handle = ocfs2_start_trans(osb,
616 OCFS2_LOCAL_QINFO_WRITE_CREDITS);
614 if (IS_ERR(handle)) { 617 if (IS_ERR(handle)) {
615 status = PTR_ERR(handle); 618 status = PTR_ERR(handle);
616 mlog_errno(status); 619 mlog_errno(status);
@@ -940,7 +943,7 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk(
940 struct ocfs2_local_disk_chunk *dchunk; 943 struct ocfs2_local_disk_chunk *dchunk;
941 int status; 944 int status;
942 handle_t *handle; 945 handle_t *handle;
943 struct buffer_head *bh = NULL; 946 struct buffer_head *bh = NULL, *dbh = NULL;
944 u64 p_blkno; 947 u64 p_blkno;
945 948
946 /* We are protected by dqio_sem so no locking needed */ 949 /* We are protected by dqio_sem so no locking needed */
@@ -964,32 +967,35 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk(
964 mlog_errno(status); 967 mlog_errno(status);
965 goto out; 968 goto out;
966 } 969 }
970 /* Local quota info and two new blocks we initialize */
971 handle = ocfs2_start_trans(OCFS2_SB(sb),
972 OCFS2_LOCAL_QINFO_WRITE_CREDITS +
973 2 * OCFS2_QUOTA_BLOCK_UPDATE_CREDITS);
974 if (IS_ERR(handle)) {
975 status = PTR_ERR(handle);
976 mlog_errno(status);
977 goto out;
978 }
967 979
980 /* Initialize chunk header */
968 down_read(&OCFS2_I(lqinode)->ip_alloc_sem); 981 down_read(&OCFS2_I(lqinode)->ip_alloc_sem);
969 status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks, 982 status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks,
970 &p_blkno, NULL, NULL); 983 &p_blkno, NULL, NULL);
971 up_read(&OCFS2_I(lqinode)->ip_alloc_sem); 984 up_read(&OCFS2_I(lqinode)->ip_alloc_sem);
972 if (status < 0) { 985 if (status < 0) {
973 mlog_errno(status); 986 mlog_errno(status);
974 goto out; 987 goto out_trans;
975 } 988 }
976 bh = sb_getblk(sb, p_blkno); 989 bh = sb_getblk(sb, p_blkno);
977 if (!bh) { 990 if (!bh) {
978 status = -ENOMEM; 991 status = -ENOMEM;
979 mlog_errno(status); 992 mlog_errno(status);
980 goto out; 993 goto out_trans;
981 } 994 }
982 dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data; 995 dchunk = (struct ocfs2_local_disk_chunk *)bh->b_data;
983 996 ocfs2_set_new_buffer_uptodate(lqinode, bh);
984 handle = ocfs2_start_trans(OCFS2_SB(sb), 2);
985 if (IS_ERR(handle)) {
986 status = PTR_ERR(handle);
987 mlog_errno(status);
988 goto out;
989 }
990
991 status = ocfs2_journal_access_dq(handle, lqinode, bh, 997 status = ocfs2_journal_access_dq(handle, lqinode, bh,
992 OCFS2_JOURNAL_ACCESS_WRITE); 998 OCFS2_JOURNAL_ACCESS_CREATE);
993 if (status < 0) { 999 if (status < 0) {
994 mlog_errno(status); 1000 mlog_errno(status);
995 goto out_trans; 1001 goto out_trans;
@@ -999,7 +1005,6 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk(
999 memset(dchunk->dqc_bitmap, 0, 1005 memset(dchunk->dqc_bitmap, 0,
1000 sb->s_blocksize - sizeof(struct ocfs2_local_disk_chunk) - 1006 sb->s_blocksize - sizeof(struct ocfs2_local_disk_chunk) -
1001 OCFS2_QBLK_RESERVED_SPACE); 1007 OCFS2_QBLK_RESERVED_SPACE);
1002 set_buffer_uptodate(bh);
1003 unlock_buffer(bh); 1008 unlock_buffer(bh);
1004 status = ocfs2_journal_dirty(handle, bh); 1009 status = ocfs2_journal_dirty(handle, bh);
1005 if (status < 0) { 1010 if (status < 0) {
@@ -1007,6 +1012,38 @@ static struct ocfs2_quota_chunk *ocfs2_local_quota_add_chunk(
1007 goto out_trans; 1012 goto out_trans;
1008 } 1013 }
1009 1014
1015 /* Initialize new block with structures */
1016 down_read(&OCFS2_I(lqinode)->ip_alloc_sem);
1017 status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks + 1,
1018 &p_blkno, NULL, NULL);
1019 up_read(&OCFS2_I(lqinode)->ip_alloc_sem);
1020 if (status < 0) {
1021 mlog_errno(status);
1022 goto out_trans;
1023 }
1024 dbh = sb_getblk(sb, p_blkno);
1025 if (!dbh) {
1026 status = -ENOMEM;
1027 mlog_errno(status);
1028 goto out_trans;
1029 }
1030 ocfs2_set_new_buffer_uptodate(lqinode, dbh);
1031 status = ocfs2_journal_access_dq(handle, lqinode, dbh,
1032 OCFS2_JOURNAL_ACCESS_CREATE);
1033 if (status < 0) {
1034 mlog_errno(status);
1035 goto out_trans;
1036 }
1037 lock_buffer(dbh);
1038 memset(dbh->b_data, 0, sb->s_blocksize - OCFS2_QBLK_RESERVED_SPACE);
1039 unlock_buffer(dbh);
1040 status = ocfs2_journal_dirty(handle, dbh);
1041 if (status < 0) {
1042 mlog_errno(status);
1043 goto out_trans;
1044 }
1045
1046 /* Update local quotafile info */
1010 oinfo->dqi_blocks += 2; 1047 oinfo->dqi_blocks += 2;
1011 oinfo->dqi_chunks++; 1048 oinfo->dqi_chunks++;
1012 status = ocfs2_local_write_info(sb, type); 1049 status = ocfs2_local_write_info(sb, type);
@@ -1031,6 +1068,7 @@ out_trans:
1031 ocfs2_commit_trans(OCFS2_SB(sb), handle); 1068 ocfs2_commit_trans(OCFS2_SB(sb), handle);
1032out: 1069out:
1033 brelse(bh); 1070 brelse(bh);
1071 brelse(dbh);
1034 kmem_cache_free(ocfs2_qf_chunk_cachep, chunk); 1072 kmem_cache_free(ocfs2_qf_chunk_cachep, chunk);
1035 return ERR_PTR(status); 1073 return ERR_PTR(status);
1036} 1074}
@@ -1048,6 +1086,8 @@ static struct ocfs2_quota_chunk *ocfs2_extend_local_quota_file(
1048 struct ocfs2_local_disk_chunk *dchunk; 1086 struct ocfs2_local_disk_chunk *dchunk;
1049 int epb = ol_quota_entries_per_block(sb); 1087 int epb = ol_quota_entries_per_block(sb);
1050 unsigned int chunk_blocks; 1088 unsigned int chunk_blocks;
1089 struct buffer_head *bh;
1090 u64 p_blkno;
1051 int status; 1091 int status;
1052 handle_t *handle; 1092 handle_t *handle;
1053 1093
@@ -1075,12 +1115,49 @@ static struct ocfs2_quota_chunk *ocfs2_extend_local_quota_file(
1075 mlog_errno(status); 1115 mlog_errno(status);
1076 goto out; 1116 goto out;
1077 } 1117 }
1078 handle = ocfs2_start_trans(OCFS2_SB(sb), 2); 1118
1119 /* Get buffer from the just added block */
1120 down_read(&OCFS2_I(lqinode)->ip_alloc_sem);
1121 status = ocfs2_extent_map_get_blocks(lqinode, oinfo->dqi_blocks,
1122 &p_blkno, NULL, NULL);
1123 up_read(&OCFS2_I(lqinode)->ip_alloc_sem);
1124 if (status < 0) {
1125 mlog_errno(status);
1126 goto out;
1127 }
1128 bh = sb_getblk(sb, p_blkno);
1129 if (!bh) {
1130 status = -ENOMEM;
1131 mlog_errno(status);
1132 goto out;
1133 }
1134 ocfs2_set_new_buffer_uptodate(lqinode, bh);
1135
1136 /* Local quota info, chunk header and the new block we initialize */
1137 handle = ocfs2_start_trans(OCFS2_SB(sb),
1138 OCFS2_LOCAL_QINFO_WRITE_CREDITS +
1139 2 * OCFS2_QUOTA_BLOCK_UPDATE_CREDITS);
1079 if (IS_ERR(handle)) { 1140 if (IS_ERR(handle)) {
1080 status = PTR_ERR(handle); 1141 status = PTR_ERR(handle);
1081 mlog_errno(status); 1142 mlog_errno(status);
1082 goto out; 1143 goto out;
1083 } 1144 }
1145 /* Zero created block */
1146 status = ocfs2_journal_access_dq(handle, lqinode, bh,
1147 OCFS2_JOURNAL_ACCESS_CREATE);
1148 if (status < 0) {
1149 mlog_errno(status);
1150 goto out_trans;
1151 }
1152 lock_buffer(bh);
1153 memset(bh->b_data, 0, sb->s_blocksize);
1154 unlock_buffer(bh);
1155 status = ocfs2_journal_dirty(handle, bh);
1156 if (status < 0) {
1157 mlog_errno(status);
1158 goto out_trans;
1159 }
1160 /* Update chunk header */
1084 status = ocfs2_journal_access_dq(handle, lqinode, chunk->qc_headerbh, 1161 status = ocfs2_journal_access_dq(handle, lqinode, chunk->qc_headerbh,
1085 OCFS2_JOURNAL_ACCESS_WRITE); 1162 OCFS2_JOURNAL_ACCESS_WRITE);
1086 if (status < 0) { 1163 if (status < 0) {
@@ -1097,6 +1174,7 @@ static struct ocfs2_quota_chunk *ocfs2_extend_local_quota_file(
1097 mlog_errno(status); 1174 mlog_errno(status);
1098 goto out_trans; 1175 goto out_trans;
1099 } 1176 }
1177 /* Update file header */
1100 oinfo->dqi_blocks++; 1178 oinfo->dqi_blocks++;
1101 status = ocfs2_local_write_info(sb, type); 1179 status = ocfs2_local_write_info(sb, type);
1102 if (status < 0) { 1180 if (status < 0) {
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c
index 3f661376a2de..e49c41050264 100644
--- a/fs/ocfs2/stack_o2cb.c
+++ b/fs/ocfs2/stack_o2cb.c
@@ -17,6 +17,7 @@
17 * General Public License for more details. 17 * General Public License for more details.
18 */ 18 */
19 19
20#include <linux/kernel.h>
20#include <linux/crc32.h> 21#include <linux/crc32.h>
21#include <linux/module.h> 22#include <linux/module.h>
22 23
@@ -153,7 +154,7 @@ static int status_map[] = {
153 154
154static int dlm_status_to_errno(enum dlm_status status) 155static int dlm_status_to_errno(enum dlm_status status)
155{ 156{
156 BUG_ON(status > (sizeof(status_map) / sizeof(status_map[0]))); 157 BUG_ON(status < 0 || status >= ARRAY_SIZE(status_map));
157 158
158 return status_map[status]; 159 return status_map[status];
159} 160}
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 7efb349fb9bd..a3f8871d21fd 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -777,6 +777,7 @@ static int ocfs2_sb_probe(struct super_block *sb,
777 } 777 }
778 di = (struct ocfs2_dinode *) (*bh)->b_data; 778 di = (struct ocfs2_dinode *) (*bh)->b_data;
779 memset(stats, 0, sizeof(struct ocfs2_blockcheck_stats)); 779 memset(stats, 0, sizeof(struct ocfs2_blockcheck_stats));
780 spin_lock_init(&stats->b_lock);
780 status = ocfs2_verify_volume(di, *bh, blksize, stats); 781 status = ocfs2_verify_volume(di, *bh, blksize, stats);
781 if (status >= 0) 782 if (status >= 0)
782 goto bail; 783 goto bail;
@@ -1182,7 +1183,7 @@ static int ocfs2_fill_super(struct super_block *sb, void *data, int silent)
1182 wake_up(&osb->osb_mount_event); 1183 wake_up(&osb->osb_mount_event);
1183 1184
1184 /* Start this when the mount is almost sure of being successful */ 1185 /* Start this when the mount is almost sure of being successful */
1185 ocfs2_orphan_scan_init(osb); 1186 ocfs2_orphan_scan_start(osb);
1186 1187
1187 mlog_exit(status); 1188 mlog_exit(status);
1188 return status; 1189 return status;
@@ -1213,14 +1214,31 @@ static int ocfs2_get_sb(struct file_system_type *fs_type,
1213 mnt); 1214 mnt);
1214} 1215}
1215 1216
1217static void ocfs2_kill_sb(struct super_block *sb)
1218{
1219 struct ocfs2_super *osb = OCFS2_SB(sb);
1220
1221 /* Failed mount? */
1222 if (!osb || atomic_read(&osb->vol_state) == VOLUME_DISABLED)
1223 goto out;
1224
1225 /* Prevent further queueing of inode drop events */
1226 spin_lock(&dentry_list_lock);
1227 ocfs2_set_osb_flag(osb, OCFS2_OSB_DROP_DENTRY_LOCK_IMMED);
1228 spin_unlock(&dentry_list_lock);
1229 /* Wait for work to finish and/or remove it */
1230 cancel_work_sync(&osb->dentry_lock_work);
1231out:
1232 kill_block_super(sb);
1233}
1234
1216static struct file_system_type ocfs2_fs_type = { 1235static struct file_system_type ocfs2_fs_type = {
1217 .owner = THIS_MODULE, 1236 .owner = THIS_MODULE,
1218 .name = "ocfs2", 1237 .name = "ocfs2",
1219 .get_sb = ocfs2_get_sb, /* is this called when we mount 1238 .get_sb = ocfs2_get_sb, /* is this called when we mount
1220 * the fs? */ 1239 * the fs? */
1221 .kill_sb = kill_block_super, /* set to the generic one 1240 .kill_sb = ocfs2_kill_sb,
1222 * right now, but do we 1241
1223 * need to change that? */
1224 .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE, 1242 .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE,
1225 .next = NULL 1243 .next = NULL
1226}; 1244};
@@ -1819,6 +1837,12 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
1819 1837
1820 debugfs_remove(osb->osb_ctxt); 1838 debugfs_remove(osb->osb_ctxt);
1821 1839
1840 /*
1841 * Flush inode dropping work queue so that deletes are
1842 * performed while the filesystem is still working
1843 */
1844 ocfs2_drop_all_dl_inodes(osb);
1845
1822 /* Orphan scan should be stopped as early as possible */ 1846 /* Orphan scan should be stopped as early as possible */
1823 ocfs2_orphan_scan_stop(osb); 1847 ocfs2_orphan_scan_stop(osb);
1824 1848
@@ -1981,6 +2005,8 @@ static int ocfs2_initialize_super(struct super_block *sb,
1981 snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u", 2005 snprintf(osb->dev_str, sizeof(osb->dev_str), "%u,%u",
1982 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev)); 2006 MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev));
1983 2007
2008 ocfs2_orphan_scan_init(osb);
2009
1984 status = ocfs2_recovery_init(osb); 2010 status = ocfs2_recovery_init(osb);
1985 if (status) { 2011 if (status) {
1986 mlog(ML_ERROR, "Unable to initialize recovery state\n"); 2012 mlog(ML_ERROR, "Unable to initialize recovery state\n");
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index ba320e250747..d1a27cda984f 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -1052,7 +1052,8 @@ static int ocfs2_xattr_block_get(struct inode *inode,
1052 struct ocfs2_xattr_block *xb; 1052 struct ocfs2_xattr_block *xb;
1053 struct ocfs2_xattr_value_root *xv; 1053 struct ocfs2_xattr_value_root *xv;
1054 size_t size; 1054 size_t size;
1055 int ret = -ENODATA, name_offset, name_len, block_off, i; 1055 int ret = -ENODATA, name_offset, name_len, i;
1056 int uninitialized_var(block_off);
1056 1057
1057 xs->bucket = ocfs2_xattr_bucket_new(inode); 1058 xs->bucket = ocfs2_xattr_bucket_new(inode);
1058 if (!xs->bucket) { 1059 if (!xs->bucket) {
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 3ce5ae9e3d2d..6f742f6658a9 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -234,23 +234,20 @@ static int check_mem_permission(struct task_struct *task)
234 234
235struct mm_struct *mm_for_maps(struct task_struct *task) 235struct mm_struct *mm_for_maps(struct task_struct *task)
236{ 236{
237 struct mm_struct *mm = get_task_mm(task); 237 struct mm_struct *mm;
238 if (!mm) 238
239 if (mutex_lock_killable(&task->cred_guard_mutex))
239 return NULL; 240 return NULL;
240 down_read(&mm->mmap_sem); 241
241 task_lock(task); 242 mm = get_task_mm(task);
242 if (task->mm != mm) 243 if (mm && mm != current->mm &&
243 goto out; 244 !ptrace_may_access(task, PTRACE_MODE_READ)) {
244 if (task->mm != current->mm && 245 mmput(mm);
245 __ptrace_may_access(task, PTRACE_MODE_READ) < 0) 246 mm = NULL;
246 goto out; 247 }
247 task_unlock(task); 248 mutex_unlock(&task->cred_guard_mutex);
249
248 return mm; 250 return mm;
249out:
250 task_unlock(task);
251 up_read(&mm->mmap_sem);
252 mmput(mm);
253 return NULL;
254} 251}
255 252
256static int proc_pid_cmdline(struct task_struct *task, char * buffer) 253static int proc_pid_cmdline(struct task_struct *task, char * buffer)
@@ -1006,12 +1003,7 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf,
1006 1003
1007 if (!task) 1004 if (!task)
1008 return -ESRCH; 1005 return -ESRCH;
1009 task_lock(task); 1006 oom_adjust = task->oomkilladj;
1010 if (task->mm)
1011 oom_adjust = task->mm->oom_adj;
1012 else
1013 oom_adjust = OOM_DISABLE;
1014 task_unlock(task);
1015 put_task_struct(task); 1007 put_task_struct(task);
1016 1008
1017 len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust); 1009 len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust);
@@ -1040,19 +1032,11 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
1040 task = get_proc_task(file->f_path.dentry->d_inode); 1032 task = get_proc_task(file->f_path.dentry->d_inode);
1041 if (!task) 1033 if (!task)
1042 return -ESRCH; 1034 return -ESRCH;
1043 task_lock(task); 1035 if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) {
1044 if (!task->mm) {
1045 task_unlock(task);
1046 put_task_struct(task);
1047 return -EINVAL;
1048 }
1049 if (oom_adjust < task->mm->oom_adj && !capable(CAP_SYS_RESOURCE)) {
1050 task_unlock(task);
1051 put_task_struct(task); 1036 put_task_struct(task);
1052 return -EACCES; 1037 return -EACCES;
1053 } 1038 }
1054 task->mm->oom_adj = oom_adjust; 1039 task->oomkilladj = oom_adjust;
1055 task_unlock(task);
1056 put_task_struct(task); 1040 put_task_struct(task);
1057 if (end - buffer == 0) 1041 if (end - buffer == 0)
1058 return -EIO; 1042 return -EIO;
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 6f61b7cc32e0..9bd8be1d235c 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -119,6 +119,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
119 mm = mm_for_maps(priv->task); 119 mm = mm_for_maps(priv->task);
120 if (!mm) 120 if (!mm)
121 return NULL; 121 return NULL;
122 down_read(&mm->mmap_sem);
122 123
123 tail_vma = get_gate_vma(priv->task); 124 tail_vma = get_gate_vma(priv->task);
124 priv->tail_vma = tail_vma; 125 priv->tail_vma = tail_vma;
diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
index 64a72e2e7650..8f5c05d3dbd3 100644
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -189,6 +189,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
189 priv->task = NULL; 189 priv->task = NULL;
190 return NULL; 190 return NULL;
191 } 191 }
192 down_read(&mm->mmap_sem);
192 193
193 /* start from the Nth VMA */ 194 /* start from the Nth VMA */
194 for (p = rb_first(&mm->mm_rb); p; p = rb_next(p)) 195 for (p = rb_first(&mm->mm_rb); p; p = rb_next(p))
diff --git a/fs/select.c b/fs/select.c
index d870237e42c7..8084834e123e 100644
--- a/fs/select.c
+++ b/fs/select.c
@@ -110,6 +110,7 @@ void poll_initwait(struct poll_wqueues *pwq)
110{ 110{
111 init_poll_funcptr(&pwq->pt, __pollwait); 111 init_poll_funcptr(&pwq->pt, __pollwait);
112 pwq->polling_task = current; 112 pwq->polling_task = current;
113 pwq->triggered = 0;
113 pwq->error = 0; 114 pwq->error = 0;
114 pwq->table = NULL; 115 pwq->table = NULL;
115 pwq->inline_index = 0; 116 pwq->inline_index = 0;
diff --git a/fs/xfs/linux-2.6/xfs_buf.c b/fs/xfs/linux-2.6/xfs_buf.c
index 0c93c7ef3d18..965df1227d64 100644
--- a/fs/xfs/linux-2.6/xfs_buf.c
+++ b/fs/xfs/linux-2.6/xfs_buf.c
@@ -770,7 +770,7 @@ xfs_buf_associate_memory(
770 bp->b_pages = NULL; 770 bp->b_pages = NULL;
771 bp->b_addr = mem; 771 bp->b_addr = mem;
772 772
773 rval = _xfs_buf_get_pages(bp, page_count, 0); 773 rval = _xfs_buf_get_pages(bp, page_count, XBF_DONT_BLOCK);
774 if (rval) 774 if (rval)
775 return rval; 775 return rval;
776 776
diff --git a/fs/xfs/linux-2.6/xfs_sync.c b/fs/xfs/linux-2.6/xfs_sync.c
index b619d6b8ca43..98ef624d9baf 100644
--- a/fs/xfs/linux-2.6/xfs_sync.c
+++ b/fs/xfs/linux-2.6/xfs_sync.c
@@ -708,6 +708,16 @@ xfs_reclaim_inode(
708 return 0; 708 return 0;
709} 709}
710 710
711void
712__xfs_inode_set_reclaim_tag(
713 struct xfs_perag *pag,
714 struct xfs_inode *ip)
715{
716 radix_tree_tag_set(&pag->pag_ici_root,
717 XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino),
718 XFS_ICI_RECLAIM_TAG);
719}
720
711/* 721/*
712 * We set the inode flag atomically with the radix tree tag. 722 * We set the inode flag atomically with the radix tree tag.
713 * Once we get tag lookups on the radix tree, this inode flag 723 * Once we get tag lookups on the radix tree, this inode flag
@@ -722,8 +732,7 @@ xfs_inode_set_reclaim_tag(
722 732
723 read_lock(&pag->pag_ici_lock); 733 read_lock(&pag->pag_ici_lock);
724 spin_lock(&ip->i_flags_lock); 734 spin_lock(&ip->i_flags_lock);
725 radix_tree_tag_set(&pag->pag_ici_root, 735 __xfs_inode_set_reclaim_tag(pag, ip);
726 XFS_INO_TO_AGINO(mp, ip->i_ino), XFS_ICI_RECLAIM_TAG);
727 __xfs_iflags_set(ip, XFS_IRECLAIMABLE); 736 __xfs_iflags_set(ip, XFS_IRECLAIMABLE);
728 spin_unlock(&ip->i_flags_lock); 737 spin_unlock(&ip->i_flags_lock);
729 read_unlock(&pag->pag_ici_lock); 738 read_unlock(&pag->pag_ici_lock);
diff --git a/fs/xfs/linux-2.6/xfs_sync.h b/fs/xfs/linux-2.6/xfs_sync.h
index 2a10301c99c7..59120602588a 100644
--- a/fs/xfs/linux-2.6/xfs_sync.h
+++ b/fs/xfs/linux-2.6/xfs_sync.h
@@ -48,6 +48,7 @@ int xfs_reclaim_inode(struct xfs_inode *ip, int locked, int sync_mode);
48int xfs_reclaim_inodes(struct xfs_mount *mp, int mode); 48int xfs_reclaim_inodes(struct xfs_mount *mp, int mode);
49 49
50void xfs_inode_set_reclaim_tag(struct xfs_inode *ip); 50void xfs_inode_set_reclaim_tag(struct xfs_inode *ip);
51void __xfs_inode_set_reclaim_tag(struct xfs_perag *pag, struct xfs_inode *ip);
51void xfs_inode_clear_reclaim_tag(struct xfs_inode *ip); 52void xfs_inode_clear_reclaim_tag(struct xfs_inode *ip);
52void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp, struct xfs_perag *pag, 53void __xfs_inode_clear_reclaim_tag(struct xfs_mount *mp, struct xfs_perag *pag,
53 struct xfs_inode *ip); 54 struct xfs_inode *ip);
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index db15feb906ff..4ece1906bd41 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -2010,7 +2010,9 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
2010 dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock); 2010 dblkno = XFS_FSB_TO_DADDR(mp, map[i].br_startblock);
2011 blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount); 2011 blkcnt = XFS_FSB_TO_BB(mp, map[i].br_blockcount);
2012 error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno, 2012 error = xfs_read_buf(mp, mp->m_ddev_targp, dblkno,
2013 blkcnt, XFS_BUF_LOCK, &bp); 2013 blkcnt,
2014 XFS_BUF_LOCK | XBF_DONT_BLOCK,
2015 &bp);
2014 if (error) 2016 if (error)
2015 return(error); 2017 return(error);
2016 2018
@@ -2141,8 +2143,8 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
2141 dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock), 2143 dblkno = XFS_FSB_TO_DADDR(mp, map.br_startblock),
2142 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount); 2144 blkcnt = XFS_FSB_TO_BB(mp, map.br_blockcount);
2143 2145
2144 bp = xfs_buf_get_flags(mp->m_ddev_targp, dblkno, 2146 bp = xfs_buf_get_flags(mp->m_ddev_targp, dblkno, blkcnt,
2145 blkcnt, XFS_BUF_LOCK); 2147 XFS_BUF_LOCK | XBF_DONT_BLOCK);
2146 ASSERT(bp); 2148 ASSERT(bp);
2147 ASSERT(!XFS_BUF_GETERROR(bp)); 2149 ASSERT(!XFS_BUF_GETERROR(bp));
2148 2150
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 7928b9983c1d..8ee5b5a76a2a 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -6009,7 +6009,7 @@ xfs_getbmap(
6009 */ 6009 */
6010 error = ENOMEM; 6010 error = ENOMEM;
6011 subnex = 16; 6011 subnex = 16;
6012 map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL); 6012 map = kmem_alloc(subnex * sizeof(*map), KM_MAYFAIL | KM_NOFS);
6013 if (!map) 6013 if (!map)
6014 goto out_unlock_ilock; 6014 goto out_unlock_ilock;
6015 6015
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c
index e9df99574829..26717388acf5 100644
--- a/fs/xfs/xfs_btree.c
+++ b/fs/xfs/xfs_btree.c
@@ -120,8 +120,8 @@ xfs_btree_check_sblock(
120 XFS_RANDOM_BTREE_CHECK_SBLOCK))) { 120 XFS_RANDOM_BTREE_CHECK_SBLOCK))) {
121 if (bp) 121 if (bp)
122 xfs_buftrace("SBTREE ERROR", bp); 122 xfs_buftrace("SBTREE ERROR", bp);
123 XFS_ERROR_REPORT("xfs_btree_check_sblock", XFS_ERRLEVEL_LOW, 123 XFS_CORRUPTION_ERROR("xfs_btree_check_sblock",
124 cur->bc_mp); 124 XFS_ERRLEVEL_LOW, cur->bc_mp, block);
125 return XFS_ERROR(EFSCORRUPTED); 125 return XFS_ERROR(EFSCORRUPTED);
126 } 126 }
127 return 0; 127 return 0;
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 9ff6e57a5075..2847bbc1c534 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -2201,7 +2201,7 @@ kmem_zone_t *xfs_dabuf_zone; /* dabuf zone */
2201xfs_da_state_t * 2201xfs_da_state_t *
2202xfs_da_state_alloc(void) 2202xfs_da_state_alloc(void)
2203{ 2203{
2204 return kmem_zone_zalloc(xfs_da_state_zone, KM_SLEEP); 2204 return kmem_zone_zalloc(xfs_da_state_zone, KM_NOFS);
2205} 2205}
2206 2206
2207/* 2207/*
@@ -2261,9 +2261,9 @@ xfs_da_buf_make(int nbuf, xfs_buf_t **bps, inst_t *ra)
2261 int off; 2261 int off;
2262 2262
2263 if (nbuf == 1) 2263 if (nbuf == 1)
2264 dabuf = kmem_zone_alloc(xfs_dabuf_zone, KM_SLEEP); 2264 dabuf = kmem_zone_alloc(xfs_dabuf_zone, KM_NOFS);
2265 else 2265 else
2266 dabuf = kmem_alloc(XFS_DA_BUF_SIZE(nbuf), KM_SLEEP); 2266 dabuf = kmem_alloc(XFS_DA_BUF_SIZE(nbuf), KM_NOFS);
2267 dabuf->dirty = 0; 2267 dabuf->dirty = 0;
2268#ifdef XFS_DABUF_DEBUG 2268#ifdef XFS_DABUF_DEBUG
2269 dabuf->ra = ra; 2269 dabuf->ra = ra;
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index c657bec6d951..bb1d58eb3982 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -256,7 +256,7 @@ xfs_dir_cilookup_result(
256 !(args->op_flags & XFS_DA_OP_CILOOKUP)) 256 !(args->op_flags & XFS_DA_OP_CILOOKUP))
257 return EEXIST; 257 return EEXIST;
258 258
259 args->value = kmem_alloc(len, KM_MAYFAIL); 259 args->value = kmem_alloc(len, KM_NOFS | KM_MAYFAIL);
260 if (!args->value) 260 if (!args->value)
261 return ENOMEM; 261 return ENOMEM;
262 262
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index cbd451bb4848..2d0b3e1da9e6 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -167,17 +167,25 @@ xfs_growfs_data_private(
167 new = nb - mp->m_sb.sb_dblocks; 167 new = nb - mp->m_sb.sb_dblocks;
168 oagcount = mp->m_sb.sb_agcount; 168 oagcount = mp->m_sb.sb_agcount;
169 if (nagcount > oagcount) { 169 if (nagcount > oagcount) {
170 void *new_perag, *old_perag;
171
170 xfs_filestream_flush(mp); 172 xfs_filestream_flush(mp);
173
174 new_perag = kmem_zalloc(sizeof(xfs_perag_t) * nagcount,
175 KM_MAYFAIL);
176 if (!new_perag)
177 return XFS_ERROR(ENOMEM);
178
171 down_write(&mp->m_peraglock); 179 down_write(&mp->m_peraglock);
172 mp->m_perag = kmem_realloc(mp->m_perag, 180 memcpy(new_perag, mp->m_perag, sizeof(xfs_perag_t) * oagcount);
173 sizeof(xfs_perag_t) * nagcount, 181 old_perag = mp->m_perag;
174 sizeof(xfs_perag_t) * oagcount, 182 mp->m_perag = new_perag;
175 KM_SLEEP); 183
176 memset(&mp->m_perag[oagcount], 0,
177 (nagcount - oagcount) * sizeof(xfs_perag_t));
178 mp->m_flags |= XFS_MOUNT_32BITINODES; 184 mp->m_flags |= XFS_MOUNT_32BITINODES;
179 nagimax = xfs_initialize_perag(mp, nagcount); 185 nagimax = xfs_initialize_perag(mp, nagcount);
180 up_write(&mp->m_peraglock); 186 up_write(&mp->m_peraglock);
187
188 kmem_free(old_perag);
181 } 189 }
182 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); 190 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS);
183 tp->t_flags |= XFS_TRANS_RESERVE; 191 tp->t_flags |= XFS_TRANS_RESERVE;
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index 5fcec6f020a7..ecbf8b4d2e2e 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -64,6 +64,10 @@ xfs_inode_alloc(
64 ip = kmem_zone_alloc(xfs_inode_zone, KM_SLEEP); 64 ip = kmem_zone_alloc(xfs_inode_zone, KM_SLEEP);
65 if (!ip) 65 if (!ip)
66 return NULL; 66 return NULL;
67 if (inode_init_always(mp->m_super, VFS_I(ip))) {
68 kmem_zone_free(xfs_inode_zone, ip);
69 return NULL;
70 }
67 71
68 ASSERT(atomic_read(&ip->i_iocount) == 0); 72 ASSERT(atomic_read(&ip->i_iocount) == 0);
69 ASSERT(atomic_read(&ip->i_pincount) == 0); 73 ASSERT(atomic_read(&ip->i_pincount) == 0);
@@ -105,17 +109,6 @@ xfs_inode_alloc(
105#ifdef XFS_DIR2_TRACE 109#ifdef XFS_DIR2_TRACE
106 ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS); 110 ip->i_dir_trace = ktrace_alloc(XFS_DIR2_KTRACE_SIZE, KM_NOFS);
107#endif 111#endif
108 /*
109 * Now initialise the VFS inode. We do this after the xfs_inode
110 * initialisation as internal failures will result in ->destroy_inode
111 * being called and that will pass down through the reclaim path and
112 * free the XFS inode. This path requires the XFS inode to already be
113 * initialised. Hence if this call fails, the xfs_inode has already
114 * been freed and we should not reference it at all in the error
115 * handling.
116 */
117 if (!inode_init_always(mp->m_super, VFS_I(ip)))
118 return NULL;
119 112
120 /* prevent anyone from using this yet */ 113 /* prevent anyone from using this yet */
121 VFS_I(ip)->i_state = I_NEW|I_LOCK; 114 VFS_I(ip)->i_state = I_NEW|I_LOCK;
@@ -123,6 +116,71 @@ xfs_inode_alloc(
123 return ip; 116 return ip;
124} 117}
125 118
119STATIC void
120xfs_inode_free(
121 struct xfs_inode *ip)
122{
123 switch (ip->i_d.di_mode & S_IFMT) {
124 case S_IFREG:
125 case S_IFDIR:
126 case S_IFLNK:
127 xfs_idestroy_fork(ip, XFS_DATA_FORK);
128 break;
129 }
130
131 if (ip->i_afp)
132 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
133
134#ifdef XFS_INODE_TRACE
135 ktrace_free(ip->i_trace);
136#endif
137#ifdef XFS_BMAP_TRACE
138 ktrace_free(ip->i_xtrace);
139#endif
140#ifdef XFS_BTREE_TRACE
141 ktrace_free(ip->i_btrace);
142#endif
143#ifdef XFS_RW_TRACE
144 ktrace_free(ip->i_rwtrace);
145#endif
146#ifdef XFS_ILOCK_TRACE
147 ktrace_free(ip->i_lock_trace);
148#endif
149#ifdef XFS_DIR2_TRACE
150 ktrace_free(ip->i_dir_trace);
151#endif
152
153 if (ip->i_itemp) {
154 /*
155 * Only if we are shutting down the fs will we see an
156 * inode still in the AIL. If it is there, we should remove
157 * it to prevent a use-after-free from occurring.
158 */
159 xfs_log_item_t *lip = &ip->i_itemp->ili_item;
160 struct xfs_ail *ailp = lip->li_ailp;
161
162 ASSERT(((lip->li_flags & XFS_LI_IN_AIL) == 0) ||
163 XFS_FORCED_SHUTDOWN(ip->i_mount));
164 if (lip->li_flags & XFS_LI_IN_AIL) {
165 spin_lock(&ailp->xa_lock);
166 if (lip->li_flags & XFS_LI_IN_AIL)
167 xfs_trans_ail_delete(ailp, lip);
168 else
169 spin_unlock(&ailp->xa_lock);
170 }
171 xfs_inode_item_destroy(ip);
172 ip->i_itemp = NULL;
173 }
174
175 /* asserts to verify all state is correct here */
176 ASSERT(atomic_read(&ip->i_iocount) == 0);
177 ASSERT(atomic_read(&ip->i_pincount) == 0);
178 ASSERT(!spin_is_locked(&ip->i_flags_lock));
179 ASSERT(completion_done(&ip->i_flush));
180
181 kmem_zone_free(xfs_inode_zone, ip);
182}
183
126/* 184/*
127 * Check the validity of the inode we just found it the cache 185 * Check the validity of the inode we just found it the cache
128 */ 186 */
@@ -133,80 +191,82 @@ xfs_iget_cache_hit(
133 int flags, 191 int flags,
134 int lock_flags) __releases(pag->pag_ici_lock) 192 int lock_flags) __releases(pag->pag_ici_lock)
135{ 193{
194 struct inode *inode = VFS_I(ip);
136 struct xfs_mount *mp = ip->i_mount; 195 struct xfs_mount *mp = ip->i_mount;
137 int error = EAGAIN; 196 int error;
197
198 spin_lock(&ip->i_flags_lock);
138 199
139 /* 200 /*
140 * If INEW is set this inode is being set up 201 * If we are racing with another cache hit that is currently
141 * If IRECLAIM is set this inode is being torn down 202 * instantiating this inode or currently recycling it out of
142 * Pause and try again. 203 * reclaimabe state, wait for the initialisation to complete
204 * before continuing.
205 *
206 * XXX(hch): eventually we should do something equivalent to
207 * wait_on_inode to wait for these flags to be cleared
208 * instead of polling for it.
143 */ 209 */
144 if (xfs_iflags_test(ip, (XFS_INEW|XFS_IRECLAIM))) { 210 if (ip->i_flags & (XFS_INEW|XFS_IRECLAIM)) {
145 XFS_STATS_INC(xs_ig_frecycle); 211 XFS_STATS_INC(xs_ig_frecycle);
212 error = EAGAIN;
146 goto out_error; 213 goto out_error;
147 } 214 }
148 215
149 /* If IRECLAIMABLE is set, we've torn down the vfs inode part */ 216 /*
150 if (xfs_iflags_test(ip, XFS_IRECLAIMABLE)) { 217 * If lookup is racing with unlink return an error immediately.
151 218 */
152 /* 219 if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) {
153 * If lookup is racing with unlink, then we should return an 220 error = ENOENT;
154 * error immediately so we don't remove it from the reclaim 221 goto out_error;
155 * list and potentially leak the inode. 222 }
156 */
157 if ((ip->i_d.di_mode == 0) && !(flags & XFS_IGET_CREATE)) {
158 error = ENOENT;
159 goto out_error;
160 }
161 223
224 /*
225 * If IRECLAIMABLE is set, we've torn down the VFS inode already.
226 * Need to carefully get it back into useable state.
227 */
228 if (ip->i_flags & XFS_IRECLAIMABLE) {
162 xfs_itrace_exit_tag(ip, "xfs_iget.alloc"); 229 xfs_itrace_exit_tag(ip, "xfs_iget.alloc");
163 230
164 /* 231 /*
165 * We need to re-initialise the VFS inode as it has been 232 * We need to set XFS_INEW atomically with clearing the
166 * 'freed' by the VFS. Do this here so we can deal with 233 * reclaimable tag so that we do have an indicator of the
167 * errors cleanly, then tag it so it can be set up correctly 234 * inode still being initialized.
168 * later.
169 */ 235 */
170 if (!inode_init_always(mp->m_super, VFS_I(ip))) { 236 ip->i_flags |= XFS_INEW;
171 error = ENOMEM; 237 ip->i_flags &= ~XFS_IRECLAIMABLE;
172 goto out_error; 238 __xfs_inode_clear_reclaim_tag(mp, pag, ip);
173 }
174 239
175 /* 240 spin_unlock(&ip->i_flags_lock);
176 * We must set the XFS_INEW flag before clearing the 241 read_unlock(&pag->pag_ici_lock);
177 * XFS_IRECLAIMABLE flag so that if a racing lookup does
178 * not find the XFS_IRECLAIMABLE above but has the igrab()
179 * below succeed we can safely check XFS_INEW to detect
180 * that this inode is still being initialised.
181 */
182 xfs_iflags_set(ip, XFS_INEW);
183 xfs_iflags_clear(ip, XFS_IRECLAIMABLE);
184 242
185 /* clear the radix tree reclaim flag as well. */ 243 error = -inode_init_always(mp->m_super, inode);
186 __xfs_inode_clear_reclaim_tag(mp, pag, ip); 244 if (error) {
187 } else if (!igrab(VFS_I(ip))) { 245 /*
246 * Re-initializing the inode failed, and we are in deep
247 * trouble. Try to re-add it to the reclaim list.
248 */
249 read_lock(&pag->pag_ici_lock);
250 spin_lock(&ip->i_flags_lock);
251
252 ip->i_flags &= ~XFS_INEW;
253 ip->i_flags |= XFS_IRECLAIMABLE;
254 __xfs_inode_set_reclaim_tag(pag, ip);
255 goto out_error;
256 }
257 inode->i_state = I_LOCK|I_NEW;
258 } else {
188 /* If the VFS inode is being torn down, pause and try again. */ 259 /* If the VFS inode is being torn down, pause and try again. */
189 XFS_STATS_INC(xs_ig_frecycle); 260 if (!igrab(inode)) {
190 goto out_error; 261 error = EAGAIN;
191 } else if (xfs_iflags_test(ip, XFS_INEW)) { 262 goto out_error;
192 /* 263 }
193 * We are racing with another cache hit that is
194 * currently recycling this inode out of the XFS_IRECLAIMABLE
195 * state. Wait for the initialisation to complete before
196 * continuing.
197 */
198 wait_on_inode(VFS_I(ip));
199 }
200 264
201 if (ip->i_d.di_mode == 0 && !(flags & XFS_IGET_CREATE)) { 265 /* We've got a live one. */
202 error = ENOENT; 266 spin_unlock(&ip->i_flags_lock);
203 iput(VFS_I(ip)); 267 read_unlock(&pag->pag_ici_lock);
204 goto out_error;
205 } 268 }
206 269
207 /* We've got a live one. */
208 read_unlock(&pag->pag_ici_lock);
209
210 if (lock_flags != 0) 270 if (lock_flags != 0)
211 xfs_ilock(ip, lock_flags); 271 xfs_ilock(ip, lock_flags);
212 272
@@ -216,6 +276,7 @@ xfs_iget_cache_hit(
216 return 0; 276 return 0;
217 277
218out_error: 278out_error:
279 spin_unlock(&ip->i_flags_lock);
219 read_unlock(&pag->pag_ici_lock); 280 read_unlock(&pag->pag_ici_lock);
220 return error; 281 return error;
221} 282}
@@ -299,7 +360,8 @@ out_preload_end:
299 if (lock_flags) 360 if (lock_flags)
300 xfs_iunlock(ip, lock_flags); 361 xfs_iunlock(ip, lock_flags);
301out_destroy: 362out_destroy:
302 xfs_destroy_inode(ip); 363 __destroy_inode(VFS_I(ip));
364 xfs_inode_free(ip);
303 return error; 365 return error;
304} 366}
305 367
@@ -504,62 +566,7 @@ xfs_ireclaim(
504 xfs_qm_dqdetach(ip); 566 xfs_qm_dqdetach(ip);
505 xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL); 567 xfs_iunlock(ip, XFS_ILOCK_EXCL | XFS_IOLOCK_EXCL);
506 568
507 switch (ip->i_d.di_mode & S_IFMT) { 569 xfs_inode_free(ip);
508 case S_IFREG:
509 case S_IFDIR:
510 case S_IFLNK:
511 xfs_idestroy_fork(ip, XFS_DATA_FORK);
512 break;
513 }
514
515 if (ip->i_afp)
516 xfs_idestroy_fork(ip, XFS_ATTR_FORK);
517
518#ifdef XFS_INODE_TRACE
519 ktrace_free(ip->i_trace);
520#endif
521#ifdef XFS_BMAP_TRACE
522 ktrace_free(ip->i_xtrace);
523#endif
524#ifdef XFS_BTREE_TRACE
525 ktrace_free(ip->i_btrace);
526#endif
527#ifdef XFS_RW_TRACE
528 ktrace_free(ip->i_rwtrace);
529#endif
530#ifdef XFS_ILOCK_TRACE
531 ktrace_free(ip->i_lock_trace);
532#endif
533#ifdef XFS_DIR2_TRACE
534 ktrace_free(ip->i_dir_trace);
535#endif
536 if (ip->i_itemp) {
537 /*
538 * Only if we are shutting down the fs will we see an
539 * inode still in the AIL. If it is there, we should remove
540 * it to prevent a use-after-free from occurring.
541 */
542 xfs_log_item_t *lip = &ip->i_itemp->ili_item;
543 struct xfs_ail *ailp = lip->li_ailp;
544
545 ASSERT(((lip->li_flags & XFS_LI_IN_AIL) == 0) ||
546 XFS_FORCED_SHUTDOWN(ip->i_mount));
547 if (lip->li_flags & XFS_LI_IN_AIL) {
548 spin_lock(&ailp->xa_lock);
549 if (lip->li_flags & XFS_LI_IN_AIL)
550 xfs_trans_ail_delete(ailp, lip);
551 else
552 spin_unlock(&ailp->xa_lock);
553 }
554 xfs_inode_item_destroy(ip);
555 ip->i_itemp = NULL;
556 }
557 /* asserts to verify all state is correct here */
558 ASSERT(atomic_read(&ip->i_iocount) == 0);
559 ASSERT(atomic_read(&ip->i_pincount) == 0);
560 ASSERT(!spin_is_locked(&ip->i_flags_lock));
561 ASSERT(completion_done(&ip->i_flush));
562 kmem_zone_free(xfs_inode_zone, ip);
563} 570}
564 571
565/* 572/*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 1f22d65fed0a..da428b3fe0f5 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -343,6 +343,16 @@ xfs_iformat(
343 return XFS_ERROR(EFSCORRUPTED); 343 return XFS_ERROR(EFSCORRUPTED);
344 } 344 }
345 345
346 if (unlikely((ip->i_d.di_flags & XFS_DIFLAG_REALTIME) &&
347 !ip->i_mount->m_rtdev_targp)) {
348 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
349 "corrupt dinode %Lu, has realtime flag set.",
350 ip->i_ino);
351 XFS_CORRUPTION_ERROR("xfs_iformat(realtime)",
352 XFS_ERRLEVEL_LOW, ip->i_mount, dip);
353 return XFS_ERROR(EFSCORRUPTED);
354 }
355
346 switch (ip->i_d.di_mode & S_IFMT) { 356 switch (ip->i_d.di_mode & S_IFMT) {
347 case S_IFIFO: 357 case S_IFIFO:
348 case S_IFCHR: 358 case S_IFCHR:
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 1804f866a71d..65f24a3cc992 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -310,23 +310,6 @@ static inline struct inode *VFS_I(struct xfs_inode *ip)
310} 310}
311 311
312/* 312/*
313 * Get rid of a partially initialized inode.
314 *
315 * We have to go through destroy_inode to make sure allocations
316 * from init_inode_always like the security data are undone.
317 *
318 * We mark the inode bad so that it takes the short cut in
319 * the reclaim path instead of going through the flush path
320 * which doesn't make sense for an inode that has never seen the
321 * light of day.
322 */
323static inline void xfs_destroy_inode(struct xfs_inode *ip)
324{
325 make_bad_inode(VFS_I(ip));
326 return destroy_inode(VFS_I(ip));
327}
328
329/*
330 * i_flags helper functions 313 * i_flags helper functions
331 */ 314 */
332static inline void 315static inline void
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 3750f04ede0b..9dbdff3ea484 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -3180,7 +3180,7 @@ try_again:
3180STATIC void 3180STATIC void
3181xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog) 3181xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog)
3182{ 3182{
3183 ASSERT(spin_is_locked(&log->l_icloglock)); 3183 assert_spin_locked(&log->l_icloglock);
3184 3184
3185 if (iclog->ic_state == XLOG_STATE_ACTIVE) { 3185 if (iclog->ic_state == XLOG_STATE_ACTIVE) {
3186 xlog_state_switch_iclogs(log, iclog, 0); 3186 xlog_state_switch_iclogs(log, iclog, 0);
diff --git a/fs/xfs/xfs_vnodeops.c b/fs/xfs/xfs_vnodeops.c
index c4eca5ed5dab..492d75bae2bf 100644
--- a/fs/xfs/xfs_vnodeops.c
+++ b/fs/xfs/xfs_vnodeops.c
@@ -538,7 +538,9 @@ xfs_readlink_bmap(
538 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock); 538 d = XFS_FSB_TO_DADDR(mp, mval[n].br_startblock);
539 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount); 539 byte_cnt = XFS_FSB_TO_B(mp, mval[n].br_blockcount);
540 540
541 bp = xfs_buf_read(mp->m_ddev_targp, d, BTOBB(byte_cnt), 0); 541 bp = xfs_buf_read_flags(mp->m_ddev_targp, d, BTOBB(byte_cnt),
542 XBF_LOCK | XBF_MAPPED |
543 XBF_DONT_BLOCK);
542 error = XFS_BUF_GETERROR(bp); 544 error = XFS_BUF_GETERROR(bp);
543 if (error) { 545 if (error) {
544 xfs_ioerror_alert("xfs_readlink", 546 xfs_ioerror_alert("xfs_readlink",
diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h
index 3e798593b17b..ab0b85cf21f3 100644
--- a/include/acpi/acpiosxf.h
+++ b/include/acpi/acpiosxf.h
@@ -242,6 +242,10 @@ acpi_os_derive_pci_id(acpi_handle rhandle,
242acpi_status acpi_os_validate_interface(char *interface); 242acpi_status acpi_os_validate_interface(char *interface);
243acpi_status acpi_osi_invalidate(char* interface); 243acpi_status acpi_osi_invalidate(char* interface);
244 244
245acpi_status
246acpi_os_validate_address(u8 space_id, acpi_physical_address address,
247 acpi_size length, char *name);
248
245u64 acpi_os_get_timer(void); 249u64 acpi_os_get_timer(void);
246 250
247acpi_status acpi_os_signal(u32 function, void *info); 251acpi_status acpi_os_signal(u32 function, void *info);
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index baf1e0a9a7ee..740ac3ad8fd0 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -174,7 +174,7 @@ struct acpi_processor_throttling {
174 cpumask_var_t shared_cpu_map; 174 cpumask_var_t shared_cpu_map;
175 int (*acpi_processor_get_throttling) (struct acpi_processor * pr); 175 int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
176 int (*acpi_processor_set_throttling) (struct acpi_processor * pr, 176 int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
177 int state); 177 int state, bool force);
178 178
179 u32 address; 179 u32 address;
180 u8 duty_offset; 180 u8 duty_offset;
@@ -321,7 +321,8 @@ static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
321/* in processor_throttling.c */ 321/* in processor_throttling.c */
322int acpi_processor_tstate_has_changed(struct acpi_processor *pr); 322int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
323int acpi_processor_get_throttling_info(struct acpi_processor *pr); 323int acpi_processor_get_throttling_info(struct acpi_processor *pr);
324extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state); 324extern int acpi_processor_set_throttling(struct acpi_processor *pr,
325 int state, bool force);
325extern const struct file_operations acpi_processor_throttling_fops; 326extern const struct file_operations acpi_processor_throttling_fops;
326extern void acpi_processor_throttling_init(void); 327extern void acpi_processor_throttling_init(void);
327/* in processor_idle.c */ 328/* in processor_idle.c */
diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h
index 7174818c2c13..853508499d20 100644
--- a/include/drm/drm_pciids.h
+++ b/include/drm/drm_pciids.h
@@ -257,9 +257,12 @@
257 {0x1002, 0x940F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \ 257 {0x1002, 0x940F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_R600|RADEON_NEW_MEMMAP}, \
258 {0x1002, 0x94A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 258 {0x1002, 0x94A0, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
259 {0x1002, 0x94A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 259 {0x1002, 0x94A1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
260 {0x1002, 0x94A3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
260 {0x1002, 0x94B1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \ 261 {0x1002, 0x94B1, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
261 {0x1002, 0x94B3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \ 262 {0x1002, 0x94B3, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
263 {0x1002, 0x94B4, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
262 {0x1002, 0x94B5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \ 264 {0x1002, 0x94B5, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_NEW_MEMMAP}, \
265 {0x1002, 0x94B9, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV740|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
263 {0x1002, 0x9440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ 266 {0x1002, 0x9440, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
264 {0x1002, 0x9441, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ 267 {0x1002, 0x9441, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
265 {0x1002, 0x9442, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \ 268 {0x1002, 0x9442, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV770|RADEON_NEW_MEMMAP}, \
@@ -288,6 +291,7 @@
288 {0x1002, 0x948F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ 291 {0x1002, 0x948F, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
289 {0x1002, 0x9490, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ 292 {0x1002, 0x9490, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
290 {0x1002, 0x9491, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 293 {0x1002, 0x9491, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
294 {0x1002, 0x9495, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
291 {0x1002, 0x9498, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ 295 {0x1002, 0x9498, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
292 {0x1002, 0x949C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ 296 {0x1002, 0x949C, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
293 {0x1002, 0x949E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \ 297 {0x1002, 0x949E, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV730|RADEON_NEW_MEMMAP}, \
@@ -325,6 +329,7 @@
325 {0x1002, 0x9552, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 329 {0x1002, 0x9552, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
326 {0x1002, 0x9553, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 330 {0x1002, 0x9553, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
327 {0x1002, 0x9555, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 331 {0x1002, 0x9555, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
332 {0x1002, 0x9557, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV710|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
328 {0x1002, 0x9580, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \ 333 {0x1002, 0x9580, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_NEW_MEMMAP}, \
329 {0x1002, 0x9581, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 334 {0x1002, 0x9581, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
330 {0x1002, 0x9583, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ 335 {0x1002, 0x9583, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RV630|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \
@@ -365,6 +370,11 @@
365 {0x1002, 0x9614, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 370 {0x1002, 0x9614, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
366 {0x1002, 0x9615, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 371 {0x1002, 0x9615, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
367 {0x1002, 0x9616, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \ 372 {0x1002, 0x9616, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS780|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
373 {0x1002, 0x9710, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
374 {0x1002, 0x9711, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
375 {0x1002, 0x9712, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
376 {0x1002, 0x9713, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
377 {0x1002, 0x9714, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_RS880|RADEON_NEW_MEMMAP|RADEON_IS_IGP}, \
368 {0, 0, 0} 378 {0, 0, 0}
369 379
370#define r128_PCI_IDS \ 380#define r128_PCI_IDS \
diff --git a/include/drm/radeon_drm.h b/include/drm/radeon_drm.h
index af4b4826997e..2ba61e18fc8b 100644
--- a/include/drm/radeon_drm.h
+++ b/include/drm/radeon_drm.h
@@ -508,6 +508,7 @@ typedef struct {
508#define DRM_RADEON_INFO 0x27 508#define DRM_RADEON_INFO 0x27
509#define DRM_RADEON_GEM_SET_TILING 0x28 509#define DRM_RADEON_GEM_SET_TILING 0x28
510#define DRM_RADEON_GEM_GET_TILING 0x29 510#define DRM_RADEON_GEM_GET_TILING 0x29
511#define DRM_RADEON_GEM_BUSY 0x2a
511 512
512#define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t) 513#define DRM_IOCTL_RADEON_CP_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_RADEON_CP_INIT, drm_radeon_init_t)
513#define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START) 514#define DRM_IOCTL_RADEON_CP_START DRM_IO( DRM_COMMAND_BASE + DRM_RADEON_CP_START)
@@ -548,6 +549,7 @@ typedef struct {
548#define DRM_IOCTL_RADEON_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INFO, struct drm_radeon_info) 549#define DRM_IOCTL_RADEON_INFO DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_INFO, struct drm_radeon_info)
549#define DRM_IOCTL_RADEON_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling) 550#define DRM_IOCTL_RADEON_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_SET_TILING, struct drm_radeon_gem_set_tiling)
550#define DRM_IOCTL_RADEON_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling) 551#define DRM_IOCTL_RADEON_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_GET_TILING, struct drm_radeon_gem_get_tiling)
552#define DRM_IOCTL_RADEON_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_RADEON_GEM_BUSY, struct drm_radeon_gem_busy)
551 553
552typedef struct drm_radeon_init { 554typedef struct drm_radeon_init {
553 enum { 555 enum {
@@ -707,6 +709,7 @@ typedef struct drm_radeon_indirect {
707#define RADEON_PARAM_FB_LOCATION 14 /* FB location */ 709#define RADEON_PARAM_FB_LOCATION 14 /* FB location */
708#define RADEON_PARAM_NUM_GB_PIPES 15 /* num GB pipes */ 710#define RADEON_PARAM_NUM_GB_PIPES 15 /* num GB pipes */
709#define RADEON_PARAM_DEVICE_ID 16 711#define RADEON_PARAM_DEVICE_ID 16
712#define RADEON_PARAM_NUM_Z_PIPES 17 /* num Z pipes */
710 713
711typedef struct drm_radeon_getparam { 714typedef struct drm_radeon_getparam {
712 int param; 715 int param;
@@ -838,7 +841,7 @@ struct drm_radeon_gem_wait_idle {
838 841
839struct drm_radeon_gem_busy { 842struct drm_radeon_gem_busy {
840 uint32_t handle; 843 uint32_t handle;
841 uint32_t busy; 844 uint32_t domain;
842}; 845};
843 846
844struct drm_radeon_gem_pread { 847struct drm_radeon_gem_pread {
@@ -895,6 +898,7 @@ struct drm_radeon_cs {
895 898
896#define RADEON_INFO_DEVICE_ID 0x00 899#define RADEON_INFO_DEVICE_ID 0x00
897#define RADEON_INFO_NUM_GB_PIPES 0x01 900#define RADEON_INFO_NUM_GB_PIPES 0x01
901#define RADEON_INFO_NUM_Z_PIPES 0x02
898 902
899struct drm_radeon_info { 903struct drm_radeon_info {
900 uint32_t request; 904 uint32_t request;
diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 2878811c6134..756d78b8c1c5 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -94,13 +94,13 @@ extern void __bitmap_shift_right(unsigned long *dst,
94 const unsigned long *src, int shift, int bits); 94 const unsigned long *src, int shift, int bits);
95extern void __bitmap_shift_left(unsigned long *dst, 95extern void __bitmap_shift_left(unsigned long *dst,
96 const unsigned long *src, int shift, int bits); 96 const unsigned long *src, int shift, int bits);
97extern void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 97extern int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
98 const unsigned long *bitmap2, int bits); 98 const unsigned long *bitmap2, int bits);
99extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1, 99extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
100 const unsigned long *bitmap2, int bits); 100 const unsigned long *bitmap2, int bits);
101extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1, 101extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
102 const unsigned long *bitmap2, int bits); 102 const unsigned long *bitmap2, int bits);
103extern void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 103extern int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
104 const unsigned long *bitmap2, int bits); 104 const unsigned long *bitmap2, int bits);
105extern int __bitmap_intersects(const unsigned long *bitmap1, 105extern int __bitmap_intersects(const unsigned long *bitmap1,
106 const unsigned long *bitmap2, int bits); 106 const unsigned long *bitmap2, int bits);
@@ -171,13 +171,12 @@ static inline void bitmap_copy(unsigned long *dst, const unsigned long *src,
171 } 171 }
172} 172}
173 173
174static inline void bitmap_and(unsigned long *dst, const unsigned long *src1, 174static inline int bitmap_and(unsigned long *dst, const unsigned long *src1,
175 const unsigned long *src2, int nbits) 175 const unsigned long *src2, int nbits)
176{ 176{
177 if (small_const_nbits(nbits)) 177 if (small_const_nbits(nbits))
178 *dst = *src1 & *src2; 178 return (*dst = *src1 & *src2) != 0;
179 else 179 return __bitmap_and(dst, src1, src2, nbits);
180 __bitmap_and(dst, src1, src2, nbits);
181} 180}
182 181
183static inline void bitmap_or(unsigned long *dst, const unsigned long *src1, 182static inline void bitmap_or(unsigned long *dst, const unsigned long *src1,
@@ -198,13 +197,12 @@ static inline void bitmap_xor(unsigned long *dst, const unsigned long *src1,
198 __bitmap_xor(dst, src1, src2, nbits); 197 __bitmap_xor(dst, src1, src2, nbits);
199} 198}
200 199
201static inline void bitmap_andnot(unsigned long *dst, const unsigned long *src1, 200static inline int bitmap_andnot(unsigned long *dst, const unsigned long *src1,
202 const unsigned long *src2, int nbits) 201 const unsigned long *src2, int nbits)
203{ 202{
204 if (small_const_nbits(nbits)) 203 if (small_const_nbits(nbits))
205 *dst = *src1 & ~(*src2); 204 return (*dst = *src1 & ~(*src2)) != 0;
206 else 205 return __bitmap_andnot(dst, src1, src2, nbits);
207 __bitmap_andnot(dst, src1, src2, nbits);
208} 206}
209 207
210static inline void bitmap_complement(unsigned long *dst, const unsigned long *src, 208static inline void bitmap_complement(unsigned long *dst, const unsigned long *src,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index e7cb5dbf6c26..69103e053c92 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -913,6 +913,7 @@ extern void blk_queue_logical_block_size(struct request_queue *, unsigned short)
913extern void blk_queue_physical_block_size(struct request_queue *, unsigned short); 913extern void blk_queue_physical_block_size(struct request_queue *, unsigned short);
914extern void blk_queue_alignment_offset(struct request_queue *q, 914extern void blk_queue_alignment_offset(struct request_queue *q,
915 unsigned int alignment); 915 unsigned int alignment);
916extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min);
916extern void blk_queue_io_min(struct request_queue *q, unsigned int min); 917extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
917extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt); 918extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
918extern void blk_set_default_limits(struct queue_limits *lim); 919extern void blk_set_default_limits(struct queue_limits *lim);
diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index c5ac87ca7bc6..796df12091b7 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -43,10 +43,10 @@
43 * int cpu_isset(cpu, mask) true iff bit 'cpu' set in mask 43 * int cpu_isset(cpu, mask) true iff bit 'cpu' set in mask
44 * int cpu_test_and_set(cpu, mask) test and set bit 'cpu' in mask 44 * int cpu_test_and_set(cpu, mask) test and set bit 'cpu' in mask
45 * 45 *
46 * void cpus_and(dst, src1, src2) dst = src1 & src2 [intersection] 46 * int cpus_and(dst, src1, src2) dst = src1 & src2 [intersection]
47 * void cpus_or(dst, src1, src2) dst = src1 | src2 [union] 47 * void cpus_or(dst, src1, src2) dst = src1 | src2 [union]
48 * void cpus_xor(dst, src1, src2) dst = src1 ^ src2 48 * void cpus_xor(dst, src1, src2) dst = src1 ^ src2
49 * void cpus_andnot(dst, src1, src2) dst = src1 & ~src2 49 * int cpus_andnot(dst, src1, src2) dst = src1 & ~src2
50 * void cpus_complement(dst, src) dst = ~src 50 * void cpus_complement(dst, src) dst = ~src
51 * 51 *
52 * int cpus_equal(mask1, mask2) Does mask1 == mask2? 52 * int cpus_equal(mask1, mask2) Does mask1 == mask2?
@@ -179,10 +179,10 @@ static inline int __cpu_test_and_set(int cpu, cpumask_t *addr)
179} 179}
180 180
181#define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS) 181#define cpus_and(dst, src1, src2) __cpus_and(&(dst), &(src1), &(src2), NR_CPUS)
182static inline void __cpus_and(cpumask_t *dstp, const cpumask_t *src1p, 182static inline int __cpus_and(cpumask_t *dstp, const cpumask_t *src1p,
183 const cpumask_t *src2p, int nbits) 183 const cpumask_t *src2p, int nbits)
184{ 184{
185 bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits); 185 return bitmap_and(dstp->bits, src1p->bits, src2p->bits, nbits);
186} 186}
187 187
188#define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS) 188#define cpus_or(dst, src1, src2) __cpus_or(&(dst), &(src1), &(src2), NR_CPUS)
@@ -201,10 +201,10 @@ static inline void __cpus_xor(cpumask_t *dstp, const cpumask_t *src1p,
201 201
202#define cpus_andnot(dst, src1, src2) \ 202#define cpus_andnot(dst, src1, src2) \
203 __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS) 203 __cpus_andnot(&(dst), &(src1), &(src2), NR_CPUS)
204static inline void __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p, 204static inline int __cpus_andnot(cpumask_t *dstp, const cpumask_t *src1p,
205 const cpumask_t *src2p, int nbits) 205 const cpumask_t *src2p, int nbits)
206{ 206{
207 bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits); 207 return bitmap_andnot(dstp->bits, src1p->bits, src2p->bits, nbits);
208} 208}
209 209
210#define cpus_complement(dst, src) __cpus_complement(&(dst), &(src), NR_CPUS) 210#define cpus_complement(dst, src) __cpus_complement(&(dst), &(src), NR_CPUS)
@@ -738,11 +738,11 @@ static inline void cpumask_clear(struct cpumask *dstp)
738 * @src1p: the first input 738 * @src1p: the first input
739 * @src2p: the second input 739 * @src2p: the second input
740 */ 740 */
741static inline void cpumask_and(struct cpumask *dstp, 741static inline int cpumask_and(struct cpumask *dstp,
742 const struct cpumask *src1p, 742 const struct cpumask *src1p,
743 const struct cpumask *src2p) 743 const struct cpumask *src2p)
744{ 744{
745 bitmap_and(cpumask_bits(dstp), cpumask_bits(src1p), 745 return bitmap_and(cpumask_bits(dstp), cpumask_bits(src1p),
746 cpumask_bits(src2p), nr_cpumask_bits); 746 cpumask_bits(src2p), nr_cpumask_bits);
747} 747}
748 748
@@ -779,11 +779,11 @@ static inline void cpumask_xor(struct cpumask *dstp,
779 * @src1p: the first input 779 * @src1p: the first input
780 * @src2p: the second input 780 * @src2p: the second input
781 */ 781 */
782static inline void cpumask_andnot(struct cpumask *dstp, 782static inline int cpumask_andnot(struct cpumask *dstp,
783 const struct cpumask *src1p, 783 const struct cpumask *src1p,
784 const struct cpumask *src2p) 784 const struct cpumask *src2p)
785{ 785{
786 bitmap_andnot(cpumask_bits(dstp), cpumask_bits(src1p), 786 return bitmap_andnot(cpumask_bits(dstp), cpumask_bits(src1p),
787 cpumask_bits(src2p), nr_cpumask_bits); 787 cpumask_bits(src2p), nr_cpumask_bits);
788} 788}
789 789
diff --git a/include/linux/decompress/generic.h b/include/linux/decompress/generic.h
index 6dfb856327bb..0c7111a55a1a 100644
--- a/include/linux/decompress/generic.h
+++ b/include/linux/decompress/generic.h
@@ -1,31 +1,37 @@
1#ifndef DECOMPRESS_GENERIC_H 1#ifndef DECOMPRESS_GENERIC_H
2#define DECOMPRESS_GENERIC_H 2#define DECOMPRESS_GENERIC_H
3 3
4/* Minimal chunksize to be read.
5 *Bzip2 prefers at least 4096
6 *Lzma prefers 0x10000 */
7#define COMPR_IOBUF_SIZE 4096
8
9typedef int (*decompress_fn) (unsigned char *inbuf, int len, 4typedef int (*decompress_fn) (unsigned char *inbuf, int len,
10 int(*fill)(void*, unsigned int), 5 int(*fill)(void*, unsigned int),
11 int(*writebb)(void*, unsigned int), 6 int(*flush)(void*, unsigned int),
12 unsigned char *output, 7 unsigned char *outbuf,
13 int *posp, 8 int *posp,
14 void(*error)(char *x)); 9 void(*error)(char *x));
15 10
16/* inbuf - input buffer 11/* inbuf - input buffer
17 *len - len of pre-read data in inbuf 12 *len - len of pre-read data in inbuf
18 *fill - function to fill inbuf if empty 13 *fill - function to fill inbuf when empty
19 *writebb - function to write out outbug 14 *flush - function to write out outbuf
15 *outbuf - output buffer
20 *posp - if non-null, input position (number of bytes read) will be 16 *posp - if non-null, input position (number of bytes read) will be
21 * returned here 17 * returned here
22 * 18 *
23 *If len != 0, the inbuf is initialized (with as much data), and fill 19 *If len != 0, inbuf should contain all the necessary input data, and fill
24 *should not be called 20 *should be NULL
25 *If len = 0, the inbuf is allocated, but empty. Its size is IOBUF_SIZE 21 *If len = 0, inbuf can be NULL, in which case the decompressor will allocate
26 *fill should be called (repeatedly...) to read data, at most IOBUF_SIZE 22 *the input buffer. If inbuf != NULL it must be at least XXX_IOBUF_SIZE bytes.
23 *fill will be called (repeatedly...) to read data, at most XXX_IOBUF_SIZE
24 *bytes should be read per call. Replace XXX with the appropriate decompressor
25 *name, i.e. LZMA_IOBUF_SIZE.
26 *
27 *If flush = NULL, outbuf must be large enough to buffer all the expected
28 *output. If flush != NULL, the output buffer will be allocated by the
29 *decompressor (outbuf = NULL), and the flush function will be called to
30 *flush the output buffer at the appropriate time (decompressor and stream
31 *dependent).
27 */ 32 */
28 33
34
29/* Utility routine to detect the decompression method */ 35/* Utility routine to detect the decompression method */
30decompress_fn decompress_method(const unsigned char *inbuf, int len, 36decompress_fn decompress_method(const unsigned char *inbuf, int len,
31 const char **name); 37 const char **name);
diff --git a/include/linux/flex_array.h b/include/linux/flex_array.h
index 23c1ec79a31b..45ff18491514 100644
--- a/include/linux/flex_array.h
+++ b/include/linux/flex_array.h
@@ -21,7 +21,7 @@ struct flex_array {
21 struct { 21 struct {
22 int element_size; 22 int element_size;
23 int total_nr_elements; 23 int total_nr_elements;
24 struct flex_array_part *parts[0]; 24 struct flex_array_part *parts[];
25 }; 25 };
26 /* 26 /*
27 * This little trick makes sure that 27 * This little trick makes sure that
@@ -36,12 +36,14 @@ struct flex_array {
36 .total_nr_elements = (total), \ 36 .total_nr_elements = (total), \
37} } } 37} } }
38 38
39struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags); 39struct flex_array *flex_array_alloc(int element_size, unsigned int total,
40int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags); 40 gfp_t flags);
41int flex_array_prealloc(struct flex_array *fa, unsigned int start,
42 unsigned int end, gfp_t flags);
41void flex_array_free(struct flex_array *fa); 43void flex_array_free(struct flex_array *fa);
42void flex_array_free_parts(struct flex_array *fa); 44void flex_array_free_parts(struct flex_array *fa);
43int flex_array_put(struct flex_array *fa, int element_nr, void *src, 45int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
44 gfp_t flags); 46 gfp_t flags);
45void *flex_array_get(struct flex_array *fa, int element_nr); 47void *flex_array_get(struct flex_array *fa, unsigned int element_nr);
46 48
47#endif /* _FLEX_ARRAY_H */ 49#endif /* _FLEX_ARRAY_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index a36ffa5a77a4..73e9b643e455 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2123,7 +2123,7 @@ extern struct file *do_filp_open(int dfd, const char *pathname,
2123 int open_flag, int mode, int acc_mode); 2123 int open_flag, int mode, int acc_mode);
2124extern int may_open(struct path *, int, int); 2124extern int may_open(struct path *, int, int);
2125 2125
2126extern int kernel_read(struct file *, unsigned long, char *, unsigned long); 2126extern int kernel_read(struct file *, loff_t, char *, unsigned long);
2127extern struct file * open_exec(const char *); 2127extern struct file * open_exec(const char *);
2128 2128
2129/* fs/dcache.c -- generic fs support functions */ 2129/* fs/dcache.c -- generic fs support functions */
@@ -2137,7 +2137,7 @@ extern loff_t default_llseek(struct file *file, loff_t offset, int origin);
2137 2137
2138extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin); 2138extern loff_t vfs_llseek(struct file *file, loff_t offset, int origin);
2139 2139
2140extern struct inode * inode_init_always(struct super_block *, struct inode *); 2140extern int inode_init_always(struct super_block *, struct inode *);
2141extern void inode_init_once(struct inode *); 2141extern void inode_init_once(struct inode *);
2142extern void inode_add_to_lists(struct super_block *, struct inode *); 2142extern void inode_add_to_lists(struct super_block *, struct inode *);
2143extern void iput(struct inode *); 2143extern void iput(struct inode *);
@@ -2164,6 +2164,7 @@ extern void __iget(struct inode * inode);
2164extern void iget_failed(struct inode *); 2164extern void iget_failed(struct inode *);
2165extern void clear_inode(struct inode *); 2165extern void clear_inode(struct inode *);
2166extern void destroy_inode(struct inode *); 2166extern void destroy_inode(struct inode *);
2167extern void __destroy_inode(struct inode *);
2167extern struct inode *new_inode(struct super_block *); 2168extern struct inode *new_inode(struct super_block *);
2168extern int should_remove_suid(struct dentry *); 2169extern int should_remove_suid(struct dentry *);
2169extern int file_remove_suid(struct file *); 2170extern int file_remove_suid(struct file *);
diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
index 5c093ffc655b..a81170de7f6b 100644
--- a/include/linux/ftrace_event.h
+++ b/include/linux/ftrace_event.h
@@ -89,7 +89,9 @@ enum print_line_t {
89 TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */ 89 TRACE_TYPE_NO_CONSUME = 3 /* Handled but ask to not consume */
90}; 90};
91 91
92 92void tracing_generic_entry_update(struct trace_entry *entry,
93 unsigned long flags,
94 int pc);
93struct ring_buffer_event * 95struct ring_buffer_event *
94trace_current_buffer_lock_reserve(int type, unsigned long len, 96trace_current_buffer_lock_reserve(int type, unsigned long len,
95 unsigned long flags, int pc); 97 unsigned long flags, int pc);
@@ -119,11 +121,9 @@ struct ftrace_event_call {
119 void *filter; 121 void *filter;
120 void *mod; 122 void *mod;
121 123
122#ifdef CONFIG_EVENT_PROFILE 124 atomic_t profile_count;
123 atomic_t profile_count; 125 int (*profile_enable)(struct ftrace_event_call *);
124 int (*profile_enable)(struct ftrace_event_call *); 126 void (*profile_disable)(struct ftrace_event_call *);
125 void (*profile_disable)(struct ftrace_event_call *);
126#endif
127}; 127};
128 128
129#define MAX_FILTER_PRED 32 129#define MAX_FILTER_PRED 32
diff --git a/include/linux/gen_stats.h b/include/linux/gen_stats.h
index 0ffa41df0ee8..710e901085d0 100644
--- a/include/linux/gen_stats.h
+++ b/include/linux/gen_stats.h
@@ -22,6 +22,11 @@ struct gnet_stats_basic
22{ 22{
23 __u64 bytes; 23 __u64 bytes;
24 __u32 packets; 24 __u32 packets;
25};
26struct gnet_stats_basic_packed
27{
28 __u64 bytes;
29 __u32 packets;
25} __attribute__ ((packed)); 30} __attribute__ ((packed));
26 31
27/** 32/**
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 2723513a5651..5cbc620bdfe0 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -10,6 +10,7 @@
10#include <asm/tlbflush.h> 10#include <asm/tlbflush.h>
11 11
12struct ctl_table; 12struct ctl_table;
13struct user_struct;
13 14
14int PageHuge(struct page *page); 15int PageHuge(struct page *page);
15 16
@@ -146,7 +147,8 @@ static inline struct hugetlbfs_sb_info *HUGETLBFS_SB(struct super_block *sb)
146 147
147extern const struct file_operations hugetlbfs_file_operations; 148extern const struct file_operations hugetlbfs_file_operations;
148extern struct vm_operations_struct hugetlb_vm_ops; 149extern struct vm_operations_struct hugetlb_vm_ops;
149struct file *hugetlb_file_setup(const char *name, size_t, int); 150struct file *hugetlb_file_setup(const char *name, size_t size, int acct,
151 struct user_struct **user);
150int hugetlb_get_quota(struct address_space *mapping, long delta); 152int hugetlb_get_quota(struct address_space *mapping, long delta);
151void hugetlb_put_quota(struct address_space *mapping, long delta); 153void hugetlb_put_quota(struct address_space *mapping, long delta);
152 154
@@ -168,7 +170,7 @@ static inline void set_file_hugepages(struct file *file)
168 170
169#define is_file_hugepages(file) 0 171#define is_file_hugepages(file) 0
170#define set_file_hugepages(file) BUG() 172#define set_file_hugepages(file) BUG()
171#define hugetlb_file_setup(name,size,acctflag) ERR_PTR(-ENOSYS) 173#define hugetlb_file_setup(name,size,acct,user) ERR_PTR(-ENOSYS)
172 174
173#endif /* !CONFIG_HUGETLBFS */ 175#endif /* !CONFIG_HUGETLBFS */
174 176
diff --git a/include/linux/inetdevice.h b/include/linux/inetdevice.h
index acef2a770b6b..ad27c7da8798 100644
--- a/include/linux/inetdevice.h
+++ b/include/linux/inetdevice.h
@@ -82,7 +82,7 @@ static inline void ipv4_devconf_setall(struct in_device *in_dev)
82 82
83#define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING) 83#define IN_DEV_FORWARD(in_dev) IN_DEV_CONF_GET((in_dev), FORWARDING)
84#define IN_DEV_MFORWARD(in_dev) IN_DEV_ANDCONF((in_dev), MC_FORWARDING) 84#define IN_DEV_MFORWARD(in_dev) IN_DEV_ANDCONF((in_dev), MC_FORWARDING)
85#define IN_DEV_RPFILTER(in_dev) IN_DEV_ANDCONF((in_dev), RP_FILTER) 85#define IN_DEV_RPFILTER(in_dev) IN_DEV_MAXCONF((in_dev), RP_FILTER)
86#define IN_DEV_SOURCE_ROUTE(in_dev) IN_DEV_ANDCONF((in_dev), \ 86#define IN_DEV_SOURCE_ROUTE(in_dev) IN_DEV_ANDCONF((in_dev), \
87 ACCEPT_SOURCE_ROUTE) 87 ACCEPT_SOURCE_ROUTE)
88#define IN_DEV_BOOTP_RELAY(in_dev) IN_DEV_ANDCONF((in_dev), BOOTP_RELAY) 88#define IN_DEV_BOOTP_RELAY(in_dev) IN_DEV_ANDCONF((in_dev), BOOTP_RELAY)
diff --git a/include/linux/input/matrix_keypad.h b/include/linux/input/matrix_keypad.h
index 7964516c6954..15d5903af2dd 100644
--- a/include/linux/input/matrix_keypad.h
+++ b/include/linux/input/matrix_keypad.h
@@ -15,12 +15,13 @@
15#define KEY_COL(k) (((k) >> 16) & 0xff) 15#define KEY_COL(k) (((k) >> 16) & 0xff)
16#define KEY_VAL(k) ((k) & 0xffff) 16#define KEY_VAL(k) ((k) & 0xffff)
17 17
18#define MATRIX_SCAN_CODE(row, col, row_shift) (((row) << (row_shift)) + (col))
19
18/** 20/**
19 * struct matrix_keymap_data - keymap for matrix keyboards 21 * struct matrix_keymap_data - keymap for matrix keyboards
20 * @keymap: pointer to array of uint32 values encoded with KEY() macro 22 * @keymap: pointer to array of uint32 values encoded with KEY() macro
21 * representing keymap 23 * representing keymap
22 * @keymap_size: number of entries (initialized) in this keymap 24 * @keymap_size: number of entries (initialized) in this keymap
23 * @max_keymap_size: maximum size of keymap supported by the device
24 * 25 *
25 * This structure is supposed to be used by platform code to supply 26 * This structure is supposed to be used by platform code to supply
26 * keymaps to drivers that implement matrix-like keypads/keyboards. 27 * keymaps to drivers that implement matrix-like keypads/keyboards.
@@ -28,14 +29,13 @@
28struct matrix_keymap_data { 29struct matrix_keymap_data {
29 const uint32_t *keymap; 30 const uint32_t *keymap;
30 unsigned int keymap_size; 31 unsigned int keymap_size;
31 unsigned int max_keymap_size;
32}; 32};
33 33
34/** 34/**
35 * struct matrix_keypad_platform_data - platform-dependent keypad data 35 * struct matrix_keypad_platform_data - platform-dependent keypad data
36 * @keymap_data: pointer to &matrix_keymap_data 36 * @keymap_data: pointer to &matrix_keymap_data
37 * @row_gpios: array of gpio numbers reporesenting rows 37 * @row_gpios: pointer to array of gpio numbers representing rows
38 * @col_gpios: array of gpio numbers reporesenting colums 38 * @col_gpios: pointer to array of gpio numbers reporesenting colums
39 * @num_row_gpios: actual number of row gpios used by device 39 * @num_row_gpios: actual number of row gpios used by device
40 * @num_col_gpios: actual number of col gpios used by device 40 * @num_col_gpios: actual number of col gpios used by device
41 * @col_scan_delay_us: delay, measured in microseconds, that is 41 * @col_scan_delay_us: delay, measured in microseconds, that is
@@ -48,8 +48,9 @@ struct matrix_keymap_data {
48struct matrix_keypad_platform_data { 48struct matrix_keypad_platform_data {
49 const struct matrix_keymap_data *keymap_data; 49 const struct matrix_keymap_data *keymap_data;
50 50
51 unsigned int row_gpios[MATRIX_MAX_ROWS]; 51 const unsigned int *row_gpios;
52 unsigned int col_gpios[MATRIX_MAX_COLS]; 52 const unsigned int *col_gpios;
53
53 unsigned int num_row_gpios; 54 unsigned int num_row_gpios;
54 unsigned int num_col_gpios; 55 unsigned int num_col_gpios;
55 56
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 16713dc672e4..3060bdc35ffe 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -110,6 +110,7 @@ struct kvm_memory_slot {
110 110
111struct kvm_kernel_irq_routing_entry { 111struct kvm_kernel_irq_routing_entry {
112 u32 gsi; 112 u32 gsi;
113 u32 type;
113 int (*set)(struct kvm_kernel_irq_routing_entry *e, 114 int (*set)(struct kvm_kernel_irq_routing_entry *e,
114 struct kvm *kvm, int level); 115 struct kvm *kvm, int level);
115 union { 116 union {
diff --git a/include/linux/lmb.h b/include/linux/lmb.h
index c46c89505dac..2442e3f3d033 100644
--- a/include/linux/lmb.h
+++ b/include/linux/lmb.h
@@ -51,7 +51,7 @@ extern u64 __init lmb_alloc_base(u64 size,
51extern u64 __init __lmb_alloc_base(u64 size, 51extern u64 __init __lmb_alloc_base(u64 size,
52 u64 align, u64 max_addr); 52 u64 align, u64 max_addr);
53extern u64 __init lmb_phys_mem_size(void); 53extern u64 __init lmb_phys_mem_size(void);
54extern u64 __init lmb_end_of_DRAM(void); 54extern u64 lmb_end_of_DRAM(void);
55extern void __init lmb_enforce_memory_limit(u64 memory_limit); 55extern void __init lmb_enforce_memory_limit(u64 memory_limit);
56extern int __init lmb_is_reserved(u64 addr); 56extern int __init lmb_is_reserved(u64 addr);
57extern int lmb_find(struct lmb_property *res); 57extern int lmb_find(struct lmb_property *res);
diff --git a/include/linux/mm.h b/include/linux/mm.h
index ba3a7cb1eaa0..9a72cc78e6b8 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -34,8 +34,6 @@ extern int sysctl_legacy_va_layout;
34#define sysctl_legacy_va_layout 0 34#define sysctl_legacy_va_layout 0
35#endif 35#endif
36 36
37extern unsigned long mmap_min_addr;
38
39#include <asm/page.h> 37#include <asm/page.h>
40#include <asm/pgtable.h> 38#include <asm/pgtable.h>
41#include <asm/processor.h> 39#include <asm/processor.h>
@@ -575,19 +573,6 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
575} 573}
576 574
577/* 575/*
578 * If a hint addr is less than mmap_min_addr change hint to be as
579 * low as possible but still greater than mmap_min_addr
580 */
581static inline unsigned long round_hint_to_min(unsigned long hint)
582{
583 hint &= PAGE_MASK;
584 if (((void *)hint != NULL) &&
585 (hint < mmap_min_addr))
586 return PAGE_ALIGN(mmap_min_addr);
587 return hint;
588}
589
590/*
591 * Some inline functions in vmstat.h depend on page_zone() 576 * Some inline functions in vmstat.h depend on page_zone()
592 */ 577 */
593#include <linux/vmstat.h> 578#include <linux/vmstat.h>
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 7acc8439d9b3..0042090a4d70 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -240,8 +240,6 @@ struct mm_struct {
240 240
241 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */ 241 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
242 242
243 s8 oom_adj; /* OOM kill score adjustment (bit shift) */
244
245 cpumask_t cpu_vm_mask; 243 cpumask_t cpu_vm_mask;
246 244
247 /* Architecture-specific MM context */ 245 /* Architecture-specific MM context */
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 5675b63a0631..0f32a9b6ff55 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -251,7 +251,7 @@ struct mtd_info {
251 251
252static inline struct mtd_info *dev_to_mtd(struct device *dev) 252static inline struct mtd_info *dev_to_mtd(struct device *dev)
253{ 253{
254 return dev ? container_of(dev, struct mtd_info, dev) : NULL; 254 return dev ? dev_get_drvdata(dev) : NULL;
255} 255}
256 256
257static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) 257static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)
diff --git a/include/linux/mtd/partitions.h b/include/linux/mtd/partitions.h
index af6dcb992bc3..b70313d33ff8 100644
--- a/include/linux/mtd/partitions.h
+++ b/include/linux/mtd/partitions.h
@@ -47,6 +47,8 @@ struct mtd_partition {
47#define MTDPART_SIZ_FULL (0) 47#define MTDPART_SIZ_FULL (0)
48 48
49 49
50struct mtd_info;
51
50int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int); 52int add_mtd_partitions(struct mtd_info *, const struct mtd_partition *, int);
51int del_mtd_partitions(struct mtd_info *); 53int del_mtd_partitions(struct mtd_info *);
52 54
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index fdffb413b192..f6b90240dd41 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -473,7 +473,6 @@ extern int nfs_writepages(struct address_space *, struct writeback_control *);
473extern int nfs_flush_incompatible(struct file *file, struct page *page); 473extern int nfs_flush_incompatible(struct file *file, struct page *page);
474extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int); 474extern int nfs_updatepage(struct file *, struct page *, unsigned int, unsigned int);
475extern int nfs_writeback_done(struct rpc_task *, struct nfs_write_data *); 475extern int nfs_writeback_done(struct rpc_task *, struct nfs_write_data *);
476extern void nfs_writedata_release(void *);
477 476
478/* 477/*
479 * Try to write back everything synchronously (but check the 478 * Try to write back everything synchronously (but check the
@@ -488,7 +487,6 @@ extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
488extern int nfs_commit_inode(struct inode *, int); 487extern int nfs_commit_inode(struct inode *, int);
489extern struct nfs_write_data *nfs_commitdata_alloc(void); 488extern struct nfs_write_data *nfs_commitdata_alloc(void);
490extern void nfs_commit_free(struct nfs_write_data *wdata); 489extern void nfs_commit_free(struct nfs_write_data *wdata);
491extern void nfs_commitdata_release(void *wdata);
492#else 490#else
493static inline int 491static inline int
494nfs_commit_inode(struct inode *inode, int how) 492nfs_commit_inode(struct inode *inode, int how)
@@ -507,6 +505,7 @@ nfs_have_writebacks(struct inode *inode)
507 * Allocate nfs_write_data structures 505 * Allocate nfs_write_data structures
508 */ 506 */
509extern struct nfs_write_data *nfs_writedata_alloc(unsigned int npages); 507extern struct nfs_write_data *nfs_writedata_alloc(unsigned int npages);
508extern void nfs_writedata_free(struct nfs_write_data *);
510 509
511/* 510/*
512 * linux/fs/nfs/read.c 511 * linux/fs/nfs/read.c
@@ -515,7 +514,6 @@ extern int nfs_readpage(struct file *, struct page *);
515extern int nfs_readpages(struct file *, struct address_space *, 514extern int nfs_readpages(struct file *, struct address_space *,
516 struct list_head *, unsigned); 515 struct list_head *, unsigned);
517extern int nfs_readpage_result(struct rpc_task *, struct nfs_read_data *); 516extern int nfs_readpage_result(struct rpc_task *, struct nfs_read_data *);
518extern void nfs_readdata_release(void *data);
519extern int nfs_readpage_async(struct nfs_open_context *, struct inode *, 517extern int nfs_readpage_async(struct nfs_open_context *, struct inode *,
520 struct page *); 518 struct page *);
521 519
@@ -523,6 +521,7 @@ extern int nfs_readpage_async(struct nfs_open_context *, struct inode *,
523 * Allocate nfs_read_data structures 521 * Allocate nfs_read_data structures
524 */ 522 */
525extern struct nfs_read_data *nfs_readdata_alloc(unsigned int npages); 523extern struct nfs_read_data *nfs_readdata_alloc(unsigned int npages);
524extern void nfs_readdata_free(struct nfs_read_data *);
526 525
527/* 526/*
528 * linux/fs/nfs3proc.c 527 * linux/fs/nfs3proc.c
diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h
index 829b94b156f2..b359c4a9ec9e 100644
--- a/include/linux/nodemask.h
+++ b/include/linux/nodemask.h
@@ -82,6 +82,12 @@
82 * to generate slightly worse code. So use a simple one-line #define 82 * to generate slightly worse code. So use a simple one-line #define
83 * for node_isset(), instead of wrapping an inline inside a macro, the 83 * for node_isset(), instead of wrapping an inline inside a macro, the
84 * way we do the other calls. 84 * way we do the other calls.
85 *
86 * NODEMASK_SCRATCH
87 * When doing above logical AND, OR, XOR, Remap operations the callers tend to
88 * need temporary nodemask_t's on the stack. But if NODES_SHIFT is large,
89 * nodemask_t's consume too much stack space. NODEMASK_SCRATCH is a helper
90 * for such situations. See below and CPUMASK_ALLOC also.
85 */ 91 */
86 92
87#include <linux/kernel.h> 93#include <linux/kernel.h>
@@ -473,4 +479,26 @@ static inline int num_node_state(enum node_states state)
473#define for_each_node(node) for_each_node_state(node, N_POSSIBLE) 479#define for_each_node(node) for_each_node_state(node, N_POSSIBLE)
474#define for_each_online_node(node) for_each_node_state(node, N_ONLINE) 480#define for_each_online_node(node) for_each_node_state(node, N_ONLINE)
475 481
482/*
483 * For nodemask scrach area.(See CPUMASK_ALLOC() in cpumask.h)
484 */
485
486#if NODES_SHIFT > 8 /* nodemask_t > 64 bytes */
487#define NODEMASK_ALLOC(x, m) struct x *m = kmalloc(sizeof(*m), GFP_KERNEL)
488#define NODEMASK_FREE(m) kfree(m)
489#else
490#define NODEMASK_ALLOC(x, m) struct x _m, *m = &_m
491#define NODEMASK_FREE(m)
492#endif
493
494/* A example struture for using NODEMASK_ALLOC, used in mempolicy. */
495struct nodemask_scratch {
496 nodemask_t mask1;
497 nodemask_t mask2;
498};
499
500#define NODEMASK_SCRATCH(x) NODEMASK_ALLOC(nodemask_scratch, x)
501#define NODEMASK_SCRATCH_FREE(x) NODEMASK_FREE(x)
502
503
476#endif /* __LINUX_NODEMASK_H */ 504#endif /* __LINUX_NODEMASK_H */
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index bd15d7a5f5ce..b53f7006cc4e 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -115,27 +115,44 @@ enum perf_counter_sample_format {
115 PERF_SAMPLE_TID = 1U << 1, 115 PERF_SAMPLE_TID = 1U << 1,
116 PERF_SAMPLE_TIME = 1U << 2, 116 PERF_SAMPLE_TIME = 1U << 2,
117 PERF_SAMPLE_ADDR = 1U << 3, 117 PERF_SAMPLE_ADDR = 1U << 3,
118 PERF_SAMPLE_GROUP = 1U << 4, 118 PERF_SAMPLE_READ = 1U << 4,
119 PERF_SAMPLE_CALLCHAIN = 1U << 5, 119 PERF_SAMPLE_CALLCHAIN = 1U << 5,
120 PERF_SAMPLE_ID = 1U << 6, 120 PERF_SAMPLE_ID = 1U << 6,
121 PERF_SAMPLE_CPU = 1U << 7, 121 PERF_SAMPLE_CPU = 1U << 7,
122 PERF_SAMPLE_PERIOD = 1U << 8, 122 PERF_SAMPLE_PERIOD = 1U << 8,
123 PERF_SAMPLE_STREAM_ID = 1U << 9, 123 PERF_SAMPLE_STREAM_ID = 1U << 9,
124 PERF_SAMPLE_RAW = 1U << 10,
124 125
125 PERF_SAMPLE_MAX = 1U << 10, /* non-ABI */ 126 PERF_SAMPLE_MAX = 1U << 11, /* non-ABI */
126}; 127};
127 128
128/* 129/*
129 * Bits that can be set in attr.read_format to request that 130 * The format of the data returned by read() on a perf counter fd,
130 * reads on the counter should return the indicated quantities, 131 * as specified by attr.read_format:
131 * in increasing order of bit value, after the counter value. 132 *
133 * struct read_format {
134 * { u64 value;
135 * { u64 time_enabled; } && PERF_FORMAT_ENABLED
136 * { u64 time_running; } && PERF_FORMAT_RUNNING
137 * { u64 id; } && PERF_FORMAT_ID
138 * } && !PERF_FORMAT_GROUP
139 *
140 * { u64 nr;
141 * { u64 time_enabled; } && PERF_FORMAT_ENABLED
142 * { u64 time_running; } && PERF_FORMAT_RUNNING
143 * { u64 value;
144 * { u64 id; } && PERF_FORMAT_ID
145 * } cntr[nr];
146 * } && PERF_FORMAT_GROUP
147 * };
132 */ 148 */
133enum perf_counter_read_format { 149enum perf_counter_read_format {
134 PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0, 150 PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0,
135 PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1, 151 PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
136 PERF_FORMAT_ID = 1U << 2, 152 PERF_FORMAT_ID = 1U << 2,
153 PERF_FORMAT_GROUP = 1U << 3,
137 154
138 PERF_FORMAT_MAX = 1U << 3, /* non-ABI */ 155 PERF_FORMAT_MAX = 1U << 4, /* non-ABI */
139}; 156};
140 157
141#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */ 158#define PERF_ATTR_SIZE_VER0 64 /* sizeof first published struct */
@@ -181,8 +198,9 @@ struct perf_counter_attr {
181 freq : 1, /* use freq, not period */ 198 freq : 1, /* use freq, not period */
182 inherit_stat : 1, /* per task counts */ 199 inherit_stat : 1, /* per task counts */
183 enable_on_exec : 1, /* next exec enables */ 200 enable_on_exec : 1, /* next exec enables */
201 task : 1, /* trace fork/exit */
184 202
185 __reserved_1 : 51; 203 __reserved_1 : 50;
186 204
187 __u32 wakeup_events; /* wakeup every n events */ 205 __u32 wakeup_events; /* wakeup every n events */
188 __u32 __reserved_2; 206 __u32 __reserved_2;
@@ -311,6 +329,15 @@ enum perf_event_type {
311 /* 329 /*
312 * struct { 330 * struct {
313 * struct perf_event_header header; 331 * struct perf_event_header header;
332 * u32 pid, ppid;
333 * u32 tid, ptid;
334 * };
335 */
336 PERF_EVENT_EXIT = 4,
337
338 /*
339 * struct {
340 * struct perf_event_header header;
314 * u64 time; 341 * u64 time;
315 * u64 id; 342 * u64 id;
316 * u64 stream_id; 343 * u64 stream_id;
@@ -323,6 +350,7 @@ enum perf_event_type {
323 * struct { 350 * struct {
324 * struct perf_event_header header; 351 * struct perf_event_header header;
325 * u32 pid, ppid; 352 * u32 pid, ppid;
353 * u32 tid, ptid;
326 * }; 354 * };
327 */ 355 */
328 PERF_EVENT_FORK = 7, 356 PERF_EVENT_FORK = 7,
@@ -331,10 +359,8 @@ enum perf_event_type {
331 * struct { 359 * struct {
332 * struct perf_event_header header; 360 * struct perf_event_header header;
333 * u32 pid, tid; 361 * u32 pid, tid;
334 * u64 value; 362 *
335 * { u64 time_enabled; } && PERF_FORMAT_ENABLED 363 * struct read_format values;
336 * { u64 time_running; } && PERF_FORMAT_RUNNING
337 * { u64 parent_id; } && PERF_FORMAT_ID
338 * }; 364 * };
339 */ 365 */
340 PERF_EVENT_READ = 8, 366 PERF_EVENT_READ = 8,
@@ -352,11 +378,24 @@ enum perf_event_type {
352 * { u32 cpu, res; } && PERF_SAMPLE_CPU 378 * { u32 cpu, res; } && PERF_SAMPLE_CPU
353 * { u64 period; } && PERF_SAMPLE_PERIOD 379 * { u64 period; } && PERF_SAMPLE_PERIOD
354 * 380 *
355 * { u64 nr; 381 * { struct read_format values; } && PERF_SAMPLE_READ
356 * { u64 id, val; } cnt[nr]; } && PERF_SAMPLE_GROUP
357 * 382 *
358 * { u64 nr, 383 * { u64 nr,
359 * u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN 384 * u64 ips[nr]; } && PERF_SAMPLE_CALLCHAIN
385 *
386 * #
387 * # The RAW record below is opaque data wrt the ABI
388 * #
389 * # That is, the ABI doesn't make any promises wrt to
390 * # the stability of its content, it may vary depending
391 * # on event, hardware, kernel version and phase of
392 * # the moon.
393 * #
394 * # In other words, PERF_SAMPLE_RAW contents are not an ABI.
395 * #
396 *
397 * { u32 size;
398 * char data[size];}&& PERF_SAMPLE_RAW
360 * }; 399 * };
361 */ 400 */
362 PERF_EVENT_SAMPLE = 9, 401 PERF_EVENT_SAMPLE = 9,
@@ -402,6 +441,11 @@ struct perf_callchain_entry {
402 __u64 ip[PERF_MAX_STACK_DEPTH]; 441 __u64 ip[PERF_MAX_STACK_DEPTH];
403}; 442};
404 443
444struct perf_raw_record {
445 u32 size;
446 void *data;
447};
448
405struct task_struct; 449struct task_struct;
406 450
407/** 451/**
@@ -670,10 +714,13 @@ struct perf_sample_data {
670 struct pt_regs *regs; 714 struct pt_regs *regs;
671 u64 addr; 715 u64 addr;
672 u64 period; 716 u64 period;
717 struct perf_raw_record *raw;
673}; 718};
674 719
675extern int perf_counter_overflow(struct perf_counter *counter, int nmi, 720extern int perf_counter_overflow(struct perf_counter *counter, int nmi,
676 struct perf_sample_data *data); 721 struct perf_sample_data *data);
722extern void perf_counter_output(struct perf_counter *counter, int nmi,
723 struct perf_sample_data *data);
677 724
678/* 725/*
679 * Return 1 for a software counter, 0 for a hardware counter 726 * Return 1 for a software counter, 0 for a hardware counter
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 3ab08e4bb6b8..0f1ea4a66957 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1198,6 +1198,7 @@ struct task_struct {
1198 * a short time 1198 * a short time
1199 */ 1199 */
1200 unsigned char fpu_counter; 1200 unsigned char fpu_counter;
1201 s8 oomkilladj; /* OOM kill score adjustment (bit shift). */
1201#ifdef CONFIG_BLK_DEV_IO_TRACE 1202#ifdef CONFIG_BLK_DEV_IO_TRACE
1202 unsigned int btrace_seq; 1203 unsigned int btrace_seq;
1203#endif 1204#endif
diff --git a/include/linux/security.h b/include/linux/security.h
index 5eff459b3833..1f16eea2017b 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -28,6 +28,7 @@
28#include <linux/resource.h> 28#include <linux/resource.h>
29#include <linux/sem.h> 29#include <linux/sem.h>
30#include <linux/shm.h> 30#include <linux/shm.h>
31#include <linux/mm.h> /* PAGE_ALIGN */
31#include <linux/msg.h> 32#include <linux/msg.h>
32#include <linux/sched.h> 33#include <linux/sched.h>
33#include <linux/key.h> 34#include <linux/key.h>
@@ -66,6 +67,9 @@ extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
66extern int cap_inode_removexattr(struct dentry *dentry, const char *name); 67extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
67extern int cap_inode_need_killpriv(struct dentry *dentry); 68extern int cap_inode_need_killpriv(struct dentry *dentry);
68extern int cap_inode_killpriv(struct dentry *dentry); 69extern int cap_inode_killpriv(struct dentry *dentry);
70extern int cap_file_mmap(struct file *file, unsigned long reqprot,
71 unsigned long prot, unsigned long flags,
72 unsigned long addr, unsigned long addr_only);
69extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags); 73extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);
70extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3, 74extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
71 unsigned long arg4, unsigned long arg5); 75 unsigned long arg4, unsigned long arg5);
@@ -92,6 +96,7 @@ extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
92extern int cap_netlink_recv(struct sk_buff *skb, int cap); 96extern int cap_netlink_recv(struct sk_buff *skb, int cap);
93 97
94extern unsigned long mmap_min_addr; 98extern unsigned long mmap_min_addr;
99extern unsigned long dac_mmap_min_addr;
95/* 100/*
96 * Values used in the task_security_ops calls 101 * Values used in the task_security_ops calls
97 */ 102 */
@@ -116,6 +121,21 @@ struct request_sock;
116#define LSM_UNSAFE_PTRACE 2 121#define LSM_UNSAFE_PTRACE 2
117#define LSM_UNSAFE_PTRACE_CAP 4 122#define LSM_UNSAFE_PTRACE_CAP 4
118 123
124/*
125 * If a hint addr is less than mmap_min_addr change hint to be as
126 * low as possible but still greater than mmap_min_addr
127 */
128static inline unsigned long round_hint_to_min(unsigned long hint)
129{
130 hint &= PAGE_MASK;
131 if (((void *)hint != NULL) &&
132 (hint < mmap_min_addr))
133 return PAGE_ALIGN(mmap_min_addr);
134 return hint;
135}
136extern int mmap_min_addr_handler(struct ctl_table *table, int write, struct file *filp,
137 void __user *buffer, size_t *lenp, loff_t *ppos);
138
119#ifdef CONFIG_SECURITY 139#ifdef CONFIG_SECURITY
120 140
121struct security_mnt_opts { 141struct security_mnt_opts {
@@ -2197,9 +2217,7 @@ static inline int security_file_mmap(struct file *file, unsigned long reqprot,
2197 unsigned long addr, 2217 unsigned long addr,
2198 unsigned long addr_only) 2218 unsigned long addr_only)
2199{ 2219{
2200 if ((addr < mmap_min_addr) && !capable(CAP_SYS_RAWIO)) 2220 return cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
2201 return -EACCES;
2202 return 0;
2203} 2221}
2204 2222
2205static inline int security_file_mprotect(struct vm_area_struct *vma, 2223static inline int security_file_mprotect(struct vm_area_struct *vma,
diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
index 40f38d896777..0c4ee9b88f85 100644
--- a/include/linux/tty_ldisc.h
+++ b/include/linux/tty_ldisc.h
@@ -144,7 +144,7 @@ struct tty_ldisc_ops {
144 144
145struct tty_ldisc { 145struct tty_ldisc {
146 struct tty_ldisc_ops *ops; 146 struct tty_ldisc_ops *ops;
147 int refcount; 147 atomic_t users;
148}; 148};
149 149
150#define TTY_LDISC_MAGIC 0x5403 150#define TTY_LDISC_MAGIC 0x5403
diff --git a/include/linux/ucb1400.h b/include/linux/ucb1400.h
index ed889f4168f3..ae779bb8cc0f 100644
--- a/include/linux/ucb1400.h
+++ b/include/linux/ucb1400.h
@@ -73,6 +73,10 @@
73 73
74#define UCB_ADC_DATA 0x68 74#define UCB_ADC_DATA 0x68
75#define UCB_ADC_DAT_VALID (1 << 15) 75#define UCB_ADC_DAT_VALID (1 << 15)
76
77#define UCB_FCSR 0x6c
78#define UCB_FCSR_AVE (1 << 12)
79
76#define UCB_ADC_DAT_MASK 0x3ff 80#define UCB_ADC_DAT_MASK 0x3ff
77 81
78#define UCB_ID 0x7e 82#define UCB_ID 0x7e
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 6788e1a4d4ca..cf3c2f5dba51 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -77,7 +77,14 @@ struct task_struct;
77#define __WAIT_BIT_KEY_INITIALIZER(word, bit) \ 77#define __WAIT_BIT_KEY_INITIALIZER(word, bit) \
78 { .flags = word, .bit_nr = bit, } 78 { .flags = word, .bit_nr = bit, }
79 79
80extern void init_waitqueue_head(wait_queue_head_t *q); 80extern void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *);
81
82#define init_waitqueue_head(q) \
83 do { \
84 static struct lock_class_key __key; \
85 \
86 __init_waitqueue_head((q), &__key); \
87 } while (0)
81 88
82#ifdef CONFIG_LOCKDEP 89#ifdef CONFIG_LOCKDEP
83# define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \ 90# define __WAIT_QUEUE_HEAD_INIT_ONSTACK(name) \
diff --git a/include/net/act_api.h b/include/net/act_api.h
index 565eed8fe496..c05fd717c588 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -16,7 +16,7 @@ struct tcf_common {
16 u32 tcfc_capab; 16 u32 tcfc_capab;
17 int tcfc_action; 17 int tcfc_action;
18 struct tcf_t tcfc_tm; 18 struct tcf_t tcfc_tm;
19 struct gnet_stats_basic tcfc_bstats; 19 struct gnet_stats_basic_packed tcfc_bstats;
20 struct gnet_stats_queue tcfc_qstats; 20 struct gnet_stats_queue tcfc_qstats;
21 struct gnet_stats_rate_est tcfc_rate_est; 21 struct gnet_stats_rate_est tcfc_rate_est;
22 spinlock_t tcfc_lock; 22 spinlock_t tcfc_lock;
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h
index 80072611d26a..c274993234e3 100644
--- a/include/net/bluetooth/rfcomm.h
+++ b/include/net/bluetooth/rfcomm.h
@@ -355,7 +355,17 @@ struct rfcomm_dev_list_req {
355}; 355};
356 356
357int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); 357int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
358
359#ifdef CONFIG_BT_RFCOMM_TTY
358int rfcomm_init_ttys(void); 360int rfcomm_init_ttys(void);
359void rfcomm_cleanup_ttys(void); 361void rfcomm_cleanup_ttys(void);
360 362#else
363static inline int rfcomm_init_ttys(void)
364{
365 return 0;
366}
367static inline void rfcomm_cleanup_ttys(void)
368{
369}
370#endif
361#endif /* __RFCOMM_H */ 371#endif /* __RFCOMM_H */
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h
index 1a21895b732b..d1892d66701a 100644
--- a/include/net/cfg80211.h
+++ b/include/net/cfg80211.h
@@ -979,6 +979,10 @@ struct cfg80211_ops {
979 * channels at a later time. This can be used for devices which do not 979 * channels at a later time. This can be used for devices which do not
980 * have calibration information gauranteed for frequencies or settings 980 * have calibration information gauranteed for frequencies or settings
981 * outside of its regulatory domain. 981 * outside of its regulatory domain.
982 * @disable_beacon_hints: enable this if your driver needs to ensure that
983 * passive scan flags and beaconing flags may not be lifted by cfg80211
984 * due to regulatory beacon hints. For more information on beacon
985 * hints read the documenation for regulatory_hint_found_beacon()
982 * @reg_notifier: the driver's regulatory notification callback 986 * @reg_notifier: the driver's regulatory notification callback
983 * @regd: the driver's regulatory domain, if one was requested via 987 * @regd: the driver's regulatory domain, if one was requested via
984 * the regulatory_hint() API. This can be used by the driver 988 * the regulatory_hint() API. This can be used by the driver
@@ -1004,6 +1008,7 @@ struct wiphy {
1004 1008
1005 bool custom_regulatory; 1009 bool custom_regulatory;
1006 bool strict_regulatory; 1010 bool strict_regulatory;
1011 bool disable_beacon_hints;
1007 1012
1008 enum cfg80211_signal_type signal_type; 1013 enum cfg80211_signal_type signal_type;
1009 1014
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h
index d136b5240ef2..c1488553e349 100644
--- a/include/net/gen_stats.h
+++ b/include/net/gen_stats.h
@@ -28,7 +28,7 @@ extern int gnet_stats_start_copy_compat(struct sk_buff *skb, int type,
28 spinlock_t *lock, struct gnet_dump *d); 28 spinlock_t *lock, struct gnet_dump *d);
29 29
30extern int gnet_stats_copy_basic(struct gnet_dump *d, 30extern int gnet_stats_copy_basic(struct gnet_dump *d,
31 struct gnet_stats_basic *b); 31 struct gnet_stats_basic_packed *b);
32extern int gnet_stats_copy_rate_est(struct gnet_dump *d, 32extern int gnet_stats_copy_rate_est(struct gnet_dump *d,
33 struct gnet_stats_rate_est *r); 33 struct gnet_stats_rate_est *r);
34extern int gnet_stats_copy_queue(struct gnet_dump *d, 34extern int gnet_stats_copy_queue(struct gnet_dump *d,
@@ -37,14 +37,14 @@ extern int gnet_stats_copy_app(struct gnet_dump *d, void *st, int len);
37 37
38extern int gnet_stats_finish_copy(struct gnet_dump *d); 38extern int gnet_stats_finish_copy(struct gnet_dump *d);
39 39
40extern int gen_new_estimator(struct gnet_stats_basic *bstats, 40extern int gen_new_estimator(struct gnet_stats_basic_packed *bstats,
41 struct gnet_stats_rate_est *rate_est, 41 struct gnet_stats_rate_est *rate_est,
42 spinlock_t *stats_lock, struct nlattr *opt); 42 spinlock_t *stats_lock, struct nlattr *opt);
43extern void gen_kill_estimator(struct gnet_stats_basic *bstats, 43extern void gen_kill_estimator(struct gnet_stats_basic_packed *bstats,
44 struct gnet_stats_rate_est *rate_est); 44 struct gnet_stats_rate_est *rate_est);
45extern int gen_replace_estimator(struct gnet_stats_basic *bstats, 45extern int gen_replace_estimator(struct gnet_stats_basic_packed *bstats,
46 struct gnet_stats_rate_est *rate_est, 46 struct gnet_stats_rate_est *rate_est,
47 spinlock_t *stats_lock, struct nlattr *opt); 47 spinlock_t *stats_lock, struct nlattr *opt);
48extern bool gen_estimator_active(const struct gnet_stats_basic *bstats, 48extern bool gen_estimator_active(const struct gnet_stats_basic_packed *bstats,
49 const struct gnet_stats_rate_est *rate_est); 49 const struct gnet_stats_rate_est *rate_est);
50#endif 50#endif
diff --git a/include/net/netfilter/xt_rateest.h b/include/net/netfilter/xt_rateest.h
index 65d594dffbff..ddbf37e19616 100644
--- a/include/net/netfilter/xt_rateest.h
+++ b/include/net/netfilter/xt_rateest.h
@@ -8,7 +8,7 @@ struct xt_rateest {
8 spinlock_t lock; 8 spinlock_t lock;
9 struct gnet_estimator params; 9 struct gnet_estimator params;
10 struct gnet_stats_rate_est rstats; 10 struct gnet_stats_rate_est rstats;
11 struct gnet_stats_basic bstats; 11 struct gnet_stats_basic_packed bstats;
12}; 12};
13 13
14extern struct xt_rateest *xt_rateest_lookup(const char *name); 14extern struct xt_rateest *xt_rateest_lookup(const char *name);
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h
index 82a3191375f5..7eafb8d54470 100644
--- a/include/net/pkt_sched.h
+++ b/include/net/pkt_sched.h
@@ -61,8 +61,8 @@ psched_tdiff_bounded(psched_time_t tv1, psched_time_t tv2, psched_time_t bound)
61} 61}
62 62
63struct qdisc_watchdog { 63struct qdisc_watchdog {
64 struct hrtimer timer; 64 struct tasklet_hrtimer timer;
65 struct Qdisc *qdisc; 65 struct Qdisc *qdisc;
66}; 66};
67 67
68extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc); 68extern void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc);
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h
index 964ffa0d8815..5482e9582f55 100644
--- a/include/net/sch_generic.h
+++ b/include/net/sch_generic.h
@@ -72,7 +72,7 @@ struct Qdisc
72 */ 72 */
73 unsigned long state; 73 unsigned long state;
74 struct sk_buff_head q; 74 struct sk_buff_head q;
75 struct gnet_stats_basic bstats; 75 struct gnet_stats_basic_packed bstats;
76 struct gnet_stats_queue qstats; 76 struct gnet_stats_queue qstats;
77}; 77};
78 78
diff --git a/include/trace/ftrace.h b/include/trace/ftrace.h
index 1867553c61e5..f64fbaae781a 100644
--- a/include/trace/ftrace.h
+++ b/include/trace/ftrace.h
@@ -144,6 +144,9 @@
144#undef TP_fast_assign 144#undef TP_fast_assign
145#define TP_fast_assign(args...) args 145#define TP_fast_assign(args...) args
146 146
147#undef TP_perf_assign
148#define TP_perf_assign(args...)
149
147#undef TRACE_EVENT 150#undef TRACE_EVENT
148#define TRACE_EVENT(call, proto, args, tstruct, func, print) \ 151#define TRACE_EVENT(call, proto, args, tstruct, func, print) \
149static int \ 152static int \
@@ -345,6 +348,56 @@ static inline int ftrace_get_offsets_##call( \
345 348
346#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 349#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
347 350
351#ifdef CONFIG_EVENT_PROFILE
352
353/*
354 * Generate the functions needed for tracepoint perf_counter support.
355 *
356 * NOTE: The insertion profile callback (ftrace_profile_<call>) is defined later
357 *
358 * static int ftrace_profile_enable_<call>(struct ftrace_event_call *event_call)
359 * {
360 * int ret = 0;
361 *
362 * if (!atomic_inc_return(&event_call->profile_count))
363 * ret = register_trace_<call>(ftrace_profile_<call>);
364 *
365 * return ret;
366 * }
367 *
368 * static void ftrace_profile_disable_<call>(struct ftrace_event_call *event_call)
369 * {
370 * if (atomic_add_negative(-1, &event->call->profile_count))
371 * unregister_trace_<call>(ftrace_profile_<call>);
372 * }
373 *
374 */
375
376#undef TRACE_EVENT
377#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
378 \
379static void ftrace_profile_##call(proto); \
380 \
381static int ftrace_profile_enable_##call(struct ftrace_event_call *event_call) \
382{ \
383 int ret = 0; \
384 \
385 if (!atomic_inc_return(&event_call->profile_count)) \
386 ret = register_trace_##call(ftrace_profile_##call); \
387 \
388 return ret; \
389} \
390 \
391static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
392{ \
393 if (atomic_add_negative(-1, &event_call->profile_count)) \
394 unregister_trace_##call(ftrace_profile_##call); \
395}
396
397#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
398
399#endif
400
348/* 401/*
349 * Stage 4 of the trace events. 402 * Stage 4 of the trace events.
350 * 403 *
@@ -447,28 +500,6 @@ static inline int ftrace_get_offsets_##call( \
447#define TP_FMT(fmt, args...) fmt "\n", ##args 500#define TP_FMT(fmt, args...) fmt "\n", ##args
448 501
449#ifdef CONFIG_EVENT_PROFILE 502#ifdef CONFIG_EVENT_PROFILE
450#define _TRACE_PROFILE(call, proto, args) \
451static void ftrace_profile_##call(proto) \
452{ \
453 extern void perf_tpcounter_event(int); \
454 perf_tpcounter_event(event_##call.id); \
455} \
456 \
457static int ftrace_profile_enable_##call(struct ftrace_event_call *event_call) \
458{ \
459 int ret = 0; \
460 \
461 if (!atomic_inc_return(&event_call->profile_count)) \
462 ret = register_trace_##call(ftrace_profile_##call); \
463 \
464 return ret; \
465} \
466 \
467static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
468{ \
469 if (atomic_add_negative(-1, &event_call->profile_count)) \
470 unregister_trace_##call(ftrace_profile_##call); \
471}
472 503
473#define _TRACE_PROFILE_INIT(call) \ 504#define _TRACE_PROFILE_INIT(call) \
474 .profile_count = ATOMIC_INIT(-1), \ 505 .profile_count = ATOMIC_INIT(-1), \
@@ -476,7 +507,6 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
476 .profile_disable = ftrace_profile_disable_##call, 507 .profile_disable = ftrace_profile_disable_##call,
477 508
478#else 509#else
479#define _TRACE_PROFILE(call, proto, args)
480#define _TRACE_PROFILE_INIT(call) 510#define _TRACE_PROFILE_INIT(call)
481#endif 511#endif
482 512
@@ -502,7 +532,6 @@ static void ftrace_profile_disable_##call(struct ftrace_event_call *event_call)\
502 532
503#undef TRACE_EVENT 533#undef TRACE_EVENT
504#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \ 534#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
505_TRACE_PROFILE(call, PARAMS(proto), PARAMS(args)) \
506 \ 535 \
507static struct ftrace_event_call event_##call; \ 536static struct ftrace_event_call event_##call; \
508 \ 537 \
@@ -586,6 +615,110 @@ __attribute__((section("_ftrace_events"))) event_##call = { \
586 615
587#include TRACE_INCLUDE(TRACE_INCLUDE_FILE) 616#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
588 617
589#undef _TRACE_PROFILE 618/*
619 * Define the insertion callback to profile events
620 *
621 * The job is very similar to ftrace_raw_event_<call> except that we don't
622 * insert in the ring buffer but in a perf counter.
623 *
624 * static void ftrace_profile_<call>(proto)
625 * {
626 * struct ftrace_data_offsets_<call> __maybe_unused __data_offsets;
627 * struct ftrace_event_call *event_call = &event_<call>;
628 * extern void perf_tpcounter_event(int, u64, u64, void *, int);
629 * struct ftrace_raw_##call *entry;
630 * u64 __addr = 0, __count = 1;
631 * unsigned long irq_flags;
632 * int __entry_size;
633 * int __data_size;
634 * int pc;
635 *
636 * local_save_flags(irq_flags);
637 * pc = preempt_count();
638 *
639 * __data_size = ftrace_get_offsets_<call>(&__data_offsets, args);
640 *
641 * // Below we want to get the aligned size by taking into account
642 * // the u32 field that will later store the buffer size
643 * __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),
644 * sizeof(u64));
645 * __entry_size -= sizeof(u32);
646 *
647 * do {
648 * char raw_data[__entry_size]; <- allocate our sample in the stack
649 * struct trace_entry *ent;
650 *
651 * zero dead bytes from alignment to avoid stack leak to userspace:
652 *
653 * *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL;
654 * entry = (struct ftrace_raw_<call> *)raw_data;
655 * ent = &entry->ent;
656 * tracing_generic_entry_update(ent, irq_flags, pc);
657 * ent->type = event_call->id;
658 *
659 * <tstruct> <- do some jobs with dynamic arrays
660 *
661 * <assign> <- affect our values
662 *
663 * perf_tpcounter_event(event_call->id, __addr, __count, entry,
664 * __entry_size); <- submit them to perf counter
665 * } while (0);
666 *
667 * }
668 */
669
670#ifdef CONFIG_EVENT_PROFILE
671
672#undef __perf_addr
673#define __perf_addr(a) __addr = (a)
674
675#undef __perf_count
676#define __perf_count(c) __count = (c)
677
678#undef TRACE_EVENT
679#define TRACE_EVENT(call, proto, args, tstruct, assign, print) \
680static void ftrace_profile_##call(proto) \
681{ \
682 struct ftrace_data_offsets_##call __maybe_unused __data_offsets;\
683 struct ftrace_event_call *event_call = &event_##call; \
684 extern void perf_tpcounter_event(int, u64, u64, void *, int); \
685 struct ftrace_raw_##call *entry; \
686 u64 __addr = 0, __count = 1; \
687 unsigned long irq_flags; \
688 int __entry_size; \
689 int __data_size; \
690 int pc; \
691 \
692 local_save_flags(irq_flags); \
693 pc = preempt_count(); \
694 \
695 __data_size = ftrace_get_offsets_##call(&__data_offsets, args); \
696 __entry_size = ALIGN(__data_size + sizeof(*entry) + sizeof(u32),\
697 sizeof(u64)); \
698 __entry_size -= sizeof(u32); \
699 \
700 do { \
701 char raw_data[__entry_size]; \
702 struct trace_entry *ent; \
703 \
704 *(u64 *)(&raw_data[__entry_size - sizeof(u64)]) = 0ULL; \
705 entry = (struct ftrace_raw_##call *)raw_data; \
706 ent = &entry->ent; \
707 tracing_generic_entry_update(ent, irq_flags, pc); \
708 ent->type = event_call->id; \
709 \
710 tstruct \
711 \
712 { assign; } \
713 \
714 perf_tpcounter_event(event_call->id, __addr, __count, entry,\
715 __entry_size); \
716 } while (0); \
717 \
718}
719
720#include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
721#endif /* CONFIG_EVENT_PROFILE */
722
590#undef _TRACE_PROFILE_INIT 723#undef _TRACE_PROFILE_INIT
591 724
diff --git a/init/Kconfig b/init/Kconfig
index cb2c09270226..3f7e60995c80 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -940,6 +940,7 @@ menu "Performance Counters"
940 940
941config PERF_COUNTERS 941config PERF_COUNTERS
942 bool "Kernel Performance Counters" 942 bool "Kernel Performance Counters"
943 default y if PROFILING
943 depends on HAVE_PERF_COUNTERS 944 depends on HAVE_PERF_COUNTERS
944 select ANON_INODES 945 select ANON_INODES
945 help 946 help
@@ -961,9 +962,17 @@ config PERF_COUNTERS
961 Say Y if unsure. 962 Say Y if unsure.
962 963
963config EVENT_PROFILE 964config EVENT_PROFILE
964 bool "Tracepoint profile sources" 965 bool "Tracepoint profiling sources"
965 depends on PERF_COUNTERS && EVENT_TRACING 966 depends on PERF_COUNTERS && EVENT_TRACING
966 default y 967 default y
968 help
969 Allow the use of tracepoints as software performance counters.
970
971 When this is enabled, you can create perf counters based on
972 tracepoints using PERF_TYPE_TRACEPOINT and the tracepoint ID
973 found in debugfs://tracing/events/*/*/id. (The -e/--events
974 option to the perf tool can parse and interpret symbolic
975 tracepoints, in the subsystem:tracepoint_name format.)
967 976
968endmenu 977endmenu
969 978
diff --git a/init/main.c b/init/main.c
index 2c5ade79eb81..11f4f145be3f 100644
--- a/init/main.c
+++ b/init/main.c
@@ -584,8 +584,8 @@ asmlinkage void __init start_kernel(void)
584 setup_arch(&command_line); 584 setup_arch(&command_line);
585 mm_init_owner(&init_mm, &init_task); 585 mm_init_owner(&init_mm, &init_task);
586 setup_command_line(command_line); 586 setup_command_line(command_line);
587 setup_per_cpu_areas();
588 setup_nr_cpu_ids(); 587 setup_nr_cpu_ids();
588 setup_per_cpu_areas();
589 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */ 589 smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
590 590
591 build_all_zonelists(); 591 build_all_zonelists();
@@ -733,13 +733,14 @@ static void __init do_ctors(void)
733int initcall_debug; 733int initcall_debug;
734core_param(initcall_debug, initcall_debug, bool, 0644); 734core_param(initcall_debug, initcall_debug, bool, 0644);
735 735
736static char msgbuf[64];
737static struct boot_trace_call call;
738static struct boot_trace_ret ret;
739
736int do_one_initcall(initcall_t fn) 740int do_one_initcall(initcall_t fn)
737{ 741{
738 int count = preempt_count(); 742 int count = preempt_count();
739 ktime_t calltime, delta, rettime; 743 ktime_t calltime, delta, rettime;
740 char msgbuf[64];
741 struct boot_trace_call call;
742 struct boot_trace_ret ret;
743 744
744 if (initcall_debug) { 745 if (initcall_debug) {
745 call.caller = task_pid_nr(current); 746 call.caller = task_pid_nr(current);
diff --git a/ipc/shm.c b/ipc/shm.c
index 15dd238e5338..1bc4701ef4f0 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -174,7 +174,7 @@ static void shm_destroy(struct ipc_namespace *ns, struct shmid_kernel *shp)
174 shm_unlock(shp); 174 shm_unlock(shp);
175 if (!is_file_hugepages(shp->shm_file)) 175 if (!is_file_hugepages(shp->shm_file))
176 shmem_lock(shp->shm_file, 0, shp->mlock_user); 176 shmem_lock(shp->shm_file, 0, shp->mlock_user);
177 else 177 else if (shp->mlock_user)
178 user_shm_unlock(shp->shm_file->f_path.dentry->d_inode->i_size, 178 user_shm_unlock(shp->shm_file->f_path.dentry->d_inode->i_size,
179 shp->mlock_user); 179 shp->mlock_user);
180 fput (shp->shm_file); 180 fput (shp->shm_file);
@@ -369,8 +369,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
369 /* hugetlb_file_setup applies strict accounting */ 369 /* hugetlb_file_setup applies strict accounting */
370 if (shmflg & SHM_NORESERVE) 370 if (shmflg & SHM_NORESERVE)
371 acctflag = VM_NORESERVE; 371 acctflag = VM_NORESERVE;
372 file = hugetlb_file_setup(name, size, acctflag); 372 file = hugetlb_file_setup(name, size, acctflag,
373 shp->mlock_user = current_user(); 373 &shp->mlock_user);
374 } else { 374 } else {
375 /* 375 /*
376 * Do not allow no accounting for OVERCOMMIT_NEVER, even 376 * Do not allow no accounting for OVERCOMMIT_NEVER, even
@@ -410,6 +410,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
410 return error; 410 return error;
411 411
412no_id: 412no_id:
413 if (shp->mlock_user) /* shmflg & SHM_HUGETLB case */
414 user_shm_unlock(size, shp->mlock_user);
413 fput(file); 415 fput(file);
414no_file: 416no_file:
415 security_shm_free(shp); 417 security_shm_free(shp);
diff --git a/kernel/fork.c b/kernel/fork.c
index 29b532e718f7..e6c04d462ab2 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -426,7 +426,6 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p)
426 init_rwsem(&mm->mmap_sem); 426 init_rwsem(&mm->mmap_sem);
427 INIT_LIST_HEAD(&mm->mmlist); 427 INIT_LIST_HEAD(&mm->mmlist);
428 mm->flags = (current->mm) ? current->mm->flags : default_dump_filter; 428 mm->flags = (current->mm) ? current->mm->flags : default_dump_filter;
429 mm->oom_adj = (current->mm) ? current->mm->oom_adj : 0;
430 mm->core_state = NULL; 429 mm->core_state = NULL;
431 mm->nr_ptes = 0; 430 mm->nr_ptes = 0;
432 set_mm_counter(mm, file_rss, 0); 431 set_mm_counter(mm, file_rss, 0);
@@ -568,18 +567,18 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
568 * the value intact in a core dump, and to save the unnecessary 567 * the value intact in a core dump, and to save the unnecessary
569 * trouble otherwise. Userland only wants this done for a sys_exit. 568 * trouble otherwise. Userland only wants this done for a sys_exit.
570 */ 569 */
571 if (tsk->clear_child_tid 570 if (tsk->clear_child_tid) {
572 && !(tsk->flags & PF_SIGNALED) 571 if (!(tsk->flags & PF_SIGNALED) &&
573 && atomic_read(&mm->mm_users) > 1) { 572 atomic_read(&mm->mm_users) > 1) {
574 u32 __user * tidptr = tsk->clear_child_tid; 573 /*
574 * We don't check the error code - if userspace has
575 * not set up a proper pointer then tough luck.
576 */
577 put_user(0, tsk->clear_child_tid);
578 sys_futex(tsk->clear_child_tid, FUTEX_WAKE,
579 1, NULL, NULL, 0);
580 }
575 tsk->clear_child_tid = NULL; 581 tsk->clear_child_tid = NULL;
576
577 /*
578 * We don't check the error code - if userspace has
579 * not set up a proper pointer then tough luck.
580 */
581 put_user(0, tidptr);
582 sys_futex(tidptr, FUTEX_WAKE, 1, NULL, NULL, 0);
583 } 582 }
584} 583}
585 584
@@ -816,11 +815,8 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk)
816{ 815{
817 struct signal_struct *sig; 816 struct signal_struct *sig;
818 817
819 if (clone_flags & CLONE_THREAD) { 818 if (clone_flags & CLONE_THREAD)
820 atomic_inc(&current->signal->count);
821 atomic_inc(&current->signal->live);
822 return 0; 819 return 0;
823 }
824 820
825 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); 821 sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL);
826 tsk->signal = sig; 822 tsk->signal = sig;
@@ -878,16 +874,6 @@ void __cleanup_signal(struct signal_struct *sig)
878 kmem_cache_free(signal_cachep, sig); 874 kmem_cache_free(signal_cachep, sig);
879} 875}
880 876
881static void cleanup_signal(struct task_struct *tsk)
882{
883 struct signal_struct *sig = tsk->signal;
884
885 atomic_dec(&sig->live);
886
887 if (atomic_dec_and_test(&sig->count))
888 __cleanup_signal(sig);
889}
890
891static void copy_flags(unsigned long clone_flags, struct task_struct *p) 877static void copy_flags(unsigned long clone_flags, struct task_struct *p)
892{ 878{
893 unsigned long new_flags = p->flags; 879 unsigned long new_flags = p->flags;
@@ -1240,6 +1226,8 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1240 } 1226 }
1241 1227
1242 if (clone_flags & CLONE_THREAD) { 1228 if (clone_flags & CLONE_THREAD) {
1229 atomic_inc(&current->signal->count);
1230 atomic_inc(&current->signal->live);
1243 p->group_leader = current->group_leader; 1231 p->group_leader = current->group_leader;
1244 list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group); 1232 list_add_tail_rcu(&p->thread_group, &p->group_leader->thread_group);
1245 } 1233 }
@@ -1269,6 +1257,7 @@ static struct task_struct *copy_process(unsigned long clone_flags,
1269 write_unlock_irq(&tasklist_lock); 1257 write_unlock_irq(&tasklist_lock);
1270 proc_fork_connector(p); 1258 proc_fork_connector(p);
1271 cgroup_post_fork(p); 1259 cgroup_post_fork(p);
1260 perf_counter_fork(p);
1272 return p; 1261 return p;
1273 1262
1274bad_fork_free_pid: 1263bad_fork_free_pid:
@@ -1282,7 +1271,8 @@ bad_fork_cleanup_mm:
1282 if (p->mm) 1271 if (p->mm)
1283 mmput(p->mm); 1272 mmput(p->mm);
1284bad_fork_cleanup_signal: 1273bad_fork_cleanup_signal:
1285 cleanup_signal(p); 1274 if (!(clone_flags & CLONE_THREAD))
1275 __cleanup_signal(p->signal);
1286bad_fork_cleanup_sighand: 1276bad_fork_cleanup_sighand:
1287 __cleanup_sighand(p->sighand); 1277 __cleanup_sighand(p->sighand);
1288bad_fork_cleanup_fs: 1278bad_fork_cleanup_fs:
@@ -1410,9 +1400,6 @@ long do_fork(unsigned long clone_flags,
1410 init_completion(&vfork); 1400 init_completion(&vfork);
1411 } 1401 }
1412 1402
1413 if (!(clone_flags & CLONE_THREAD))
1414 perf_counter_fork(p);
1415
1416 audit_finish_fork(p); 1403 audit_finish_fork(p);
1417 tracehook_report_clone(regs, clone_flags, nr, p); 1404 tracehook_report_clone(regs, clone_flags, nr, p);
1418 1405
diff --git a/kernel/futex.c b/kernel/futex.c
index 0672ff88f159..e18cfbdc7190 100644
--- a/kernel/futex.c
+++ b/kernel/futex.c
@@ -1010,15 +1010,19 @@ void requeue_futex(struct futex_q *q, struct futex_hash_bucket *hb1,
1010 * requeue_pi_wake_futex() - Wake a task that acquired the lock during requeue 1010 * requeue_pi_wake_futex() - Wake a task that acquired the lock during requeue
1011 * q: the futex_q 1011 * q: the futex_q
1012 * key: the key of the requeue target futex 1012 * key: the key of the requeue target futex
1013 * hb: the hash_bucket of the requeue target futex
1013 * 1014 *
1014 * During futex_requeue, with requeue_pi=1, it is possible to acquire the 1015 * During futex_requeue, with requeue_pi=1, it is possible to acquire the
1015 * target futex if it is uncontended or via a lock steal. Set the futex_q key 1016 * target futex if it is uncontended or via a lock steal. Set the futex_q key
1016 * to the requeue target futex so the waiter can detect the wakeup on the right 1017 * to the requeue target futex so the waiter can detect the wakeup on the right
1017 * futex, but remove it from the hb and NULL the rt_waiter so it can detect 1018 * futex, but remove it from the hb and NULL the rt_waiter so it can detect
1018 * atomic lock acquisition. Must be called with the q->lock_ptr held. 1019 * atomic lock acquisition. Set the q->lock_ptr to the requeue target hb->lock
1020 * to protect access to the pi_state to fixup the owner later. Must be called
1021 * with both q->lock_ptr and hb->lock held.
1019 */ 1022 */
1020static inline 1023static inline
1021void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key) 1024void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key,
1025 struct futex_hash_bucket *hb)
1022{ 1026{
1023 drop_futex_key_refs(&q->key); 1027 drop_futex_key_refs(&q->key);
1024 get_futex_key_refs(key); 1028 get_futex_key_refs(key);
@@ -1030,6 +1034,11 @@ void requeue_pi_wake_futex(struct futex_q *q, union futex_key *key)
1030 WARN_ON(!q->rt_waiter); 1034 WARN_ON(!q->rt_waiter);
1031 q->rt_waiter = NULL; 1035 q->rt_waiter = NULL;
1032 1036
1037 q->lock_ptr = &hb->lock;
1038#ifdef CONFIG_DEBUG_PI_LIST
1039 q->list.plist.lock = &hb->lock;
1040#endif
1041
1033 wake_up_state(q->task, TASK_NORMAL); 1042 wake_up_state(q->task, TASK_NORMAL);
1034} 1043}
1035 1044
@@ -1088,7 +1097,7 @@ static int futex_proxy_trylock_atomic(u32 __user *pifutex,
1088 ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task, 1097 ret = futex_lock_pi_atomic(pifutex, hb2, key2, ps, top_waiter->task,
1089 set_waiters); 1098 set_waiters);
1090 if (ret == 1) 1099 if (ret == 1)
1091 requeue_pi_wake_futex(top_waiter, key2); 1100 requeue_pi_wake_futex(top_waiter, key2, hb2);
1092 1101
1093 return ret; 1102 return ret;
1094} 1103}
@@ -1247,8 +1256,15 @@ retry_private:
1247 if (!match_futex(&this->key, &key1)) 1256 if (!match_futex(&this->key, &key1))
1248 continue; 1257 continue;
1249 1258
1250 WARN_ON(!requeue_pi && this->rt_waiter); 1259 /*
1251 WARN_ON(requeue_pi && !this->rt_waiter); 1260 * FUTEX_WAIT_REQEUE_PI and FUTEX_CMP_REQUEUE_PI should always
1261 * be paired with each other and no other futex ops.
1262 */
1263 if ((requeue_pi && !this->rt_waiter) ||
1264 (!requeue_pi && this->rt_waiter)) {
1265 ret = -EINVAL;
1266 break;
1267 }
1252 1268
1253 /* 1269 /*
1254 * Wake nr_wake waiters. For requeue_pi, if we acquired the 1270 * Wake nr_wake waiters. For requeue_pi, if we acquired the
@@ -1273,7 +1289,7 @@ retry_private:
1273 this->task, 1); 1289 this->task, 1);
1274 if (ret == 1) { 1290 if (ret == 1) {
1275 /* We got the lock. */ 1291 /* We got the lock. */
1276 requeue_pi_wake_futex(this, &key2); 1292 requeue_pi_wake_futex(this, &key2, hb2);
1277 continue; 1293 continue;
1278 } else if (ret) { 1294 } else if (ret) {
1279 /* -EDEADLK */ 1295 /* -EDEADLK */
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index d607a5b9ee29..235716556bf1 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -180,7 +180,8 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
180 int cmd = op & FUTEX_CMD_MASK; 180 int cmd = op & FUTEX_CMD_MASK;
181 181
182 if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || 182 if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI ||
183 cmd == FUTEX_WAIT_BITSET)) { 183 cmd == FUTEX_WAIT_BITSET ||
184 cmd == FUTEX_WAIT_REQUEUE_PI)) {
184 if (get_compat_timespec(&ts, utime)) 185 if (get_compat_timespec(&ts, utime))
185 return -EFAULT; 186 return -EFAULT;
186 if (!timespec_valid(&ts)) 187 if (!timespec_valid(&ts))
@@ -191,7 +192,8 @@ asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
191 t = ktime_add_safe(ktime_get(), t); 192 t = ktime_add_safe(ktime_get(), t);
192 tp = &t; 193 tp = &t;
193 } 194 }
194 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE) 195 if (cmd == FUTEX_REQUEUE || cmd == FUTEX_CMP_REQUEUE ||
196 cmd == FUTEX_CMP_REQUEUE_PI || cmd == FUTEX_WAKE_OP)
195 val2 = (int) (unsigned long) utime; 197 val2 = (int) (unsigned long) utime;
196 198
197 return do_futex(uaddr, op, val, tp, uaddr2, val2, val3); 199 return do_futex(uaddr, op, val, tp, uaddr2, val2, val3);
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 61c679db4687..0ec9ed831737 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -607,7 +607,6 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
607 */ 607 */
608 get_task_struct(t); 608 get_task_struct(t);
609 new->thread = t; 609 new->thread = t;
610 wake_up_process(t);
611 } 610 }
612 611
613 /* 612 /*
@@ -690,6 +689,7 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
690 (int)(new->flags & IRQF_TRIGGER_MASK)); 689 (int)(new->flags & IRQF_TRIGGER_MASK));
691 } 690 }
692 691
692 new->irq = irq;
693 *old_ptr = new; 693 *old_ptr = new;
694 694
695 /* Reset broken irq detection when installing new handler */ 695 /* Reset broken irq detection when installing new handler */
@@ -707,7 +707,13 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)
707 707
708 spin_unlock_irqrestore(&desc->lock, flags); 708 spin_unlock_irqrestore(&desc->lock, flags);
709 709
710 new->irq = irq; 710 /*
711 * Strictly no need to wake it up, but hung_task complains
712 * when no hard interrupt wakes the thread up.
713 */
714 if (new->thread)
715 wake_up_process(new->thread);
716
711 register_irq_proc(irq, desc); 717 register_irq_proc(irq, desc);
712 new->dir = NULL; 718 new->dir = NULL;
713 register_handler_proc(irq, new); 719 register_handler_proc(irq, new);
@@ -761,7 +767,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
761{ 767{
762 struct irq_desc *desc = irq_to_desc(irq); 768 struct irq_desc *desc = irq_to_desc(irq);
763 struct irqaction *action, **action_ptr; 769 struct irqaction *action, **action_ptr;
764 struct task_struct *irqthread;
765 unsigned long flags; 770 unsigned long flags;
766 771
767 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq); 772 WARN(in_interrupt(), "Trying to free IRQ %d from IRQ context!\n", irq);
@@ -809,9 +814,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
809 desc->chip->disable(irq); 814 desc->chip->disable(irq);
810 } 815 }
811 816
812 irqthread = action->thread;
813 action->thread = NULL;
814
815 spin_unlock_irqrestore(&desc->lock, flags); 817 spin_unlock_irqrestore(&desc->lock, flags);
816 818
817 unregister_handler_proc(irq, action); 819 unregister_handler_proc(irq, action);
@@ -819,12 +821,6 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
819 /* Make sure it's not being used on another CPU: */ 821 /* Make sure it's not being used on another CPU: */
820 synchronize_irq(irq); 822 synchronize_irq(irq);
821 823
822 if (irqthread) {
823 if (!test_bit(IRQTF_DIED, &action->thread_flags))
824 kthread_stop(irqthread);
825 put_task_struct(irqthread);
826 }
827
828#ifdef CONFIG_DEBUG_SHIRQ 824#ifdef CONFIG_DEBUG_SHIRQ
829 /* 825 /*
830 * It's a shared IRQ -- the driver ought to be prepared for an IRQ 826 * It's a shared IRQ -- the driver ought to be prepared for an IRQ
@@ -840,6 +836,13 @@ static struct irqaction *__free_irq(unsigned int irq, void *dev_id)
840 local_irq_restore(flags); 836 local_irq_restore(flags);
841 } 837 }
842#endif 838#endif
839
840 if (action->thread) {
841 if (!test_bit(IRQTF_DIED, &action->thread_flags))
842 kthread_stop(action->thread);
843 put_task_struct(action->thread);
844 }
845
843 return action; 846 return action;
844} 847}
845 848
diff --git a/kernel/irq/numa_migrate.c b/kernel/irq/numa_migrate.c
index 2f69bee57bf2..3fd30197da2e 100644
--- a/kernel/irq/numa_migrate.c
+++ b/kernel/irq/numa_migrate.c
@@ -107,8 +107,8 @@ out_unlock:
107 107
108struct irq_desc *move_irq_desc(struct irq_desc *desc, int node) 108struct irq_desc *move_irq_desc(struct irq_desc *desc, int node)
109{ 109{
110 /* those all static, do move them */ 110 /* those static or target node is -1, do not move them */
111 if (desc->irq < NR_IRQS_LEGACY) 111 if (desc->irq < NR_IRQS_LEGACY || node == -1)
112 return desc; 112 return desc;
113 113
114 if (desc->node != node) 114 if (desc->node != node)
diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
index d7135aa2d2c4..e94caa666dba 100644
--- a/kernel/lockdep_proc.c
+++ b/kernel/lockdep_proc.c
@@ -758,7 +758,8 @@ static int __init lockdep_proc_init(void)
758 &proc_lockdep_stats_operations); 758 &proc_lockdep_stats_operations);
759 759
760#ifdef CONFIG_LOCK_STAT 760#ifdef CONFIG_LOCK_STAT
761 proc_create("lock_stat", S_IRUSR, NULL, &proc_lock_stat_operations); 761 proc_create("lock_stat", S_IRUSR | S_IWUSR, NULL,
762 &proc_lock_stat_operations);
762#endif 763#endif
763 764
764 return 0; 765 return 0;
diff --git a/kernel/module.c b/kernel/module.c
index fd1411403558..2d537186191f 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -909,16 +909,18 @@ void __symbol_put(const char *symbol)
909} 909}
910EXPORT_SYMBOL(__symbol_put); 910EXPORT_SYMBOL(__symbol_put);
911 911
912/* Note this assumes addr is a function, which it currently always is. */
912void symbol_put_addr(void *addr) 913void symbol_put_addr(void *addr)
913{ 914{
914 struct module *modaddr; 915 struct module *modaddr;
916 unsigned long a = (unsigned long)dereference_function_descriptor(addr);
915 917
916 if (core_kernel_text((unsigned long)addr)) 918 if (core_kernel_text(a))
917 return; 919 return;
918 920
919 /* module_text_address is safe here: we're supposed to have reference 921 /* module_text_address is safe here: we're supposed to have reference
920 * to module from symbol_get, so it can't go away. */ 922 * to module from symbol_get, so it can't go away. */
921 modaddr = __module_text_address((unsigned long)addr); 923 modaddr = __module_text_address(a);
922 BUG_ON(!modaddr); 924 BUG_ON(!modaddr);
923 module_put(modaddr); 925 module_put(modaddr);
924} 926}
@@ -1272,6 +1274,10 @@ static void add_notes_attrs(struct module *mod, unsigned int nsect,
1272 struct module_notes_attrs *notes_attrs; 1274 struct module_notes_attrs *notes_attrs;
1273 struct bin_attribute *nattr; 1275 struct bin_attribute *nattr;
1274 1276
1277 /* failed to create section attributes, so can't create notes */
1278 if (!mod->sect_attrs)
1279 return;
1280
1275 /* Count notes sections and allocate structures. */ 1281 /* Count notes sections and allocate structures. */
1276 notes = 0; 1282 notes = 0;
1277 for (i = 0; i < nsect; i++) 1283 for (i = 0; i < nsect; i++)
diff --git a/kernel/panic.c b/kernel/panic.c
index 984b3ecbd72c..512ab73b0ca3 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -301,6 +301,7 @@ int oops_may_print(void)
301 */ 301 */
302void oops_enter(void) 302void oops_enter(void)
303{ 303{
304 tracing_off();
304 /* can't trust the integrity of the kernel anymore: */ 305 /* can't trust the integrity of the kernel anymore: */
305 debug_locks_off(); 306 debug_locks_off();
306 do_oops_enter_exit(); 307 do_oops_enter_exit();
diff --git a/kernel/perf_counter.c b/kernel/perf_counter.c
index 950931041954..f274e1959885 100644
--- a/kernel/perf_counter.c
+++ b/kernel/perf_counter.c
@@ -42,6 +42,7 @@ static int perf_overcommit __read_mostly = 1;
42static atomic_t nr_counters __read_mostly; 42static atomic_t nr_counters __read_mostly;
43static atomic_t nr_mmap_counters __read_mostly; 43static atomic_t nr_mmap_counters __read_mostly;
44static atomic_t nr_comm_counters __read_mostly; 44static atomic_t nr_comm_counters __read_mostly;
45static atomic_t nr_task_counters __read_mostly;
45 46
46/* 47/*
47 * perf counter paranoia level: 48 * perf counter paranoia level:
@@ -87,6 +88,7 @@ void __weak hw_perf_disable(void) { barrier(); }
87void __weak hw_perf_enable(void) { barrier(); } 88void __weak hw_perf_enable(void) { barrier(); }
88 89
89void __weak hw_perf_counter_setup(int cpu) { barrier(); } 90void __weak hw_perf_counter_setup(int cpu) { barrier(); }
91void __weak hw_perf_counter_setup_online(int cpu) { barrier(); }
90 92
91int __weak 93int __weak
92hw_perf_group_sched_in(struct perf_counter *group_leader, 94hw_perf_group_sched_in(struct perf_counter *group_leader,
@@ -305,6 +307,10 @@ counter_sched_out(struct perf_counter *counter,
305 return; 307 return;
306 308
307 counter->state = PERF_COUNTER_STATE_INACTIVE; 309 counter->state = PERF_COUNTER_STATE_INACTIVE;
310 if (counter->pending_disable) {
311 counter->pending_disable = 0;
312 counter->state = PERF_COUNTER_STATE_OFF;
313 }
308 counter->tstamp_stopped = ctx->time; 314 counter->tstamp_stopped = ctx->time;
309 counter->pmu->disable(counter); 315 counter->pmu->disable(counter);
310 counter->oncpu = -1; 316 counter->oncpu = -1;
@@ -1103,7 +1109,7 @@ static void perf_counter_sync_stat(struct perf_counter_context *ctx,
1103 __perf_counter_sync_stat(counter, next_counter); 1109 __perf_counter_sync_stat(counter, next_counter);
1104 1110
1105 counter = list_next_entry(counter, event_entry); 1111 counter = list_next_entry(counter, event_entry);
1106 next_counter = list_next_entry(counter, event_entry); 1112 next_counter = list_next_entry(next_counter, event_entry);
1107 } 1113 }
1108} 1114}
1109 1115
@@ -1497,10 +1503,21 @@ static void perf_counter_enable_on_exec(struct task_struct *task)
1497 */ 1503 */
1498static void __perf_counter_read(void *info) 1504static void __perf_counter_read(void *info)
1499{ 1505{
1506 struct perf_cpu_context *cpuctx = &__get_cpu_var(perf_cpu_context);
1500 struct perf_counter *counter = info; 1507 struct perf_counter *counter = info;
1501 struct perf_counter_context *ctx = counter->ctx; 1508 struct perf_counter_context *ctx = counter->ctx;
1502 unsigned long flags; 1509 unsigned long flags;
1503 1510
1511 /*
1512 * If this is a task context, we need to check whether it is
1513 * the current task context of this cpu. If not it has been
1514 * scheduled out before the smp call arrived. In that case
1515 * counter->count would have been updated to a recent sample
1516 * when the counter was scheduled out.
1517 */
1518 if (ctx->task && cpuctx->task_ctx != ctx)
1519 return;
1520
1504 local_irq_save(flags); 1521 local_irq_save(flags);
1505 if (ctx->is_active) 1522 if (ctx->is_active)
1506 update_context_time(ctx); 1523 update_context_time(ctx);
@@ -1654,6 +1671,8 @@ static void free_counter(struct perf_counter *counter)
1654 atomic_dec(&nr_mmap_counters); 1671 atomic_dec(&nr_mmap_counters);
1655 if (counter->attr.comm) 1672 if (counter->attr.comm)
1656 atomic_dec(&nr_comm_counters); 1673 atomic_dec(&nr_comm_counters);
1674 if (counter->attr.task)
1675 atomic_dec(&nr_task_counters);
1657 } 1676 }
1658 1677
1659 if (counter->destroy) 1678 if (counter->destroy)
@@ -1688,14 +1707,133 @@ static int perf_release(struct inode *inode, struct file *file)
1688 return 0; 1707 return 0;
1689} 1708}
1690 1709
1710static int perf_counter_read_size(struct perf_counter *counter)
1711{
1712 int entry = sizeof(u64); /* value */
1713 int size = 0;
1714 int nr = 1;
1715
1716 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
1717 size += sizeof(u64);
1718
1719 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
1720 size += sizeof(u64);
1721
1722 if (counter->attr.read_format & PERF_FORMAT_ID)
1723 entry += sizeof(u64);
1724
1725 if (counter->attr.read_format & PERF_FORMAT_GROUP) {
1726 nr += counter->group_leader->nr_siblings;
1727 size += sizeof(u64);
1728 }
1729
1730 size += entry * nr;
1731
1732 return size;
1733}
1734
1735static u64 perf_counter_read_value(struct perf_counter *counter)
1736{
1737 struct perf_counter *child;
1738 u64 total = 0;
1739
1740 total += perf_counter_read(counter);
1741 list_for_each_entry(child, &counter->child_list, child_list)
1742 total += perf_counter_read(child);
1743
1744 return total;
1745}
1746
1747static int perf_counter_read_entry(struct perf_counter *counter,
1748 u64 read_format, char __user *buf)
1749{
1750 int n = 0, count = 0;
1751 u64 values[2];
1752
1753 values[n++] = perf_counter_read_value(counter);
1754 if (read_format & PERF_FORMAT_ID)
1755 values[n++] = primary_counter_id(counter);
1756
1757 count = n * sizeof(u64);
1758
1759 if (copy_to_user(buf, values, count))
1760 return -EFAULT;
1761
1762 return count;
1763}
1764
1765static int perf_counter_read_group(struct perf_counter *counter,
1766 u64 read_format, char __user *buf)
1767{
1768 struct perf_counter *leader = counter->group_leader, *sub;
1769 int n = 0, size = 0, err = -EFAULT;
1770 u64 values[3];
1771
1772 values[n++] = 1 + leader->nr_siblings;
1773 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
1774 values[n++] = leader->total_time_enabled +
1775 atomic64_read(&leader->child_total_time_enabled);
1776 }
1777 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
1778 values[n++] = leader->total_time_running +
1779 atomic64_read(&leader->child_total_time_running);
1780 }
1781
1782 size = n * sizeof(u64);
1783
1784 if (copy_to_user(buf, values, size))
1785 return -EFAULT;
1786
1787 err = perf_counter_read_entry(leader, read_format, buf + size);
1788 if (err < 0)
1789 return err;
1790
1791 size += err;
1792
1793 list_for_each_entry(sub, &leader->sibling_list, list_entry) {
1794 err = perf_counter_read_entry(sub, read_format,
1795 buf + size);
1796 if (err < 0)
1797 return err;
1798
1799 size += err;
1800 }
1801
1802 return size;
1803}
1804
1805static int perf_counter_read_one(struct perf_counter *counter,
1806 u64 read_format, char __user *buf)
1807{
1808 u64 values[4];
1809 int n = 0;
1810
1811 values[n++] = perf_counter_read_value(counter);
1812 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
1813 values[n++] = counter->total_time_enabled +
1814 atomic64_read(&counter->child_total_time_enabled);
1815 }
1816 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
1817 values[n++] = counter->total_time_running +
1818 atomic64_read(&counter->child_total_time_running);
1819 }
1820 if (read_format & PERF_FORMAT_ID)
1821 values[n++] = primary_counter_id(counter);
1822
1823 if (copy_to_user(buf, values, n * sizeof(u64)))
1824 return -EFAULT;
1825
1826 return n * sizeof(u64);
1827}
1828
1691/* 1829/*
1692 * Read the performance counter - simple non blocking version for now 1830 * Read the performance counter - simple non blocking version for now
1693 */ 1831 */
1694static ssize_t 1832static ssize_t
1695perf_read_hw(struct perf_counter *counter, char __user *buf, size_t count) 1833perf_read_hw(struct perf_counter *counter, char __user *buf, size_t count)
1696{ 1834{
1697 u64 values[4]; 1835 u64 read_format = counter->attr.read_format;
1698 int n; 1836 int ret;
1699 1837
1700 /* 1838 /*
1701 * Return end-of-file for a read on a counter that is in 1839 * Return end-of-file for a read on a counter that is in
@@ -1705,28 +1843,18 @@ perf_read_hw(struct perf_counter *counter, char __user *buf, size_t count)
1705 if (counter->state == PERF_COUNTER_STATE_ERROR) 1843 if (counter->state == PERF_COUNTER_STATE_ERROR)
1706 return 0; 1844 return 0;
1707 1845
1846 if (count < perf_counter_read_size(counter))
1847 return -ENOSPC;
1848
1708 WARN_ON_ONCE(counter->ctx->parent_ctx); 1849 WARN_ON_ONCE(counter->ctx->parent_ctx);
1709 mutex_lock(&counter->child_mutex); 1850 mutex_lock(&counter->child_mutex);
1710 values[0] = perf_counter_read(counter); 1851 if (read_format & PERF_FORMAT_GROUP)
1711 n = 1; 1852 ret = perf_counter_read_group(counter, read_format, buf);
1712 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) 1853 else
1713 values[n++] = counter->total_time_enabled + 1854 ret = perf_counter_read_one(counter, read_format, buf);
1714 atomic64_read(&counter->child_total_time_enabled);
1715 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
1716 values[n++] = counter->total_time_running +
1717 atomic64_read(&counter->child_total_time_running);
1718 if (counter->attr.read_format & PERF_FORMAT_ID)
1719 values[n++] = primary_counter_id(counter);
1720 mutex_unlock(&counter->child_mutex); 1855 mutex_unlock(&counter->child_mutex);
1721 1856
1722 if (count < n * sizeof(u64)) 1857 return ret;
1723 return -EINVAL;
1724 count = n * sizeof(u64);
1725
1726 if (copy_to_user(buf, values, count))
1727 return -EFAULT;
1728
1729 return count;
1730} 1858}
1731 1859
1732static ssize_t 1860static ssize_t
@@ -1891,6 +2019,10 @@ int perf_counter_task_disable(void)
1891 return 0; 2019 return 0;
1892} 2020}
1893 2021
2022#ifndef PERF_COUNTER_INDEX_OFFSET
2023# define PERF_COUNTER_INDEX_OFFSET 0
2024#endif
2025
1894static int perf_counter_index(struct perf_counter *counter) 2026static int perf_counter_index(struct perf_counter *counter)
1895{ 2027{
1896 if (counter->state != PERF_COUNTER_STATE_ACTIVE) 2028 if (counter->state != PERF_COUNTER_STATE_ACTIVE)
@@ -2230,7 +2362,7 @@ static void perf_pending_counter(struct perf_pending_entry *entry)
2230 2362
2231 if (counter->pending_disable) { 2363 if (counter->pending_disable) {
2232 counter->pending_disable = 0; 2364 counter->pending_disable = 0;
2233 perf_counter_disable(counter); 2365 __perf_counter_disable(counter);
2234 } 2366 }
2235 2367
2236 if (counter->pending_wakeup) { 2368 if (counter->pending_wakeup) {
@@ -2615,7 +2747,80 @@ static u32 perf_counter_tid(struct perf_counter *counter, struct task_struct *p)
2615 return task_pid_nr_ns(p, counter->ns); 2747 return task_pid_nr_ns(p, counter->ns);
2616} 2748}
2617 2749
2618static void perf_counter_output(struct perf_counter *counter, int nmi, 2750static void perf_output_read_one(struct perf_output_handle *handle,
2751 struct perf_counter *counter)
2752{
2753 u64 read_format = counter->attr.read_format;
2754 u64 values[4];
2755 int n = 0;
2756
2757 values[n++] = atomic64_read(&counter->count);
2758 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
2759 values[n++] = counter->total_time_enabled +
2760 atomic64_read(&counter->child_total_time_enabled);
2761 }
2762 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
2763 values[n++] = counter->total_time_running +
2764 atomic64_read(&counter->child_total_time_running);
2765 }
2766 if (read_format & PERF_FORMAT_ID)
2767 values[n++] = primary_counter_id(counter);
2768
2769 perf_output_copy(handle, values, n * sizeof(u64));
2770}
2771
2772/*
2773 * XXX PERF_FORMAT_GROUP vs inherited counters seems difficult.
2774 */
2775static void perf_output_read_group(struct perf_output_handle *handle,
2776 struct perf_counter *counter)
2777{
2778 struct perf_counter *leader = counter->group_leader, *sub;
2779 u64 read_format = counter->attr.read_format;
2780 u64 values[5];
2781 int n = 0;
2782
2783 values[n++] = 1 + leader->nr_siblings;
2784
2785 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED)
2786 values[n++] = leader->total_time_enabled;
2787
2788 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING)
2789 values[n++] = leader->total_time_running;
2790
2791 if (leader != counter)
2792 leader->pmu->read(leader);
2793
2794 values[n++] = atomic64_read(&leader->count);
2795 if (read_format & PERF_FORMAT_ID)
2796 values[n++] = primary_counter_id(leader);
2797
2798 perf_output_copy(handle, values, n * sizeof(u64));
2799
2800 list_for_each_entry(sub, &leader->sibling_list, list_entry) {
2801 n = 0;
2802
2803 if (sub != counter)
2804 sub->pmu->read(sub);
2805
2806 values[n++] = atomic64_read(&sub->count);
2807 if (read_format & PERF_FORMAT_ID)
2808 values[n++] = primary_counter_id(sub);
2809
2810 perf_output_copy(handle, values, n * sizeof(u64));
2811 }
2812}
2813
2814static void perf_output_read(struct perf_output_handle *handle,
2815 struct perf_counter *counter)
2816{
2817 if (counter->attr.read_format & PERF_FORMAT_GROUP)
2818 perf_output_read_group(handle, counter);
2819 else
2820 perf_output_read_one(handle, counter);
2821}
2822
2823void perf_counter_output(struct perf_counter *counter, int nmi,
2619 struct perf_sample_data *data) 2824 struct perf_sample_data *data)
2620{ 2825{
2621 int ret; 2826 int ret;
@@ -2626,10 +2831,6 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2626 struct { 2831 struct {
2627 u32 pid, tid; 2832 u32 pid, tid;
2628 } tid_entry; 2833 } tid_entry;
2629 struct {
2630 u64 id;
2631 u64 counter;
2632 } group_entry;
2633 struct perf_callchain_entry *callchain = NULL; 2834 struct perf_callchain_entry *callchain = NULL;
2634 int callchain_size = 0; 2835 int callchain_size = 0;
2635 u64 time; 2836 u64 time;
@@ -2684,10 +2885,8 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2684 if (sample_type & PERF_SAMPLE_PERIOD) 2885 if (sample_type & PERF_SAMPLE_PERIOD)
2685 header.size += sizeof(u64); 2886 header.size += sizeof(u64);
2686 2887
2687 if (sample_type & PERF_SAMPLE_GROUP) { 2888 if (sample_type & PERF_SAMPLE_READ)
2688 header.size += sizeof(u64) + 2889 header.size += perf_counter_read_size(counter);
2689 counter->nr_siblings * sizeof(group_entry);
2690 }
2691 2890
2692 if (sample_type & PERF_SAMPLE_CALLCHAIN) { 2891 if (sample_type & PERF_SAMPLE_CALLCHAIN) {
2693 callchain = perf_callchain(data->regs); 2892 callchain = perf_callchain(data->regs);
@@ -2699,6 +2898,18 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2699 header.size += sizeof(u64); 2898 header.size += sizeof(u64);
2700 } 2899 }
2701 2900
2901 if (sample_type & PERF_SAMPLE_RAW) {
2902 int size = sizeof(u32);
2903
2904 if (data->raw)
2905 size += data->raw->size;
2906 else
2907 size += sizeof(u32);
2908
2909 WARN_ON_ONCE(size & (sizeof(u64)-1));
2910 header.size += size;
2911 }
2912
2702 ret = perf_output_begin(&handle, counter, header.size, nmi, 1); 2913 ret = perf_output_begin(&handle, counter, header.size, nmi, 1);
2703 if (ret) 2914 if (ret)
2704 return; 2915 return;
@@ -2732,26 +2943,8 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2732 if (sample_type & PERF_SAMPLE_PERIOD) 2943 if (sample_type & PERF_SAMPLE_PERIOD)
2733 perf_output_put(&handle, data->period); 2944 perf_output_put(&handle, data->period);
2734 2945
2735 /* 2946 if (sample_type & PERF_SAMPLE_READ)
2736 * XXX PERF_SAMPLE_GROUP vs inherited counters seems difficult. 2947 perf_output_read(&handle, counter);
2737 */
2738 if (sample_type & PERF_SAMPLE_GROUP) {
2739 struct perf_counter *leader, *sub;
2740 u64 nr = counter->nr_siblings;
2741
2742 perf_output_put(&handle, nr);
2743
2744 leader = counter->group_leader;
2745 list_for_each_entry(sub, &leader->sibling_list, list_entry) {
2746 if (sub != counter)
2747 sub->pmu->read(sub);
2748
2749 group_entry.id = primary_counter_id(sub);
2750 group_entry.counter = atomic64_read(&sub->count);
2751
2752 perf_output_put(&handle, group_entry);
2753 }
2754 }
2755 2948
2756 if (sample_type & PERF_SAMPLE_CALLCHAIN) { 2949 if (sample_type & PERF_SAMPLE_CALLCHAIN) {
2757 if (callchain) 2950 if (callchain)
@@ -2762,6 +2955,22 @@ static void perf_counter_output(struct perf_counter *counter, int nmi,
2762 } 2955 }
2763 } 2956 }
2764 2957
2958 if (sample_type & PERF_SAMPLE_RAW) {
2959 if (data->raw) {
2960 perf_output_put(&handle, data->raw->size);
2961 perf_output_copy(&handle, data->raw->data, data->raw->size);
2962 } else {
2963 struct {
2964 u32 size;
2965 u32 data;
2966 } raw = {
2967 .size = sizeof(u32),
2968 .data = 0,
2969 };
2970 perf_output_put(&handle, raw);
2971 }
2972 }
2973
2765 perf_output_end(&handle); 2974 perf_output_end(&handle);
2766} 2975}
2767 2976
@@ -2774,8 +2983,6 @@ struct perf_read_event {
2774 2983
2775 u32 pid; 2984 u32 pid;
2776 u32 tid; 2985 u32 tid;
2777 u64 value;
2778 u64 format[3];
2779}; 2986};
2780 2987
2781static void 2988static void
@@ -2787,80 +2994,74 @@ perf_counter_read_event(struct perf_counter *counter,
2787 .header = { 2994 .header = {
2788 .type = PERF_EVENT_READ, 2995 .type = PERF_EVENT_READ,
2789 .misc = 0, 2996 .misc = 0,
2790 .size = sizeof(event) - sizeof(event.format), 2997 .size = sizeof(event) + perf_counter_read_size(counter),
2791 }, 2998 },
2792 .pid = perf_counter_pid(counter, task), 2999 .pid = perf_counter_pid(counter, task),
2793 .tid = perf_counter_tid(counter, task), 3000 .tid = perf_counter_tid(counter, task),
2794 .value = atomic64_read(&counter->count),
2795 }; 3001 };
2796 int ret, i = 0; 3002 int ret;
2797
2798 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
2799 event.header.size += sizeof(u64);
2800 event.format[i++] = counter->total_time_enabled;
2801 }
2802
2803 if (counter->attr.read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
2804 event.header.size += sizeof(u64);
2805 event.format[i++] = counter->total_time_running;
2806 }
2807
2808 if (counter->attr.read_format & PERF_FORMAT_ID) {
2809 event.header.size += sizeof(u64);
2810 event.format[i++] = primary_counter_id(counter);
2811 }
2812 3003
2813 ret = perf_output_begin(&handle, counter, event.header.size, 0, 0); 3004 ret = perf_output_begin(&handle, counter, event.header.size, 0, 0);
2814 if (ret) 3005 if (ret)
2815 return; 3006 return;
2816 3007
2817 perf_output_copy(&handle, &event, event.header.size); 3008 perf_output_put(&handle, event);
3009 perf_output_read(&handle, counter);
3010
2818 perf_output_end(&handle); 3011 perf_output_end(&handle);
2819} 3012}
2820 3013
2821/* 3014/*
2822 * fork tracking 3015 * task tracking -- fork/exit
3016 *
3017 * enabled by: attr.comm | attr.mmap | attr.task
2823 */ 3018 */
2824 3019
2825struct perf_fork_event { 3020struct perf_task_event {
2826 struct task_struct *task; 3021 struct task_struct *task;
3022 struct perf_counter_context *task_ctx;
2827 3023
2828 struct { 3024 struct {
2829 struct perf_event_header header; 3025 struct perf_event_header header;
2830 3026
2831 u32 pid; 3027 u32 pid;
2832 u32 ppid; 3028 u32 ppid;
3029 u32 tid;
3030 u32 ptid;
2833 } event; 3031 } event;
2834}; 3032};
2835 3033
2836static void perf_counter_fork_output(struct perf_counter *counter, 3034static void perf_counter_task_output(struct perf_counter *counter,
2837 struct perf_fork_event *fork_event) 3035 struct perf_task_event *task_event)
2838{ 3036{
2839 struct perf_output_handle handle; 3037 struct perf_output_handle handle;
2840 int size = fork_event->event.header.size; 3038 int size = task_event->event.header.size;
2841 struct task_struct *task = fork_event->task; 3039 struct task_struct *task = task_event->task;
2842 int ret = perf_output_begin(&handle, counter, size, 0, 0); 3040 int ret = perf_output_begin(&handle, counter, size, 0, 0);
2843 3041
2844 if (ret) 3042 if (ret)
2845 return; 3043 return;
2846 3044
2847 fork_event->event.pid = perf_counter_pid(counter, task); 3045 task_event->event.pid = perf_counter_pid(counter, task);
2848 fork_event->event.ppid = perf_counter_pid(counter, task->real_parent); 3046 task_event->event.ppid = perf_counter_pid(counter, current);
2849 3047
2850 perf_output_put(&handle, fork_event->event); 3048 task_event->event.tid = perf_counter_tid(counter, task);
3049 task_event->event.ptid = perf_counter_tid(counter, current);
3050
3051 perf_output_put(&handle, task_event->event);
2851 perf_output_end(&handle); 3052 perf_output_end(&handle);
2852} 3053}
2853 3054
2854static int perf_counter_fork_match(struct perf_counter *counter) 3055static int perf_counter_task_match(struct perf_counter *counter)
2855{ 3056{
2856 if (counter->attr.comm || counter->attr.mmap) 3057 if (counter->attr.comm || counter->attr.mmap || counter->attr.task)
2857 return 1; 3058 return 1;
2858 3059
2859 return 0; 3060 return 0;
2860} 3061}
2861 3062
2862static void perf_counter_fork_ctx(struct perf_counter_context *ctx, 3063static void perf_counter_task_ctx(struct perf_counter_context *ctx,
2863 struct perf_fork_event *fork_event) 3064 struct perf_task_event *task_event)
2864{ 3065{
2865 struct perf_counter *counter; 3066 struct perf_counter *counter;
2866 3067
@@ -2869,54 +3070,62 @@ static void perf_counter_fork_ctx(struct perf_counter_context *ctx,
2869 3070
2870 rcu_read_lock(); 3071 rcu_read_lock();
2871 list_for_each_entry_rcu(counter, &ctx->event_list, event_entry) { 3072 list_for_each_entry_rcu(counter, &ctx->event_list, event_entry) {
2872 if (perf_counter_fork_match(counter)) 3073 if (perf_counter_task_match(counter))
2873 perf_counter_fork_output(counter, fork_event); 3074 perf_counter_task_output(counter, task_event);
2874 } 3075 }
2875 rcu_read_unlock(); 3076 rcu_read_unlock();
2876} 3077}
2877 3078
2878static void perf_counter_fork_event(struct perf_fork_event *fork_event) 3079static void perf_counter_task_event(struct perf_task_event *task_event)
2879{ 3080{
2880 struct perf_cpu_context *cpuctx; 3081 struct perf_cpu_context *cpuctx;
2881 struct perf_counter_context *ctx; 3082 struct perf_counter_context *ctx = task_event->task_ctx;
2882 3083
2883 cpuctx = &get_cpu_var(perf_cpu_context); 3084 cpuctx = &get_cpu_var(perf_cpu_context);
2884 perf_counter_fork_ctx(&cpuctx->ctx, fork_event); 3085 perf_counter_task_ctx(&cpuctx->ctx, task_event);
2885 put_cpu_var(perf_cpu_context); 3086 put_cpu_var(perf_cpu_context);
2886 3087
2887 rcu_read_lock(); 3088 rcu_read_lock();
2888 /* 3089 if (!ctx)
2889 * doesn't really matter which of the child contexts the 3090 ctx = rcu_dereference(task_event->task->perf_counter_ctxp);
2890 * events ends up in.
2891 */
2892 ctx = rcu_dereference(current->perf_counter_ctxp);
2893 if (ctx) 3091 if (ctx)
2894 perf_counter_fork_ctx(ctx, fork_event); 3092 perf_counter_task_ctx(ctx, task_event);
2895 rcu_read_unlock(); 3093 rcu_read_unlock();
2896} 3094}
2897 3095
2898void perf_counter_fork(struct task_struct *task) 3096static void perf_counter_task(struct task_struct *task,
3097 struct perf_counter_context *task_ctx,
3098 int new)
2899{ 3099{
2900 struct perf_fork_event fork_event; 3100 struct perf_task_event task_event;
2901 3101
2902 if (!atomic_read(&nr_comm_counters) && 3102 if (!atomic_read(&nr_comm_counters) &&
2903 !atomic_read(&nr_mmap_counters)) 3103 !atomic_read(&nr_mmap_counters) &&
3104 !atomic_read(&nr_task_counters))
2904 return; 3105 return;
2905 3106
2906 fork_event = (struct perf_fork_event){ 3107 task_event = (struct perf_task_event){
2907 .task = task, 3108 .task = task,
2908 .event = { 3109 .task_ctx = task_ctx,
3110 .event = {
2909 .header = { 3111 .header = {
2910 .type = PERF_EVENT_FORK, 3112 .type = new ? PERF_EVENT_FORK : PERF_EVENT_EXIT,
2911 .misc = 0, 3113 .misc = 0,
2912 .size = sizeof(fork_event.event), 3114 .size = sizeof(task_event.event),
2913 }, 3115 },
2914 /* .pid */ 3116 /* .pid */
2915 /* .ppid */ 3117 /* .ppid */
3118 /* .tid */
3119 /* .ptid */
2916 }, 3120 },
2917 }; 3121 };
2918 3122
2919 perf_counter_fork_event(&fork_event); 3123 perf_counter_task_event(&task_event);
3124}
3125
3126void perf_counter_fork(struct task_struct *task)
3127{
3128 perf_counter_task(task, NULL, 1);
2920} 3129}
2921 3130
2922/* 3131/*
@@ -3305,125 +3514,111 @@ int perf_counter_overflow(struct perf_counter *counter, int nmi,
3305 * Generic software counter infrastructure 3514 * Generic software counter infrastructure
3306 */ 3515 */
3307 3516
3308static void perf_swcounter_update(struct perf_counter *counter) 3517/*
3518 * We directly increment counter->count and keep a second value in
3519 * counter->hw.period_left to count intervals. This period counter
3520 * is kept in the range [-sample_period, 0] so that we can use the
3521 * sign as trigger.
3522 */
3523
3524static u64 perf_swcounter_set_period(struct perf_counter *counter)
3309{ 3525{
3310 struct hw_perf_counter *hwc = &counter->hw; 3526 struct hw_perf_counter *hwc = &counter->hw;
3311 u64 prev, now; 3527 u64 period = hwc->last_period;
3312 s64 delta; 3528 u64 nr, offset;
3529 s64 old, val;
3530
3531 hwc->last_period = hwc->sample_period;
3313 3532
3314again: 3533again:
3315 prev = atomic64_read(&hwc->prev_count); 3534 old = val = atomic64_read(&hwc->period_left);
3316 now = atomic64_read(&hwc->count); 3535 if (val < 0)
3317 if (atomic64_cmpxchg(&hwc->prev_count, prev, now) != prev) 3536 return 0;
3318 goto again;
3319 3537
3320 delta = now - prev; 3538 nr = div64_u64(period + val, period);
3539 offset = nr * period;
3540 val -= offset;
3541 if (atomic64_cmpxchg(&hwc->period_left, old, val) != old)
3542 goto again;
3321 3543
3322 atomic64_add(delta, &counter->count); 3544 return nr;
3323 atomic64_sub(delta, &hwc->period_left);
3324} 3545}
3325 3546
3326static void perf_swcounter_set_period(struct perf_counter *counter) 3547static void perf_swcounter_overflow(struct perf_counter *counter,
3548 int nmi, struct perf_sample_data *data)
3327{ 3549{
3328 struct hw_perf_counter *hwc = &counter->hw; 3550 struct hw_perf_counter *hwc = &counter->hw;
3329 s64 left = atomic64_read(&hwc->period_left); 3551 u64 overflow;
3330 s64 period = hwc->sample_period;
3331 3552
3332 if (unlikely(left <= -period)) { 3553 data->period = counter->hw.last_period;
3333 left = period; 3554 overflow = perf_swcounter_set_period(counter);
3334 atomic64_set(&hwc->period_left, left);
3335 hwc->last_period = period;
3336 }
3337 3555
3338 if (unlikely(left <= 0)) { 3556 if (hwc->interrupts == MAX_INTERRUPTS)
3339 left += period; 3557 return;
3340 atomic64_add(period, &hwc->period_left);
3341 hwc->last_period = period;
3342 }
3343 3558
3344 atomic64_set(&hwc->prev_count, -left); 3559 for (; overflow; overflow--) {
3345 atomic64_set(&hwc->count, -left); 3560 if (perf_counter_overflow(counter, nmi, data)) {
3561 /*
3562 * We inhibit the overflow from happening when
3563 * hwc->interrupts == MAX_INTERRUPTS.
3564 */
3565 break;
3566 }
3567 }
3346} 3568}
3347 3569
3348static enum hrtimer_restart perf_swcounter_hrtimer(struct hrtimer *hrtimer) 3570static void perf_swcounter_unthrottle(struct perf_counter *counter)
3349{ 3571{
3350 enum hrtimer_restart ret = HRTIMER_RESTART;
3351 struct perf_sample_data data;
3352 struct perf_counter *counter;
3353 u64 period;
3354
3355 counter = container_of(hrtimer, struct perf_counter, hw.hrtimer);
3356 counter->pmu->read(counter);
3357
3358 data.addr = 0;
3359 data.regs = get_irq_regs();
3360 /* 3572 /*
3361 * In case we exclude kernel IPs or are somehow not in interrupt 3573 * Nothing to do, we already reset hwc->interrupts.
3362 * context, provide the next best thing, the user IP.
3363 */ 3574 */
3364 if ((counter->attr.exclude_kernel || !data.regs) && 3575}
3365 !counter->attr.exclude_user)
3366 data.regs = task_pt_regs(current);
3367 3576
3368 if (data.regs) { 3577static void perf_swcounter_add(struct perf_counter *counter, u64 nr,
3369 if (perf_counter_overflow(counter, 0, &data)) 3578 int nmi, struct perf_sample_data *data)
3370 ret = HRTIMER_NORESTART; 3579{
3371 } 3580 struct hw_perf_counter *hwc = &counter->hw;
3372 3581
3373 period = max_t(u64, 10000, counter->hw.sample_period); 3582 atomic64_add(nr, &counter->count);
3374 hrtimer_forward_now(hrtimer, ns_to_ktime(period));
3375 3583
3376 return ret; 3584 if (!hwc->sample_period)
3377} 3585 return;
3378 3586
3379static void perf_swcounter_overflow(struct perf_counter *counter, 3587 if (!data->regs)
3380 int nmi, struct perf_sample_data *data) 3588 return;
3381{
3382 data->period = counter->hw.last_period;
3383 3589
3384 perf_swcounter_update(counter); 3590 if (!atomic64_add_negative(nr, &hwc->period_left))
3385 perf_swcounter_set_period(counter); 3591 perf_swcounter_overflow(counter, nmi, data);
3386 if (perf_counter_overflow(counter, nmi, data))
3387 /* soft-disable the counter */
3388 ;
3389} 3592}
3390 3593
3391static int perf_swcounter_is_counting(struct perf_counter *counter) 3594static int perf_swcounter_is_counting(struct perf_counter *counter)
3392{ 3595{
3393 struct perf_counter_context *ctx; 3596 /*
3394 unsigned long flags; 3597 * The counter is active, we're good!
3395 int count; 3598 */
3396
3397 if (counter->state == PERF_COUNTER_STATE_ACTIVE) 3599 if (counter->state == PERF_COUNTER_STATE_ACTIVE)
3398 return 1; 3600 return 1;
3399 3601
3602 /*
3603 * The counter is off/error, not counting.
3604 */
3400 if (counter->state != PERF_COUNTER_STATE_INACTIVE) 3605 if (counter->state != PERF_COUNTER_STATE_INACTIVE)
3401 return 0; 3606 return 0;
3402 3607
3403 /* 3608 /*
3404 * If the counter is inactive, it could be just because 3609 * The counter is inactive, if the context is active
3405 * its task is scheduled out, or because it's in a group 3610 * we're part of a group that didn't make it on the 'pmu',
3406 * which could not go on the PMU. We want to count in 3611 * not counting.
3407 * the first case but not the second. If the context is
3408 * currently active then an inactive software counter must
3409 * be the second case. If it's not currently active then
3410 * we need to know whether the counter was active when the
3411 * context was last active, which we can determine by
3412 * comparing counter->tstamp_stopped with ctx->time.
3413 *
3414 * We are within an RCU read-side critical section,
3415 * which protects the existence of *ctx.
3416 */ 3612 */
3417 ctx = counter->ctx; 3613 if (counter->ctx->is_active)
3418 spin_lock_irqsave(&ctx->lock, flags); 3614 return 0;
3419 count = 1; 3615
3420 /* Re-check state now we have the lock */ 3616 /*
3421 if (counter->state < PERF_COUNTER_STATE_INACTIVE || 3617 * We're inactive and the context is too, this means the
3422 counter->ctx->is_active || 3618 * task is scheduled out, we're counting events that happen
3423 counter->tstamp_stopped < ctx->time) 3619 * to us, like migration events.
3424 count = 0; 3620 */
3425 spin_unlock_irqrestore(&ctx->lock, flags); 3621 return 1;
3426 return count;
3427} 3622}
3428 3623
3429static int perf_swcounter_match(struct perf_counter *counter, 3624static int perf_swcounter_match(struct perf_counter *counter,
@@ -3449,15 +3644,6 @@ static int perf_swcounter_match(struct perf_counter *counter,
3449 return 1; 3644 return 1;
3450} 3645}
3451 3646
3452static void perf_swcounter_add(struct perf_counter *counter, u64 nr,
3453 int nmi, struct perf_sample_data *data)
3454{
3455 int neg = atomic64_add_negative(nr, &counter->hw.count);
3456
3457 if (counter->hw.sample_period && !neg && data->regs)
3458 perf_swcounter_overflow(counter, nmi, data);
3459}
3460
3461static void perf_swcounter_ctx_event(struct perf_counter_context *ctx, 3647static void perf_swcounter_ctx_event(struct perf_counter_context *ctx,
3462 enum perf_type_id type, 3648 enum perf_type_id type,
3463 u32 event, u64 nr, int nmi, 3649 u32 event, u64 nr, int nmi,
@@ -3536,27 +3722,66 @@ void __perf_swcounter_event(u32 event, u64 nr, int nmi,
3536 3722
3537static void perf_swcounter_read(struct perf_counter *counter) 3723static void perf_swcounter_read(struct perf_counter *counter)
3538{ 3724{
3539 perf_swcounter_update(counter);
3540} 3725}
3541 3726
3542static int perf_swcounter_enable(struct perf_counter *counter) 3727static int perf_swcounter_enable(struct perf_counter *counter)
3543{ 3728{
3544 perf_swcounter_set_period(counter); 3729 struct hw_perf_counter *hwc = &counter->hw;
3730
3731 if (hwc->sample_period) {
3732 hwc->last_period = hwc->sample_period;
3733 perf_swcounter_set_period(counter);
3734 }
3545 return 0; 3735 return 0;
3546} 3736}
3547 3737
3548static void perf_swcounter_disable(struct perf_counter *counter) 3738static void perf_swcounter_disable(struct perf_counter *counter)
3549{ 3739{
3550 perf_swcounter_update(counter);
3551} 3740}
3552 3741
3553static const struct pmu perf_ops_generic = { 3742static const struct pmu perf_ops_generic = {
3554 .enable = perf_swcounter_enable, 3743 .enable = perf_swcounter_enable,
3555 .disable = perf_swcounter_disable, 3744 .disable = perf_swcounter_disable,
3556 .read = perf_swcounter_read, 3745 .read = perf_swcounter_read,
3746 .unthrottle = perf_swcounter_unthrottle,
3557}; 3747};
3558 3748
3559/* 3749/*
3750 * hrtimer based swcounter callback
3751 */
3752
3753static enum hrtimer_restart perf_swcounter_hrtimer(struct hrtimer *hrtimer)
3754{
3755 enum hrtimer_restart ret = HRTIMER_RESTART;
3756 struct perf_sample_data data;
3757 struct perf_counter *counter;
3758 u64 period;
3759
3760 counter = container_of(hrtimer, struct perf_counter, hw.hrtimer);
3761 counter->pmu->read(counter);
3762
3763 data.addr = 0;
3764 data.regs = get_irq_regs();
3765 /*
3766 * In case we exclude kernel IPs or are somehow not in interrupt
3767 * context, provide the next best thing, the user IP.
3768 */
3769 if ((counter->attr.exclude_kernel || !data.regs) &&
3770 !counter->attr.exclude_user)
3771 data.regs = task_pt_regs(current);
3772
3773 if (data.regs) {
3774 if (perf_counter_overflow(counter, 0, &data))
3775 ret = HRTIMER_NORESTART;
3776 }
3777
3778 period = max_t(u64, 10000, counter->hw.sample_period);
3779 hrtimer_forward_now(hrtimer, ns_to_ktime(period));
3780
3781 return ret;
3782}
3783
3784/*
3560 * Software counter: cpu wall time clock 3785 * Software counter: cpu wall time clock
3561 */ 3786 */
3562 3787
@@ -3673,17 +3898,24 @@ static const struct pmu perf_ops_task_clock = {
3673}; 3898};
3674 3899
3675#ifdef CONFIG_EVENT_PROFILE 3900#ifdef CONFIG_EVENT_PROFILE
3676void perf_tpcounter_event(int event_id) 3901void perf_tpcounter_event(int event_id, u64 addr, u64 count, void *record,
3902 int entry_size)
3677{ 3903{
3904 struct perf_raw_record raw = {
3905 .size = entry_size,
3906 .data = record,
3907 };
3908
3678 struct perf_sample_data data = { 3909 struct perf_sample_data data = {
3679 .regs = get_irq_regs(), 3910 .regs = get_irq_regs(),
3680 .addr = 0, 3911 .addr = addr,
3912 .raw = &raw,
3681 }; 3913 };
3682 3914
3683 if (!data.regs) 3915 if (!data.regs)
3684 data.regs = task_pt_regs(current); 3916 data.regs = task_pt_regs(current);
3685 3917
3686 do_perf_swcounter_event(PERF_TYPE_TRACEPOINT, event_id, 1, 1, &data); 3918 do_perf_swcounter_event(PERF_TYPE_TRACEPOINT, event_id, count, 1, &data);
3687} 3919}
3688EXPORT_SYMBOL_GPL(perf_tpcounter_event); 3920EXPORT_SYMBOL_GPL(perf_tpcounter_event);
3689 3921
@@ -3697,6 +3929,14 @@ static void tp_perf_counter_destroy(struct perf_counter *counter)
3697 3929
3698static const struct pmu *tp_perf_counter_init(struct perf_counter *counter) 3930static const struct pmu *tp_perf_counter_init(struct perf_counter *counter)
3699{ 3931{
3932 /*
3933 * Raw tracepoint data is a severe data leak, only allow root to
3934 * have these.
3935 */
3936 if ((counter->attr.sample_type & PERF_SAMPLE_RAW) &&
3937 !capable(CAP_SYS_ADMIN))
3938 return ERR_PTR(-EPERM);
3939
3700 if (ftrace_profile_enable(counter->attr.config)) 3940 if (ftrace_profile_enable(counter->attr.config))
3701 return NULL; 3941 return NULL;
3702 3942
@@ -3830,9 +4070,9 @@ perf_counter_alloc(struct perf_counter_attr *attr,
3830 atomic64_set(&hwc->period_left, hwc->sample_period); 4070 atomic64_set(&hwc->period_left, hwc->sample_period);
3831 4071
3832 /* 4072 /*
3833 * we currently do not support PERF_SAMPLE_GROUP on inherited counters 4073 * we currently do not support PERF_FORMAT_GROUP on inherited counters
3834 */ 4074 */
3835 if (attr->inherit && (attr->sample_type & PERF_SAMPLE_GROUP)) 4075 if (attr->inherit && (attr->read_format & PERF_FORMAT_GROUP))
3836 goto done; 4076 goto done;
3837 4077
3838 switch (attr->type) { 4078 switch (attr->type) {
@@ -3875,6 +4115,8 @@ done:
3875 atomic_inc(&nr_mmap_counters); 4115 atomic_inc(&nr_mmap_counters);
3876 if (counter->attr.comm) 4116 if (counter->attr.comm)
3877 atomic_inc(&nr_comm_counters); 4117 atomic_inc(&nr_comm_counters);
4118 if (counter->attr.task)
4119 atomic_inc(&nr_task_counters);
3878 } 4120 }
3879 4121
3880 return counter; 4122 return counter;
@@ -4236,8 +4478,10 @@ void perf_counter_exit_task(struct task_struct *child)
4236 struct perf_counter_context *child_ctx; 4478 struct perf_counter_context *child_ctx;
4237 unsigned long flags; 4479 unsigned long flags;
4238 4480
4239 if (likely(!child->perf_counter_ctxp)) 4481 if (likely(!child->perf_counter_ctxp)) {
4482 perf_counter_task(child, NULL, 0);
4240 return; 4483 return;
4484 }
4241 4485
4242 local_irq_save(flags); 4486 local_irq_save(flags);
4243 /* 4487 /*
@@ -4262,8 +4506,14 @@ void perf_counter_exit_task(struct task_struct *child)
4262 * the counters from it. 4506 * the counters from it.
4263 */ 4507 */
4264 unclone_ctx(child_ctx); 4508 unclone_ctx(child_ctx);
4265 spin_unlock(&child_ctx->lock); 4509 spin_unlock_irqrestore(&child_ctx->lock, flags);
4266 local_irq_restore(flags); 4510
4511 /*
4512 * Report the task dead after unscheduling the counters so that we
4513 * won't get any samples after PERF_EVENT_EXIT. We can however still
4514 * get a few PERF_EVENT_READ events.
4515 */
4516 perf_counter_task(child, child_ctx, 0);
4267 4517
4268 /* 4518 /*
4269 * We can recurse on the same lock type through: 4519 * We can recurse on the same lock type through:
@@ -4484,6 +4734,11 @@ perf_cpu_notify(struct notifier_block *self, unsigned long action, void *hcpu)
4484 perf_counter_init_cpu(cpu); 4734 perf_counter_init_cpu(cpu);
4485 break; 4735 break;
4486 4736
4737 case CPU_ONLINE:
4738 case CPU_ONLINE_FROZEN:
4739 hw_perf_counter_setup_online(cpu);
4740 break;
4741
4487 case CPU_DOWN_PREPARE: 4742 case CPU_DOWN_PREPARE:
4488 case CPU_DOWN_PREPARE_FROZEN: 4743 case CPU_DOWN_PREPARE_FROZEN:
4489 perf_counter_exit_cpu(cpu); 4744 perf_counter_exit_cpu(cpu);
@@ -4508,6 +4763,8 @@ void __init perf_counter_init(void)
4508{ 4763{
4509 perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_UP_PREPARE, 4764 perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_UP_PREPARE,
4510 (void *)(long)smp_processor_id()); 4765 (void *)(long)smp_processor_id());
4766 perf_cpu_notify(&perf_cpu_nb, (unsigned long)CPU_ONLINE,
4767 (void *)(long)smp_processor_id());
4511 register_cpu_notifier(&perf_cpu_nb); 4768 register_cpu_notifier(&perf_cpu_nb);
4512} 4769}
4513 4770
diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
index bece7c0b67b2..e33a21cb9407 100644
--- a/kernel/posix-cpu-timers.c
+++ b/kernel/posix-cpu-timers.c
@@ -521,11 +521,12 @@ void posix_cpu_timers_exit(struct task_struct *tsk)
521} 521}
522void posix_cpu_timers_exit_group(struct task_struct *tsk) 522void posix_cpu_timers_exit_group(struct task_struct *tsk)
523{ 523{
524 struct task_cputime cputime; 524 struct signal_struct *const sig = tsk->signal;
525 525
526 thread_group_cputimer(tsk, &cputime);
527 cleanup_timers(tsk->signal->cpu_timers, 526 cleanup_timers(tsk->signal->cpu_timers,
528 cputime.utime, cputime.stime, cputime.sum_exec_runtime); 527 cputime_add(tsk->utime, sig->utime),
528 cputime_add(tsk->stime, sig->stime),
529 tsk->se.sum_exec_runtime + sig->sum_sched_runtime);
529} 530}
530 531
531static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now) 532static void clear_dead_task(struct k_itimer *timer, union cpu_time_count now)
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
index 052ec4d195c7..d089d052c4a9 100644
--- a/kernel/posix-timers.c
+++ b/kernel/posix-timers.c
@@ -202,6 +202,12 @@ static int no_timer_create(struct k_itimer *new_timer)
202 return -EOPNOTSUPP; 202 return -EOPNOTSUPP;
203} 203}
204 204
205static int no_nsleep(const clockid_t which_clock, int flags,
206 struct timespec *tsave, struct timespec __user *rmtp)
207{
208 return -EOPNOTSUPP;
209}
210
205/* 211/*
206 * Return nonzero if we know a priori this clockid_t value is bogus. 212 * Return nonzero if we know a priori this clockid_t value is bogus.
207 */ 213 */
@@ -254,6 +260,7 @@ static __init int init_posix_timers(void)
254 .clock_get = posix_get_monotonic_raw, 260 .clock_get = posix_get_monotonic_raw,
255 .clock_set = do_posix_clock_nosettime, 261 .clock_set = do_posix_clock_nosettime,
256 .timer_create = no_timer_create, 262 .timer_create = no_timer_create,
263 .nsleep = no_nsleep,
257 }; 264 };
258 265
259 register_posix_clock(CLOCK_REALTIME, &clock_realtime); 266 register_posix_clock(CLOCK_REALTIME, &clock_realtime);
diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
index fcd107a78c5a..29bd4baf9e75 100644
--- a/kernel/rtmutex.c
+++ b/kernel/rtmutex.c
@@ -1039,16 +1039,14 @@ int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
1039 if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) { 1039 if (!rt_mutex_owner(lock) || try_to_steal_lock(lock, task)) {
1040 /* We got the lock for task. */ 1040 /* We got the lock for task. */
1041 debug_rt_mutex_lock(lock); 1041 debug_rt_mutex_lock(lock);
1042
1043 rt_mutex_set_owner(lock, task, 0); 1042 rt_mutex_set_owner(lock, task, 0);
1044 1043 spin_unlock(&lock->wait_lock);
1045 rt_mutex_deadlock_account_lock(lock, task); 1044 rt_mutex_deadlock_account_lock(lock, task);
1046 return 1; 1045 return 1;
1047 } 1046 }
1048 1047
1049 ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock); 1048 ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock);
1050 1049
1051
1052 if (ret && !waiter->task) { 1050 if (ret && !waiter->task) {
1053 /* 1051 /*
1054 * Reset the return value. We might have 1052 * Reset the return value. We might have
diff --git a/kernel/sched_cpupri.c b/kernel/sched_cpupri.c
index e6c251790dde..d014efbf947a 100644
--- a/kernel/sched_cpupri.c
+++ b/kernel/sched_cpupri.c
@@ -81,8 +81,21 @@ int cpupri_find(struct cpupri *cp, struct task_struct *p,
81 if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids) 81 if (cpumask_any_and(&p->cpus_allowed, vec->mask) >= nr_cpu_ids)
82 continue; 82 continue;
83 83
84 if (lowest_mask) 84 if (lowest_mask) {
85 cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask); 85 cpumask_and(lowest_mask, &p->cpus_allowed, vec->mask);
86
87 /*
88 * We have to ensure that we have at least one bit
89 * still set in the array, since the map could have
90 * been concurrently emptied between the first and
91 * second reads of vec->mask. If we hit this
92 * condition, simply act as though we never hit this
93 * priority level and continue on.
94 */
95 if (cpumask_any(lowest_mask) >= nr_cpu_ids)
96 continue;
97 }
98
86 return 1; 99 return 1;
87 } 100 }
88 101
diff --git a/kernel/sched_fair.c b/kernel/sched_fair.c
index 9ffb2b2ceba4..652e8bdef9aa 100644
--- a/kernel/sched_fair.c
+++ b/kernel/sched_fair.c
@@ -611,9 +611,13 @@ account_entity_dequeue(struct cfs_rq *cfs_rq, struct sched_entity *se)
611static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se) 611static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se)
612{ 612{
613#ifdef CONFIG_SCHEDSTATS 613#ifdef CONFIG_SCHEDSTATS
614 struct task_struct *tsk = NULL;
615
616 if (entity_is_task(se))
617 tsk = task_of(se);
618
614 if (se->sleep_start) { 619 if (se->sleep_start) {
615 u64 delta = rq_of(cfs_rq)->clock - se->sleep_start; 620 u64 delta = rq_of(cfs_rq)->clock - se->sleep_start;
616 struct task_struct *tsk = task_of(se);
617 621
618 if ((s64)delta < 0) 622 if ((s64)delta < 0)
619 delta = 0; 623 delta = 0;
@@ -624,11 +628,11 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se)
624 se->sleep_start = 0; 628 se->sleep_start = 0;
625 se->sum_sleep_runtime += delta; 629 se->sum_sleep_runtime += delta;
626 630
627 account_scheduler_latency(tsk, delta >> 10, 1); 631 if (tsk)
632 account_scheduler_latency(tsk, delta >> 10, 1);
628 } 633 }
629 if (se->block_start) { 634 if (se->block_start) {
630 u64 delta = rq_of(cfs_rq)->clock - se->block_start; 635 u64 delta = rq_of(cfs_rq)->clock - se->block_start;
631 struct task_struct *tsk = task_of(se);
632 636
633 if ((s64)delta < 0) 637 if ((s64)delta < 0)
634 delta = 0; 638 delta = 0;
@@ -639,17 +643,19 @@ static void enqueue_sleeper(struct cfs_rq *cfs_rq, struct sched_entity *se)
639 se->block_start = 0; 643 se->block_start = 0;
640 se->sum_sleep_runtime += delta; 644 se->sum_sleep_runtime += delta;
641 645
642 /* 646 if (tsk) {
643 * Blocking time is in units of nanosecs, so shift by 20 to 647 /*
644 * get a milliseconds-range estimation of the amount of 648 * Blocking time is in units of nanosecs, so shift by
645 * time that the task spent sleeping: 649 * 20 to get a milliseconds-range estimation of the
646 */ 650 * amount of time that the task spent sleeping:
647 if (unlikely(prof_on == SLEEP_PROFILING)) { 651 */
648 652 if (unlikely(prof_on == SLEEP_PROFILING)) {
649 profile_hits(SLEEP_PROFILING, (void *)get_wchan(tsk), 653 profile_hits(SLEEP_PROFILING,
650 delta >> 20); 654 (void *)get_wchan(tsk),
655 delta >> 20);
656 }
657 account_scheduler_latency(tsk, delta >> 10, 0);
651 } 658 }
652 account_scheduler_latency(tsk, delta >> 10, 0);
653 } 659 }
654#endif 660#endif
655} 661}
diff --git a/kernel/signal.c b/kernel/signal.c
index ccf1ceedaebe..64c5deeaca5d 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2454,11 +2454,9 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
2454 stack_t oss; 2454 stack_t oss;
2455 int error; 2455 int error;
2456 2456
2457 if (uoss) { 2457 oss.ss_sp = (void __user *) current->sas_ss_sp;
2458 oss.ss_sp = (void __user *) current->sas_ss_sp; 2458 oss.ss_size = current->sas_ss_size;
2459 oss.ss_size = current->sas_ss_size; 2459 oss.ss_flags = sas_ss_flags(sp);
2460 oss.ss_flags = sas_ss_flags(sp);
2461 }
2462 2460
2463 if (uss) { 2461 if (uss) {
2464 void __user *ss_sp; 2462 void __user *ss_sp;
@@ -2466,10 +2464,12 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
2466 int ss_flags; 2464 int ss_flags;
2467 2465
2468 error = -EFAULT; 2466 error = -EFAULT;
2469 if (!access_ok(VERIFY_READ, uss, sizeof(*uss)) 2467 if (!access_ok(VERIFY_READ, uss, sizeof(*uss)))
2470 || __get_user(ss_sp, &uss->ss_sp) 2468 goto out;
2471 || __get_user(ss_flags, &uss->ss_flags) 2469 error = __get_user(ss_sp, &uss->ss_sp) |
2472 || __get_user(ss_size, &uss->ss_size)) 2470 __get_user(ss_flags, &uss->ss_flags) |
2471 __get_user(ss_size, &uss->ss_size);
2472 if (error)
2473 goto out; 2473 goto out;
2474 2474
2475 error = -EPERM; 2475 error = -EPERM;
@@ -2501,13 +2501,16 @@ do_sigaltstack (const stack_t __user *uss, stack_t __user *uoss, unsigned long s
2501 current->sas_ss_size = ss_size; 2501 current->sas_ss_size = ss_size;
2502 } 2502 }
2503 2503
2504 error = 0;
2504 if (uoss) { 2505 if (uoss) {
2505 error = -EFAULT; 2506 error = -EFAULT;
2506 if (copy_to_user(uoss, &oss, sizeof(oss))) 2507 if (!access_ok(VERIFY_WRITE, uoss, sizeof(*uoss)))
2507 goto out; 2508 goto out;
2509 error = __put_user(oss.ss_sp, &uoss->ss_sp) |
2510 __put_user(oss.ss_size, &uoss->ss_size) |
2511 __put_user(oss.ss_flags, &uoss->ss_flags);
2508 } 2512 }
2509 2513
2510 error = 0;
2511out: 2514out:
2512 return error; 2515 return error;
2513} 2516}
diff --git a/kernel/smp.c b/kernel/smp.c
index ad63d8501207..94188b8ecc33 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -57,7 +57,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
57 return NOTIFY_BAD; 57 return NOTIFY_BAD;
58 break; 58 break;
59 59
60#ifdef CONFIG_CPU_HOTPLUG 60#ifdef CONFIG_HOTPLUG_CPU
61 case CPU_UP_CANCELED: 61 case CPU_UP_CANCELED:
62 case CPU_UP_CANCELED_FROZEN: 62 case CPU_UP_CANCELED_FROZEN:
63 63
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 98e02328c67d..58be76017fd0 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -49,6 +49,7 @@
49#include <linux/acpi.h> 49#include <linux/acpi.h>
50#include <linux/reboot.h> 50#include <linux/reboot.h>
51#include <linux/ftrace.h> 51#include <linux/ftrace.h>
52#include <linux/security.h>
52#include <linux/slow-work.h> 53#include <linux/slow-work.h>
53#include <linux/perf_counter.h> 54#include <linux/perf_counter.h>
54 55
@@ -1306,10 +1307,10 @@ static struct ctl_table vm_table[] = {
1306 { 1307 {
1307 .ctl_name = CTL_UNNUMBERED, 1308 .ctl_name = CTL_UNNUMBERED,
1308 .procname = "mmap_min_addr", 1309 .procname = "mmap_min_addr",
1309 .data = &mmap_min_addr, 1310 .data = &dac_mmap_min_addr,
1310 .maxlen = sizeof(unsigned long), 1311 .maxlen = sizeof(unsigned long),
1311 .mode = 0644, 1312 .mode = 0644,
1312 .proc_handler = &proc_doulongvec_minmax, 1313 .proc_handler = &mmap_min_addr_handler,
1313 }, 1314 },
1314#ifdef CONFIG_NUMA 1315#ifdef CONFIG_NUMA
1315 { 1316 {
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index a6dcd67b041d..620b58abdc32 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -137,11 +137,12 @@ int clockevents_program_event(struct clock_event_device *dev, ktime_t expires,
137 */ 137 */
138int clockevents_register_notifier(struct notifier_block *nb) 138int clockevents_register_notifier(struct notifier_block *nb)
139{ 139{
140 unsigned long flags;
140 int ret; 141 int ret;
141 142
142 spin_lock(&clockevents_lock); 143 spin_lock_irqsave(&clockevents_lock, flags);
143 ret = raw_notifier_chain_register(&clockevents_chain, nb); 144 ret = raw_notifier_chain_register(&clockevents_chain, nb);
144 spin_unlock(&clockevents_lock); 145 spin_unlock_irqrestore(&clockevents_lock, flags);
145 146
146 return ret; 147 return ret;
147} 148}
@@ -178,16 +179,18 @@ static void clockevents_notify_released(void)
178 */ 179 */
179void clockevents_register_device(struct clock_event_device *dev) 180void clockevents_register_device(struct clock_event_device *dev)
180{ 181{
182 unsigned long flags;
183
181 BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED); 184 BUG_ON(dev->mode != CLOCK_EVT_MODE_UNUSED);
182 BUG_ON(!dev->cpumask); 185 BUG_ON(!dev->cpumask);
183 186
184 spin_lock(&clockevents_lock); 187 spin_lock_irqsave(&clockevents_lock, flags);
185 188
186 list_add(&dev->list, &clockevent_devices); 189 list_add(&dev->list, &clockevent_devices);
187 clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev); 190 clockevents_do_notify(CLOCK_EVT_NOTIFY_ADD, dev);
188 clockevents_notify_released(); 191 clockevents_notify_released();
189 192
190 spin_unlock(&clockevents_lock); 193 spin_unlock_irqrestore(&clockevents_lock, flags);
191} 194}
192EXPORT_SYMBOL_GPL(clockevents_register_device); 195EXPORT_SYMBOL_GPL(clockevents_register_device);
193 196
@@ -235,8 +238,9 @@ void clockevents_exchange_device(struct clock_event_device *old,
235void clockevents_notify(unsigned long reason, void *arg) 238void clockevents_notify(unsigned long reason, void *arg)
236{ 239{
237 struct list_head *node, *tmp; 240 struct list_head *node, *tmp;
241 unsigned long flags;
238 242
239 spin_lock(&clockevents_lock); 243 spin_lock_irqsave(&clockevents_lock, flags);
240 clockevents_do_notify(reason, arg); 244 clockevents_do_notify(reason, arg);
241 245
242 switch (reason) { 246 switch (reason) {
@@ -251,7 +255,7 @@ void clockevents_notify(unsigned long reason, void *arg)
251 default: 255 default:
252 break; 256 break;
253 } 257 }
254 spin_unlock(&clockevents_lock); 258 spin_unlock_irqrestore(&clockevents_lock, flags);
255} 259}
256EXPORT_SYMBOL_GPL(clockevents_notify); 260EXPORT_SYMBOL_GPL(clockevents_notify);
257#endif 261#endif
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 877dbedc3118..c2ec25087a35 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -205,11 +205,11 @@ static void tick_handle_periodic_broadcast(struct clock_event_device *dev)
205 * Powerstate information: The system enters/leaves a state, where 205 * Powerstate information: The system enters/leaves a state, where
206 * affected devices might stop 206 * affected devices might stop
207 */ 207 */
208static void tick_do_broadcast_on_off(void *why) 208static void tick_do_broadcast_on_off(unsigned long *reason)
209{ 209{
210 struct clock_event_device *bc, *dev; 210 struct clock_event_device *bc, *dev;
211 struct tick_device *td; 211 struct tick_device *td;
212 unsigned long flags, *reason = why; 212 unsigned long flags;
213 int cpu, bc_stopped; 213 int cpu, bc_stopped;
214 214
215 spin_lock_irqsave(&tick_broadcast_lock, flags); 215 spin_lock_irqsave(&tick_broadcast_lock, flags);
@@ -276,8 +276,7 @@ void tick_broadcast_on_off(unsigned long reason, int *oncpu)
276 printk(KERN_ERR "tick-broadcast: ignoring broadcast for " 276 printk(KERN_ERR "tick-broadcast: ignoring broadcast for "
277 "offline CPU #%d\n", *oncpu); 277 "offline CPU #%d\n", *oncpu);
278 else 278 else
279 smp_call_function_single(*oncpu, tick_do_broadcast_on_off, 279 tick_do_broadcast_on_off(&reason);
280 &reason, 1);
281} 280}
282 281
283/* 282/*
diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
index a999b92a1277..fddd69d16e03 100644
--- a/kernel/time/timer_list.c
+++ b/kernel/time/timer_list.c
@@ -286,7 +286,7 @@ static int __init init_timer_list_procfs(void)
286{ 286{
287 struct proc_dir_entry *pe; 287 struct proc_dir_entry *pe;
288 288
289 pe = proc_create("timer_list", 0644, NULL, &timer_list_fops); 289 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
290 if (!pe) 290 if (!pe)
291 return -ENOMEM; 291 return -ENOMEM;
292 return 0; 292 return 0;
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 1090b0aed9ba..7a34cb563fec 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -267,8 +267,8 @@ static void blk_trace_free(struct blk_trace *bt)
267{ 267{
268 debugfs_remove(bt->msg_file); 268 debugfs_remove(bt->msg_file);
269 debugfs_remove(bt->dropped_file); 269 debugfs_remove(bt->dropped_file);
270 debugfs_remove(bt->dir);
271 relay_close(bt->rchan); 270 relay_close(bt->rchan);
271 debugfs_remove(bt->dir);
272 free_percpu(bt->sequence); 272 free_percpu(bt->sequence);
273 free_percpu(bt->msg_data); 273 free_percpu(bt->msg_data);
274 kfree(bt); 274 kfree(bt);
@@ -378,18 +378,8 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
378 378
379static int blk_remove_buf_file_callback(struct dentry *dentry) 379static int blk_remove_buf_file_callback(struct dentry *dentry)
380{ 380{
381 struct dentry *parent = dentry->d_parent;
382 debugfs_remove(dentry); 381 debugfs_remove(dentry);
383 382
384 /*
385 * this will fail for all but the last file, but that is ok. what we
386 * care about is the top level buts->name directory going away, when
387 * the last trace file is gone. Then we don't have to rmdir() that
388 * manually on trace stop, so it nicely solves the issue with
389 * force killing of running traces.
390 */
391
392 debugfs_remove(parent);
393 return 0; 383 return 0;
394} 384}
395 385
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 1f3ec2afa511..25edd5cc5935 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1662,7 +1662,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
1662 1662
1663 mutex_lock(&ftrace_regex_lock); 1663 mutex_lock(&ftrace_regex_lock);
1664 if ((file->f_mode & FMODE_WRITE) && 1664 if ((file->f_mode & FMODE_WRITE) &&
1665 !(file->f_flags & O_APPEND)) 1665 (file->f_flags & O_TRUNC))
1666 ftrace_filter_reset(enable); 1666 ftrace_filter_reset(enable);
1667 1667
1668 if (file->f_mode & FMODE_READ) { 1668 if (file->f_mode & FMODE_READ) {
@@ -2278,7 +2278,11 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2278 read++; 2278 read++;
2279 cnt--; 2279 cnt--;
2280 2280
2281 if (!(iter->flags & ~FTRACE_ITER_CONT)) { 2281 /*
2282 * If the parser haven't finished with the last write,
2283 * continue reading the user input without skipping spaces.
2284 */
2285 if (!(iter->flags & FTRACE_ITER_CONT)) {
2282 /* skip white space */ 2286 /* skip white space */
2283 while (cnt && isspace(ch)) { 2287 while (cnt && isspace(ch)) {
2284 ret = get_user(ch, ubuf++); 2288 ret = get_user(ch, ubuf++);
@@ -2288,8 +2292,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2288 cnt--; 2292 cnt--;
2289 } 2293 }
2290 2294
2295 /* only spaces were written */
2291 if (isspace(ch)) { 2296 if (isspace(ch)) {
2292 file->f_pos += read; 2297 *ppos += read;
2293 ret = read; 2298 ret = read;
2294 goto out; 2299 goto out;
2295 } 2300 }
@@ -2319,12 +2324,12 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2319 if (ret) 2324 if (ret)
2320 goto out; 2325 goto out;
2321 iter->buffer_idx = 0; 2326 iter->buffer_idx = 0;
2322 } else 2327 } else {
2323 iter->flags |= FTRACE_ITER_CONT; 2328 iter->flags |= FTRACE_ITER_CONT;
2329 iter->buffer[iter->buffer_idx++] = ch;
2330 }
2324 2331
2325 2332 *ppos += read;
2326 file->f_pos += read;
2327
2328 ret = read; 2333 ret = read;
2329 out: 2334 out:
2330 mutex_unlock(&ftrace_regex_lock); 2335 mutex_unlock(&ftrace_regex_lock);
@@ -2577,7 +2582,7 @@ ftrace_graph_open(struct inode *inode, struct file *file)
2577 2582
2578 mutex_lock(&graph_lock); 2583 mutex_lock(&graph_lock);
2579 if ((file->f_mode & FMODE_WRITE) && 2584 if ((file->f_mode & FMODE_WRITE) &&
2580 !(file->f_flags & O_APPEND)) { 2585 (file->f_flags & O_TRUNC)) {
2581 ftrace_graph_count = 0; 2586 ftrace_graph_count = 0;
2582 memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs)); 2587 memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs));
2583 } 2588 }
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index bf27bb7a63e2..a330513d96ce 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -735,6 +735,7 @@ ring_buffer_free(struct ring_buffer *buffer)
735 735
736 put_online_cpus(); 736 put_online_cpus();
737 737
738 kfree(buffer->buffers);
738 free_cpumask_var(buffer->cpumask); 739 free_cpumask_var(buffer->cpumask);
739 740
740 kfree(buffer); 741 kfree(buffer);
@@ -1785,7 +1786,7 @@ void ring_buffer_discard_commit(struct ring_buffer *buffer,
1785 */ 1786 */
1786 RB_WARN_ON(buffer, !local_read(&cpu_buffer->committing)); 1787 RB_WARN_ON(buffer, !local_read(&cpu_buffer->committing));
1787 1788
1788 if (!rb_try_to_discard(cpu_buffer, event)) 1789 if (rb_try_to_discard(cpu_buffer, event))
1789 goto out; 1790 goto out;
1790 1791
1791 /* 1792 /*
@@ -2383,7 +2384,6 @@ rb_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
2383 * the box. Return the padding, and we will release 2384 * the box. Return the padding, and we will release
2384 * the current locks, and try again. 2385 * the current locks, and try again.
2385 */ 2386 */
2386 rb_advance_reader(cpu_buffer);
2387 return event; 2387 return event;
2388 2388
2389 case RINGBUF_TYPE_TIME_EXTEND: 2389 case RINGBUF_TYPE_TIME_EXTEND:
@@ -2486,7 +2486,7 @@ static inline int rb_ok_to_lock(void)
2486 * buffer too. A one time deal is all you get from reading 2486 * buffer too. A one time deal is all you get from reading
2487 * the ring buffer from an NMI. 2487 * the ring buffer from an NMI.
2488 */ 2488 */
2489 if (likely(!in_nmi() && !oops_in_progress)) 2489 if (likely(!in_nmi()))
2490 return 1; 2490 return 1;
2491 2491
2492 tracing_off_permanent(); 2492 tracing_off_permanent();
@@ -2519,6 +2519,8 @@ ring_buffer_peek(struct ring_buffer *buffer, int cpu, u64 *ts)
2519 if (dolock) 2519 if (dolock)
2520 spin_lock(&cpu_buffer->reader_lock); 2520 spin_lock(&cpu_buffer->reader_lock);
2521 event = rb_buffer_peek(buffer, cpu, ts); 2521 event = rb_buffer_peek(buffer, cpu, ts);
2522 if (event && event->type_len == RINGBUF_TYPE_PADDING)
2523 rb_advance_reader(cpu_buffer);
2522 if (dolock) 2524 if (dolock)
2523 spin_unlock(&cpu_buffer->reader_lock); 2525 spin_unlock(&cpu_buffer->reader_lock);
2524 local_irq_restore(flags); 2526 local_irq_restore(flags);
@@ -2590,12 +2592,9 @@ ring_buffer_consume(struct ring_buffer *buffer, int cpu, u64 *ts)
2590 spin_lock(&cpu_buffer->reader_lock); 2592 spin_lock(&cpu_buffer->reader_lock);
2591 2593
2592 event = rb_buffer_peek(buffer, cpu, ts); 2594 event = rb_buffer_peek(buffer, cpu, ts);
2593 if (!event) 2595 if (event)
2594 goto out_unlock; 2596 rb_advance_reader(cpu_buffer);
2595
2596 rb_advance_reader(cpu_buffer);
2597 2597
2598 out_unlock:
2599 if (dolock) 2598 if (dolock)
2600 spin_unlock(&cpu_buffer->reader_lock); 2599 spin_unlock(&cpu_buffer->reader_lock);
2601 local_irq_restore(flags); 2600 local_irq_restore(flags);
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 8bc8d8afea6a..8c358395d338 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -848,6 +848,7 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags,
848 ((pc & SOFTIRQ_MASK) ? TRACE_FLAG_SOFTIRQ : 0) | 848 ((pc & SOFTIRQ_MASK) ? TRACE_FLAG_SOFTIRQ : 0) |
849 (need_resched() ? TRACE_FLAG_NEED_RESCHED : 0); 849 (need_resched() ? TRACE_FLAG_NEED_RESCHED : 0);
850} 850}
851EXPORT_SYMBOL_GPL(tracing_generic_entry_update);
851 852
852struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr, 853struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr,
853 int type, 854 int type,
@@ -2031,7 +2032,7 @@ static int tracing_open(struct inode *inode, struct file *file)
2031 2032
2032 /* If this file was open for write, then erase contents */ 2033 /* If this file was open for write, then erase contents */
2033 if ((file->f_mode & FMODE_WRITE) && 2034 if ((file->f_mode & FMODE_WRITE) &&
2034 !(file->f_flags & O_APPEND)) { 2035 (file->f_flags & O_TRUNC)) {
2035 long cpu = (long) inode->i_private; 2036 long cpu = (long) inode->i_private;
2036 2037
2037 if (cpu == TRACE_PIPE_ALL_CPU) 2038 if (cpu == TRACE_PIPE_ALL_CPU)
@@ -3085,7 +3086,8 @@ tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter)
3085 break; 3086 break;
3086 } 3087 }
3087 3088
3088 trace_consume(iter); 3089 if (ret != TRACE_TYPE_NO_CONSUME)
3090 trace_consume(iter);
3089 rem -= count; 3091 rem -= count;
3090 if (!find_next_entry_inc(iter)) { 3092 if (!find_next_entry_inc(iter)) {
3091 rem = 0; 3093 rem = 0;
@@ -3894,17 +3896,9 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
3894 if (ret < 0) 3896 if (ret < 0)
3895 return ret; 3897 return ret;
3896 3898
3897 switch (val) { 3899 if (val != 0 && val != 1)
3898 case 0:
3899 trace_flags &= ~(1 << index);
3900 break;
3901 case 1:
3902 trace_flags |= 1 << index;
3903 break;
3904
3905 default:
3906 return -EINVAL; 3900 return -EINVAL;
3907 } 3901 set_tracer_flags(1 << index, val);
3908 3902
3909 *ppos += cnt; 3903 *ppos += cnt;
3910 3904
@@ -4233,8 +4227,11 @@ static void __ftrace_dump(bool disable_tracing)
4233 iter.pos = -1; 4227 iter.pos = -1;
4234 4228
4235 if (find_next_entry_inc(&iter) != NULL) { 4229 if (find_next_entry_inc(&iter) != NULL) {
4236 print_trace_line(&iter); 4230 int ret;
4237 trace_consume(&iter); 4231
4232 ret = print_trace_line(&iter);
4233 if (ret != TRACE_TYPE_NO_CONSUME)
4234 trace_consume(&iter);
4238 } 4235 }
4239 4236
4240 trace_printk_seq(&iter.seq); 4237 trace_printk_seq(&iter.seq);
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 3548ae5cc780..8b9f4f6e9559 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -438,10 +438,6 @@ struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
438struct trace_entry *trace_find_next_entry(struct trace_iterator *iter, 438struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
439 int *ent_cpu, u64 *ent_ts); 439 int *ent_cpu, u64 *ent_ts);
440 440
441void tracing_generic_entry_update(struct trace_entry *entry,
442 unsigned long flags,
443 int pc);
444
445void default_wait_pipe(struct trace_iterator *iter); 441void default_wait_pipe(struct trace_iterator *iter);
446void poll_wait_pipe(struct trace_iterator *iter); 442void poll_wait_pipe(struct trace_iterator *iter);
447 443
diff --git a/kernel/trace/trace_event_profile.c b/kernel/trace/trace_event_profile.c
index 5b5895afecfe..11ba5bb4ed0a 100644
--- a/kernel/trace/trace_event_profile.c
+++ b/kernel/trace/trace_event_profile.c
@@ -14,7 +14,7 @@ int ftrace_profile_enable(int event_id)
14 14
15 mutex_lock(&event_mutex); 15 mutex_lock(&event_mutex);
16 list_for_each_entry(event, &ftrace_events, list) { 16 list_for_each_entry(event, &ftrace_events, list) {
17 if (event->id == event_id) { 17 if (event->id == event_id && event->profile_enable) {
18 ret = event->profile_enable(event); 18 ret = event->profile_enable(event);
19 break; 19 break;
20 } 20 }
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 53c8fd376a88..e75276a49cf5 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -376,7 +376,7 @@ ftrace_event_seq_open(struct inode *inode, struct file *file)
376 const struct seq_operations *seq_ops; 376 const struct seq_operations *seq_ops;
377 377
378 if ((file->f_mode & FMODE_WRITE) && 378 if ((file->f_mode & FMODE_WRITE) &&
379 !(file->f_flags & O_APPEND)) 379 (file->f_flags & O_TRUNC))
380 ftrace_clear_events(); 380 ftrace_clear_events();
381 381
382 seq_ops = inode->i_private; 382 seq_ops = inode->i_private;
@@ -940,7 +940,7 @@ event_create_dir(struct ftrace_event_call *call, struct dentry *d_events,
940 entry = trace_create_file("enable", 0644, call->dir, call, 940 entry = trace_create_file("enable", 0644, call->dir, call,
941 enable); 941 enable);
942 942
943 if (call->id) 943 if (call->id && call->profile_enable)
944 entry = trace_create_file("id", 0444, call->dir, call, 944 entry = trace_create_file("id", 0444, call->dir, call,
945 id); 945 id);
946 946
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
index 936c621bbf46..f32dc9d1ea7b 100644
--- a/kernel/trace/trace_events_filter.c
+++ b/kernel/trace/trace_events_filter.c
@@ -624,9 +624,6 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
624 return -ENOSPC; 624 return -ENOSPC;
625 } 625 }
626 626
627 filter->preds[filter->n_preds] = pred;
628 filter->n_preds++;
629
630 list_for_each_entry(call, &ftrace_events, list) { 627 list_for_each_entry(call, &ftrace_events, list) {
631 628
632 if (!call->define_fields) 629 if (!call->define_fields)
@@ -643,6 +640,9 @@ static int filter_add_subsystem_pred(struct filter_parse_state *ps,
643 } 640 }
644 replace_filter_string(call->filter, filter_string); 641 replace_filter_string(call->filter, filter_string);
645 } 642 }
643
644 filter->preds[filter->n_preds] = pred;
645 filter->n_preds++;
646out: 646out:
647 return err; 647 return err;
648} 648}
@@ -1029,12 +1029,17 @@ static int replace_preds(struct event_subsystem *system,
1029 1029
1030 if (elt->op == OP_AND || elt->op == OP_OR) { 1030 if (elt->op == OP_AND || elt->op == OP_OR) {
1031 pred = create_logical_pred(elt->op); 1031 pred = create_logical_pred(elt->op);
1032 if (!pred)
1033 return -ENOMEM;
1032 if (call) { 1034 if (call) {
1033 err = filter_add_pred(ps, call, pred); 1035 err = filter_add_pred(ps, call, pred);
1034 filter_free_pred(pred); 1036 filter_free_pred(pred);
1035 } else 1037 } else {
1036 err = filter_add_subsystem_pred(ps, system, 1038 err = filter_add_subsystem_pred(ps, system,
1037 pred, filter_string); 1039 pred, filter_string);
1040 if (err)
1041 filter_free_pred(pred);
1042 }
1038 if (err) 1043 if (err)
1039 return err; 1044 return err;
1040 1045
@@ -1048,12 +1053,17 @@ static int replace_preds(struct event_subsystem *system,
1048 } 1053 }
1049 1054
1050 pred = create_pred(elt->op, operand1, operand2); 1055 pred = create_pred(elt->op, operand1, operand2);
1056 if (!pred)
1057 return -ENOMEM;
1051 if (call) { 1058 if (call) {
1052 err = filter_add_pred(ps, call, pred); 1059 err = filter_add_pred(ps, call, pred);
1053 filter_free_pred(pred); 1060 filter_free_pred(pred);
1054 } else 1061 } else {
1055 err = filter_add_subsystem_pred(ps, system, pred, 1062 err = filter_add_subsystem_pred(ps, system, pred,
1056 filter_string); 1063 filter_string);
1064 if (err)
1065 filter_free_pred(pred);
1066 }
1057 if (err) 1067 if (err)
1058 return err; 1068 return err;
1059 1069
diff --git a/kernel/trace/trace_functions_graph.c b/kernel/trace/trace_functions_graph.c
index d2249abafb53..420ec3487579 100644
--- a/kernel/trace/trace_functions_graph.c
+++ b/kernel/trace/trace_functions_graph.c
@@ -843,9 +843,16 @@ print_graph_function(struct trace_iterator *iter)
843 843
844 switch (entry->type) { 844 switch (entry->type) {
845 case TRACE_GRAPH_ENT: { 845 case TRACE_GRAPH_ENT: {
846 struct ftrace_graph_ent_entry *field; 846 /*
847 * print_graph_entry() may consume the current event,
848 * thus @field may become invalid, so we need to save it.
849 * sizeof(struct ftrace_graph_ent_entry) is very small,
850 * it can be safely saved at the stack.
851 */
852 struct ftrace_graph_ent_entry *field, saved;
847 trace_assign_type(field, entry); 853 trace_assign_type(field, entry);
848 return print_graph_entry(field, s, iter); 854 saved = *field;
855 return print_graph_entry(&saved, s, iter);
849 } 856 }
850 case TRACE_GRAPH_RET: { 857 case TRACE_GRAPH_RET: {
851 struct ftrace_graph_ret_entry *field; 858 struct ftrace_graph_ret_entry *field;
diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
index 7b6278110827..687699d365ae 100644
--- a/kernel/trace/trace_printk.c
+++ b/kernel/trace/trace_printk.c
@@ -176,7 +176,7 @@ static int t_show(struct seq_file *m, void *v)
176 const char *str = *fmt; 176 const char *str = *fmt;
177 int i; 177 int i;
178 178
179 seq_printf(m, "0x%lx : \"", (unsigned long)fmt); 179 seq_printf(m, "0x%lx : \"", *(unsigned long *)fmt);
180 180
181 /* 181 /*
182 * Tabs and new lines need to be converted. 182 * Tabs and new lines need to be converted.
diff --git a/kernel/wait.c b/kernel/wait.c
index ea7c3b4275cf..c4bd3d825f35 100644
--- a/kernel/wait.c
+++ b/kernel/wait.c
@@ -10,13 +10,14 @@
10#include <linux/wait.h> 10#include <linux/wait.h>
11#include <linux/hash.h> 11#include <linux/hash.h>
12 12
13void init_waitqueue_head(wait_queue_head_t *q) 13void __init_waitqueue_head(wait_queue_head_t *q, struct lock_class_key *key)
14{ 14{
15 spin_lock_init(&q->lock); 15 spin_lock_init(&q->lock);
16 lockdep_set_class(&q->lock, key);
16 INIT_LIST_HEAD(&q->task_list); 17 INIT_LIST_HEAD(&q->task_list);
17} 18}
18 19
19EXPORT_SYMBOL(init_waitqueue_head); 20EXPORT_SYMBOL(__init_waitqueue_head);
20 21
21void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait) 22void add_wait_queue(wait_queue_head_t *q, wait_queue_t *wait)
22{ 23{
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 35a1f7ff4149..702565821c99 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -179,14 +179,16 @@ void __bitmap_shift_left(unsigned long *dst,
179} 179}
180EXPORT_SYMBOL(__bitmap_shift_left); 180EXPORT_SYMBOL(__bitmap_shift_left);
181 181
182void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1, 182int __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
183 const unsigned long *bitmap2, int bits) 183 const unsigned long *bitmap2, int bits)
184{ 184{
185 int k; 185 int k;
186 int nr = BITS_TO_LONGS(bits); 186 int nr = BITS_TO_LONGS(bits);
187 unsigned long result = 0;
187 188
188 for (k = 0; k < nr; k++) 189 for (k = 0; k < nr; k++)
189 dst[k] = bitmap1[k] & bitmap2[k]; 190 result |= (dst[k] = bitmap1[k] & bitmap2[k]);
191 return result != 0;
190} 192}
191EXPORT_SYMBOL(__bitmap_and); 193EXPORT_SYMBOL(__bitmap_and);
192 194
@@ -212,14 +214,16 @@ void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
212} 214}
213EXPORT_SYMBOL(__bitmap_xor); 215EXPORT_SYMBOL(__bitmap_xor);
214 216
215void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1, 217int __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
216 const unsigned long *bitmap2, int bits) 218 const unsigned long *bitmap2, int bits)
217{ 219{
218 int k; 220 int k;
219 int nr = BITS_TO_LONGS(bits); 221 int nr = BITS_TO_LONGS(bits);
222 unsigned long result = 0;
220 223
221 for (k = 0; k < nr; k++) 224 for (k = 0; k < nr; k++)
222 dst[k] = bitmap1[k] & ~bitmap2[k]; 225 result |= (dst[k] = bitmap1[k] & ~bitmap2[k]);
226 return result != 0;
223} 227}
224EXPORT_SYMBOL(__bitmap_andnot); 228EXPORT_SYMBOL(__bitmap_andnot);
225 229
diff --git a/lib/decompress_bunzip2.c b/lib/decompress_bunzip2.c
index 708e2a86d87b..600f473a5610 100644
--- a/lib/decompress_bunzip2.c
+++ b/lib/decompress_bunzip2.c
@@ -45,12 +45,14 @@
45*/ 45*/
46 46
47 47
48#ifndef STATIC 48#ifdef STATIC
49#define PREBOOT
50#else
49#include <linux/decompress/bunzip2.h> 51#include <linux/decompress/bunzip2.h>
50#endif /* !STATIC */ 52#include <linux/slab.h>
53#endif /* STATIC */
51 54
52#include <linux/decompress/mm.h> 55#include <linux/decompress/mm.h>
53#include <linux/slab.h>
54 56
55#ifndef INT_MAX 57#ifndef INT_MAX
56#define INT_MAX 0x7fffffff 58#define INT_MAX 0x7fffffff
@@ -681,9 +683,7 @@ STATIC int INIT bunzip2(unsigned char *buf, int len,
681 set_error_fn(error_fn); 683 set_error_fn(error_fn);
682 if (flush) 684 if (flush)
683 outbuf = malloc(BZIP2_IOBUF_SIZE); 685 outbuf = malloc(BZIP2_IOBUF_SIZE);
684 else 686
685 len -= 4; /* Uncompressed size hack active in pre-boot
686 environment */
687 if (!outbuf) { 687 if (!outbuf) {
688 error("Could not allocate output bufer"); 688 error("Could not allocate output bufer");
689 return -1; 689 return -1;
@@ -733,4 +733,14 @@ exit_0:
733 return i; 733 return i;
734} 734}
735 735
736#define decompress bunzip2 736#ifdef PREBOOT
737STATIC int INIT decompress(unsigned char *buf, int len,
738 int(*fill)(void*, unsigned int),
739 int(*flush)(void*, unsigned int),
740 unsigned char *outbuf,
741 int *pos,
742 void(*error_fn)(char *x))
743{
744 return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn);
745}
746#endif
diff --git a/lib/decompress_inflate.c b/lib/decompress_inflate.c
index e36b296fc9f8..68dfce59c1b8 100644
--- a/lib/decompress_inflate.c
+++ b/lib/decompress_inflate.c
@@ -19,13 +19,13 @@
19#include "zlib_inflate/inflate.h" 19#include "zlib_inflate/inflate.h"
20 20
21#include "zlib_inflate/infutil.h" 21#include "zlib_inflate/infutil.h"
22#include <linux/slab.h>
22 23
23#endif /* STATIC */ 24#endif /* STATIC */
24 25
25#include <linux/decompress/mm.h> 26#include <linux/decompress/mm.h>
26#include <linux/slab.h>
27 27
28#define INBUF_LEN (16*1024) 28#define GZIP_IOBUF_SIZE (16*1024)
29 29
30/* Included from initramfs et al code */ 30/* Included from initramfs et al code */
31STATIC int INIT gunzip(unsigned char *buf, int len, 31STATIC int INIT gunzip(unsigned char *buf, int len,
@@ -55,7 +55,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
55 if (buf) 55 if (buf)
56 zbuf = buf; 56 zbuf = buf;
57 else { 57 else {
58 zbuf = malloc(INBUF_LEN); 58 zbuf = malloc(GZIP_IOBUF_SIZE);
59 len = 0; 59 len = 0;
60 } 60 }
61 if (!zbuf) { 61 if (!zbuf) {
@@ -77,7 +77,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
77 } 77 }
78 78
79 if (len == 0) 79 if (len == 0)
80 len = fill(zbuf, INBUF_LEN); 80 len = fill(zbuf, GZIP_IOBUF_SIZE);
81 81
82 /* verify the gzip header */ 82 /* verify the gzip header */
83 if (len < 10 || 83 if (len < 10 ||
@@ -113,7 +113,7 @@ STATIC int INIT gunzip(unsigned char *buf, int len,
113 while (rc == Z_OK) { 113 while (rc == Z_OK) {
114 if (strm->avail_in == 0) { 114 if (strm->avail_in == 0) {
115 /* TODO: handle case where both pos and fill are set */ 115 /* TODO: handle case where both pos and fill are set */
116 len = fill(zbuf, INBUF_LEN); 116 len = fill(zbuf, GZIP_IOBUF_SIZE);
117 if (len < 0) { 117 if (len < 0) {
118 rc = -1; 118 rc = -1;
119 error("read error"); 119 error("read error");
diff --git a/lib/decompress_unlzma.c b/lib/decompress_unlzma.c
index 32123a1340e6..0b954e04bd30 100644
--- a/lib/decompress_unlzma.c
+++ b/lib/decompress_unlzma.c
@@ -29,12 +29,14 @@
29 *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 29 *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 */ 30 */
31 31
32#ifndef STATIC 32#ifdef STATIC
33#define PREBOOT
34#else
33#include <linux/decompress/unlzma.h> 35#include <linux/decompress/unlzma.h>
36#include <linux/slab.h>
34#endif /* STATIC */ 37#endif /* STATIC */
35 38
36#include <linux/decompress/mm.h> 39#include <linux/decompress/mm.h>
37#include <linux/slab.h>
38 40
39#define MIN(a, b) (((a) < (b)) ? (a) : (b)) 41#define MIN(a, b) (((a) < (b)) ? (a) : (b))
40 42
@@ -543,9 +545,7 @@ STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
543 int ret = -1; 545 int ret = -1;
544 546
545 set_error_fn(error_fn); 547 set_error_fn(error_fn);
546 if (!flush) 548
547 in_len -= 4; /* Uncompressed size hack active in pre-boot
548 environment */
549 if (buf) 549 if (buf)
550 inbuf = buf; 550 inbuf = buf;
551 else 551 else
@@ -645,4 +645,15 @@ exit_0:
645 return ret; 645 return ret;
646} 646}
647 647
648#define decompress unlzma 648#ifdef PREBOOT
649STATIC int INIT decompress(unsigned char *buf, int in_len,
650 int(*fill)(void*, unsigned int),
651 int(*flush)(void*, unsigned int),
652 unsigned char *output,
653 int *posp,
654 void(*error_fn)(char *x)
655 )
656{
657 return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn);
658}
659#endif
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 65b0d99b6d0a..58a9f9fc609a 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -156,9 +156,13 @@ static bool driver_filter(struct device *dev)
156 return true; 156 return true;
157 157
158 /* driver filter on and initialized */ 158 /* driver filter on and initialized */
159 if (current_driver && dev->driver == current_driver) 159 if (current_driver && dev && dev->driver == current_driver)
160 return true; 160 return true;
161 161
162 /* driver filter on, but we can't filter on a NULL device... */
163 if (!dev)
164 return false;
165
162 if (current_driver || !current_driver_name[0]) 166 if (current_driver || !current_driver_name[0])
163 return false; 167 return false;
164 168
@@ -183,17 +187,17 @@ static bool driver_filter(struct device *dev)
183 return ret; 187 return ret;
184} 188}
185 189
186#define err_printk(dev, entry, format, arg...) do { \ 190#define err_printk(dev, entry, format, arg...) do { \
187 error_count += 1; \ 191 error_count += 1; \
188 if (driver_filter(dev) && \ 192 if (driver_filter(dev) && \
189 (show_all_errors || show_num_errors > 0)) { \ 193 (show_all_errors || show_num_errors > 0)) { \
190 WARN(1, "%s %s: " format, \ 194 WARN(1, "%s %s: " format, \
191 dev_driver_string(dev), \ 195 dev ? dev_driver_string(dev) : "NULL", \
192 dev_name(dev) , ## arg); \ 196 dev ? dev_name(dev) : "NULL", ## arg); \
193 dump_entry_trace(entry); \ 197 dump_entry_trace(entry); \
194 } \ 198 } \
195 if (!show_all_errors && show_num_errors > 0) \ 199 if (!show_all_errors && show_num_errors > 0) \
196 show_num_errors -= 1; \ 200 show_num_errors -= 1; \
197 } while (0); 201 } while (0);
198 202
199/* 203/*
diff --git a/lib/flex_array.c b/lib/flex_array.c
index 0e7894ce8882..7baed2fc3bc8 100644
--- a/lib/flex_array.c
+++ b/lib/flex_array.c
@@ -99,7 +99,8 @@ static inline int elements_fit_in_base(struct flex_array *fa)
99 * capacity in the base structure. Also note that no effort is made 99 * capacity in the base structure. Also note that no effort is made
100 * to efficiently pack objects across page boundaries. 100 * to efficiently pack objects across page boundaries.
101 */ 101 */
102struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags) 102struct flex_array *flex_array_alloc(int element_size, unsigned int total,
103 gfp_t flags)
103{ 104{
104 struct flex_array *ret; 105 struct flex_array *ret;
105 int max_size = nr_base_part_ptrs() * __elements_per_part(element_size); 106 int max_size = nr_base_part_ptrs() * __elements_per_part(element_size);
@@ -115,16 +116,14 @@ struct flex_array *flex_array_alloc(int element_size, int total, gfp_t flags)
115 return ret; 116 return ret;
116} 117}
117 118
118static int fa_element_to_part_nr(struct flex_array *fa, int element_nr) 119static int fa_element_to_part_nr(struct flex_array *fa,
120 unsigned int element_nr)
119{ 121{
120 return element_nr / __elements_per_part(fa->element_size); 122 return element_nr / __elements_per_part(fa->element_size);
121} 123}
122 124
123/** 125/**
124 * flex_array_free_parts - just free the second-level pages 126 * flex_array_free_parts - just free the second-level pages
125 * @src: address of data to copy into the array
126 * @element_nr: index of the position in which to insert
127 * the new element.
128 * 127 *
129 * This is to be used in cases where the base 'struct flex_array' 128 * This is to be used in cases where the base 'struct flex_array'
130 * has been statically allocated and should not be free. 129 * has been statically allocated and should not be free.
@@ -146,14 +145,12 @@ void flex_array_free(struct flex_array *fa)
146 kfree(fa); 145 kfree(fa);
147} 146}
148 147
149static int fa_index_inside_part(struct flex_array *fa, int element_nr) 148static unsigned int index_inside_part(struct flex_array *fa,
149 unsigned int element_nr)
150{ 150{
151 return element_nr % __elements_per_part(fa->element_size); 151 unsigned int part_offset;
152}
153 152
154static int index_inside_part(struct flex_array *fa, int element_nr) 153 part_offset = element_nr % __elements_per_part(fa->element_size);
155{
156 int part_offset = fa_index_inside_part(fa, element_nr);
157 return part_offset * fa->element_size; 154 return part_offset * fa->element_size;
158} 155}
159 156
@@ -188,7 +185,8 @@ __fa_get_part(struct flex_array *fa, int part_nr, gfp_t flags)
188 * 185 *
189 * Locking must be provided by the caller. 186 * Locking must be provided by the caller.
190 */ 187 */
191int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags) 188int flex_array_put(struct flex_array *fa, unsigned int element_nr, void *src,
189 gfp_t flags)
192{ 190{
193 int part_nr = fa_element_to_part_nr(fa, element_nr); 191 int part_nr = fa_element_to_part_nr(fa, element_nr);
194 struct flex_array_part *part; 192 struct flex_array_part *part;
@@ -198,10 +196,11 @@ int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags
198 return -ENOSPC; 196 return -ENOSPC;
199 if (elements_fit_in_base(fa)) 197 if (elements_fit_in_base(fa))
200 part = (struct flex_array_part *)&fa->parts[0]; 198 part = (struct flex_array_part *)&fa->parts[0];
201 else 199 else {
202 part = __fa_get_part(fa, part_nr, flags); 200 part = __fa_get_part(fa, part_nr, flags);
203 if (!part) 201 if (!part)
204 return -ENOMEM; 202 return -ENOMEM;
203 }
205 dst = &part->elements[index_inside_part(fa, element_nr)]; 204 dst = &part->elements[index_inside_part(fa, element_nr)];
206 memcpy(dst, src, fa->element_size); 205 memcpy(dst, src, fa->element_size);
207 return 0; 206 return 0;
@@ -219,7 +218,8 @@ int flex_array_put(struct flex_array *fa, int element_nr, void *src, gfp_t flags
219 * 218 *
220 * Locking must be provided by the caller. 219 * Locking must be provided by the caller.
221 */ 220 */
222int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags) 221int flex_array_prealloc(struct flex_array *fa, unsigned int start,
222 unsigned int end, gfp_t flags)
223{ 223{
224 int start_part; 224 int start_part;
225 int end_part; 225 int end_part;
@@ -250,20 +250,19 @@ int flex_array_prealloc(struct flex_array *fa, int start, int end, gfp_t flags)
250 * 250 *
251 * Locking must be provided by the caller. 251 * Locking must be provided by the caller.
252 */ 252 */
253void *flex_array_get(struct flex_array *fa, int element_nr) 253void *flex_array_get(struct flex_array *fa, unsigned int element_nr)
254{ 254{
255 int part_nr = fa_element_to_part_nr(fa, element_nr); 255 int part_nr = fa_element_to_part_nr(fa, element_nr);
256 struct flex_array_part *part; 256 struct flex_array_part *part;
257 int index;
258 257
259 if (element_nr >= fa->total_nr_elements) 258 if (element_nr >= fa->total_nr_elements)
260 return NULL; 259 return NULL;
261 if (!fa->parts[part_nr])
262 return NULL;
263 if (elements_fit_in_base(fa)) 260 if (elements_fit_in_base(fa))
264 part = (struct flex_array_part *)&fa->parts[0]; 261 part = (struct flex_array_part *)&fa->parts[0];
265 else 262 else {
266 part = fa->parts[part_nr]; 263 part = fa->parts[part_nr];
267 index = index_inside_part(fa, element_nr); 264 if (!part)
265 return NULL;
266 }
268 return &part->elements[index_inside_part(fa, element_nr)]; 267 return &part->elements[index_inside_part(fa, element_nr)];
269} 268}
diff --git a/lib/lmb.c b/lib/lmb.c
index e4a6482d8b26..0343c05609f0 100644
--- a/lib/lmb.c
+++ b/lib/lmb.c
@@ -429,7 +429,7 @@ u64 __init lmb_phys_mem_size(void)
429 return lmb.memory.size; 429 return lmb.memory.size;
430} 430}
431 431
432u64 __init lmb_end_of_DRAM(void) 432u64 lmb_end_of_DRAM(void)
433{ 433{
434 int idx = lmb.memory.cnt - 1; 434 int idx = lmb.memory.cnt - 1;
435 435
diff --git a/mm/Kconfig b/mm/Kconfig
index c948d4ca8bde..fe5f674d7a7d 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -225,9 +225,9 @@ config DEFAULT_MMAP_MIN_ADDR
225 For most ia64, ppc64 and x86 users with lots of address space 225 For most ia64, ppc64 and x86 users with lots of address space
226 a value of 65536 is reasonable and should cause no problems. 226 a value of 65536 is reasonable and should cause no problems.
227 On arm and other archs it should not be higher than 32768. 227 On arm and other archs it should not be higher than 32768.
228 Programs which use vm86 functionality would either need additional 228 Programs which use vm86 functionality or have some need to map
229 permissions from either the LSM or the capabilities module or have 229 this low address space will need CAP_SYS_RAWIO or disable this
230 this protection disabled. 230 protection by setting the value to 0.
231 231
232 This value can be changed after boot using the 232 This value can be changed after boot using the
233 /proc/sys/vm/mmap_min_addr tunable. 233 /proc/sys/vm/mmap_min_addr tunable.
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index e08e2c4da63a..7dd9d9f80694 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -191,25 +191,27 @@ static int mpol_new_bind(struct mempolicy *pol, const nodemask_t *nodes)
191 * Must be called holding task's alloc_lock to protect task's mems_allowed 191 * Must be called holding task's alloc_lock to protect task's mems_allowed
192 * and mempolicy. May also be called holding the mmap_semaphore for write. 192 * and mempolicy. May also be called holding the mmap_semaphore for write.
193 */ 193 */
194static int mpol_set_nodemask(struct mempolicy *pol, const nodemask_t *nodes) 194static int mpol_set_nodemask(struct mempolicy *pol,
195 const nodemask_t *nodes, struct nodemask_scratch *nsc)
195{ 196{
196 nodemask_t cpuset_context_nmask;
197 int ret; 197 int ret;
198 198
199 /* if mode is MPOL_DEFAULT, pol is NULL. This is right. */ 199 /* if mode is MPOL_DEFAULT, pol is NULL. This is right. */
200 if (pol == NULL) 200 if (pol == NULL)
201 return 0; 201 return 0;
202 /* Check N_HIGH_MEMORY */
203 nodes_and(nsc->mask1,
204 cpuset_current_mems_allowed, node_states[N_HIGH_MEMORY]);
202 205
203 VM_BUG_ON(!nodes); 206 VM_BUG_ON(!nodes);
204 if (pol->mode == MPOL_PREFERRED && nodes_empty(*nodes)) 207 if (pol->mode == MPOL_PREFERRED && nodes_empty(*nodes))
205 nodes = NULL; /* explicit local allocation */ 208 nodes = NULL; /* explicit local allocation */
206 else { 209 else {
207 if (pol->flags & MPOL_F_RELATIVE_NODES) 210 if (pol->flags & MPOL_F_RELATIVE_NODES)
208 mpol_relative_nodemask(&cpuset_context_nmask, nodes, 211 mpol_relative_nodemask(&nsc->mask2, nodes,&nsc->mask1);
209 &cpuset_current_mems_allowed);
210 else 212 else
211 nodes_and(cpuset_context_nmask, *nodes, 213 nodes_and(nsc->mask2, *nodes, nsc->mask1);
212 cpuset_current_mems_allowed); 214
213 if (mpol_store_user_nodemask(pol)) 215 if (mpol_store_user_nodemask(pol))
214 pol->w.user_nodemask = *nodes; 216 pol->w.user_nodemask = *nodes;
215 else 217 else
@@ -217,8 +219,10 @@ static int mpol_set_nodemask(struct mempolicy *pol, const nodemask_t *nodes)
217 cpuset_current_mems_allowed; 219 cpuset_current_mems_allowed;
218 } 220 }
219 221
220 ret = mpol_ops[pol->mode].create(pol, 222 if (nodes)
221 nodes ? &cpuset_context_nmask : NULL); 223 ret = mpol_ops[pol->mode].create(pol, &nsc->mask2);
224 else
225 ret = mpol_ops[pol->mode].create(pol, NULL);
222 return ret; 226 return ret;
223} 227}
224 228
@@ -620,12 +624,17 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags,
620{ 624{
621 struct mempolicy *new, *old; 625 struct mempolicy *new, *old;
622 struct mm_struct *mm = current->mm; 626 struct mm_struct *mm = current->mm;
627 NODEMASK_SCRATCH(scratch);
623 int ret; 628 int ret;
624 629
625 new = mpol_new(mode, flags, nodes); 630 if (!scratch)
626 if (IS_ERR(new)) 631 return -ENOMEM;
627 return PTR_ERR(new);
628 632
633 new = mpol_new(mode, flags, nodes);
634 if (IS_ERR(new)) {
635 ret = PTR_ERR(new);
636 goto out;
637 }
629 /* 638 /*
630 * prevent changing our mempolicy while show_numa_maps() 639 * prevent changing our mempolicy while show_numa_maps()
631 * is using it. 640 * is using it.
@@ -635,13 +644,13 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags,
635 if (mm) 644 if (mm)
636 down_write(&mm->mmap_sem); 645 down_write(&mm->mmap_sem);
637 task_lock(current); 646 task_lock(current);
638 ret = mpol_set_nodemask(new, nodes); 647 ret = mpol_set_nodemask(new, nodes, scratch);
639 if (ret) { 648 if (ret) {
640 task_unlock(current); 649 task_unlock(current);
641 if (mm) 650 if (mm)
642 up_write(&mm->mmap_sem); 651 up_write(&mm->mmap_sem);
643 mpol_put(new); 652 mpol_put(new);
644 return ret; 653 goto out;
645 } 654 }
646 old = current->mempolicy; 655 old = current->mempolicy;
647 current->mempolicy = new; 656 current->mempolicy = new;
@@ -654,7 +663,10 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags,
654 up_write(&mm->mmap_sem); 663 up_write(&mm->mmap_sem);
655 664
656 mpol_put(old); 665 mpol_put(old);
657 return 0; 666 ret = 0;
667out:
668 NODEMASK_SCRATCH_FREE(scratch);
669 return ret;
658} 670}
659 671
660/* 672/*
@@ -1014,12 +1026,20 @@ static long do_mbind(unsigned long start, unsigned long len,
1014 if (err) 1026 if (err)
1015 return err; 1027 return err;
1016 } 1028 }
1017 down_write(&mm->mmap_sem); 1029 {
1018 task_lock(current); 1030 NODEMASK_SCRATCH(scratch);
1019 err = mpol_set_nodemask(new, nmask); 1031 if (scratch) {
1020 task_unlock(current); 1032 down_write(&mm->mmap_sem);
1033 task_lock(current);
1034 err = mpol_set_nodemask(new, nmask, scratch);
1035 task_unlock(current);
1036 if (err)
1037 up_write(&mm->mmap_sem);
1038 } else
1039 err = -ENOMEM;
1040 NODEMASK_SCRATCH_FREE(scratch);
1041 }
1021 if (err) { 1042 if (err) {
1022 up_write(&mm->mmap_sem);
1023 mpol_put(new); 1043 mpol_put(new);
1024 return err; 1044 return err;
1025 } 1045 }
@@ -1891,6 +1911,7 @@ restart:
1891 * Install non-NULL @mpol in inode's shared policy rb-tree. 1911 * Install non-NULL @mpol in inode's shared policy rb-tree.
1892 * On entry, the current task has a reference on a non-NULL @mpol. 1912 * On entry, the current task has a reference on a non-NULL @mpol.
1893 * This must be released on exit. 1913 * This must be released on exit.
1914 * This is called at get_inode() calls and we can use GFP_KERNEL.
1894 */ 1915 */
1895void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol) 1916void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
1896{ 1917{
@@ -1902,19 +1923,24 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
1902 if (mpol) { 1923 if (mpol) {
1903 struct vm_area_struct pvma; 1924 struct vm_area_struct pvma;
1904 struct mempolicy *new; 1925 struct mempolicy *new;
1926 NODEMASK_SCRATCH(scratch);
1905 1927
1928 if (!scratch)
1929 return;
1906 /* contextualize the tmpfs mount point mempolicy */ 1930 /* contextualize the tmpfs mount point mempolicy */
1907 new = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask); 1931 new = mpol_new(mpol->mode, mpol->flags, &mpol->w.user_nodemask);
1908 if (IS_ERR(new)) { 1932 if (IS_ERR(new)) {
1909 mpol_put(mpol); /* drop our ref on sb mpol */ 1933 mpol_put(mpol); /* drop our ref on sb mpol */
1934 NODEMASK_SCRATCH_FREE(scratch);
1910 return; /* no valid nodemask intersection */ 1935 return; /* no valid nodemask intersection */
1911 } 1936 }
1912 1937
1913 task_lock(current); 1938 task_lock(current);
1914 ret = mpol_set_nodemask(new, &mpol->w.user_nodemask); 1939 ret = mpol_set_nodemask(new, &mpol->w.user_nodemask, scratch);
1915 task_unlock(current); 1940 task_unlock(current);
1916 mpol_put(mpol); /* drop our ref on sb mpol */ 1941 mpol_put(mpol); /* drop our ref on sb mpol */
1917 if (ret) { 1942 if (ret) {
1943 NODEMASK_SCRATCH_FREE(scratch);
1918 mpol_put(new); 1944 mpol_put(new);
1919 return; 1945 return;
1920 } 1946 }
@@ -1924,6 +1950,7 @@ void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol)
1924 pvma.vm_end = TASK_SIZE; /* policy covers entire file */ 1950 pvma.vm_end = TASK_SIZE; /* policy covers entire file */
1925 mpol_set_shared_policy(sp, &pvma, new); /* adds ref */ 1951 mpol_set_shared_policy(sp, &pvma, new); /* adds ref */
1926 mpol_put(new); /* drop initial ref */ 1952 mpol_put(new); /* drop initial ref */
1953 NODEMASK_SCRATCH_FREE(scratch);
1927 } 1954 }
1928} 1955}
1929 1956
@@ -2140,13 +2167,18 @@ int mpol_parse_str(char *str, struct mempolicy **mpol, int no_context)
2140 err = 1; 2167 err = 1;
2141 else { 2168 else {
2142 int ret; 2169 int ret;
2143 2170 NODEMASK_SCRATCH(scratch);
2144 task_lock(current); 2171 if (scratch) {
2145 ret = mpol_set_nodemask(new, &nodes); 2172 task_lock(current);
2146 task_unlock(current); 2173 ret = mpol_set_nodemask(new, &nodes, scratch);
2147 if (ret) 2174 task_unlock(current);
2175 } else
2176 ret = -ENOMEM;
2177 NODEMASK_SCRATCH_FREE(scratch);
2178 if (ret) {
2148 err = 1; 2179 err = 1;
2149 else if (no_context) { 2180 mpol_put(new);
2181 } else if (no_context) {
2150 /* save for contextualization */ 2182 /* save for contextualization */
2151 new->w.user_nodemask = nodes; 2183 new->w.user_nodemask = nodes;
2152 } 2184 }
diff --git a/mm/mempool.c b/mm/mempool.c
index a46eb1b4bb66..32e75d400503 100644
--- a/mm/mempool.c
+++ b/mm/mempool.c
@@ -303,14 +303,14 @@ EXPORT_SYMBOL(mempool_free_slab);
303 */ 303 */
304void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data) 304void *mempool_kmalloc(gfp_t gfp_mask, void *pool_data)
305{ 305{
306 size_t size = (size_t)(long)pool_data; 306 size_t size = (size_t)pool_data;
307 return kmalloc(size, gfp_mask); 307 return kmalloc(size, gfp_mask);
308} 308}
309EXPORT_SYMBOL(mempool_kmalloc); 309EXPORT_SYMBOL(mempool_kmalloc);
310 310
311void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data) 311void *mempool_kzalloc(gfp_t gfp_mask, void *pool_data)
312{ 312{
313 size_t size = (size_t) pool_data; 313 size_t size = (size_t)pool_data;
314 return kzalloc(size, gfp_mask); 314 return kzalloc(size, gfp_mask);
315} 315}
316EXPORT_SYMBOL(mempool_kzalloc); 316EXPORT_SYMBOL(mempool_kzalloc);
diff --git a/mm/mmap.c b/mm/mmap.c
index 34579b23ebd5..8101de490c73 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -88,9 +88,6 @@ int sysctl_overcommit_ratio = 50; /* default is 50% */
88int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT; 88int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
89struct percpu_counter vm_committed_as; 89struct percpu_counter vm_committed_as;
90 90
91/* amount of vm to protect from userspace access */
92unsigned long mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
93
94/* 91/*
95 * Check that a process has enough memory to allocate a new virtual 92 * Check that a process has enough memory to allocate a new virtual
96 * mapping. 0 means there is enough memory for the allocation to 93 * mapping. 0 means there is enough memory for the allocation to
diff --git a/mm/nommu.c b/mm/nommu.c
index 53cab10fece4..4bde489ec431 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -69,9 +69,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
69int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS; 69int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
70int heap_stack_gap = 0; 70int heap_stack_gap = 0;
71 71
72/* amount of vm to protect from userspace access */
73unsigned long mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
74
75atomic_long_t mmap_pages_allocated; 72atomic_long_t mmap_pages_allocated;
76 73
77EXPORT_SYMBOL(mem_map); 74EXPORT_SYMBOL(mem_map);
@@ -922,6 +919,10 @@ static int validate_mmap_request(struct file *file,
922 if (!file->f_op->read) 919 if (!file->f_op->read)
923 capabilities &= ~BDI_CAP_MAP_COPY; 920 capabilities &= ~BDI_CAP_MAP_COPY;
924 921
922 /* The file shall have been opened with read permission. */
923 if (!(file->f_mode & FMODE_READ))
924 return -EACCES;
925
925 if (flags & MAP_SHARED) { 926 if (flags & MAP_SHARED) {
926 /* do checks for writing, appending and locking */ 927 /* do checks for writing, appending and locking */
927 if ((prot & PROT_WRITE) && 928 if ((prot & PROT_WRITE) &&
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index 175a67a78a99..a7b2460e922b 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -58,7 +58,6 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
58 unsigned long points, cpu_time, run_time; 58 unsigned long points, cpu_time, run_time;
59 struct mm_struct *mm; 59 struct mm_struct *mm;
60 struct task_struct *child; 60 struct task_struct *child;
61 int oom_adj;
62 61
63 task_lock(p); 62 task_lock(p);
64 mm = p->mm; 63 mm = p->mm;
@@ -66,11 +65,6 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
66 task_unlock(p); 65 task_unlock(p);
67 return 0; 66 return 0;
68 } 67 }
69 oom_adj = mm->oom_adj;
70 if (oom_adj == OOM_DISABLE) {
71 task_unlock(p);
72 return 0;
73 }
74 68
75 /* 69 /*
76 * The memory size of the process is the basis for the badness. 70 * The memory size of the process is the basis for the badness.
@@ -154,15 +148,15 @@ unsigned long badness(struct task_struct *p, unsigned long uptime)
154 points /= 8; 148 points /= 8;
155 149
156 /* 150 /*
157 * Adjust the score by oom_adj. 151 * Adjust the score by oomkilladj.
158 */ 152 */
159 if (oom_adj) { 153 if (p->oomkilladj) {
160 if (oom_adj > 0) { 154 if (p->oomkilladj > 0) {
161 if (!points) 155 if (!points)
162 points = 1; 156 points = 1;
163 points <<= oom_adj; 157 points <<= p->oomkilladj;
164 } else 158 } else
165 points >>= -(oom_adj); 159 points >>= -(p->oomkilladj);
166 } 160 }
167 161
168#ifdef DEBUG 162#ifdef DEBUG
@@ -257,8 +251,11 @@ static struct task_struct *select_bad_process(unsigned long *ppoints,
257 *ppoints = ULONG_MAX; 251 *ppoints = ULONG_MAX;
258 } 252 }
259 253
254 if (p->oomkilladj == OOM_DISABLE)
255 continue;
256
260 points = badness(p, uptime.tv_sec); 257 points = badness(p, uptime.tv_sec);
261 if (points > *ppoints) { 258 if (points > *ppoints || !chosen) {
262 chosen = p; 259 chosen = p;
263 *ppoints = points; 260 *ppoints = points;
264 } 261 }
@@ -307,7 +304,8 @@ static void dump_tasks(const struct mem_cgroup *mem)
307 } 304 }
308 printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n", 305 printk(KERN_INFO "[%5d] %5d %5d %8lu %8lu %3d %3d %s\n",
309 p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm, 306 p->pid, __task_cred(p)->uid, p->tgid, mm->total_vm,
310 get_mm_rss(mm), (int)task_cpu(p), mm->oom_adj, p->comm); 307 get_mm_rss(mm), (int)task_cpu(p), p->oomkilladj,
308 p->comm);
311 task_unlock(p); 309 task_unlock(p);
312 } while_each_thread(g, p); 310 } while_each_thread(g, p);
313} 311}
@@ -325,8 +323,11 @@ static void __oom_kill_task(struct task_struct *p, int verbose)
325 return; 323 return;
326 } 324 }
327 325
328 if (!p->mm) 326 if (!p->mm) {
327 WARN_ON(1);
328 printk(KERN_WARNING "tried to kill an mm-less task!\n");
329 return; 329 return;
330 }
330 331
331 if (verbose) 332 if (verbose)
332 printk(KERN_ERR "Killed process %d (%s)\n", 333 printk(KERN_ERR "Killed process %d (%s)\n",
@@ -348,13 +349,28 @@ static int oom_kill_task(struct task_struct *p)
348 struct mm_struct *mm; 349 struct mm_struct *mm;
349 struct task_struct *g, *q; 350 struct task_struct *g, *q;
350 351
351 task_lock(p);
352 mm = p->mm; 352 mm = p->mm;
353 if (!mm || mm->oom_adj == OOM_DISABLE) { 353
354 task_unlock(p); 354 /* WARNING: mm may not be dereferenced since we did not obtain its
355 * value from get_task_mm(p). This is OK since all we need to do is
356 * compare mm to q->mm below.
357 *
358 * Furthermore, even if mm contains a non-NULL value, p->mm may
359 * change to NULL at any time since we do not hold task_lock(p).
360 * However, this is of no concern to us.
361 */
362
363 if (mm == NULL)
355 return 1; 364 return 1;
356 } 365
357 task_unlock(p); 366 /*
367 * Don't kill the process if any threads are set to OOM_DISABLE
368 */
369 do_each_thread(g, q) {
370 if (q->mm == mm && q->oomkilladj == OOM_DISABLE)
371 return 1;
372 } while_each_thread(g, q);
373
358 __oom_kill_task(p, 1); 374 __oom_kill_task(p, 1);
359 375
360 /* 376 /*
@@ -377,11 +393,10 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
377 struct task_struct *c; 393 struct task_struct *c;
378 394
379 if (printk_ratelimit()) { 395 if (printk_ratelimit()) {
380 task_lock(current);
381 printk(KERN_WARNING "%s invoked oom-killer: " 396 printk(KERN_WARNING "%s invoked oom-killer: "
382 "gfp_mask=0x%x, order=%d, oom_adj=%d\n", 397 "gfp_mask=0x%x, order=%d, oomkilladj=%d\n",
383 current->comm, gfp_mask, order, 398 current->comm, gfp_mask, order, current->oomkilladj);
384 current->mm ? current->mm->oom_adj : OOM_DISABLE); 399 task_lock(current);
385 cpuset_print_task_mems_allowed(current); 400 cpuset_print_task_mems_allowed(current);
386 task_unlock(current); 401 task_unlock(current);
387 dump_stack(); 402 dump_stack();
@@ -394,9 +409,8 @@ static int oom_kill_process(struct task_struct *p, gfp_t gfp_mask, int order,
394 /* 409 /*
395 * If the task is already exiting, don't alarm the sysadmin or kill 410 * If the task is already exiting, don't alarm the sysadmin or kill
396 * its children or threads, just set TIF_MEMDIE so it can die quickly 411 * its children or threads, just set TIF_MEMDIE so it can die quickly
397 * if its mm is still attached.
398 */ 412 */
399 if (p->mm && (p->flags & PF_EXITING)) { 413 if (p->flags & PF_EXITING) {
400 __oom_kill_task(p, 0); 414 __oom_kill_task(p, 0);
401 return 0; 415 return 0;
402 } 416 }
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index d052abbe3063..5cc986eb9f6f 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2544,7 +2544,6 @@ static void build_zonelists(pg_data_t *pgdat)
2544 prev_node = local_node; 2544 prev_node = local_node;
2545 nodes_clear(used_mask); 2545 nodes_clear(used_mask);
2546 2546
2547 memset(node_load, 0, sizeof(node_load));
2548 memset(node_order, 0, sizeof(node_order)); 2547 memset(node_order, 0, sizeof(node_order));
2549 j = 0; 2548 j = 0;
2550 2549
@@ -2653,6 +2652,9 @@ static int __build_all_zonelists(void *dummy)
2653{ 2652{
2654 int nid; 2653 int nid;
2655 2654
2655#ifdef CONFIG_NUMA
2656 memset(node_load, 0, sizeof(node_load));
2657#endif
2656 for_each_online_node(nid) { 2658 for_each_online_node(nid) {
2657 pg_data_t *pgdat = NODE_DATA(nid); 2659 pg_data_t *pgdat = NODE_DATA(nid);
2658 2660
diff --git a/mm/percpu.c b/mm/percpu.c
index b70f2acd8853..5fe37842e0ea 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -8,12 +8,12 @@
8 * 8 *
9 * This is percpu allocator which can handle both static and dynamic 9 * This is percpu allocator which can handle both static and dynamic
10 * areas. Percpu areas are allocated in chunks in vmalloc area. Each 10 * areas. Percpu areas are allocated in chunks in vmalloc area. Each
11 * chunk is consisted of num_possible_cpus() units and the first chunk 11 * chunk is consisted of nr_cpu_ids units and the first chunk is used
12 * is used for static percpu variables in the kernel image (special 12 * for static percpu variables in the kernel image (special boot time
13 * boot time alloc/init handling necessary as these areas need to be 13 * alloc/init handling necessary as these areas need to be brought up
14 * brought up before allocation services are running). Unit grows as 14 * before allocation services are running). Unit grows as necessary
15 * necessary and all units grow or shrink in unison. When a chunk is 15 * and all units grow or shrink in unison. When a chunk is filled up,
16 * filled up, another chunk is allocated. ie. in vmalloc area 16 * another chunk is allocated. ie. in vmalloc area
17 * 17 *
18 * c0 c1 c2 18 * c0 c1 c2
19 * ------------------- ------------------- ------------ 19 * ------------------- ------------------- ------------
@@ -558,7 +558,7 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int freeme)
558static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end, 558static void pcpu_unmap(struct pcpu_chunk *chunk, int page_start, int page_end,
559 bool flush_tlb) 559 bool flush_tlb)
560{ 560{
561 unsigned int last = num_possible_cpus() - 1; 561 unsigned int last = nr_cpu_ids - 1;
562 unsigned int cpu; 562 unsigned int cpu;
563 563
564 /* unmap must not be done on immutable chunk */ 564 /* unmap must not be done on immutable chunk */
@@ -643,7 +643,7 @@ static void pcpu_depopulate_chunk(struct pcpu_chunk *chunk, int off, int size,
643 */ 643 */
644static int pcpu_map(struct pcpu_chunk *chunk, int page_start, int page_end) 644static int pcpu_map(struct pcpu_chunk *chunk, int page_start, int page_end)
645{ 645{
646 unsigned int last = num_possible_cpus() - 1; 646 unsigned int last = nr_cpu_ids - 1;
647 unsigned int cpu; 647 unsigned int cpu;
648 int err; 648 int err;
649 649
@@ -749,7 +749,7 @@ static struct pcpu_chunk *alloc_pcpu_chunk(void)
749 chunk->map[chunk->map_used++] = pcpu_unit_size; 749 chunk->map[chunk->map_used++] = pcpu_unit_size;
750 chunk->page = chunk->page_ar; 750 chunk->page = chunk->page_ar;
751 751
752 chunk->vm = get_vm_area(pcpu_chunk_size, GFP_KERNEL); 752 chunk->vm = get_vm_area(pcpu_chunk_size, VM_ALLOC);
753 if (!chunk->vm) { 753 if (!chunk->vm) {
754 free_pcpu_chunk(chunk); 754 free_pcpu_chunk(chunk);
755 return NULL; 755 return NULL;
@@ -1067,9 +1067,9 @@ size_t __init pcpu_setup_first_chunk(pcpu_get_page_fn_t get_page_fn,
1067 PFN_UP(size_sum)); 1067 PFN_UP(size_sum));
1068 1068
1069 pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT; 1069 pcpu_unit_size = pcpu_unit_pages << PAGE_SHIFT;
1070 pcpu_chunk_size = num_possible_cpus() * pcpu_unit_size; 1070 pcpu_chunk_size = nr_cpu_ids * pcpu_unit_size;
1071 pcpu_chunk_struct_size = sizeof(struct pcpu_chunk) 1071 pcpu_chunk_struct_size = sizeof(struct pcpu_chunk)
1072 + num_possible_cpus() * pcpu_unit_pages * sizeof(struct page *); 1072 + nr_cpu_ids * pcpu_unit_pages * sizeof(struct page *);
1073 1073
1074 if (dyn_size < 0) 1074 if (dyn_size < 0)
1075 dyn_size = pcpu_unit_size - static_size - reserved_size; 1075 dyn_size = pcpu_unit_size - static_size - reserved_size;
@@ -1248,7 +1248,7 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size,
1248 } else 1248 } else
1249 pcpue_unit_size = max_t(size_t, pcpue_size, PCPU_MIN_UNIT_SIZE); 1249 pcpue_unit_size = max_t(size_t, pcpue_size, PCPU_MIN_UNIT_SIZE);
1250 1250
1251 chunk_size = pcpue_unit_size * num_possible_cpus(); 1251 chunk_size = pcpue_unit_size * nr_cpu_ids;
1252 1252
1253 pcpue_ptr = __alloc_bootmem_nopanic(chunk_size, PAGE_SIZE, 1253 pcpue_ptr = __alloc_bootmem_nopanic(chunk_size, PAGE_SIZE,
1254 __pa(MAX_DMA_ADDRESS)); 1254 __pa(MAX_DMA_ADDRESS));
@@ -1259,12 +1259,15 @@ ssize_t __init pcpu_embed_first_chunk(size_t static_size, size_t reserved_size,
1259 } 1259 }
1260 1260
1261 /* return the leftover and copy */ 1261 /* return the leftover and copy */
1262 for_each_possible_cpu(cpu) { 1262 for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
1263 void *ptr = pcpue_ptr + cpu * pcpue_unit_size; 1263 void *ptr = pcpue_ptr + cpu * pcpue_unit_size;
1264 1264
1265 free_bootmem(__pa(ptr + pcpue_size), 1265 if (cpu_possible(cpu)) {
1266 pcpue_unit_size - pcpue_size); 1266 free_bootmem(__pa(ptr + pcpue_size),
1267 memcpy(ptr, __per_cpu_load, static_size); 1267 pcpue_unit_size - pcpue_size);
1268 memcpy(ptr, __per_cpu_load, static_size);
1269 } else
1270 free_bootmem(__pa(ptr), pcpue_unit_size);
1268 } 1271 }
1269 1272
1270 /* we're ready, commit */ 1273 /* we're ready, commit */
diff --git a/mm/rmap.c b/mm/rmap.c
index 836c6c63e1f2..0895b5c7cbff 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -358,6 +358,7 @@ static int page_referenced_one(struct page *page,
358 */ 358 */
359 if (vma->vm_flags & VM_LOCKED) { 359 if (vma->vm_flags & VM_LOCKED) {
360 *mapcount = 1; /* break early from loop */ 360 *mapcount = 1; /* break early from loop */
361 *vm_flags |= VM_LOCKED;
361 goto out_unmap; 362 goto out_unmap;
362 } 363 }
363 364
diff --git a/mm/vmscan.c b/mm/vmscan.c
index dea7abd31098..94e86dd6954c 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -630,9 +630,14 @@ static unsigned long shrink_page_list(struct list_head *page_list,
630 630
631 referenced = page_referenced(page, 1, 631 referenced = page_referenced(page, 1,
632 sc->mem_cgroup, &vm_flags); 632 sc->mem_cgroup, &vm_flags);
633 /* In active use or really unfreeable? Activate it. */ 633 /*
634 * In active use or really unfreeable? Activate it.
635 * If page which have PG_mlocked lost isoltation race,
636 * try_to_unmap moves it to unevictable list
637 */
634 if (sc->order <= PAGE_ALLOC_COSTLY_ORDER && 638 if (sc->order <= PAGE_ALLOC_COSTLY_ORDER &&
635 referenced && page_mapping_inuse(page)) 639 referenced && page_mapping_inuse(page)
640 && !(vm_flags & VM_LOCKED))
636 goto activate_locked; 641 goto activate_locked;
637 642
638 /* 643 /*
diff --git a/net/9p/client.c b/net/9p/client.c
index 787ccddb85ea..5bf5f227dbe0 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -60,9 +60,9 @@ static struct p9_req_t *
60p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...); 60p9_client_rpc(struct p9_client *c, int8_t type, const char *fmt, ...);
61 61
62/** 62/**
63 * v9fs_parse_options - parse mount options into session structure 63 * parse_options - parse mount options into client structure
64 * @options: options string passed from mount 64 * @opts: options string passed from mount
65 * @v9ses: existing v9fs session information 65 * @clnt: existing v9fs client information
66 * 66 *
67 * Return 0 upon success, -ERRNO upon failure 67 * Return 0 upon success, -ERRNO upon failure
68 */ 68 */
@@ -232,7 +232,7 @@ EXPORT_SYMBOL(p9_tag_lookup);
232 232
233/** 233/**
234 * p9_tag_init - setup tags structure and contents 234 * p9_tag_init - setup tags structure and contents
235 * @tags: tags structure from the client struct 235 * @c: v9fs client struct
236 * 236 *
237 * This initializes the tags structure for each client instance. 237 * This initializes the tags structure for each client instance.
238 * 238 *
@@ -258,7 +258,7 @@ error:
258 258
259/** 259/**
260 * p9_tag_cleanup - cleans up tags structure and reclaims resources 260 * p9_tag_cleanup - cleans up tags structure and reclaims resources
261 * @tags: tags structure from the client struct 261 * @c: v9fs client struct
262 * 262 *
263 * This frees resources associated with the tags structure 263 * This frees resources associated with the tags structure
264 * 264 *
@@ -411,14 +411,9 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
411 if (c->dotu) 411 if (c->dotu)
412 err = -ecode; 412 err = -ecode;
413 413
414 if (!err) { 414 if (!err || !IS_ERR_VALUE(err))
415 err = p9_errstr2errno(ename, strlen(ename)); 415 err = p9_errstr2errno(ename, strlen(ename));
416 416
417 /* string match failed */
418 if (!err)
419 err = -ESERVERFAULT;
420 }
421
422 P9_DPRINTK(P9_DEBUG_9P, "<<< RERROR (%d) %s\n", -ecode, ename); 417 P9_DPRINTK(P9_DEBUG_9P, "<<< RERROR (%d) %s\n", -ecode, ename);
423 418
424 kfree(ename); 419 kfree(ename);
@@ -430,8 +425,8 @@ static int p9_check_errors(struct p9_client *c, struct p9_req_t *req)
430 425
431/** 426/**
432 * p9_client_flush - flush (cancel) a request 427 * p9_client_flush - flush (cancel) a request
433 * c: client state 428 * @c: client state
434 * req: request to cancel 429 * @oldreq: request to cancel
435 * 430 *
436 * This sents a flush for a particular requests and links 431 * This sents a flush for a particular requests and links
437 * the flush request to the original request. The current 432 * the flush request to the original request. The current
diff --git a/net/9p/error.c b/net/9p/error.c
index fdebe4314062..52518512a93e 100644
--- a/net/9p/error.c
+++ b/net/9p/error.c
@@ -239,7 +239,7 @@ int p9_errstr2errno(char *errstr, int len)
239 errstr[len] = 0; 239 errstr[len] = 0;
240 printk(KERN_ERR "%s: server reported unknown error %s\n", 240 printk(KERN_ERR "%s: server reported unknown error %s\n",
241 __func__, errstr); 241 __func__, errstr);
242 errno = 1; 242 errno = ESERVERFAULT;
243 } 243 }
244 244
245 return -errno; 245 return -errno;
diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 8c2588e4edc0..8d934dd7fd54 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -119,8 +119,8 @@ struct p9_poll_wait {
119 * @wpos: write position for current frame 119 * @wpos: write position for current frame
120 * @wsize: amount of data to write for current frame 120 * @wsize: amount of data to write for current frame
121 * @wbuf: current write buffer 121 * @wbuf: current write buffer
122 * @poll_pending_link: pending links to be polled per conn
122 * @poll_wait: array of wait_q's for various worker threads 123 * @poll_wait: array of wait_q's for various worker threads
123 * @poll_waddr: ????
124 * @pt: poll state 124 * @pt: poll state
125 * @rq: current read work 125 * @rq: current read work
126 * @wq: current write work 126 * @wq: current write work
@@ -700,9 +700,9 @@ static int p9_fd_cancel(struct p9_client *client, struct p9_req_t *req)
700} 700}
701 701
702/** 702/**
703 * parse_options - parse mount options into session structure 703 * parse_opts - parse mount options into p9_fd_opts structure
704 * @options: options string passed from mount 704 * @params: options string passed from mount
705 * @opts: transport-specific structure to parse options into 705 * @opts: fd transport-specific structure to parse options into
706 * 706 *
707 * Returns 0 upon success, -ERRNO upon failure 707 * Returns 0 upon success, -ERRNO upon failure
708 */ 708 */
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
index ac4990041ebb..65cb29db03f8 100644
--- a/net/9p/trans_rdma.c
+++ b/net/9p/trans_rdma.c
@@ -67,14 +67,15 @@
67 * @pd: Protection Domain pointer 67 * @pd: Protection Domain pointer
68 * @qp: Queue Pair pointer 68 * @qp: Queue Pair pointer
69 * @cq: Completion Queue pointer 69 * @cq: Completion Queue pointer
70 * @dm_mr: DMA Memory Region pointer
70 * @lkey: The local access only memory region key 71 * @lkey: The local access only memory region key
71 * @timeout: Number of uSecs to wait for connection management events 72 * @timeout: Number of uSecs to wait for connection management events
72 * @sq_depth: The depth of the Send Queue 73 * @sq_depth: The depth of the Send Queue
73 * @sq_sem: Semaphore for the SQ 74 * @sq_sem: Semaphore for the SQ
74 * @rq_depth: The depth of the Receive Queue. 75 * @rq_depth: The depth of the Receive Queue.
76 * @rq_count: Count of requests in the Receive Queue.
75 * @addr: The remote peer's address 77 * @addr: The remote peer's address
76 * @req_lock: Protects the active request list 78 * @req_lock: Protects the active request list
77 * @send_wait: Wait list when the SQ fills up
78 * @cm_done: Completion event for connection management tracking 79 * @cm_done: Completion event for connection management tracking
79 */ 80 */
80struct p9_trans_rdma { 81struct p9_trans_rdma {
@@ -154,9 +155,9 @@ static match_table_t tokens = {
154}; 155};
155 156
156/** 157/**
157 * parse_options - parse mount options into session structure 158 * parse_opts - parse mount options into rdma options structure
158 * @options: options string passed from mount 159 * @params: options string passed from mount
159 * @opts: transport-specific structure to parse options into 160 * @opts: rdma transport-specific structure to parse options into
160 * 161 *
161 * Returns 0 upon success, -ERRNO upon failure 162 * Returns 0 upon success, -ERRNO upon failure
162 */ 163 */
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index a49484e67e1d..9bf0b737aa51 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -57,11 +57,9 @@ static int chan_index;
57 * @initialized: whether the channel is initialized 57 * @initialized: whether the channel is initialized
58 * @inuse: whether the channel is in use 58 * @inuse: whether the channel is in use
59 * @lock: protects multiple elements within this structure 59 * @lock: protects multiple elements within this structure
60 * @client: client instance
60 * @vdev: virtio dev associated with this channel 61 * @vdev: virtio dev associated with this channel
61 * @vq: virtio queue associated with this channel 62 * @vq: virtio queue associated with this channel
62 * @tagpool: accounting for tag ids (and request slots)
63 * @reqs: array of request slots
64 * @max_tag: current number of request_slots allocated
65 * @sg: scatter gather list which is used to pack a request (protected?) 63 * @sg: scatter gather list which is used to pack a request (protected?)
66 * 64 *
67 * We keep all per-channel information in a structure. 65 * We keep all per-channel information in a structure.
@@ -92,7 +90,7 @@ static unsigned int rest_of_page(void *data)
92 90
93/** 91/**
94 * p9_virtio_close - reclaim resources of a channel 92 * p9_virtio_close - reclaim resources of a channel
95 * @trans: transport state 93 * @client: client instance
96 * 94 *
97 * This reclaims a channel by freeing its resources and 95 * This reclaims a channel by freeing its resources and
98 * reseting its inuse flag. 96 * reseting its inuse flag.
@@ -181,9 +179,8 @@ static int p9_virtio_cancel(struct p9_client *client, struct p9_req_t *req)
181 179
182/** 180/**
183 * p9_virtio_request - issue a request 181 * p9_virtio_request - issue a request
184 * @t: transport state 182 * @client: client instance issuing the request
185 * @tc: &p9_fcall request to transmit 183 * @req: request to be issued
186 * @rc: &p9_fcall to put reponse into
187 * 184 *
188 */ 185 */
189 186
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c
index bfbe13786bb4..875eda5dbad7 100644
--- a/net/appletalk/ddp.c
+++ b/net/appletalk/ddp.c
@@ -1238,6 +1238,7 @@ static int atalk_getname(struct socket *sock, struct sockaddr *uaddr,
1238 return -ENOBUFS; 1238 return -ENOBUFS;
1239 1239
1240 *uaddr_len = sizeof(struct sockaddr_at); 1240 *uaddr_len = sizeof(struct sockaddr_at);
1241 memset(&sat.sat_zero, 0, sizeof(sat.sat_zero));
1241 1242
1242 if (peer) { 1243 if (peer) {
1243 if (sk->sk_state != TCP_ESTABLISHED) 1244 if (sk->sk_state != TCP_ESTABLISHED)
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index e50566ebf9f9..94b3388c188b 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2080,28 +2080,41 @@ static CLASS_ATTR(rfcomm_dlc, S_IRUGO, rfcomm_dlc_sysfs_show, NULL);
2080/* ---- Initialization ---- */ 2080/* ---- Initialization ---- */
2081static int __init rfcomm_init(void) 2081static int __init rfcomm_init(void)
2082{ 2082{
2083 int ret;
2084
2083 l2cap_load(); 2085 l2cap_load();
2084 2086
2085 hci_register_cb(&rfcomm_cb); 2087 hci_register_cb(&rfcomm_cb);
2086 2088
2087 rfcomm_thread = kthread_run(rfcomm_run, NULL, "krfcommd"); 2089 rfcomm_thread = kthread_run(rfcomm_run, NULL, "krfcommd");
2088 if (IS_ERR(rfcomm_thread)) { 2090 if (IS_ERR(rfcomm_thread)) {
2089 hci_unregister_cb(&rfcomm_cb); 2091 ret = PTR_ERR(rfcomm_thread);
2090 return PTR_ERR(rfcomm_thread); 2092 goto out_thread;
2091 } 2093 }
2092 2094
2093 if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0) 2095 if (class_create_file(bt_class, &class_attr_rfcomm_dlc) < 0)
2094 BT_ERR("Failed to create RFCOMM info file"); 2096 BT_ERR("Failed to create RFCOMM info file");
2095 2097
2096 rfcomm_init_sockets(); 2098 ret = rfcomm_init_ttys();
2099 if (ret)
2100 goto out_tty;
2097 2101
2098#ifdef CONFIG_BT_RFCOMM_TTY 2102 ret = rfcomm_init_sockets();
2099 rfcomm_init_ttys(); 2103 if (ret)
2100#endif 2104 goto out_sock;
2101 2105
2102 BT_INFO("RFCOMM ver %s", VERSION); 2106 BT_INFO("RFCOMM ver %s", VERSION);
2103 2107
2104 return 0; 2108 return 0;
2109
2110out_sock:
2111 rfcomm_cleanup_ttys();
2112out_tty:
2113 kthread_stop(rfcomm_thread);
2114out_thread:
2115 hci_unregister_cb(&rfcomm_cb);
2116
2117 return ret;
2105} 2118}
2106 2119
2107static void __exit rfcomm_exit(void) 2120static void __exit rfcomm_exit(void)
@@ -2112,9 +2125,7 @@ static void __exit rfcomm_exit(void)
2112 2125
2113 kthread_stop(rfcomm_thread); 2126 kthread_stop(rfcomm_thread);
2114 2127
2115#ifdef CONFIG_BT_RFCOMM_TTY
2116 rfcomm_cleanup_ttys(); 2128 rfcomm_cleanup_ttys();
2117#endif
2118 2129
2119 rfcomm_cleanup_sockets(); 2130 rfcomm_cleanup_sockets();
2120} 2131}
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 7f482784e9f7..0b85e8116859 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -1132,7 +1132,7 @@ error:
1132 return err; 1132 return err;
1133} 1133}
1134 1134
1135void __exit rfcomm_cleanup_sockets(void) 1135void rfcomm_cleanup_sockets(void)
1136{ 1136{
1137 class_remove_file(bt_class, &class_attr_rfcomm); 1137 class_remove_file(bt_class, &class_attr_rfcomm);
1138 1138
diff --git a/net/can/raw.c b/net/can/raw.c
index f4cc44548bda..db3152df7d2b 100644
--- a/net/can/raw.c
+++ b/net/can/raw.c
@@ -401,6 +401,7 @@ static int raw_getname(struct socket *sock, struct sockaddr *uaddr,
401 if (peer) 401 if (peer)
402 return -EOPNOTSUPP; 402 return -EOPNOTSUPP;
403 403
404 memset(addr, 0, sizeof(*addr));
404 addr->can_family = AF_CAN; 405 addr->can_family = AF_CAN;
405 addr->can_ifindex = ro->ifindex; 406 addr->can_ifindex = ro->ifindex;
406 407
diff --git a/net/core/dev.c b/net/core/dev.c
index 70c27e0c7c32..6a94475aee85 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3865,10 +3865,12 @@ int dev_unicast_delete(struct net_device *dev, void *addr)
3865 3865
3866 ASSERT_RTNL(); 3866 ASSERT_RTNL();
3867 3867
3868 netif_addr_lock_bh(dev);
3868 err = __hw_addr_del(&dev->uc, addr, dev->addr_len, 3869 err = __hw_addr_del(&dev->uc, addr, dev->addr_len,
3869 NETDEV_HW_ADDR_T_UNICAST); 3870 NETDEV_HW_ADDR_T_UNICAST);
3870 if (!err) 3871 if (!err)
3871 __dev_set_rx_mode(dev); 3872 __dev_set_rx_mode(dev);
3873 netif_addr_unlock_bh(dev);
3872 return err; 3874 return err;
3873} 3875}
3874EXPORT_SYMBOL(dev_unicast_delete); 3876EXPORT_SYMBOL(dev_unicast_delete);
@@ -3889,10 +3891,12 @@ int dev_unicast_add(struct net_device *dev, void *addr)
3889 3891
3890 ASSERT_RTNL(); 3892 ASSERT_RTNL();
3891 3893
3894 netif_addr_lock_bh(dev);
3892 err = __hw_addr_add(&dev->uc, addr, dev->addr_len, 3895 err = __hw_addr_add(&dev->uc, addr, dev->addr_len,
3893 NETDEV_HW_ADDR_T_UNICAST); 3896 NETDEV_HW_ADDR_T_UNICAST);
3894 if (!err) 3897 if (!err)
3895 __dev_set_rx_mode(dev); 3898 __dev_set_rx_mode(dev);
3899 netif_addr_unlock_bh(dev);
3896 return err; 3900 return err;
3897} 3901}
3898EXPORT_SYMBOL(dev_unicast_add); 3902EXPORT_SYMBOL(dev_unicast_add);
@@ -3949,7 +3953,8 @@ void __dev_addr_unsync(struct dev_addr_list **to, int *to_count,
3949 * @from: source device 3953 * @from: source device
3950 * 3954 *
3951 * Add newly added addresses to the destination device and release 3955 * Add newly added addresses to the destination device and release
3952 * addresses that have no users left. 3956 * addresses that have no users left. The source device must be
3957 * locked by netif_tx_lock_bh.
3953 * 3958 *
3954 * This function is intended to be called from the dev->set_rx_mode 3959 * This function is intended to be called from the dev->set_rx_mode
3955 * function of layered software devices. 3960 * function of layered software devices.
@@ -3958,14 +3963,14 @@ int dev_unicast_sync(struct net_device *to, struct net_device *from)
3958{ 3963{
3959 int err = 0; 3964 int err = 0;
3960 3965
3961 ASSERT_RTNL();
3962
3963 if (to->addr_len != from->addr_len) 3966 if (to->addr_len != from->addr_len)
3964 return -EINVAL; 3967 return -EINVAL;
3965 3968
3969 netif_addr_lock_bh(to);
3966 err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len); 3970 err = __hw_addr_sync(&to->uc, &from->uc, to->addr_len);
3967 if (!err) 3971 if (!err)
3968 __dev_set_rx_mode(to); 3972 __dev_set_rx_mode(to);
3973 netif_addr_unlock_bh(to);
3969 return err; 3974 return err;
3970} 3975}
3971EXPORT_SYMBOL(dev_unicast_sync); 3976EXPORT_SYMBOL(dev_unicast_sync);
@@ -3981,27 +3986,27 @@ EXPORT_SYMBOL(dev_unicast_sync);
3981 */ 3986 */
3982void dev_unicast_unsync(struct net_device *to, struct net_device *from) 3987void dev_unicast_unsync(struct net_device *to, struct net_device *from)
3983{ 3988{
3984 ASSERT_RTNL();
3985
3986 if (to->addr_len != from->addr_len) 3989 if (to->addr_len != from->addr_len)
3987 return; 3990 return;
3988 3991
3992 netif_addr_lock_bh(from);
3993 netif_addr_lock(to);
3989 __hw_addr_unsync(&to->uc, &from->uc, to->addr_len); 3994 __hw_addr_unsync(&to->uc, &from->uc, to->addr_len);
3990 __dev_set_rx_mode(to); 3995 __dev_set_rx_mode(to);
3996 netif_addr_unlock(to);
3997 netif_addr_unlock_bh(from);
3991} 3998}
3992EXPORT_SYMBOL(dev_unicast_unsync); 3999EXPORT_SYMBOL(dev_unicast_unsync);
3993 4000
3994static void dev_unicast_flush(struct net_device *dev) 4001static void dev_unicast_flush(struct net_device *dev)
3995{ 4002{
3996 /* rtnl_mutex must be held here */ 4003 netif_addr_lock_bh(dev);
3997
3998 __hw_addr_flush(&dev->uc); 4004 __hw_addr_flush(&dev->uc);
4005 netif_addr_unlock_bh(dev);
3999} 4006}
4000 4007
4001static void dev_unicast_init(struct net_device *dev) 4008static void dev_unicast_init(struct net_device *dev)
4002{ 4009{
4003 /* rtnl_mutex must be held here */
4004
4005 __hw_addr_init(&dev->uc); 4010 __hw_addr_init(&dev->uc);
4006} 4011}
4007 4012
diff --git a/net/core/gen_estimator.c b/net/core/gen_estimator.c
index 78e5bfc454ae..493775f4f2f1 100644
--- a/net/core/gen_estimator.c
+++ b/net/core/gen_estimator.c
@@ -81,7 +81,7 @@
81struct gen_estimator 81struct gen_estimator
82{ 82{
83 struct list_head list; 83 struct list_head list;
84 struct gnet_stats_basic *bstats; 84 struct gnet_stats_basic_packed *bstats;
85 struct gnet_stats_rate_est *rate_est; 85 struct gnet_stats_rate_est *rate_est;
86 spinlock_t *stats_lock; 86 spinlock_t *stats_lock;
87 int ewma_log; 87 int ewma_log;
@@ -165,7 +165,7 @@ static void gen_add_node(struct gen_estimator *est)
165} 165}
166 166
167static 167static
168struct gen_estimator *gen_find_node(const struct gnet_stats_basic *bstats, 168struct gen_estimator *gen_find_node(const struct gnet_stats_basic_packed *bstats,
169 const struct gnet_stats_rate_est *rate_est) 169 const struct gnet_stats_rate_est *rate_est)
170{ 170{
171 struct rb_node *p = est_root.rb_node; 171 struct rb_node *p = est_root.rb_node;
@@ -202,7 +202,7 @@ struct gen_estimator *gen_find_node(const struct gnet_stats_basic *bstats,
202 * 202 *
203 * NOTE: Called under rtnl_mutex 203 * NOTE: Called under rtnl_mutex
204 */ 204 */
205int gen_new_estimator(struct gnet_stats_basic *bstats, 205int gen_new_estimator(struct gnet_stats_basic_packed *bstats,
206 struct gnet_stats_rate_est *rate_est, 206 struct gnet_stats_rate_est *rate_est,
207 spinlock_t *stats_lock, 207 spinlock_t *stats_lock,
208 struct nlattr *opt) 208 struct nlattr *opt)
@@ -262,7 +262,7 @@ static void __gen_kill_estimator(struct rcu_head *head)
262 * 262 *
263 * NOTE: Called under rtnl_mutex 263 * NOTE: Called under rtnl_mutex
264 */ 264 */
265void gen_kill_estimator(struct gnet_stats_basic *bstats, 265void gen_kill_estimator(struct gnet_stats_basic_packed *bstats,
266 struct gnet_stats_rate_est *rate_est) 266 struct gnet_stats_rate_est *rate_est)
267{ 267{
268 struct gen_estimator *e; 268 struct gen_estimator *e;
@@ -292,7 +292,7 @@ EXPORT_SYMBOL(gen_kill_estimator);
292 * 292 *
293 * Returns 0 on success or a negative error code. 293 * Returns 0 on success or a negative error code.
294 */ 294 */
295int gen_replace_estimator(struct gnet_stats_basic *bstats, 295int gen_replace_estimator(struct gnet_stats_basic_packed *bstats,
296 struct gnet_stats_rate_est *rate_est, 296 struct gnet_stats_rate_est *rate_est,
297 spinlock_t *stats_lock, struct nlattr *opt) 297 spinlock_t *stats_lock, struct nlattr *opt)
298{ 298{
@@ -308,7 +308,7 @@ EXPORT_SYMBOL(gen_replace_estimator);
308 * 308 *
309 * Returns true if estimator is active, and false if not. 309 * Returns true if estimator is active, and false if not.
310 */ 310 */
311bool gen_estimator_active(const struct gnet_stats_basic *bstats, 311bool gen_estimator_active(const struct gnet_stats_basic_packed *bstats,
312 const struct gnet_stats_rate_est *rate_est) 312 const struct gnet_stats_rate_est *rate_est)
313{ 313{
314 ASSERT_RTNL(); 314 ASSERT_RTNL();
diff --git a/net/core/gen_stats.c b/net/core/gen_stats.c
index c3d0ffeac243..8569310268ab 100644
--- a/net/core/gen_stats.c
+++ b/net/core/gen_stats.c
@@ -106,16 +106,21 @@ gnet_stats_start_copy(struct sk_buff *skb, int type, spinlock_t *lock,
106 * if the room in the socket buffer was not sufficient. 106 * if the room in the socket buffer was not sufficient.
107 */ 107 */
108int 108int
109gnet_stats_copy_basic(struct gnet_dump *d, struct gnet_stats_basic *b) 109gnet_stats_copy_basic(struct gnet_dump *d, struct gnet_stats_basic_packed *b)
110{ 110{
111 if (d->compat_tc_stats) { 111 if (d->compat_tc_stats) {
112 d->tc_stats.bytes = b->bytes; 112 d->tc_stats.bytes = b->bytes;
113 d->tc_stats.packets = b->packets; 113 d->tc_stats.packets = b->packets;
114 } 114 }
115 115
116 if (d->tail) 116 if (d->tail) {
117 return gnet_stats_copy(d, TCA_STATS_BASIC, b, sizeof(*b)); 117 struct gnet_stats_basic sb;
118 118
119 memset(&sb, 0, sizeof(sb));
120 sb.bytes = b->bytes;
121 sb.packets = b->packets;
122 return gnet_stats_copy(d, TCA_STATS_BASIC, &sb, sizeof(sb));
123 }
119 return 0; 124 return 0;
120} 125}
121 126
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index b7292a2719dc..197283072cc8 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -488,7 +488,7 @@ int net_assign_generic(struct net *net, int id, void *data)
488 */ 488 */
489 489
490 ng->len = id; 490 ng->len = id;
491 memcpy(&ng->ptr, &old_ng->ptr, old_ng->len); 491 memcpy(&ng->ptr, &old_ng->ptr, old_ng->len * sizeof(void*));
492 492
493 rcu_assign_pointer(net->gen, ng); 493 rcu_assign_pointer(net->gen, ng);
494 call_rcu(&old_ng->rcu, net_generic_release); 494 call_rcu(&old_ng->rcu, net_generic_release);
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index df30feb2fc72..1b76eb11deb4 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -319,6 +319,11 @@ static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
319 319
320 udelay(USEC_PER_POLL); 320 udelay(USEC_PER_POLL);
321 } 321 }
322
323 WARN_ONCE(!irqs_disabled(),
324 "netpoll_send_skb(): %s enabled interrupts in poll (%pF)\n",
325 dev->name, ops->ndo_start_xmit);
326
322 local_irq_restore(flags); 327 local_irq_restore(flags);
323 } 328 }
324 329
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 3281013ce038..1bca9205104e 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -1159,6 +1159,7 @@ static void __exit dccp_fini(void)
1159 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep); 1159 kmem_cache_destroy(dccp_hashinfo.bind_bucket_cachep);
1160 dccp_ackvec_exit(); 1160 dccp_ackvec_exit();
1161 dccp_sysctl_exit(); 1161 dccp_sysctl_exit();
1162 percpu_counter_destroy(&dccp_orphan_count);
1162} 1163}
1163 1164
1164module_init(dccp_init); 1165module_init(dccp_init);
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c
index 2e1f836d4240..f0bbc57926cd 100644
--- a/net/econet/af_econet.c
+++ b/net/econet/af_econet.c
@@ -520,6 +520,7 @@ static int econet_getname(struct socket *sock, struct sockaddr *uaddr,
520 if (peer) 520 if (peer)
521 return -EOPNOTSUPP; 521 return -EOPNOTSUPP;
522 522
523 memset(sec, 0, sizeof(*sec));
523 mutex_lock(&econet_mutex); 524 mutex_lock(&econet_mutex);
524 525
525 sk = sock->sk; 526 sk = sock->sk;
diff --git a/net/ieee802154/af_ieee802154.c b/net/ieee802154/af_ieee802154.c
index 3bb6bdb1dac1..af661805b9fa 100644
--- a/net/ieee802154/af_ieee802154.c
+++ b/net/ieee802154/af_ieee802154.c
@@ -136,7 +136,7 @@ static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg,
136 unsigned int cmd) 136 unsigned int cmd)
137{ 137{
138 struct ifreq ifr; 138 struct ifreq ifr;
139 int ret = -EINVAL; 139 int ret = -ENOIOCTLCMD;
140 struct net_device *dev; 140 struct net_device *dev;
141 141
142 if (copy_from_user(&ifr, arg, sizeof(struct ifreq))) 142 if (copy_from_user(&ifr, arg, sizeof(struct ifreq)))
@@ -146,8 +146,10 @@ static int ieee802154_dev_ioctl(struct sock *sk, struct ifreq __user *arg,
146 146
147 dev_load(sock_net(sk), ifr.ifr_name); 147 dev_load(sock_net(sk), ifr.ifr_name);
148 dev = dev_get_by_name(sock_net(sk), ifr.ifr_name); 148 dev = dev_get_by_name(sock_net(sk), ifr.ifr_name);
149 if (dev->type == ARPHRD_IEEE802154 || 149
150 dev->type == ARPHRD_IEEE802154_PHY) 150 if ((dev->type == ARPHRD_IEEE802154 ||
151 dev->type == ARPHRD_IEEE802154_PHY) &&
152 dev->netdev_ops->ndo_do_ioctl)
151 ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, cmd); 153 ret = dev->netdev_ops->ndo_do_ioctl(dev, &ifr, cmd);
152 154
153 if (!ret && copy_to_user(arg, &ifr, sizeof(struct ifreq))) 155 if (!ret && copy_to_user(arg, &ifr, sizeof(struct ifreq)))
diff --git a/net/ieee802154/dgram.c b/net/ieee802154/dgram.c
index 14d39840dd62..ba8b214dda8f 100644
--- a/net/ieee802154/dgram.c
+++ b/net/ieee802154/dgram.c
@@ -377,6 +377,18 @@ int ieee802154_dgram_deliver(struct net_device *dev, struct sk_buff *skb)
377 return ret; 377 return ret;
378} 378}
379 379
380static int dgram_getsockopt(struct sock *sk, int level, int optname,
381 char __user *optval, int __user *optlen)
382{
383 return -EOPNOTSUPP;
384}
385
386static int dgram_setsockopt(struct sock *sk, int level, int optname,
387 char __user *optval, int __user optlen)
388{
389 return -EOPNOTSUPP;
390}
391
380struct proto ieee802154_dgram_prot = { 392struct proto ieee802154_dgram_prot = {
381 .name = "IEEE-802.15.4-MAC", 393 .name = "IEEE-802.15.4-MAC",
382 .owner = THIS_MODULE, 394 .owner = THIS_MODULE,
@@ -391,5 +403,7 @@ struct proto ieee802154_dgram_prot = {
391 .connect = dgram_connect, 403 .connect = dgram_connect,
392 .disconnect = dgram_disconnect, 404 .disconnect = dgram_disconnect,
393 .ioctl = dgram_ioctl, 405 .ioctl = dgram_ioctl,
406 .getsockopt = dgram_getsockopt,
407 .setsockopt = dgram_setsockopt,
394}; 408};
395 409
diff --git a/net/ieee802154/raw.c b/net/ieee802154/raw.c
index fca44d59f97e..9315977c4c61 100644
--- a/net/ieee802154/raw.c
+++ b/net/ieee802154/raw.c
@@ -238,6 +238,18 @@ void ieee802154_raw_deliver(struct net_device *dev, struct sk_buff *skb)
238 read_unlock(&raw_lock); 238 read_unlock(&raw_lock);
239} 239}
240 240
241static int raw_getsockopt(struct sock *sk, int level, int optname,
242 char __user *optval, int __user *optlen)
243{
244 return -EOPNOTSUPP;
245}
246
247static int raw_setsockopt(struct sock *sk, int level, int optname,
248 char __user *optval, int __user optlen)
249{
250 return -EOPNOTSUPP;
251}
252
241struct proto ieee802154_raw_prot = { 253struct proto ieee802154_raw_prot = {
242 .name = "IEEE-802.15.4-RAW", 254 .name = "IEEE-802.15.4-RAW",
243 .owner = THIS_MODULE, 255 .owner = THIS_MODULE,
@@ -250,5 +262,7 @@ struct proto ieee802154_raw_prot = {
250 .unhash = raw_unhash, 262 .unhash = raw_unhash,
251 .connect = raw_connect, 263 .connect = raw_connect,
252 .disconnect = raw_disconnect, 264 .disconnect = raw_disconnect,
265 .getsockopt = raw_getsockopt,
266 .setsockopt = raw_setsockopt,
253}; 267};
254 268
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index c29d75d8f1b1..090e9991ac2a 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -1304,7 +1304,9 @@ static void arp_format_neigh_entry(struct seq_file *seq,
1304 hbuffer[k++] = hex_asc_lo(n->ha[j]); 1304 hbuffer[k++] = hex_asc_lo(n->ha[j]);
1305 hbuffer[k++] = ':'; 1305 hbuffer[k++] = ':';
1306 } 1306 }
1307 hbuffer[--k] = 0; 1307 if (k != 0)
1308 --k;
1309 hbuffer[k] = 0;
1308#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE) 1310#if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
1309 } 1311 }
1310#endif 1312#endif
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index cb4a0f4bd5e5..82c11dd10a62 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -951,7 +951,7 @@ static int ipgre_tunnel_bind_dev(struct net_device *dev)
951 addend += 4; 951 addend += 4;
952 } 952 }
953 dev->needed_headroom = addend + hlen; 953 dev->needed_headroom = addend + hlen;
954 mtu -= dev->hard_header_len - addend; 954 mtu -= dev->hard_header_len + addend;
955 955
956 if (mtu < 68) 956 if (mtu < 68)
957 mtu = 68; 957 mtu = 68;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 7d0821054729..7ffcd96fe591 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -813,6 +813,8 @@ int ip_append_data(struct sock *sk,
813 inet->cork.addr = ipc->addr; 813 inet->cork.addr = ipc->addr;
814 } 814 }
815 rt = *rtp; 815 rt = *rtp;
816 if (unlikely(!rt))
817 return -EFAULT;
816 /* 818 /*
817 * We steal reference to this route, caller should not release it 819 * We steal reference to this route, caller should not release it
818 */ 820 */
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index caa0278d30a9..45f9a2a42d56 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -306,8 +306,10 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
306 v4addr != htonl(INADDR_ANY) && 306 v4addr != htonl(INADDR_ANY) &&
307 chk_addr_ret != RTN_LOCAL && 307 chk_addr_ret != RTN_LOCAL &&
308 chk_addr_ret != RTN_MULTICAST && 308 chk_addr_ret != RTN_MULTICAST &&
309 chk_addr_ret != RTN_BROADCAST) 309 chk_addr_ret != RTN_BROADCAST) {
310 err = -EADDRNOTAVAIL;
310 goto out; 311 goto out;
312 }
311 } else { 313 } else {
312 if (addr_type != IPV6_ADDR_ANY) { 314 if (addr_type != IPV6_ADDR_ANY) {
313 struct net_device *dev = NULL; 315 struct net_device *dev = NULL;
diff --git a/net/irda/af_irda.c b/net/irda/af_irda.c
index 80cf29aae096..50b43c57d5d8 100644
--- a/net/irda/af_irda.c
+++ b/net/irda/af_irda.c
@@ -715,6 +715,7 @@ static int irda_getname(struct socket *sock, struct sockaddr *uaddr,
715 struct sock *sk = sock->sk; 715 struct sock *sk = sock->sk;
716 struct irda_sock *self = irda_sk(sk); 716 struct irda_sock *self = irda_sk(sk);
717 717
718 memset(&saddr, 0, sizeof(saddr));
718 if (peer) { 719 if (peer) {
719 if (sk->sk_state != TCP_ESTABLISHED) 720 if (sk->sk_state != TCP_ESTABLISHED)
720 return -ENOTCONN; 721 return -ENOTCONN;
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index 9208cf5f2bd5..c45eee1c0e8d 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -914,6 +914,7 @@ static int llc_ui_getname(struct socket *sock, struct sockaddr *uaddr,
914 struct llc_sock *llc = llc_sk(sk); 914 struct llc_sock *llc = llc_sk(sk);
915 int rc = 0; 915 int rc = 0;
916 916
917 memset(&sllc, 0, sizeof(sllc));
917 lock_sock(sk); 918 lock_sock(sk);
918 if (sock_flag(sk, SOCK_ZAPPED)) 919 if (sock_flag(sk, SOCK_ZAPPED))
919 goto out; 920 goto out;
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c
index 9e5762ad307d..a24e59816b93 100644
--- a/net/mac80211/agg-tx.c
+++ b/net/mac80211/agg-tx.c
@@ -381,6 +381,14 @@ static void ieee80211_agg_splice_packets(struct ieee80211_local *local,
381 &local->hw, queue, 381 &local->hw, queue,
382 IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 382 IEEE80211_QUEUE_STOP_REASON_AGGREGATION);
383 383
384 if (!(sta->ampdu_mlme.tid_state_tx[tid] & HT_ADDBA_REQUESTED_MSK))
385 return;
386
387 if (WARN(!sta->ampdu_mlme.tid_tx[tid],
388 "TID %d gone but expected when splicing aggregates from"
389 "the pending queue\n", tid))
390 return;
391
384 if (!skb_queue_empty(&sta->ampdu_mlme.tid_tx[tid]->pending)) { 392 if (!skb_queue_empty(&sta->ampdu_mlme.tid_tx[tid]->pending)) {
385 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 393 spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
386 /* mark queue as pending, it is stopped already */ 394 /* mark queue as pending, it is stopped already */
diff --git a/net/mac80211/key.c b/net/mac80211/key.c
index ce267565e180..659a42d529e3 100644
--- a/net/mac80211/key.c
+++ b/net/mac80211/key.c
@@ -67,6 +67,8 @@ static DECLARE_WORK(todo_work, key_todo);
67 * 67 *
68 * @key: key to add to do item for 68 * @key: key to add to do item for
69 * @flag: todo flag(s) 69 * @flag: todo flag(s)
70 *
71 * Must be called with IRQs or softirqs disabled.
70 */ 72 */
71static void add_todo(struct ieee80211_key *key, u32 flag) 73static void add_todo(struct ieee80211_key *key, u32 flag)
72{ 74{
@@ -140,9 +142,9 @@ static void ieee80211_key_enable_hw_accel(struct ieee80211_key *key)
140 ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf); 142 ret = drv_set_key(key->local, SET_KEY, &sdata->vif, sta, &key->conf);
141 143
142 if (!ret) { 144 if (!ret) {
143 spin_lock(&todo_lock); 145 spin_lock_bh(&todo_lock);
144 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE; 146 key->flags |= KEY_FLAG_UPLOADED_TO_HARDWARE;
145 spin_unlock(&todo_lock); 147 spin_unlock_bh(&todo_lock);
146 } 148 }
147 149
148 if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP) 150 if (ret && ret != -ENOSPC && ret != -EOPNOTSUPP)
@@ -164,12 +166,12 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
164 if (!key || !key->local->ops->set_key) 166 if (!key || !key->local->ops->set_key)
165 return; 167 return;
166 168
167 spin_lock(&todo_lock); 169 spin_lock_bh(&todo_lock);
168 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) { 170 if (!(key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) {
169 spin_unlock(&todo_lock); 171 spin_unlock_bh(&todo_lock);
170 return; 172 return;
171 } 173 }
172 spin_unlock(&todo_lock); 174 spin_unlock_bh(&todo_lock);
173 175
174 sta = get_sta_for_key(key); 176 sta = get_sta_for_key(key);
175 sdata = key->sdata; 177 sdata = key->sdata;
@@ -188,9 +190,9 @@ static void ieee80211_key_disable_hw_accel(struct ieee80211_key *key)
188 wiphy_name(key->local->hw.wiphy), 190 wiphy_name(key->local->hw.wiphy),
189 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret); 191 key->conf.keyidx, sta ? sta->addr : bcast_addr, ret);
190 192
191 spin_lock(&todo_lock); 193 spin_lock_bh(&todo_lock);
192 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE; 194 key->flags &= ~KEY_FLAG_UPLOADED_TO_HARDWARE;
193 spin_unlock(&todo_lock); 195 spin_unlock_bh(&todo_lock);
194} 196}
195 197
196static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata, 198static void __ieee80211_set_default_key(struct ieee80211_sub_if_data *sdata,
@@ -437,14 +439,14 @@ void ieee80211_key_link(struct ieee80211_key *key,
437 439
438 __ieee80211_key_replace(sdata, sta, old_key, key); 440 __ieee80211_key_replace(sdata, sta, old_key, key);
439 441
440 spin_unlock_irqrestore(&sdata->local->key_lock, flags);
441
442 /* free old key later */ 442 /* free old key later */
443 add_todo(old_key, KEY_FLAG_TODO_DELETE); 443 add_todo(old_key, KEY_FLAG_TODO_DELETE);
444 444
445 add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS); 445 add_todo(key, KEY_FLAG_TODO_ADD_DEBUGFS);
446 if (netif_running(sdata->dev)) 446 if (netif_running(sdata->dev))
447 add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD); 447 add_todo(key, KEY_FLAG_TODO_HWACCEL_ADD);
448
449 spin_unlock_irqrestore(&sdata->local->key_lock, flags);
448} 450}
449 451
450static void __ieee80211_key_free(struct ieee80211_key *key) 452static void __ieee80211_key_free(struct ieee80211_key *key)
@@ -547,7 +549,7 @@ static void __ieee80211_key_todo(void)
547 */ 549 */
548 synchronize_rcu(); 550 synchronize_rcu();
549 551
550 spin_lock(&todo_lock); 552 spin_lock_bh(&todo_lock);
551 while (!list_empty(&todo_list)) { 553 while (!list_empty(&todo_list)) {
552 key = list_first_entry(&todo_list, struct ieee80211_key, todo); 554 key = list_first_entry(&todo_list, struct ieee80211_key, todo);
553 list_del_init(&key->todo); 555 list_del_init(&key->todo);
@@ -558,7 +560,7 @@ static void __ieee80211_key_todo(void)
558 KEY_FLAG_TODO_HWACCEL_REMOVE | 560 KEY_FLAG_TODO_HWACCEL_REMOVE |
559 KEY_FLAG_TODO_DELETE); 561 KEY_FLAG_TODO_DELETE);
560 key->flags &= ~todoflags; 562 key->flags &= ~todoflags;
561 spin_unlock(&todo_lock); 563 spin_unlock_bh(&todo_lock);
562 564
563 work_done = false; 565 work_done = false;
564 566
@@ -591,9 +593,9 @@ static void __ieee80211_key_todo(void)
591 593
592 WARN_ON(!work_done); 594 WARN_ON(!work_done);
593 595
594 spin_lock(&todo_lock); 596 spin_lock_bh(&todo_lock);
595 } 597 }
596 spin_unlock(&todo_lock); 598 spin_unlock_bh(&todo_lock);
597} 599}
598 600
599void ieee80211_key_todo(void) 601void ieee80211_key_todo(void)
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index aca22b00b6a3..07e7e41816be 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -721,7 +721,7 @@ void ieee80211_dynamic_ps_timer(unsigned long data)
721{ 721{
722 struct ieee80211_local *local = (void *) data; 722 struct ieee80211_local *local = (void *) data;
723 723
724 if (local->quiescing) 724 if (local->quiescing || local->suspended)
725 return; 725 return;
726 726
727 queue_work(local->hw.workqueue, &local->dynamic_ps_enable_work); 727 queue_work(local->hw.workqueue, &local->dynamic_ps_enable_work);
diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
index 7a549f9deb96..5e3d476972f9 100644
--- a/net/mac80211/pm.c
+++ b/net/mac80211/pm.c
@@ -55,15 +55,6 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
55 55
56 rcu_read_unlock(); 56 rcu_read_unlock();
57 57
58 /* flush again, in case driver queued work */
59 flush_workqueue(local->hw.workqueue);
60
61 /* stop hardware - this must stop RX */
62 if (local->open_count) {
63 ieee80211_led_radio(local, false);
64 drv_stop(local);
65 }
66
67 /* remove STAs */ 58 /* remove STAs */
68 spin_lock_irqsave(&local->sta_lock, flags); 59 spin_lock_irqsave(&local->sta_lock, flags);
69 list_for_each_entry(sta, &local->sta_list, list) { 60 list_for_each_entry(sta, &local->sta_list, list) {
@@ -111,7 +102,22 @@ int __ieee80211_suspend(struct ieee80211_hw *hw)
111 drv_remove_interface(local, &conf); 102 drv_remove_interface(local, &conf);
112 } 103 }
113 104
105 /* stop hardware - this must stop RX */
106 if (local->open_count) {
107 ieee80211_led_radio(local, false);
108 drv_stop(local);
109 }
110
111 /*
112 * flush again, in case driver queued work -- it
113 * shouldn't be doing (or cancel everything in the
114 * stop callback) that but better safe than sorry.
115 */
116 flush_workqueue(local->hw.workqueue);
117
114 local->suspended = true; 118 local->suspended = true;
119 /* need suspended to be visible before quiescing is false */
120 barrier();
115 local->quiescing = false; 121 local->quiescing = false;
116 122
117 return 0; 123 return 0;
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c
index de5bba7f910a..0936fc24942d 100644
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -2453,6 +2453,18 @@ void __ieee80211_rx(struct ieee80211_hw *hw, struct sk_buff *skb,
2453 return; 2453 return;
2454 } 2454 }
2455 2455
2456 /*
2457 * If we're suspending, it is possible although not too likely
2458 * that we'd be receiving frames after having already partially
2459 * quiesced the stack. We can't process such frames then since
2460 * that might, for example, cause stations to be added or other
2461 * driver callbacks be invoked.
2462 */
2463 if (unlikely(local->quiescing || local->suspended)) {
2464 kfree_skb(skb);
2465 return;
2466 }
2467
2456 if (status->flag & RX_FLAG_HT) { 2468 if (status->flag & RX_FLAG_HT) {
2457 /* rate_idx is MCS index */ 2469 /* rate_idx is MCS index */
2458 if (WARN_ON(status->rate_idx < 0 || 2470 if (WARN_ON(status->rate_idx < 0 ||
diff --git a/net/netfilter/xt_RATEEST.c b/net/netfilter/xt_RATEEST.c
index 43f5676b1af4..d80b8192e0d4 100644
--- a/net/netfilter/xt_RATEEST.c
+++ b/net/netfilter/xt_RATEEST.c
@@ -74,7 +74,7 @@ static unsigned int
74xt_rateest_tg(struct sk_buff *skb, const struct xt_target_param *par) 74xt_rateest_tg(struct sk_buff *skb, const struct xt_target_param *par)
75{ 75{
76 const struct xt_rateest_target_info *info = par->targinfo; 76 const struct xt_rateest_target_info *info = par->targinfo;
77 struct gnet_stats_basic *stats = &info->est->bstats; 77 struct gnet_stats_basic_packed *stats = &info->est->bstats;
78 78
79 spin_lock_bh(&info->est->lock); 79 spin_lock_bh(&info->est->lock);
80 stats->bytes += skb->len; 80 stats->bytes += skb->len;
diff --git a/net/netfilter/xt_quota.c b/net/netfilter/xt_quota.c
index 98fc190e8f0e..390b7d09fe51 100644
--- a/net/netfilter/xt_quota.c
+++ b/net/netfilter/xt_quota.c
@@ -52,7 +52,7 @@ static bool quota_mt_check(const struct xt_mtchk_param *par)
52 52
53 q->master = kmalloc(sizeof(*q->master), GFP_KERNEL); 53 q->master = kmalloc(sizeof(*q->master), GFP_KERNEL);
54 if (q->master == NULL) 54 if (q->master == NULL)
55 return -ENOMEM; 55 return false;
56 56
57 q->master->quota = q->quota; 57 q->master->quota = q->quota;
58 return true; 58 return true;
diff --git a/net/netlabel/netlabel_kapi.c b/net/netlabel/netlabel_kapi.c
index b0e582f2d37a..16e6c4378ff1 100644
--- a/net/netlabel/netlabel_kapi.c
+++ b/net/netlabel/netlabel_kapi.c
@@ -151,7 +151,7 @@ int netlbl_cfg_unlbl_map_add(const char *domain,
151 addr6 = addr; 151 addr6 = addr;
152 mask6 = mask; 152 mask6 = mask;
153 map6 = kzalloc(sizeof(*map6), GFP_ATOMIC); 153 map6 = kzalloc(sizeof(*map6), GFP_ATOMIC);
154 if (map4 == NULL) 154 if (map6 == NULL)
155 goto cfg_unlbl_map_add_failure; 155 goto cfg_unlbl_map_add_failure;
156 map6->type = NETLBL_NLTYPE_UNLABELED; 156 map6->type = NETLBL_NLTYPE_UNLABELED;
157 ipv6_addr_copy(&map6->list.addr, addr6); 157 ipv6_addr_copy(&map6->list.addr, addr6);
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index ce51ce012cda..ce1a34b99c23 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -847,6 +847,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
847 sax->fsa_ax25.sax25_family = AF_NETROM; 847 sax->fsa_ax25.sax25_family = AF_NETROM;
848 sax->fsa_ax25.sax25_ndigis = 1; 848 sax->fsa_ax25.sax25_ndigis = 1;
849 sax->fsa_ax25.sax25_call = nr->user_addr; 849 sax->fsa_ax25.sax25_call = nr->user_addr;
850 memset(sax->fsa_digipeater, 0, sizeof(sax->fsa_digipeater));
850 sax->fsa_digipeater[0] = nr->dest_addr; 851 sax->fsa_digipeater[0] = nr->dest_addr;
851 *uaddr_len = sizeof(struct full_sockaddr_ax25); 852 *uaddr_len = sizeof(struct full_sockaddr_ax25);
852 } else { 853 } else {
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
index e943c16552a2..4eb1ac9a7679 100644
--- a/net/netrom/nr_route.c
+++ b/net/netrom/nr_route.c
@@ -630,23 +630,23 @@ out:
630 return dev; 630 return dev;
631} 631}
632 632
633static ax25_digi *nr_call_to_digi(int ndigis, ax25_address *digipeaters) 633static ax25_digi *nr_call_to_digi(ax25_digi *digi, int ndigis,
634 ax25_address *digipeaters)
634{ 635{
635 static ax25_digi ax25_digi;
636 int i; 636 int i;
637 637
638 if (ndigis == 0) 638 if (ndigis == 0)
639 return NULL; 639 return NULL;
640 640
641 for (i = 0; i < ndigis; i++) { 641 for (i = 0; i < ndigis; i++) {
642 ax25_digi.calls[i] = digipeaters[i]; 642 digi->calls[i] = digipeaters[i];
643 ax25_digi.repeated[i] = 0; 643 digi->repeated[i] = 0;
644 } 644 }
645 645
646 ax25_digi.ndigi = ndigis; 646 digi->ndigi = ndigis;
647 ax25_digi.lastrepeat = -1; 647 digi->lastrepeat = -1;
648 648
649 return &ax25_digi; 649 return digi;
650} 650}
651 651
652/* 652/*
@@ -656,6 +656,7 @@ int nr_rt_ioctl(unsigned int cmd, void __user *arg)
656{ 656{
657 struct nr_route_struct nr_route; 657 struct nr_route_struct nr_route;
658 struct net_device *dev; 658 struct net_device *dev;
659 ax25_digi digi;
659 int ret; 660 int ret;
660 661
661 switch (cmd) { 662 switch (cmd) {
@@ -673,13 +674,15 @@ int nr_rt_ioctl(unsigned int cmd, void __user *arg)
673 ret = nr_add_node(&nr_route.callsign, 674 ret = nr_add_node(&nr_route.callsign,
674 nr_route.mnemonic, 675 nr_route.mnemonic,
675 &nr_route.neighbour, 676 &nr_route.neighbour,
676 nr_call_to_digi(nr_route.ndigis, nr_route.digipeaters), 677 nr_call_to_digi(&digi, nr_route.ndigis,
678 nr_route.digipeaters),
677 dev, nr_route.quality, 679 dev, nr_route.quality,
678 nr_route.obs_count); 680 nr_route.obs_count);
679 break; 681 break;
680 case NETROM_NEIGH: 682 case NETROM_NEIGH:
681 ret = nr_add_neigh(&nr_route.callsign, 683 ret = nr_add_neigh(&nr_route.callsign,
682 nr_call_to_digi(nr_route.ndigis, nr_route.digipeaters), 684 nr_call_to_digi(&digi, nr_route.ndigis,
685 nr_route.digipeaters),
683 dev, nr_route.quality); 686 dev, nr_route.quality);
684 break; 687 break;
685 default: 688 default:
diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c
index b0d6ddd82a9d..c2b77a698695 100644
--- a/net/phonet/pn_dev.c
+++ b/net/phonet/pn_dev.c
@@ -96,7 +96,7 @@ struct net_device *phonet_device_get(struct net *net)
96{ 96{
97 struct phonet_device_list *pndevs = phonet_device_list(net); 97 struct phonet_device_list *pndevs = phonet_device_list(net);
98 struct phonet_device *pnd; 98 struct phonet_device *pnd;
99 struct net_device *dev; 99 struct net_device *dev = NULL;
100 100
101 spin_lock_bh(&pndevs->lock); 101 spin_lock_bh(&pndevs->lock);
102 list_for_each_entry(pnd, &pndevs->list, list) { 102 list_for_each_entry(pnd, &pndevs->list, list) {
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index f0a76f6bca71..e5f478ca3d61 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -954,6 +954,7 @@ static int rose_getname(struct socket *sock, struct sockaddr *uaddr,
954 struct rose_sock *rose = rose_sk(sk); 954 struct rose_sock *rose = rose_sk(sk);
955 int n; 955 int n;
956 956
957 memset(srose, 0, sizeof(*srose));
957 if (peer != 0) { 958 if (peer != 0) {
958 if (sk->sk_state != TCP_ESTABLISHED) 959 if (sk->sk_state != TCP_ESTABLISHED)
959 return -ENOTCONN; 960 return -ENOTCONN;
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index 24d17ce9c294..92e6f3a52c13 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -458,7 +458,7 @@ EXPORT_SYMBOL(qdisc_warn_nonwc);
458static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer) 458static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
459{ 459{
460 struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog, 460 struct qdisc_watchdog *wd = container_of(timer, struct qdisc_watchdog,
461 timer); 461 timer.timer);
462 462
463 wd->qdisc->flags &= ~TCQ_F_THROTTLED; 463 wd->qdisc->flags &= ~TCQ_F_THROTTLED;
464 __netif_schedule(qdisc_root(wd->qdisc)); 464 __netif_schedule(qdisc_root(wd->qdisc));
@@ -468,8 +468,8 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer)
468 468
469void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc) 469void qdisc_watchdog_init(struct qdisc_watchdog *wd, struct Qdisc *qdisc)
470{ 470{
471 hrtimer_init(&wd->timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 471 tasklet_hrtimer_init(&wd->timer, qdisc_watchdog,
472 wd->timer.function = qdisc_watchdog; 472 CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
473 wd->qdisc = qdisc; 473 wd->qdisc = qdisc;
474} 474}
475EXPORT_SYMBOL(qdisc_watchdog_init); 475EXPORT_SYMBOL(qdisc_watchdog_init);
@@ -485,13 +485,13 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires)
485 wd->qdisc->flags |= TCQ_F_THROTTLED; 485 wd->qdisc->flags |= TCQ_F_THROTTLED;
486 time = ktime_set(0, 0); 486 time = ktime_set(0, 0);
487 time = ktime_add_ns(time, PSCHED_TICKS2NS(expires)); 487 time = ktime_add_ns(time, PSCHED_TICKS2NS(expires));
488 hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS); 488 tasklet_hrtimer_start(&wd->timer, time, HRTIMER_MODE_ABS);
489} 489}
490EXPORT_SYMBOL(qdisc_watchdog_schedule); 490EXPORT_SYMBOL(qdisc_watchdog_schedule);
491 491
492void qdisc_watchdog_cancel(struct qdisc_watchdog *wd) 492void qdisc_watchdog_cancel(struct qdisc_watchdog *wd)
493{ 493{
494 hrtimer_cancel(&wd->timer); 494 tasklet_hrtimer_cancel(&wd->timer);
495 wd->qdisc->flags &= ~TCQ_F_THROTTLED; 495 wd->qdisc->flags &= ~TCQ_F_THROTTLED;
496} 496}
497EXPORT_SYMBOL(qdisc_watchdog_cancel); 497EXPORT_SYMBOL(qdisc_watchdog_cancel);
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index 2a8b83af7c47..ab82f145f689 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -49,7 +49,7 @@ struct atm_flow_data {
49 struct socket *sock; /* for closing */ 49 struct socket *sock; /* for closing */
50 u32 classid; /* x:y type ID */ 50 u32 classid; /* x:y type ID */
51 int ref; /* reference count */ 51 int ref; /* reference count */
52 struct gnet_stats_basic bstats; 52 struct gnet_stats_basic_packed bstats;
53 struct gnet_stats_queue qstats; 53 struct gnet_stats_queue qstats;
54 struct atm_flow_data *next; 54 struct atm_flow_data *next;
55 struct atm_flow_data *excess; /* flow for excess traffic; 55 struct atm_flow_data *excess; /* flow for excess traffic;
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index 23a167670fd5..149b0405c5ec 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -128,7 +128,7 @@ struct cbq_class
128 long avgidle; 128 long avgidle;
129 long deficit; /* Saved deficit for WRR */ 129 long deficit; /* Saved deficit for WRR */
130 psched_time_t penalized; 130 psched_time_t penalized;
131 struct gnet_stats_basic bstats; 131 struct gnet_stats_basic_packed bstats;
132 struct gnet_stats_queue qstats; 132 struct gnet_stats_queue qstats;
133 struct gnet_stats_rate_est rate_est; 133 struct gnet_stats_rate_est rate_est;
134 struct tc_cbq_xstats xstats; 134 struct tc_cbq_xstats xstats;
@@ -163,7 +163,7 @@ struct cbq_sched_data
163 psched_time_t now_rt; /* Cached real time */ 163 psched_time_t now_rt; /* Cached real time */
164 unsigned pmask; 164 unsigned pmask;
165 165
166 struct hrtimer delay_timer; 166 struct tasklet_hrtimer delay_timer;
167 struct qdisc_watchdog watchdog; /* Watchdog timer, 167 struct qdisc_watchdog watchdog; /* Watchdog timer,
168 started when CBQ has 168 started when CBQ has
169 backlog, but cannot 169 backlog, but cannot
@@ -503,6 +503,8 @@ static void cbq_ovl_delay(struct cbq_class *cl)
503 cl->undertime = q->now + delay; 503 cl->undertime = q->now + delay;
504 504
505 if (delay > 0) { 505 if (delay > 0) {
506 struct hrtimer *ht;
507
506 sched += delay + cl->penalty; 508 sched += delay + cl->penalty;
507 cl->penalized = sched; 509 cl->penalized = sched;
508 cl->cpriority = TC_CBQ_MAXPRIO; 510 cl->cpriority = TC_CBQ_MAXPRIO;
@@ -510,12 +512,12 @@ static void cbq_ovl_delay(struct cbq_class *cl)
510 512
511 expires = ktime_set(0, 0); 513 expires = ktime_set(0, 0);
512 expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched)); 514 expires = ktime_add_ns(expires, PSCHED_TICKS2NS(sched));
513 if (hrtimer_try_to_cancel(&q->delay_timer) && 515 ht = &q->delay_timer.timer;
514 ktime_to_ns(ktime_sub( 516 if (hrtimer_try_to_cancel(ht) &&
515 hrtimer_get_expires(&q->delay_timer), 517 ktime_to_ns(ktime_sub(hrtimer_get_expires(ht),
516 expires)) > 0) 518 expires)) > 0)
517 hrtimer_set_expires(&q->delay_timer, expires); 519 hrtimer_set_expires(ht, expires);
518 hrtimer_restart(&q->delay_timer); 520 hrtimer_restart(ht);
519 cl->delayed = 1; 521 cl->delayed = 1;
520 cl->xstats.overactions++; 522 cl->xstats.overactions++;
521 return; 523 return;
@@ -591,7 +593,7 @@ static psched_tdiff_t cbq_undelay_prio(struct cbq_sched_data *q, int prio,
591static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) 593static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
592{ 594{
593 struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data, 595 struct cbq_sched_data *q = container_of(timer, struct cbq_sched_data,
594 delay_timer); 596 delay_timer.timer);
595 struct Qdisc *sch = q->watchdog.qdisc; 597 struct Qdisc *sch = q->watchdog.qdisc;
596 psched_time_t now; 598 psched_time_t now;
597 psched_tdiff_t delay = 0; 599 psched_tdiff_t delay = 0;
@@ -621,7 +623,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer)
621 623
622 time = ktime_set(0, 0); 624 time = ktime_set(0, 0);
623 time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay)); 625 time = ktime_add_ns(time, PSCHED_TICKS2NS(now + delay));
624 hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS); 626 tasklet_hrtimer_start(&q->delay_timer, time, HRTIMER_MODE_ABS);
625 } 627 }
626 628
627 sch->flags &= ~TCQ_F_THROTTLED; 629 sch->flags &= ~TCQ_F_THROTTLED;
@@ -1214,7 +1216,7 @@ cbq_reset(struct Qdisc* sch)
1214 q->tx_class = NULL; 1216 q->tx_class = NULL;
1215 q->tx_borrowed = NULL; 1217 q->tx_borrowed = NULL;
1216 qdisc_watchdog_cancel(&q->watchdog); 1218 qdisc_watchdog_cancel(&q->watchdog);
1217 hrtimer_cancel(&q->delay_timer); 1219 tasklet_hrtimer_cancel(&q->delay_timer);
1218 q->toplevel = TC_CBQ_MAXLEVEL; 1220 q->toplevel = TC_CBQ_MAXLEVEL;
1219 q->now = psched_get_time(); 1221 q->now = psched_get_time();
1220 q->now_rt = q->now; 1222 q->now_rt = q->now;
@@ -1397,7 +1399,8 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt)
1397 q->link.minidle = -0x7FFFFFFF; 1399 q->link.minidle = -0x7FFFFFFF;
1398 1400
1399 qdisc_watchdog_init(&q->watchdog, sch); 1401 qdisc_watchdog_init(&q->watchdog, sch);
1400 hrtimer_init(&q->delay_timer, CLOCK_MONOTONIC, HRTIMER_MODE_ABS); 1402 tasklet_hrtimer_init(&q->delay_timer, cbq_undelay,
1403 CLOCK_MONOTONIC, HRTIMER_MODE_ABS);
1401 q->delay_timer.function = cbq_undelay; 1404 q->delay_timer.function = cbq_undelay;
1402 q->toplevel = TC_CBQ_MAXLEVEL; 1405 q->toplevel = TC_CBQ_MAXLEVEL;
1403 q->now = psched_get_time(); 1406 q->now = psched_get_time();
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
index 7597fe146866..12b2fb04b29b 100644
--- a/net/sched/sch_drr.c
+++ b/net/sched/sch_drr.c
@@ -22,7 +22,7 @@ struct drr_class {
22 unsigned int refcnt; 22 unsigned int refcnt;
23 unsigned int filter_cnt; 23 unsigned int filter_cnt;
24 24
25 struct gnet_stats_basic bstats; 25 struct gnet_stats_basic_packed bstats;
26 struct gnet_stats_queue qstats; 26 struct gnet_stats_queue qstats;
27 struct gnet_stats_rate_est rate_est; 27 struct gnet_stats_rate_est rate_est;
28 struct list_head alist; 28 struct list_head alist;
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 362c2811b2df..dad0144423da 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -116,7 +116,7 @@ struct hfsc_class
116 struct Qdisc_class_common cl_common; 116 struct Qdisc_class_common cl_common;
117 unsigned int refcnt; /* usage count */ 117 unsigned int refcnt; /* usage count */
118 118
119 struct gnet_stats_basic bstats; 119 struct gnet_stats_basic_packed bstats;
120 struct gnet_stats_queue qstats; 120 struct gnet_stats_queue qstats;
121 struct gnet_stats_rate_est rate_est; 121 struct gnet_stats_rate_est rate_est;
122 unsigned int level; /* class level in hierarchy */ 122 unsigned int level; /* class level in hierarchy */
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 88cd02626621..ec4d46399d59 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -74,7 +74,7 @@ enum htb_cmode {
74struct htb_class { 74struct htb_class {
75 struct Qdisc_class_common common; 75 struct Qdisc_class_common common;
76 /* general class parameters */ 76 /* general class parameters */
77 struct gnet_stats_basic bstats; 77 struct gnet_stats_basic_packed bstats;
78 struct gnet_stats_queue qstats; 78 struct gnet_stats_queue qstats;
79 struct gnet_stats_rate_est rate_est; 79 struct gnet_stats_rate_est rate_est;
80 struct tc_htb_xstats xstats; /* our special stats */ 80 struct tc_htb_xstats xstats; /* our special stats */
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
index 79cbd47f4df7..a76da657244a 100644
--- a/net/sctp/protocol.c
+++ b/net/sctp/protocol.c
@@ -160,6 +160,7 @@ static void sctp_proc_exit(void)
160 remove_proc_entry("sctp", init_net.proc_net); 160 remove_proc_entry("sctp", init_net.proc_net);
161 } 161 }
162#endif 162#endif
163 percpu_counter_destroy(&sctp_sockets_allocated);
163} 164}
164 165
165/* Private helper to extract ipv4 address and stash them in 166/* Private helper to extract ipv4 address and stash them in
diff --git a/net/socket.c b/net/socket.c
index 791d71a36a93..6d4716559047 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -736,7 +736,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
736 if (more) 736 if (more)
737 flags |= MSG_MORE; 737 flags |= MSG_MORE;
738 738
739 return sock->ops->sendpage(sock, page, offset, size, flags); 739 return kernel_sendpage(sock, page, offset, size, flags);
740} 740}
741 741
742static ssize_t sock_splice_read(struct file *file, loff_t *ppos, 742static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index ebfcf9b89909..df1039f077c2 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -937,6 +937,7 @@ static inline void
937rpc_task_force_reencode(struct rpc_task *task) 937rpc_task_force_reencode(struct rpc_task *task)
938{ 938{
939 task->tk_rqstp->rq_snd_buf.len = 0; 939 task->tk_rqstp->rq_snd_buf.len = 0;
940 task->tk_rqstp->rq_bytes_sent = 0;
940} 941}
941 942
942static inline void 943static inline void
diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 5e14371cda70..75a406d33619 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -1089,17 +1089,18 @@ static void handle_reg_beacon(struct wiphy *wiphy,
1089 1089
1090 chan->beacon_found = true; 1090 chan->beacon_found = true;
1091 1091
1092 if (wiphy->disable_beacon_hints)
1093 return;
1094
1092 chan_before.center_freq = chan->center_freq; 1095 chan_before.center_freq = chan->center_freq;
1093 chan_before.flags = chan->flags; 1096 chan_before.flags = chan->flags;
1094 1097
1095 if ((chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) && 1098 if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) {
1096 !(chan->orig_flags & IEEE80211_CHAN_PASSIVE_SCAN)) {
1097 chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; 1099 chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN;
1098 channel_changed = true; 1100 channel_changed = true;
1099 } 1101 }
1100 1102
1101 if ((chan->flags & IEEE80211_CHAN_NO_IBSS) && 1103 if (chan->flags & IEEE80211_CHAN_NO_IBSS) {
1102 !(chan->orig_flags & IEEE80211_CHAN_NO_IBSS)) {
1103 chan->flags &= ~IEEE80211_CHAN_NO_IBSS; 1104 chan->flags &= ~IEEE80211_CHAN_NO_IBSS;
1104 channel_changed = true; 1105 channel_changed = true;
1105 } 1106 }
diff --git a/net/wireless/reg.h b/net/wireless/reg.h
index e37829a49dc4..4e167a8e11be 100644
--- a/net/wireless/reg.h
+++ b/net/wireless/reg.h
@@ -30,7 +30,8 @@ int set_regdom(const struct ieee80211_regdomain *rd);
30 * non-radar 5 GHz channels. 30 * non-radar 5 GHz channels.
31 * 31 *
32 * Drivers do not need to call this, cfg80211 will do it for after a scan 32 * Drivers do not need to call this, cfg80211 will do it for after a scan
33 * on a newly found BSS. 33 * on a newly found BSS. If you cannot make use of this feature you can
34 * set the wiphy->disable_beacon_hints to true.
34 */ 35 */
35int regulatory_hint_found_beacon(struct wiphy *wiphy, 36int regulatory_hint_found_beacon(struct wiphy *wiphy,
36 struct ieee80211_channel *beacon_chan, 37 struct ieee80211_channel *beacon_chan,
diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 9271118e1fc4..7e595ce24eeb 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -118,7 +118,7 @@ static int cmp_ies(u8 num, u8 *ies1, size_t len1, u8 *ies2, size_t len2)
118 118
119 if (!ie1 && !ie2) 119 if (!ie1 && !ie2)
120 return 0; 120 return 0;
121 if (!ie1) 121 if (!ie1 || !ie2)
122 return -1; 122 return -1;
123 123
124 r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1])); 124 r = memcmp(ie1 + 2, ie2 + 2, min(ie1[1], ie2[1]));
@@ -171,6 +171,8 @@ static bool is_mesh(struct cfg80211_bss *a,
171 ie = find_ie(WLAN_EID_MESH_CONFIG, 171 ie = find_ie(WLAN_EID_MESH_CONFIG,
172 a->information_elements, 172 a->information_elements,
173 a->len_information_elements); 173 a->len_information_elements);
174 if (!ie)
175 return false;
174 if (ie[1] != IEEE80211_MESH_CONFIG_LEN) 176 if (ie[1] != IEEE80211_MESH_CONFIG_LEN)
175 return false; 177 return false;
176 178
diff --git a/net/xfrm/xfrm_hash.h b/net/xfrm/xfrm_hash.h
index d401dc8f05ed..e5195c99f71e 100644
--- a/net/xfrm/xfrm_hash.h
+++ b/net/xfrm/xfrm_hash.h
@@ -16,7 +16,7 @@ static inline unsigned int __xfrm6_addr_hash(xfrm_address_t *addr)
16 16
17static inline unsigned int __xfrm4_daddr_saddr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr) 17static inline unsigned int __xfrm4_daddr_saddr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr)
18{ 18{
19 return ntohl(daddr->a4 ^ saddr->a4); 19 return ntohl(daddr->a4 + saddr->a4);
20} 20}
21 21
22static inline unsigned int __xfrm6_daddr_saddr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr) 22static inline unsigned int __xfrm6_daddr_saddr_hash(xfrm_address_t *daddr, xfrm_address_t *saddr)
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 7109e2b5bc0a..911ba7ffab84 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -393,7 +393,7 @@ while (<IN>) {
393 $read_function = 0; 393 $read_function = 0;
394 } 394 }
395 # print out any recorded offsets 395 # print out any recorded offsets
396 update_funcs() if ($text_found); 396 update_funcs() if (defined($ref_func));
397 397
398 # reset all markers and arrays 398 # reset all markers and arrays
399 $text_found = 0; 399 $text_found = 0;
@@ -403,7 +403,6 @@ while (<IN>) {
403 # section found, now is this a start of a function? 403 # section found, now is this a start of a function?
404 } elsif ($read_function && /$function_regex/) { 404 } elsif ($read_function && /$function_regex/) {
405 $text_found = 1; 405 $text_found = 1;
406 $offset = hex $1;
407 $text = $2; 406 $text = $2;
408 407
409 # if this is either a local function or a weak function 408 # if this is either a local function or a weak function
@@ -412,10 +411,15 @@ while (<IN>) {
412 if (!defined($locals{$text}) && !defined($weak{$text})) { 411 if (!defined($locals{$text}) && !defined($weak{$text})) {
413 $ref_func = $text; 412 $ref_func = $text;
414 $read_function = 0; 413 $read_function = 0;
414 $offset = hex $1;
415 } else { 415 } else {
416 # if we already have a function, and this is weak, skip it 416 # if we already have a function, and this is weak, skip it
417 if (!defined($ref_func) || !defined($weak{$text})) { 417 if (!defined($ref_func) && !defined($weak{$text}) &&
418 # PPC64 can have symbols that start with .L and
419 # gcc considers these special. Don't use them!
420 $text !~ /^\.L/) {
418 $ref_func = $text; 421 $ref_func = $text;
422 $offset = hex $1;
419 } 423 }
420 } 424 }
421 } elsif ($read_headers && /$mcount_section/) { 425 } elsif ($read_headers && /$mcount_section/) {
@@ -440,7 +444,7 @@ while (<IN>) {
440} 444}
441 445
442# dump out anymore offsets that may have been found 446# dump out anymore offsets that may have been found
443update_funcs() if ($text_found); 447update_funcs() if (defined($ref_func));
444 448
445# If we did not find any mcount callers, we are done (do nothing). 449# If we did not find any mcount callers, we are done (do nothing).
446if (!$opened) { 450if (!$opened) {
diff --git a/security/Kconfig b/security/Kconfig
index d23c839038f0..4c865345caa0 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -113,6 +113,22 @@ config SECURITY_ROOTPLUG
113 113
114 If you are unsure how to answer this question, answer N. 114 If you are unsure how to answer this question, answer N.
115 115
116config LSM_MMAP_MIN_ADDR
117 int "Low address space for LSM to protect from user allocation"
118 depends on SECURITY && SECURITY_SELINUX
119 default 65536
120 help
121 This is the portion of low virtual memory which should be protected
122 from userspace allocation. Keeping a user from writing to low pages
123 can help reduce the impact of kernel NULL pointer bugs.
124
125 For most ia64, ppc64 and x86 users with lots of address space
126 a value of 65536 is reasonable and should cause no problems.
127 On arm and other archs it should not be higher than 32768.
128 Programs which use vm86 functionality or have some need to map
129 this low address space will need the permission specific to the
130 systems running LSM.
131
116source security/selinux/Kconfig 132source security/selinux/Kconfig
117source security/smack/Kconfig 133source security/smack/Kconfig
118source security/tomoyo/Kconfig 134source security/tomoyo/Kconfig
diff --git a/security/Makefile b/security/Makefile
index c67557cdaa85..b56e7f9ecbc2 100644
--- a/security/Makefile
+++ b/security/Makefile
@@ -8,7 +8,7 @@ subdir-$(CONFIG_SECURITY_SMACK) += smack
8subdir-$(CONFIG_SECURITY_TOMOYO) += tomoyo 8subdir-$(CONFIG_SECURITY_TOMOYO) += tomoyo
9 9
10# always enable default capabilities 10# always enable default capabilities
11obj-y += commoncap.o 11obj-y += commoncap.o min_addr.o
12 12
13# Object file lists 13# Object file lists
14obj-$(CONFIG_SECURITY) += security.o capability.o 14obj-$(CONFIG_SECURITY) += security.o capability.o
diff --git a/security/capability.c b/security/capability.c
index 21b6cead6a8e..88f752e8152c 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -330,15 +330,6 @@ static int cap_file_ioctl(struct file *file, unsigned int command,
330 return 0; 330 return 0;
331} 331}
332 332
333static int cap_file_mmap(struct file *file, unsigned long reqprot,
334 unsigned long prot, unsigned long flags,
335 unsigned long addr, unsigned long addr_only)
336{
337 if ((addr < mmap_min_addr) && !capable(CAP_SYS_RAWIO))
338 return -EACCES;
339 return 0;
340}
341
342static int cap_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot, 333static int cap_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
343 unsigned long prot) 334 unsigned long prot)
344{ 335{
diff --git a/security/commoncap.c b/security/commoncap.c
index 48b7e0228fa3..e3097c0a1311 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -984,3 +984,33 @@ int cap_vm_enough_memory(struct mm_struct *mm, long pages)
984 cap_sys_admin = 1; 984 cap_sys_admin = 1;
985 return __vm_enough_memory(mm, pages, cap_sys_admin); 985 return __vm_enough_memory(mm, pages, cap_sys_admin);
986} 986}
987
988/*
989 * cap_file_mmap - check if able to map given addr
990 * @file: unused
991 * @reqprot: unused
992 * @prot: unused
993 * @flags: unused
994 * @addr: address attempting to be mapped
995 * @addr_only: unused
996 *
997 * If the process is attempting to map memory below mmap_min_addr they need
998 * CAP_SYS_RAWIO. The other parameters to this function are unused by the
999 * capability security module. Returns 0 if this mapping should be allowed
1000 * -EPERM if not.
1001 */
1002int cap_file_mmap(struct file *file, unsigned long reqprot,
1003 unsigned long prot, unsigned long flags,
1004 unsigned long addr, unsigned long addr_only)
1005{
1006 int ret = 0;
1007
1008 if (addr < dac_mmap_min_addr) {
1009 ret = cap_capable(current, current_cred(), CAP_SYS_RAWIO,
1010 SECURITY_CAP_AUDIT);
1011 /* set PF_SUPERPRIV if it turns out we allow the low mmap */
1012 if (ret == 0)
1013 current->flags |= PF_SUPERPRIV;
1014 }
1015 return ret;
1016}
diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c
index 63003a63aaee..46642a19bc78 100644
--- a/security/integrity/ima/ima_crypto.c
+++ b/security/integrity/ima/ima_crypto.c
@@ -45,9 +45,9 @@ int ima_calc_hash(struct file *file, char *digest)
45{ 45{
46 struct hash_desc desc; 46 struct hash_desc desc;
47 struct scatterlist sg[1]; 47 struct scatterlist sg[1];
48 loff_t i_size; 48 loff_t i_size, offset = 0;
49 char *rbuf; 49 char *rbuf;
50 int rc, offset = 0; 50 int rc;
51 51
52 rc = init_desc(&desc); 52 rc = init_desc(&desc);
53 if (rc != 0) 53 if (rc != 0)
@@ -67,6 +67,8 @@ int ima_calc_hash(struct file *file, char *digest)
67 rc = rbuf_len; 67 rc = rbuf_len;
68 break; 68 break;
69 } 69 }
70 if (rbuf_len == 0)
71 break;
70 offset += rbuf_len; 72 offset += rbuf_len;
71 sg_init_one(sg, rbuf, rbuf_len); 73 sg_init_one(sg, rbuf, rbuf_len);
72 74
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 101c512564ec..4732f5e5d127 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -262,6 +262,8 @@ void ima_counts_put(struct path *path, int mask)
262 else if (mask & (MAY_READ | MAY_EXEC)) 262 else if (mask & (MAY_READ | MAY_EXEC))
263 iint->readcount--; 263 iint->readcount--;
264 mutex_unlock(&iint->mutex); 264 mutex_unlock(&iint->mutex);
265
266 kref_put(&iint->refcount, iint_free);
265} 267}
266 268
267/* 269/*
@@ -291,6 +293,8 @@ void ima_counts_get(struct file *file)
291 if (file->f_mode & FMODE_WRITE) 293 if (file->f_mode & FMODE_WRITE)
292 iint->writecount++; 294 iint->writecount++;
293 mutex_unlock(&iint->mutex); 295 mutex_unlock(&iint->mutex);
296
297 kref_put(&iint->refcount, iint_free);
294} 298}
295EXPORT_SYMBOL_GPL(ima_counts_get); 299EXPORT_SYMBOL_GPL(ima_counts_get);
296 300
diff --git a/security/min_addr.c b/security/min_addr.c
new file mode 100644
index 000000000000..14cc7b3b8d03
--- /dev/null
+++ b/security/min_addr.c
@@ -0,0 +1,49 @@
1#include <linux/init.h>
2#include <linux/mm.h>
3#include <linux/security.h>
4#include <linux/sysctl.h>
5
6/* amount of vm to protect from userspace access by both DAC and the LSM*/
7unsigned long mmap_min_addr;
8/* amount of vm to protect from userspace using CAP_SYS_RAWIO (DAC) */
9unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
10/* amount of vm to protect from userspace using the LSM = CONFIG_LSM_MMAP_MIN_ADDR */
11
12/*
13 * Update mmap_min_addr = max(dac_mmap_min_addr, CONFIG_LSM_MMAP_MIN_ADDR)
14 */
15static void update_mmap_min_addr(void)
16{
17#ifdef CONFIG_LSM_MMAP_MIN_ADDR
18 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
19 mmap_min_addr = dac_mmap_min_addr;
20 else
21 mmap_min_addr = CONFIG_LSM_MMAP_MIN_ADDR;
22#else
23 mmap_min_addr = dac_mmap_min_addr;
24#endif
25}
26
27/*
28 * sysctl handler which just sets dac_mmap_min_addr = the new value and then
29 * calls update_mmap_min_addr() so non MAP_FIXED hints get rounded properly
30 */
31int mmap_min_addr_handler(struct ctl_table *table, int write, struct file *filp,
32 void __user *buffer, size_t *lenp, loff_t *ppos)
33{
34 int ret;
35
36 ret = proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos);
37
38 update_mmap_min_addr();
39
40 return ret;
41}
42
43int __init init_mmap_min_addr(void)
44{
45 update_mmap_min_addr();
46
47 return 0;
48}
49pure_initcall(init_mmap_min_addr);
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 15c2a08a66f1..8d8b69c5664e 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1285,6 +1285,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
1285 rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX, 1285 rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
1286 context, len); 1286 context, len);
1287 if (rc == -ERANGE) { 1287 if (rc == -ERANGE) {
1288 kfree(context);
1289
1288 /* Need a larger buffer. Query for the right size. */ 1290 /* Need a larger buffer. Query for the right size. */
1289 rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX, 1291 rc = inode->i_op->getxattr(dentry, XATTR_NAME_SELINUX,
1290 NULL, 0); 1292 NULL, 0);
@@ -1292,7 +1294,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent
1292 dput(dentry); 1294 dput(dentry);
1293 goto out_unlock; 1295 goto out_unlock;
1294 } 1296 }
1295 kfree(context);
1296 len = rc; 1297 len = rc;
1297 context = kmalloc(len+1, GFP_NOFS); 1298 context = kmalloc(len+1, GFP_NOFS);
1298 if (!context) { 1299 if (!context) {
@@ -3029,9 +3030,21 @@ static int selinux_file_mmap(struct file *file, unsigned long reqprot,
3029 int rc = 0; 3030 int rc = 0;
3030 u32 sid = current_sid(); 3031 u32 sid = current_sid();
3031 3032
3032 if (addr < mmap_min_addr) 3033 /*
3034 * notice that we are intentionally putting the SELinux check before
3035 * the secondary cap_file_mmap check. This is such a likely attempt
3036 * at bad behaviour/exploit that we always want to get the AVC, even
3037 * if DAC would have also denied the operation.
3038 */
3039 if (addr < CONFIG_LSM_MMAP_MIN_ADDR) {
3033 rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT, 3040 rc = avc_has_perm(sid, sid, SECCLASS_MEMPROTECT,
3034 MEMPROTECT__MMAP_ZERO, NULL); 3041 MEMPROTECT__MMAP_ZERO, NULL);
3042 if (rc)
3043 return rc;
3044 }
3045
3046 /* do DAC check on address space usage */
3047 rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
3035 if (rc || addr_only) 3048 if (rc || addr_only)
3036 return rc; 3049 return rc;
3037 3050
diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c
index 72cfd47af6b8..9db60d831bb2 100644
--- a/sound/core/pcm_lib.c
+++ b/sound/core/pcm_lib.c
@@ -943,47 +943,24 @@ static int snd_interval_ratden(struct snd_interval *i,
943int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask) 943int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask)
944{ 944{
945 unsigned int k; 945 unsigned int k;
946 int changed = 0; 946 struct snd_interval list_range;
947 947
948 if (!count) { 948 if (!count) {
949 i->empty = 1; 949 i->empty = 1;
950 return -EINVAL; 950 return -EINVAL;
951 } 951 }
952 snd_interval_any(&list_range);
953 list_range.min = UINT_MAX;
954 list_range.max = 0;
952 for (k = 0; k < count; k++) { 955 for (k = 0; k < count; k++) {
953 if (mask && !(mask & (1 << k))) 956 if (mask && !(mask & (1 << k)))
954 continue; 957 continue;
955 if (i->min == list[k] && !i->openmin) 958 if (!snd_interval_test(i, list[k]))
956 goto _l1;
957 if (i->min < list[k]) {
958 i->min = list[k];
959 i->openmin = 0;
960 changed = 1;
961 goto _l1;
962 }
963 }
964 i->empty = 1;
965 return -EINVAL;
966 _l1:
967 for (k = count; k-- > 0;) {
968 if (mask && !(mask & (1 << k)))
969 continue; 959 continue;
970 if (i->max == list[k] && !i->openmax) 960 list_range.min = min(list_range.min, list[k]);
971 goto _l2; 961 list_range.max = max(list_range.max, list[k]);
972 if (i->max > list[k]) {
973 i->max = list[k];
974 i->openmax = 0;
975 changed = 1;
976 goto _l2;
977 }
978 } 962 }
979 i->empty = 1; 963 return snd_interval_refine(i, &list_range);
980 return -EINVAL;
981 _l2:
982 if (snd_interval_checkempty(i)) {
983 i->empty = 1;
984 return -EINVAL;
985 }
986 return changed;
987} 964}
988 965
989EXPORT_SYMBOL(snd_interval_list); 966EXPORT_SYMBOL(snd_interval_list);
diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c
index c551006e2920..76d76c08339b 100644
--- a/sound/pci/ali5451/ali5451.c
+++ b/sound/pci/ali5451/ali5451.c
@@ -310,12 +310,16 @@ static int snd_ali_codec_ready(struct snd_ali *codec,
310 unsigned int res; 310 unsigned int res;
311 311
312 end_time = jiffies + msecs_to_jiffies(250); 312 end_time = jiffies + msecs_to_jiffies(250);
313 do { 313
314 for (;;) {
314 res = snd_ali_5451_peek(codec,port); 315 res = snd_ali_5451_peek(codec,port);
315 if (!(res & 0x8000)) 316 if (!(res & 0x8000))
316 return 0; 317 return 0;
318 if (!time_after_eq(end_time, jiffies))
319 break;
317 schedule_timeout_uninterruptible(1); 320 schedule_timeout_uninterruptible(1);
318 } while (time_after_eq(end_time, jiffies)); 321 }
322
319 snd_ali_5451_poke(codec, port, res & ~0x8000); 323 snd_ali_5451_poke(codec, port, res & ~0x8000);
320 snd_printdd("ali_codec_ready: codec is not ready.\n "); 324 snd_printdd("ali_codec_ready: codec is not ready.\n ");
321 return -EIO; 325 return -EIO;
@@ -327,15 +331,17 @@ static int snd_ali_stimer_ready(struct snd_ali *codec)
327 unsigned long dwChk1,dwChk2; 331 unsigned long dwChk1,dwChk2;
328 332
329 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER); 333 dwChk1 = snd_ali_5451_peek(codec, ALI_STIMER);
330 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
331
332 end_time = jiffies + msecs_to_jiffies(250); 334 end_time = jiffies + msecs_to_jiffies(250);
333 do { 335
336 for (;;) {
334 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER); 337 dwChk2 = snd_ali_5451_peek(codec, ALI_STIMER);
335 if (dwChk2 != dwChk1) 338 if (dwChk2 != dwChk1)
336 return 0; 339 return 0;
340 if (!time_after_eq(end_time, jiffies))
341 break;
337 schedule_timeout_uninterruptible(1); 342 schedule_timeout_uninterruptible(1);
338 } while (time_after_eq(end_time, jiffies)); 343 }
344
339 snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n"); 345 snd_printk(KERN_ERR "ali_stimer_read: stimer is not ready.\n");
340 return -EIO; 346 return -EIO;
341} 347}
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 88480c0c58a0..c7df01b72cac 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -174,7 +174,7 @@ static int codec_exec_verb(struct hda_codec *codec, unsigned int cmd,
174 mutex_lock(&bus->cmd_mutex); 174 mutex_lock(&bus->cmd_mutex);
175 err = bus->ops.command(bus, cmd); 175 err = bus->ops.command(bus, cmd);
176 if (!err && res) 176 if (!err && res)
177 *res = bus->ops.get_response(bus); 177 *res = bus->ops.get_response(bus, codec->addr);
178 mutex_unlock(&bus->cmd_mutex); 178 mutex_unlock(&bus->cmd_mutex);
179 snd_hda_power_down(codec); 179 snd_hda_power_down(codec);
180 if (res && *res == -1 && bus->rirb_error) { 180 if (res && *res == -1 && bus->rirb_error) {
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index cad79efaabc9..1b75f28ed092 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -568,7 +568,7 @@ struct hda_bus_ops {
568 /* send a single command */ 568 /* send a single command */
569 int (*command)(struct hda_bus *bus, unsigned int cmd); 569 int (*command)(struct hda_bus *bus, unsigned int cmd);
570 /* get a response from the last command */ 570 /* get a response from the last command */
571 unsigned int (*get_response)(struct hda_bus *bus); 571 unsigned int (*get_response)(struct hda_bus *bus, unsigned int addr);
572 /* free the private data */ 572 /* free the private data */
573 void (*private_free)(struct hda_bus *); 573 void (*private_free)(struct hda_bus *);
574 /* attach a PCM stream */ 574 /* attach a PCM stream */
diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index 77c1b840ca8b..175f07a381ba 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -253,7 +253,7 @@ enum { SDI0, SDI1, SDI2, SDI3, SDO0, SDO1, SDO2, SDO3 };
253 253
254/* STATESTS int mask: S3,SD2,SD1,SD0 */ 254/* STATESTS int mask: S3,SD2,SD1,SD0 */
255#define AZX_MAX_CODECS 4 255#define AZX_MAX_CODECS 4
256#define STATESTS_INT_MASK 0x0f 256#define STATESTS_INT_MASK ((1 << AZX_MAX_CODECS) - 1)
257 257
258/* SD_CTL bits */ 258/* SD_CTL bits */
259#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */ 259#define SD_CTL_STREAM_RESET 0x01 /* stream reset bit */
@@ -361,8 +361,8 @@ struct azx_rb {
361 dma_addr_t addr; /* physical address of CORB/RIRB buffer */ 361 dma_addr_t addr; /* physical address of CORB/RIRB buffer */
362 /* for RIRB */ 362 /* for RIRB */
363 unsigned short rp, wp; /* read/write pointers */ 363 unsigned short rp, wp; /* read/write pointers */
364 int cmds; /* number of pending requests */ 364 int cmds[AZX_MAX_CODECS]; /* number of pending requests */
365 u32 res; /* last read value */ 365 u32 res[AZX_MAX_CODECS]; /* last read value */
366}; 366};
367 367
368struct azx { 368struct azx {
@@ -418,7 +418,7 @@ struct azx {
418 unsigned int probing :1; /* codec probing phase */ 418 unsigned int probing :1; /* codec probing phase */
419 419
420 /* for debugging */ 420 /* for debugging */
421 unsigned int last_cmd; /* last issued command (to sync) */ 421 unsigned int last_cmd[AZX_MAX_CODECS];
422 422
423 /* for pending irqs */ 423 /* for pending irqs */
424 struct work_struct irq_pending_work; 424 struct work_struct irq_pending_work;
@@ -513,6 +513,7 @@ static int azx_alloc_cmd_io(struct azx *chip)
513 513
514static void azx_init_cmd_io(struct azx *chip) 514static void azx_init_cmd_io(struct azx *chip)
515{ 515{
516 spin_lock_irq(&chip->reg_lock);
516 /* CORB set up */ 517 /* CORB set up */
517 chip->corb.addr = chip->rb.addr; 518 chip->corb.addr = chip->rb.addr;
518 chip->corb.buf = (u32 *)chip->rb.area; 519 chip->corb.buf = (u32 *)chip->rb.area;
@@ -531,7 +532,8 @@ static void azx_init_cmd_io(struct azx *chip)
531 /* RIRB set up */ 532 /* RIRB set up */
532 chip->rirb.addr = chip->rb.addr + 2048; 533 chip->rirb.addr = chip->rb.addr + 2048;
533 chip->rirb.buf = (u32 *)(chip->rb.area + 2048); 534 chip->rirb.buf = (u32 *)(chip->rb.area + 2048);
534 chip->rirb.wp = chip->rirb.rp = chip->rirb.cmds = 0; 535 chip->rirb.wp = chip->rirb.rp = 0;
536 memset(chip->rirb.cmds, 0, sizeof(chip->rirb.cmds));
535 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr); 537 azx_writel(chip, RIRBLBASE, (u32)chip->rirb.addr);
536 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr)); 538 azx_writel(chip, RIRBUBASE, upper_32_bits(chip->rirb.addr));
537 539
@@ -543,30 +545,60 @@ static void azx_init_cmd_io(struct azx *chip)
543 azx_writew(chip, RINTCNT, 1); 545 azx_writew(chip, RINTCNT, 1);
544 /* enable rirb dma and response irq */ 546 /* enable rirb dma and response irq */
545 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN); 547 azx_writeb(chip, RIRBCTL, ICH6_RBCTL_DMA_EN | ICH6_RBCTL_IRQ_EN);
548 spin_unlock_irq(&chip->reg_lock);
546} 549}
547 550
548static void azx_free_cmd_io(struct azx *chip) 551static void azx_free_cmd_io(struct azx *chip)
549{ 552{
553 spin_lock_irq(&chip->reg_lock);
550 /* disable ringbuffer DMAs */ 554 /* disable ringbuffer DMAs */
551 azx_writeb(chip, RIRBCTL, 0); 555 azx_writeb(chip, RIRBCTL, 0);
552 azx_writeb(chip, CORBCTL, 0); 556 azx_writeb(chip, CORBCTL, 0);
557 spin_unlock_irq(&chip->reg_lock);
558}
559
560static unsigned int azx_command_addr(u32 cmd)
561{
562 unsigned int addr = cmd >> 28;
563
564 if (addr >= AZX_MAX_CODECS) {
565 snd_BUG();
566 addr = 0;
567 }
568
569 return addr;
570}
571
572static unsigned int azx_response_addr(u32 res)
573{
574 unsigned int addr = res & 0xf;
575
576 if (addr >= AZX_MAX_CODECS) {
577 snd_BUG();
578 addr = 0;
579 }
580
581 return addr;
553} 582}
554 583
555/* send a command */ 584/* send a command */
556static int azx_corb_send_cmd(struct hda_bus *bus, u32 val) 585static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
557{ 586{
558 struct azx *chip = bus->private_data; 587 struct azx *chip = bus->private_data;
588 unsigned int addr = azx_command_addr(val);
559 unsigned int wp; 589 unsigned int wp;
560 590
591 spin_lock_irq(&chip->reg_lock);
592
561 /* add command to corb */ 593 /* add command to corb */
562 wp = azx_readb(chip, CORBWP); 594 wp = azx_readb(chip, CORBWP);
563 wp++; 595 wp++;
564 wp %= ICH6_MAX_CORB_ENTRIES; 596 wp %= ICH6_MAX_CORB_ENTRIES;
565 597
566 spin_lock_irq(&chip->reg_lock); 598 chip->rirb.cmds[addr]++;
567 chip->rirb.cmds++;
568 chip->corb.buf[wp] = cpu_to_le32(val); 599 chip->corb.buf[wp] = cpu_to_le32(val);
569 azx_writel(chip, CORBWP, wp); 600 azx_writel(chip, CORBWP, wp);
601
570 spin_unlock_irq(&chip->reg_lock); 602 spin_unlock_irq(&chip->reg_lock);
571 603
572 return 0; 604 return 0;
@@ -578,13 +610,14 @@ static int azx_corb_send_cmd(struct hda_bus *bus, u32 val)
578static void azx_update_rirb(struct azx *chip) 610static void azx_update_rirb(struct azx *chip)
579{ 611{
580 unsigned int rp, wp; 612 unsigned int rp, wp;
613 unsigned int addr;
581 u32 res, res_ex; 614 u32 res, res_ex;
582 615
583 wp = azx_readb(chip, RIRBWP); 616 wp = azx_readb(chip, RIRBWP);
584 if (wp == chip->rirb.wp) 617 if (wp == chip->rirb.wp)
585 return; 618 return;
586 chip->rirb.wp = wp; 619 chip->rirb.wp = wp;
587 620
588 while (chip->rirb.rp != wp) { 621 while (chip->rirb.rp != wp) {
589 chip->rirb.rp++; 622 chip->rirb.rp++;
590 chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES; 623 chip->rirb.rp %= ICH6_MAX_RIRB_ENTRIES;
@@ -592,18 +625,24 @@ static void azx_update_rirb(struct azx *chip)
592 rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */ 625 rp = chip->rirb.rp << 1; /* an RIRB entry is 8-bytes */
593 res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]); 626 res_ex = le32_to_cpu(chip->rirb.buf[rp + 1]);
594 res = le32_to_cpu(chip->rirb.buf[rp]); 627 res = le32_to_cpu(chip->rirb.buf[rp]);
628 addr = azx_response_addr(res_ex);
595 if (res_ex & ICH6_RIRB_EX_UNSOL_EV) 629 if (res_ex & ICH6_RIRB_EX_UNSOL_EV)
596 snd_hda_queue_unsol_event(chip->bus, res, res_ex); 630 snd_hda_queue_unsol_event(chip->bus, res, res_ex);
597 else if (chip->rirb.cmds) { 631 else if (chip->rirb.cmds[addr]) {
598 chip->rirb.res = res; 632 chip->rirb.res[addr] = res;
599 smp_wmb(); 633 smp_wmb();
600 chip->rirb.cmds--; 634 chip->rirb.cmds[addr]--;
601 } 635 } else
636 snd_printk(KERN_ERR SFX "spurious response %#x:%#x, "
637 "last cmd=%#08x\n",
638 res, res_ex,
639 chip->last_cmd[addr]);
602 } 640 }
603} 641}
604 642
605/* receive a response */ 643/* receive a response */
606static unsigned int azx_rirb_get_response(struct hda_bus *bus) 644static unsigned int azx_rirb_get_response(struct hda_bus *bus,
645 unsigned int addr)
607{ 646{
608 struct azx *chip = bus->private_data; 647 struct azx *chip = bus->private_data;
609 unsigned long timeout; 648 unsigned long timeout;
@@ -616,10 +655,10 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
616 azx_update_rirb(chip); 655 azx_update_rirb(chip);
617 spin_unlock_irq(&chip->reg_lock); 656 spin_unlock_irq(&chip->reg_lock);
618 } 657 }
619 if (!chip->rirb.cmds) { 658 if (!chip->rirb.cmds[addr]) {
620 smp_rmb(); 659 smp_rmb();
621 bus->rirb_error = 0; 660 bus->rirb_error = 0;
622 return chip->rirb.res; /* the last value */ 661 return chip->rirb.res[addr]; /* the last value */
623 } 662 }
624 if (time_after(jiffies, timeout)) 663 if (time_after(jiffies, timeout))
625 break; 664 break;
@@ -633,7 +672,8 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
633 672
634 if (chip->msi) { 673 if (chip->msi) {
635 snd_printk(KERN_WARNING SFX "No response from codec, " 674 snd_printk(KERN_WARNING SFX "No response from codec, "
636 "disabling MSI: last cmd=0x%08x\n", chip->last_cmd); 675 "disabling MSI: last cmd=0x%08x\n",
676 chip->last_cmd[addr]);
637 free_irq(chip->irq, chip); 677 free_irq(chip->irq, chip);
638 chip->irq = -1; 678 chip->irq = -1;
639 pci_disable_msi(chip->pci); 679 pci_disable_msi(chip->pci);
@@ -648,7 +688,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
648 if (!chip->polling_mode) { 688 if (!chip->polling_mode) {
649 snd_printk(KERN_WARNING SFX "azx_get_response timeout, " 689 snd_printk(KERN_WARNING SFX "azx_get_response timeout, "
650 "switching to polling mode: last cmd=0x%08x\n", 690 "switching to polling mode: last cmd=0x%08x\n",
651 chip->last_cmd); 691 chip->last_cmd[addr]);
652 chip->polling_mode = 1; 692 chip->polling_mode = 1;
653 goto again; 693 goto again;
654 } 694 }
@@ -672,7 +712,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
672 712
673 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, " 713 snd_printk(KERN_ERR "hda_intel: azx_get_response timeout, "
674 "switching to single_cmd mode: last cmd=0x%08x\n", 714 "switching to single_cmd mode: last cmd=0x%08x\n",
675 chip->last_cmd); 715 chip->last_cmd[addr]);
676 chip->single_cmd = 1; 716 chip->single_cmd = 1;
677 bus->response_reset = 0; 717 bus->response_reset = 0;
678 /* re-initialize CORB/RIRB */ 718 /* re-initialize CORB/RIRB */
@@ -692,7 +732,7 @@ static unsigned int azx_rirb_get_response(struct hda_bus *bus)
692 */ 732 */
693 733
694/* receive a response */ 734/* receive a response */
695static int azx_single_wait_for_response(struct azx *chip) 735static int azx_single_wait_for_response(struct azx *chip, unsigned int addr)
696{ 736{
697 int timeout = 50; 737 int timeout = 50;
698 738
@@ -700,7 +740,7 @@ static int azx_single_wait_for_response(struct azx *chip)
700 /* check IRV busy bit */ 740 /* check IRV busy bit */
701 if (azx_readw(chip, IRS) & ICH6_IRS_VALID) { 741 if (azx_readw(chip, IRS) & ICH6_IRS_VALID) {
702 /* reuse rirb.res as the response return value */ 742 /* reuse rirb.res as the response return value */
703 chip->rirb.res = azx_readl(chip, IR); 743 chip->rirb.res[addr] = azx_readl(chip, IR);
704 return 0; 744 return 0;
705 } 745 }
706 udelay(1); 746 udelay(1);
@@ -708,7 +748,7 @@ static int azx_single_wait_for_response(struct azx *chip)
708 if (printk_ratelimit()) 748 if (printk_ratelimit())
709 snd_printd(SFX "get_response timeout: IRS=0x%x\n", 749 snd_printd(SFX "get_response timeout: IRS=0x%x\n",
710 azx_readw(chip, IRS)); 750 azx_readw(chip, IRS));
711 chip->rirb.res = -1; 751 chip->rirb.res[addr] = -1;
712 return -EIO; 752 return -EIO;
713} 753}
714 754
@@ -716,6 +756,7 @@ static int azx_single_wait_for_response(struct azx *chip)
716static int azx_single_send_cmd(struct hda_bus *bus, u32 val) 756static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
717{ 757{
718 struct azx *chip = bus->private_data; 758 struct azx *chip = bus->private_data;
759 unsigned int addr = azx_command_addr(val);
719 int timeout = 50; 760 int timeout = 50;
720 761
721 bus->rirb_error = 0; 762 bus->rirb_error = 0;
@@ -728,7 +769,7 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
728 azx_writel(chip, IC, val); 769 azx_writel(chip, IC, val);
729 azx_writew(chip, IRS, azx_readw(chip, IRS) | 770 azx_writew(chip, IRS, azx_readw(chip, IRS) |
730 ICH6_IRS_BUSY); 771 ICH6_IRS_BUSY);
731 return azx_single_wait_for_response(chip); 772 return azx_single_wait_for_response(chip, addr);
732 } 773 }
733 udelay(1); 774 udelay(1);
734 } 775 }
@@ -739,10 +780,11 @@ static int azx_single_send_cmd(struct hda_bus *bus, u32 val)
739} 780}
740 781
741/* receive a response */ 782/* receive a response */
742static unsigned int azx_single_get_response(struct hda_bus *bus) 783static unsigned int azx_single_get_response(struct hda_bus *bus,
784 unsigned int addr)
743{ 785{
744 struct azx *chip = bus->private_data; 786 struct azx *chip = bus->private_data;
745 return chip->rirb.res; 787 return chip->rirb.res[addr];
746} 788}
747 789
748/* 790/*
@@ -757,7 +799,7 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
757{ 799{
758 struct azx *chip = bus->private_data; 800 struct azx *chip = bus->private_data;
759 801
760 chip->last_cmd = val; 802 chip->last_cmd[azx_command_addr(val)] = val;
761 if (chip->single_cmd) 803 if (chip->single_cmd)
762 return azx_single_send_cmd(bus, val); 804 return azx_single_send_cmd(bus, val);
763 else 805 else
@@ -765,13 +807,14 @@ static int azx_send_cmd(struct hda_bus *bus, unsigned int val)
765} 807}
766 808
767/* get a response */ 809/* get a response */
768static unsigned int azx_get_response(struct hda_bus *bus) 810static unsigned int azx_get_response(struct hda_bus *bus,
811 unsigned int addr)
769{ 812{
770 struct azx *chip = bus->private_data; 813 struct azx *chip = bus->private_data;
771 if (chip->single_cmd) 814 if (chip->single_cmd)
772 return azx_single_get_response(bus); 815 return azx_single_get_response(bus, addr);
773 else 816 else
774 return azx_rirb_get_response(bus); 817 return azx_rirb_get_response(bus, addr);
775} 818}
776 819
777#ifdef CONFIG_SND_HDA_POWER_SAVE 820#ifdef CONFIG_SND_HDA_POWER_SAVE
@@ -1243,10 +1286,12 @@ static int probe_codec(struct azx *chip, int addr)
1243 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; 1286 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
1244 unsigned int res; 1287 unsigned int res;
1245 1288
1289 mutex_lock(&chip->bus->cmd_mutex);
1246 chip->probing = 1; 1290 chip->probing = 1;
1247 azx_send_cmd(chip->bus, cmd); 1291 azx_send_cmd(chip->bus, cmd);
1248 res = azx_get_response(chip->bus); 1292 res = azx_get_response(chip->bus, addr);
1249 chip->probing = 0; 1293 chip->probing = 0;
1294 mutex_unlock(&chip->bus->cmd_mutex);
1250 if (res == -1) 1295 if (res == -1)
1251 return -EIO; 1296 return -EIO;
1252 snd_printdd(SFX "codec #%d probed OK\n", addr); 1297 snd_printdd(SFX "codec #%d probed OK\n", addr);
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c
index 3da85caf8af1..403588c6e3f6 100644
--- a/sound/pci/hda/patch_analog.c
+++ b/sound/pci/hda/patch_analog.c
@@ -3835,9 +3835,11 @@ static struct hda_verb ad1884a_laptop_verbs[] = {
3835 /* Port-F (int speaker) mixer - route only from analog mixer */ 3835 /* Port-F (int speaker) mixer - route only from analog mixer */
3836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 3836 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
3837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)}, 3837 {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
3838 /* Port-F pin */ 3838 /* Port-F (int speaker) pin */
3839 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, 3839 {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 3840 {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
3841 /* required for compaq 6530s/6531s speaker output */
3842 {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
3841 /* Port-C pin - internal mic-in */ 3843 /* Port-C pin - internal mic-in */
3842 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 3844 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
3843 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */ 3845 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7002}, /* raise mic as default */
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index b95df5d5dcc2..30eeb304351c 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -559,7 +559,7 @@ static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
559 559
560 /* Find enumerated value for current pinctl setting */ 560 /* Find enumerated value for current pinctl setting */
561 i = alc_pin_mode_min(dir); 561 i = alc_pin_mode_min(dir);
562 while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir)) 562 while (i <= alc_pin_mode_max(dir) && alc_pin_mode_values[i] != pinctl)
563 i++; 563 i++;
564 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir); 564 *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
565 return 0; 565 return 0;
@@ -6423,9 +6423,9 @@ static struct hda_verb alc885_mbp_ch2_init[] = {
6423}; 6423};
6424 6424
6425/* 6425/*
6426 * 6ch mode 6426 * 4ch mode
6427 */ 6427 */
6428static struct hda_verb alc885_mbp_ch6_init[] = { 6428static struct hda_verb alc885_mbp_ch4_init[] = {
6429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, 6429 { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
6430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6430 { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6431 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 }, 6431 { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
@@ -6434,9 +6434,9 @@ static struct hda_verb alc885_mbp_ch6_init[] = {
6434 { } /* end */ 6434 { } /* end */
6435}; 6435};
6436 6436
6437static struct hda_channel_mode alc885_mbp_6ch_modes[2] = { 6437static struct hda_channel_mode alc885_mbp_4ch_modes[2] = {
6438 { 2, alc885_mbp_ch2_init }, 6438 { 2, alc885_mbp_ch2_init },
6439 { 6, alc885_mbp_ch6_init }, 6439 { 4, alc885_mbp_ch4_init },
6440}; 6440};
6441 6441
6442/* 6442/*
@@ -6497,10 +6497,11 @@ static struct snd_kcontrol_new alc882_base_mixer[] = {
6497}; 6497};
6498 6498
6499static struct snd_kcontrol_new alc885_mbp3_mixer[] = { 6499static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
6500 HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x00, HDA_OUTPUT), 6500 HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
6501 HDA_BIND_MUTE ("Front Playback Switch", 0x0c, 0x02, HDA_INPUT), 6501 HDA_BIND_MUTE ("Speaker Playback Switch", 0x0c, 0x02, HDA_INPUT),
6502 HDA_CODEC_MUTE ("Speaker Playback Switch", 0x14, 0x00, HDA_OUTPUT), 6502 HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0e, 0x00, HDA_OUTPUT),
6503 HDA_CODEC_VOLUME("Line-Out Playback Volume", 0x0d, 0x00, HDA_OUTPUT), 6503 HDA_BIND_MUTE ("Headphone Playback Switch", 0x0e, 0x02, HDA_INPUT),
6504 HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x00, HDA_OUTPUT),
6504 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT), 6505 HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
6505 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT), 6506 HDA_CODEC_MUTE ("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
6506 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT), 6507 HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
@@ -6814,14 +6815,18 @@ static struct hda_verb alc885_mbp3_init_verbs[] = {
6814 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO}, 6815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6815 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, 6816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6816 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, 6817 {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6818 /* HP mixer */
6819 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
6820 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
6821 {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
6817 /* Front Pin: output 0 (0x0c) */ 6822 /* Front Pin: output 0 (0x0c) */
6818 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT}, 6823 {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
6819 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, 6824 {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6820 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, 6825 {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
6821 /* HP Pin: output 0 (0x0d) */ 6826 /* HP Pin: output 0 (0x0e) */
6822 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4}, 6827 {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
6823 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, 6828 {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
6824 {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, 6829 {0x15, AC_VERB_SET_CONNECT_SEL, 0x02},
6825 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN}, 6830 {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
6826 /* Mic (rear) pin: input vref at 80% */ 6831 /* Mic (rear) pin: input vref at 80% */
6827 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80}, 6832 {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
@@ -7195,10 +7200,11 @@ static struct alc_config_preset alc882_presets[] = {
7195 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer }, 7200 .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
7196 .init_verbs = { alc885_mbp3_init_verbs, 7201 .init_verbs = { alc885_mbp3_init_verbs,
7197 alc880_gpio1_init_verbs }, 7202 alc880_gpio1_init_verbs },
7198 .num_dacs = ARRAY_SIZE(alc882_dac_nids), 7203 .num_dacs = 2,
7199 .dac_nids = alc882_dac_nids, 7204 .dac_nids = alc882_dac_nids,
7200 .channel_mode = alc885_mbp_6ch_modes, 7205 .hp_nid = 0x04,
7201 .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes), 7206 .channel_mode = alc885_mbp_4ch_modes,
7207 .num_channel_mode = ARRAY_SIZE(alc885_mbp_4ch_modes),
7202 .input_mux = &alc882_capture_source, 7208 .input_mux = &alc882_capture_source,
7203 .dig_out_nid = ALC882_DIGOUT_NID, 7209 .dig_out_nid = ALC882_DIGOUT_NID,
7204 .dig_in_nid = ALC882_DIGIN_NID, 7210 .dig_in_nid = ALC882_DIGIN_NID,
@@ -12521,8 +12527,6 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12521 ALC268_TOSHIBA), 12527 ALC268_TOSHIBA),
12522 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST), 12528 SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
12523 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO), 12529 SND_PCI_QUIRK(0x1170, 0x0040, "ZEPTO", ALC268_ZEPTO),
12524 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12525 ALC268_TOSHIBA),
12526 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA), 12530 SND_PCI_QUIRK(0x14c0, 0x0025, "COMPAL IFL90/JFL-92", ALC268_TOSHIBA),
12527 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER), 12531 SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
12528 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1), 12532 SND_PCI_QUIRK(0x152d, 0x0771, "Quanta IL1", ALC267_QUANTA_IL1),
@@ -12530,6 +12534,15 @@ static struct snd_pci_quirk alc268_cfg_tbl[] = {
12530 {} 12534 {}
12531}; 12535};
12532 12536
12537/* Toshiba laptops have no unique PCI SSID but only codec SSID */
12538static struct snd_pci_quirk alc268_ssid_cfg_tbl[] = {
12539 SND_PCI_QUIRK(0x1179, 0xff0a, "TOSHIBA X-200", ALC268_AUTO),
12540 SND_PCI_QUIRK(0x1179, 0xff0e, "TOSHIBA X-200 HDMI", ALC268_AUTO),
12541 SND_PCI_QUIRK_MASK(0x1179, 0xff00, 0xff00, "TOSHIBA A/Lx05",
12542 ALC268_TOSHIBA),
12543 {}
12544};
12545
12533static struct alc_config_preset alc268_presets[] = { 12546static struct alc_config_preset alc268_presets[] = {
12534 [ALC267_QUANTA_IL1] = { 12547 [ALC267_QUANTA_IL1] = {
12535 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer }, 12548 .mixers = { alc267_quanta_il1_mixer, alc268_beep_mixer },
@@ -12696,6 +12709,10 @@ static int patch_alc268(struct hda_codec *codec)
12696 alc268_models, 12709 alc268_models,
12697 alc268_cfg_tbl); 12710 alc268_cfg_tbl);
12698 12711
12712 if (board_config < 0 || board_config >= ALC268_MODEL_LAST)
12713 board_config = snd_hda_check_board_codec_sid_config(codec,
12714 ALC882_MODEL_LAST, alc268_models, alc268_ssid_cfg_tbl);
12715
12699 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) { 12716 if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
12700 printk(KERN_INFO "hda_codec: Unknown model for %s, " 12717 printk(KERN_INFO "hda_codec: Unknown model for %s, "
12701 "trying auto-probe from BIOS...\n", codec->chip_name); 12718 "trying auto-probe from BIOS...\n", codec->chip_name);
@@ -13563,6 +13580,8 @@ static int patch_alc269(struct hda_codec *codec)
13563 set_capture_mixer(spec); 13580 set_capture_mixer(spec);
13564 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT); 13581 set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
13565 13582
13583 spec->vmaster_nid = 0x02;
13584
13566 codec->patch_ops = alc_patch_ops; 13585 codec->patch_ops = alc_patch_ops;
13567 if (board_config == ALC269_AUTO) 13586 if (board_config == ALC269_AUTO)
13568 spec->init_hook = alc269_auto_init; 13587 spec->init_hook = alc269_auto_init;
@@ -15157,7 +15176,7 @@ static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
15157 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST), 15176 SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
15158 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO), 15177 SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
15159 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/ 15178 /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
15160 SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS), 15179 SND_PCI_QUIRK(0x1179, 0xff01, "Toshiba A135", ALC861VD_LENOVO),
15161 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO), 15180 SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
15162 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS), 15181 SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_DALLAS),
15163 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG), 15182 SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
@@ -15577,9 +15596,12 @@ static int patch_alc861vd(struct hda_codec *codec)
15577 spec->stream_digital_playback = &alc861vd_pcm_digital_playback; 15596 spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
15578 spec->stream_digital_capture = &alc861vd_pcm_digital_capture; 15597 spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
15579 15598
15580 spec->adc_nids = alc861vd_adc_nids; 15599 if (!spec->adc_nids) {
15581 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids); 15600 spec->adc_nids = alc861vd_adc_nids;
15582 spec->capsrc_nids = alc861vd_capsrc_nids; 15601 spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
15602 }
15603 if (!spec->capsrc_nids)
15604 spec->capsrc_nids = alc861vd_capsrc_nids;
15583 15605
15584 set_capture_mixer(spec); 15606 set_capture_mixer(spec);
15585 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT); 15607 set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
@@ -17496,9 +17518,12 @@ static int patch_alc662(struct hda_codec *codec)
17496 spec->stream_digital_playback = &alc662_pcm_digital_playback; 17518 spec->stream_digital_playback = &alc662_pcm_digital_playback;
17497 spec->stream_digital_capture = &alc662_pcm_digital_capture; 17519 spec->stream_digital_capture = &alc662_pcm_digital_capture;
17498 17520
17499 spec->adc_nids = alc662_adc_nids; 17521 if (!spec->adc_nids) {
17500 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids); 17522 spec->adc_nids = alc662_adc_nids;
17501 spec->capsrc_nids = alc662_capsrc_nids; 17523 spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
17524 }
17525 if (!spec->capsrc_nids)
17526 spec->capsrc_nids = alc662_capsrc_nids;
17502 17527
17503 if (!spec->cap_mixer) 17528 if (!spec->cap_mixer)
17504 set_capture_mixer(spec); 17529 set_capture_mixer(spec);
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c
index 5383d8cff88b..6990cfcb6a38 100644
--- a/sound/pci/hda/patch_sigmatel.c
+++ b/sound/pci/hda/patch_sigmatel.c
@@ -76,6 +76,7 @@ enum {
76 STAC_92HD73XX_AUTO, 76 STAC_92HD73XX_AUTO,
77 STAC_92HD73XX_NO_JD, /* no jack-detection */ 77 STAC_92HD73XX_NO_JD, /* no jack-detection */
78 STAC_92HD73XX_REF, 78 STAC_92HD73XX_REF,
79 STAC_92HD73XX_INTEL,
79 STAC_DELL_M6_AMIC, 80 STAC_DELL_M6_AMIC,
80 STAC_DELL_M6_DMIC, 81 STAC_DELL_M6_DMIC,
81 STAC_DELL_M6_BOTH, 82 STAC_DELL_M6_BOTH,
@@ -1777,6 +1778,7 @@ static const char *stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
1777 [STAC_92HD73XX_AUTO] = "auto", 1778 [STAC_92HD73XX_AUTO] = "auto",
1778 [STAC_92HD73XX_NO_JD] = "no-jd", 1779 [STAC_92HD73XX_NO_JD] = "no-jd",
1779 [STAC_92HD73XX_REF] = "ref", 1780 [STAC_92HD73XX_REF] = "ref",
1781 [STAC_92HD73XX_INTEL] = "intel",
1780 [STAC_DELL_M6_AMIC] = "dell-m6-amic", 1782 [STAC_DELL_M6_AMIC] = "dell-m6-amic",
1781 [STAC_DELL_M6_DMIC] = "dell-m6-dmic", 1783 [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
1782 [STAC_DELL_M6_BOTH] = "dell-m6", 1784 [STAC_DELL_M6_BOTH] = "dell-m6",
@@ -1789,6 +1791,10 @@ static struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
1789 "DFI LanParty", STAC_92HD73XX_REF), 1791 "DFI LanParty", STAC_92HD73XX_REF),
1790 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, 1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
1791 "DFI LanParty", STAC_92HD73XX_REF), 1793 "DFI LanParty", STAC_92HD73XX_REF),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
1795 "Intel DG45ID", STAC_92HD73XX_INTEL),
1796 SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
1797 "Intel DG45FC", STAC_92HD73XX_INTEL),
1792 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254, 1798 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
1793 "Dell Studio 1535", STAC_DELL_M6_DMIC), 1799 "Dell Studio 1535", STAC_DELL_M6_DMIC),
1794 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255, 1800 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
@@ -2266,7 +2272,7 @@ static struct snd_pci_quirk stac927x_cfg_tbl[] = {
2266 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS), 2272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
2267 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS), 2273 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
2268 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS), 2274 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
2269 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_3ST), 2275 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
2270 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS), 2276 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
2271 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS), 2277 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
2272 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS), 2278 SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
@@ -5645,6 +5651,13 @@ static int patch_stac927x(struct hda_codec *codec)
5645 /* GPIO2 High = Enable EAPD */ 5651 /* GPIO2 High = Enable EAPD */
5646 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04; 5652 spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x04;
5647 spec->gpio_data = 0x04; 5653 spec->gpio_data = 0x04;
5654 switch (codec->subsystem_id) {
5655 case 0x1028022f:
5656 /* correct EAPD to be GPIO0 */
5657 spec->eapd_mask = spec->gpio_mask = 0x01;
5658 spec->gpio_dir = spec->gpio_data = 0x01;
5659 break;
5660 };
5648 spec->dmic_nids = stac927x_dmic_nids; 5661 spec->dmic_nids = stac927x_dmic_nids;
5649 spec->num_dmics = STAC927X_NUM_DMICS; 5662 spec->num_dmics = STAC927X_NUM_DMICS;
5650 5663
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c
index 9008b4b013aa..e8f10b10cceb 100644
--- a/sound/pci/hda/patch_via.c
+++ b/sound/pci/hda/patch_via.c
@@ -1395,6 +1395,7 @@ static int patch_vt1708(struct hda_codec *codec)
1395 if (!spec->adc_nids && spec->input_mux) { 1395 if (!spec->adc_nids && spec->input_mux) {
1396 spec->adc_nids = vt1708_adc_nids; 1396 spec->adc_nids = vt1708_adc_nids;
1397 spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids); 1397 spec->num_adc_nids = ARRAY_SIZE(vt1708_adc_nids);
1398 get_mux_nids(codec);
1398 spec->mixers[spec->num_mixers] = vt1708_capture_mixer; 1399 spec->mixers[spec->num_mixers] = vt1708_capture_mixer;
1399 spec->num_mixers++; 1400 spec->num_mixers++;
1400 } 1401 }
diff --git a/sound/pci/vx222/vx222_ops.c b/sound/pci/vx222/vx222_ops.c
index 6416d3f0c7be..a69e774d0b13 100644
--- a/sound/pci/vx222/vx222_ops.c
+++ b/sound/pci/vx222/vx222_ops.c
@@ -885,10 +885,10 @@ static int vx_input_level_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem
885 struct vx_core *_chip = snd_kcontrol_chip(kcontrol); 885 struct vx_core *_chip = snd_kcontrol_chip(kcontrol);
886 struct snd_vx222 *chip = (struct snd_vx222 *)_chip; 886 struct snd_vx222 *chip = (struct snd_vx222 *)_chip;
887 if (ucontrol->value.integer.value[0] < 0 || 887 if (ucontrol->value.integer.value[0] < 0 ||
888 ucontrol->value.integer.value[0] < MIC_LEVEL_MAX) 888 ucontrol->value.integer.value[0] > MIC_LEVEL_MAX)
889 return -EINVAL; 889 return -EINVAL;
890 if (ucontrol->value.integer.value[1] < 0 || 890 if (ucontrol->value.integer.value[1] < 0 ||
891 ucontrol->value.integer.value[1] < MIC_LEVEL_MAX) 891 ucontrol->value.integer.value[1] > MIC_LEVEL_MAX)
892 return -EINVAL; 892 return -EINVAL;
893 mutex_lock(&_chip->mixer_mutex); 893 mutex_lock(&_chip->mixer_mutex);
894 if (chip->input_level[0] != ucontrol->value.integer.value[0] || 894 if (chip->input_level[0] != ucontrol->value.integer.value[0] ||
diff --git a/sound/soc/fsl/efika-audio-fabric.c b/sound/soc/fsl/efika-audio-fabric.c
index 85b0e7569504..3326e2a1e863 100644
--- a/sound/soc/fsl/efika-audio-fabric.c
+++ b/sound/soc/fsl/efika-audio-fabric.c
@@ -30,6 +30,8 @@
30#include "mpc5200_psc_ac97.h" 30#include "mpc5200_psc_ac97.h"
31#include "../codecs/stac9766.h" 31#include "../codecs/stac9766.h"
32 32
33#define DRV_NAME "efika-audio-fabric"
34
33static struct snd_soc_device device; 35static struct snd_soc_device device;
34static struct snd_soc_card card; 36static struct snd_soc_card card;
35 37
diff --git a/sound/soc/fsl/pcm030-audio-fabric.c b/sound/soc/fsl/pcm030-audio-fabric.c
index 8766f7a3893d..b928ef7d28eb 100644
--- a/sound/soc/fsl/pcm030-audio-fabric.c
+++ b/sound/soc/fsl/pcm030-audio-fabric.c
@@ -30,6 +30,8 @@
30#include "mpc5200_psc_ac97.h" 30#include "mpc5200_psc_ac97.h"
31#include "../codecs/wm9712.h" 31#include "../codecs/wm9712.h"
32 32
33#define DRV_NAME "pcm030-audio-fabric"
34
33static struct snd_soc_device device; 35static struct snd_soc_device device;
34static struct snd_soc_card card; 36static struct snd_soc_card card;
35 37
diff --git a/tools/perf/Documentation/Makefile b/tools/perf/Documentation/Makefile
index 5457192e1b41..bdd3b7ecad0a 100644
--- a/tools/perf/Documentation/Makefile
+++ b/tools/perf/Documentation/Makefile
@@ -35,7 +35,7 @@ man7dir=$(mandir)/man7
35# DESTDIR= 35# DESTDIR=
36 36
37ASCIIDOC=asciidoc 37ASCIIDOC=asciidoc
38ASCIIDOC_EXTRA = 38ASCIIDOC_EXTRA = --unsafe
39MANPAGE_XSL = manpage-normal.xsl 39MANPAGE_XSL = manpage-normal.xsl
40XMLTO_EXTRA = 40XMLTO_EXTRA =
41INSTALL?=install 41INSTALL?=install
diff --git a/tools/perf/Documentation/examples.txt b/tools/perf/Documentation/examples.txt
new file mode 100644
index 000000000000..8eb6c489fb15
--- /dev/null
+++ b/tools/perf/Documentation/examples.txt
@@ -0,0 +1,225 @@
1
2 ------------------------------
3 ****** perf by examples ******
4 ------------------------------
5
6[ From an e-mail by Ingo Molnar, http://lkml.org/lkml/2009/8/4/346 ]
7
8
9First, discovery/enumeration of available counters can be done via
10'perf list':
11
12titan:~> perf list
13 [...]
14 kmem:kmalloc [Tracepoint event]
15 kmem:kmem_cache_alloc [Tracepoint event]
16 kmem:kmalloc_node [Tracepoint event]
17 kmem:kmem_cache_alloc_node [Tracepoint event]
18 kmem:kfree [Tracepoint event]
19 kmem:kmem_cache_free [Tracepoint event]
20 kmem:mm_page_free_direct [Tracepoint event]
21 kmem:mm_pagevec_free [Tracepoint event]
22 kmem:mm_page_alloc [Tracepoint event]
23 kmem:mm_page_alloc_zone_locked [Tracepoint event]
24 kmem:mm_page_pcpu_drain [Tracepoint event]
25 kmem:mm_page_alloc_extfrag [Tracepoint event]
26
27Then any (or all) of the above event sources can be activated and
28measured. For example the page alloc/free properties of a 'hackbench
29run' are:
30
31 titan:~> perf stat -e kmem:mm_page_pcpu_drain -e kmem:mm_page_alloc
32 -e kmem:mm_pagevec_free -e kmem:mm_page_free_direct ./hackbench 10
33 Time: 0.575
34
35 Performance counter stats for './hackbench 10':
36
37 13857 kmem:mm_page_pcpu_drain
38 27576 kmem:mm_page_alloc
39 6025 kmem:mm_pagevec_free
40 20934 kmem:mm_page_free_direct
41
42 0.613972165 seconds time elapsed
43
44You can observe the statistical properties as well, by using the
45'repeat the workload N times' feature of perf stat:
46
47 titan:~> perf stat --repeat 5 -e kmem:mm_page_pcpu_drain -e
48 kmem:mm_page_alloc -e kmem:mm_pagevec_free -e
49 kmem:mm_page_free_direct ./hackbench 10
50 Time: 0.627
51 Time: 0.644
52 Time: 0.564
53 Time: 0.559
54 Time: 0.626
55
56 Performance counter stats for './hackbench 10' (5 runs):
57
58 12920 kmem:mm_page_pcpu_drain ( +- 3.359% )
59 25035 kmem:mm_page_alloc ( +- 3.783% )
60 6104 kmem:mm_pagevec_free ( +- 0.934% )
61 18376 kmem:mm_page_free_direct ( +- 4.941% )
62
63 0.643954516 seconds time elapsed ( +- 2.363% )
64
65Furthermore, these tracepoints can be used to sample the workload as
66well. For example the page allocations done by a 'git gc' can be
67captured the following way:
68
69 titan:~/git> perf record -f -e kmem:mm_page_alloc -c 1 ./git gc
70 Counting objects: 1148, done.
71 Delta compression using up to 2 threads.
72 Compressing objects: 100% (450/450), done.
73 Writing objects: 100% (1148/1148), done.
74 Total 1148 (delta 690), reused 1148 (delta 690)
75 [ perf record: Captured and wrote 0.267 MB perf.data (~11679 samples) ]
76
77To check which functions generated page allocations:
78
79 titan:~/git> perf report
80 # Samples: 10646
81 #
82 # Overhead Command Shared Object
83 # ........ ............... ..........................
84 #
85 23.57% git-repack /lib64/libc-2.5.so
86 21.81% git /lib64/libc-2.5.so
87 14.59% git ./git
88 11.79% git-repack ./git
89 7.12% git /lib64/ld-2.5.so
90 3.16% git-repack /lib64/libpthread-2.5.so
91 2.09% git-repack /bin/bash
92 1.97% rm /lib64/libc-2.5.so
93 1.39% mv /lib64/ld-2.5.so
94 1.37% mv /lib64/libc-2.5.so
95 1.12% git-repack /lib64/ld-2.5.so
96 0.95% rm /lib64/ld-2.5.so
97 0.90% git-update-serv /lib64/libc-2.5.so
98 0.73% git-update-serv /lib64/ld-2.5.so
99 0.68% perf /lib64/libpthread-2.5.so
100 0.64% git-repack /usr/lib64/libz.so.1.2.3
101
102Or to see it on a more finegrained level:
103
104titan:~/git> perf report --sort comm,dso,symbol
105# Samples: 10646
106#
107# Overhead Command Shared Object Symbol
108# ........ ............... .......................... ......
109#
110 9.35% git-repack ./git [.] insert_obj_hash
111 9.12% git ./git [.] insert_obj_hash
112 7.31% git /lib64/libc-2.5.so [.] memcpy
113 6.34% git-repack /lib64/libc-2.5.so [.] _int_malloc
114 6.24% git-repack /lib64/libc-2.5.so [.] memcpy
115 5.82% git-repack /lib64/libc-2.5.so [.] __GI___fork
116 5.47% git /lib64/libc-2.5.so [.] _int_malloc
117 2.99% git /lib64/libc-2.5.so [.] memset
118
119Furthermore, call-graph sampling can be done too, of page
120allocations - to see precisely what kind of page allocations there
121are:
122
123 titan:~/git> perf record -f -g -e kmem:mm_page_alloc -c 1 ./git gc
124 Counting objects: 1148, done.
125 Delta compression using up to 2 threads.
126 Compressing objects: 100% (450/450), done.
127 Writing objects: 100% (1148/1148), done.
128 Total 1148 (delta 690), reused 1148 (delta 690)
129 [ perf record: Captured and wrote 0.963 MB perf.data (~42069 samples) ]
130
131 titan:~/git> perf report -g
132 # Samples: 10686
133 #
134 # Overhead Command Shared Object
135 # ........ ............... ..........................
136 #
137 23.25% git-repack /lib64/libc-2.5.so
138 |
139 |--50.00%-- _int_free
140 |
141 |--37.50%-- __GI___fork
142 | make_child
143 |
144 |--12.50%-- ptmalloc_unlock_all2
145 | make_child
146 |
147 --6.25%-- __GI_strcpy
148 21.61% git /lib64/libc-2.5.so
149 |
150 |--30.00%-- __GI_read
151 | |
152 | --83.33%-- git_config_from_file
153 | git_config
154 | |
155 [...]
156
157Or you can observe the whole system's page allocations for 10
158seconds:
159
160titan:~/git> perf stat -a -e kmem:mm_page_pcpu_drain -e
161kmem:mm_page_alloc -e kmem:mm_pagevec_free -e
162kmem:mm_page_free_direct sleep 10
163
164 Performance counter stats for 'sleep 10':
165
166 171585 kmem:mm_page_pcpu_drain
167 322114 kmem:mm_page_alloc
168 73623 kmem:mm_pagevec_free
169 254115 kmem:mm_page_free_direct
170
171 10.000591410 seconds time elapsed
172
173Or observe how fluctuating the page allocations are, via statistical
174analysis done over ten 1-second intervals:
175
176 titan:~/git> perf stat --repeat 10 -a -e kmem:mm_page_pcpu_drain -e
177 kmem:mm_page_alloc -e kmem:mm_pagevec_free -e
178 kmem:mm_page_free_direct sleep 1
179
180 Performance counter stats for 'sleep 1' (10 runs):
181
182 17254 kmem:mm_page_pcpu_drain ( +- 3.709% )
183 34394 kmem:mm_page_alloc ( +- 4.617% )
184 7509 kmem:mm_pagevec_free ( +- 4.820% )
185 25653 kmem:mm_page_free_direct ( +- 3.672% )
186
187 1.058135029 seconds time elapsed ( +- 3.089% )
188
189Or you can annotate the recorded 'git gc' run on a per symbol basis
190and check which instructions/source-code generated page allocations:
191
192 titan:~/git> perf annotate __GI___fork
193 ------------------------------------------------
194 Percent | Source code & Disassembly of libc-2.5.so
195 ------------------------------------------------
196 :
197 :
198 : Disassembly of section .plt:
199 : Disassembly of section .text:
200 :
201 : 00000031a2e95560 <__fork>:
202 [...]
203 0.00 : 31a2e95602: b8 38 00 00 00 mov $0x38,%eax
204 0.00 : 31a2e95607: 0f 05 syscall
205 83.42 : 31a2e95609: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax
206 0.00 : 31a2e9560f: 0f 87 4d 01 00 00 ja 31a2e95762 <__fork+0x202>
207 0.00 : 31a2e95615: 85 c0 test %eax,%eax
208
209( this shows that 83.42% of __GI___fork's page allocations come from
210 the 0x38 system call it performs. )
211
212etc. etc. - a lot more is possible. I could list a dozen of
213other different usecases straight away - neither of which is
214possible via /proc/vmstat.
215
216/proc/vmstat is not in the same league really, in terms of
217expressive power of system analysis and performance
218analysis.
219
220All that the above results needed were those new tracepoints
221in include/tracing/events/kmem.h.
222
223 Ingo
224
225
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 1dbc1eeb4c01..6be696b0a2bb 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -29,13 +29,67 @@ OPTIONS
29 Select the PMU event. Selection can be a symbolic event name 29 Select the PMU event. Selection can be a symbolic event name
30 (use 'perf list' to list all events) or a raw PMU 30 (use 'perf list' to list all events) or a raw PMU
31 event (eventsel+umask) in the form of rNNN where NNN is a 31 event (eventsel+umask) in the form of rNNN where NNN is a
32 hexadecimal event descriptor. 32 hexadecimal event descriptor.
33 33
34-a:: 34-a::
35 system-wide collection 35 System-wide collection.
36 36
37-l:: 37-l::
38 scale counter values 38 Scale counter values.
39
40-p::
41--pid=::
42 Record events on existing pid.
43
44-r::
45--realtime=::
46 Collect data with this RT SCHED_FIFO priority.
47-A::
48--append::
49 Append to the output file to do incremental profiling.
50
51-f::
52--force::
53 Overwrite existing data file.
54
55-c::
56--count=::
57 Event period to sample.
58
59-o::
60--output=::
61 Output file name.
62
63-i::
64--inherit::
65 Child tasks inherit counters.
66-F::
67--freq=::
68 Profile at this frequency.
69
70-m::
71--mmap-pages=::
72 Number of mmap data pages.
73
74-g::
75--call-graph::
76 Do call-graph (stack chain/backtrace) recording.
77
78-v::
79--verbose::
80 Be more verbose (show counter open errors, etc).
81
82-s::
83--stat::
84 Per thread counts.
85
86-d::
87--data::
88 Sample addresses.
89
90-n::
91--no-samples::
92 Don't sample.
39 93
40SEE ALSO 94SEE ALSO
41-------- 95--------
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 0d74346d21ab..484080dd5b6f 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -40,7 +40,7 @@ OPTIONS
40-a:: 40-a::
41 system-wide collection 41 system-wide collection
42 42
43-S:: 43-c::
44 scale counter values 44 scale counter values
45 45
46EXAMPLES 46EXAMPLES
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 539d01289725..4a7d558dc309 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -3,36 +3,122 @@ perf-top(1)
3 3
4NAME 4NAME
5---- 5----
6perf-top - Run a command and profile it 6perf-top - System profiling tool.
7 7
8SYNOPSIS 8SYNOPSIS
9-------- 9--------
10[verse] 10[verse]
11'perf top' [-e <EVENT> | --event=EVENT] [-l] [-a] <command> 11'perf top' [-e <EVENT> | --event=EVENT] [<options>]
12 12
13DESCRIPTION 13DESCRIPTION
14----------- 14-----------
15This command runs a command and gathers a performance counter profile 15This command generates and displays a performance counter profile in realtime.
16from it.
17 16
18 17
19OPTIONS 18OPTIONS
20------- 19-------
21<command>...:: 20-a::
22 Any command you can specify in a shell. 21--all-cpus::
22 System-wide collection. (default)
23
24-c <count>::
25--count=<count>::
26 Event period to sample.
27
28-C <cpu>::
29--CPU=<cpu>::
30 CPU to profile.
31
32-d <seconds>::
33--delay=<seconds>::
34 Number of seconds to delay between refreshes.
23 35
24-e:: 36-e <event>::
25--event=:: 37--event=<event>::
26 Select the PMU event. Selection can be a symbolic event name 38 Select the PMU event. Selection can be a symbolic event name
27 (use 'perf list' to list all events) or a raw PMU 39 (use 'perf list' to list all events) or a raw PMU
28 event (eventsel+umask) in the form of rNNN where NNN is a 40 event (eventsel+umask) in the form of rNNN where NNN is a
29 hexadecimal event descriptor. 41 hexadecimal event descriptor.
30 42
31-a:: 43-E <entries>::
32 system-wide collection 44--entries=<entries>::
45 Display this many functions.
46
47-f <count>::
48--count-filter=<count>::
49 Only display functions with more events than this.
50
51-F <freq>::
52--freq=<freq>::
53 Profile at this frequency.
54
55-i::
56--inherit::
57 Child tasks inherit counters, only makes sens with -p option.
58
59-k <path>::
60--vmlinux=<path>::
61 Path to vmlinux. Required for annotation functionality.
62
63-m <pages>::
64--mmap-pages=<pages>::
65 Number of mmapped data pages.
66
67-p <pid>::
68--pid=<pid>::
69 Profile events on existing pid.
70
71-r <priority>::
72--realtime=<priority>::
73 Collect data with this RT SCHED_FIFO priority.
74
75-s <symbol>::
76--sym-annotate=<symbol>::
77 Annotate this symbol. Requires -k option.
78
79-v::
80--verbose::
81 Be more verbose (show counter open errors, etc).
82
83-z::
84--zero::
85 Zero history across display updates.
86
87INTERACTIVE PROMPTING KEYS
88--------------------------
89
90[d]::
91 Display refresh delay.
92
93[e]::
94 Number of entries to display.
95
96[E]::
97 Event to display when multiple counters are active.
98
99[f]::
100 Profile display filter (>= hit count).
101
102[F]::
103 Annotation display filter (>= % of total).
104
105[s]::
106 Annotate symbol.
107
108[S]::
109 Stop annotation, return to full profile display.
110
111[w]::
112 Toggle between weighted sum and individual count[E]r profile.
113
114[z]::
115 Toggle event count zeroing across display updates.
116
117[qQ]::
118 Quit.
119
120Pressing any unmapped key displays a menu, and prompts for input.
33 121
34-l::
35 scale counter values
36 122
37SEE ALSO 123SEE ALSO
38-------- 124--------
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index a5e9b876ca09..c045b4271e57 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -158,8 +158,10 @@ uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
158uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not') 158uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')
159 159
160# If we're on a 64-bit kernel, use -m64 160# If we're on a 64-bit kernel, use -m64
161ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M)) 161ifndef NO_64BIT
162 M64 := -m64 162 ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
163 M64 := -m64
164 endif
163endif 165endif
164 166
165# CFLAGS and LDFLAGS are for the users to override from the command line. 167# CFLAGS and LDFLAGS are for the users to override from the command line.
@@ -345,7 +347,6 @@ BUILTIN_OBJS += builtin-stat.o
345BUILTIN_OBJS += builtin-top.o 347BUILTIN_OBJS += builtin-top.o
346 348
347PERFLIBS = $(LIB_FILE) 349PERFLIBS = $(LIB_FILE)
348EXTLIBS = -lbfd
349 350
350# 351#
351# Platform specific tweaks 352# Platform specific tweaks
@@ -374,6 +375,39 @@ ifeq ($(uname_S),Darwin)
374 PTHREAD_LIBS = 375 PTHREAD_LIBS =
375endif 376endif
376 377
378ifneq ($(shell sh -c "(echo '\#include <libelf.h>'; echo 'int main(void) { Elf * elf = elf_begin(0, ELF_C_READ_MMAP, 0); return (long)elf; }') | $(CC) -x c - $(ALL_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -o /dev/null $(ALL_LDFLAGS) > /dev/null 2>&1 && echo y"), y)
379 msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel);
380endif
381
382ifdef NO_DEMANGLE
383 BASIC_CFLAGS += -DNO_DEMANGLE
384else
385 has_bfd := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) -lbfd > /dev/null 2>&1 && echo y")
386
387 ifeq ($(has_bfd),y)
388 EXTLIBS += -lbfd
389 else
390 has_bfd_iberty := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) -lbfd -liberty > /dev/null 2>&1 && echo y")
391 ifeq ($(has_bfd_iberty),y)
392 EXTLIBS += -lbfd -liberty
393 else
394 has_bfd_iberty_z := $(shell sh -c "(echo '\#include <bfd.h>'; echo 'int main(void) { bfd_demangle(0, 0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) -lbfd -liberty -lz > /dev/null 2>&1 && echo y")
395 ifeq ($(has_bfd_iberty_z),y)
396 EXTLIBS += -lbfd -liberty -lz
397 else
398 has_cplus_demangle := $(shell sh -c "(echo 'extern char *cplus_demangle(const char *, int);'; echo 'int main(void) { cplus_demangle(0, 0); return 0; }') | $(CC) -x c - $(ALL_CFLAGS) -o /dev/null $(ALL_LDFLAGS) -liberty > /dev/null 2>&1 && echo y")
399 ifeq ($(has_cplus_demangle),y)
400 EXTLIBS += -liberty
401 BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
402 else
403 msg := $(warning No bfd.h/libbfd found, install binutils-dev[el] to gain symbol demangling)
404 BASIC_CFLAGS += -DNO_DEMANGLE
405 endif
406 endif
407 endif
408 endif
409endif
410
377ifndef CC_LD_DYNPATH 411ifndef CC_LD_DYNPATH
378 ifdef NO_R_TO_GCC_LINKER 412 ifdef NO_R_TO_GCC_LINKER
379 # Some gcc does not accept and pass -R to the linker to specify 413 # Some gcc does not accept and pass -R to the linker to specify
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 1dba568e1941..5e17de984dc8 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -31,6 +31,7 @@ static char *vmlinux = "vmlinux";
31static char default_sort_order[] = "comm,symbol"; 31static char default_sort_order[] = "comm,symbol";
32static char *sort_order = default_sort_order; 32static char *sort_order = default_sort_order;
33 33
34static int force;
34static int input; 35static int input;
35static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; 36static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
36 37
@@ -980,6 +981,13 @@ process_fork_event(event_t *event, unsigned long offset, unsigned long head)
980 (void *)(long)(event->header.size), 981 (void *)(long)(event->header.size),
981 event->fork.pid, event->fork.ppid); 982 event->fork.pid, event->fork.ppid);
982 983
984 /*
985 * A thread clone will have the same PID for both
986 * parent and child.
987 */
988 if (thread == parent)
989 return 0;
990
983 if (!thread || !parent || thread__fork(thread, parent)) { 991 if (!thread || !parent || thread__fork(thread, parent)) {
984 dprintf("problem processing PERF_EVENT_FORK, skipping event.\n"); 992 dprintf("problem processing PERF_EVENT_FORK, skipping event.\n");
985 return -1; 993 return -1;
@@ -1327,6 +1335,11 @@ static int __cmd_annotate(void)
1327 exit(-1); 1335 exit(-1);
1328 } 1336 }
1329 1337
1338 if (!force && (stat.st_uid != geteuid())) {
1339 fprintf(stderr, "file: %s not owned by current user\n", input_name);
1340 exit(-1);
1341 }
1342
1330 if (!stat.st_size) { 1343 if (!stat.st_size) {
1331 fprintf(stderr, "zero-sized file, nothing to do!\n"); 1344 fprintf(stderr, "zero-sized file, nothing to do!\n");
1332 exit(0); 1345 exit(0);
@@ -1432,6 +1445,7 @@ static const struct option options[] = {
1432 "input file name"), 1445 "input file name"),
1433 OPT_STRING('s', "symbol", &sym_hist_filter, "symbol", 1446 OPT_STRING('s', "symbol", &sym_hist_filter, "symbol",
1434 "symbol to annotate"), 1447 "symbol to annotate"),
1448 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
1435 OPT_BOOLEAN('v', "verbose", &verbose, 1449 OPT_BOOLEAN('v', "verbose", &verbose,
1436 "be more verbose (show symbol address, etc)"), 1450 "be more verbose (show symbol address, etc)"),
1437 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 1451 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index f990fa8a35c9..d88c6961274c 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -10,11 +10,12 @@
10 10
11#include "perf.h" 11#include "perf.h"
12 12
13#include "util/parse-options.h"
14#include "util/parse-events.h" 13#include "util/parse-events.h"
14#include "util/cache.h"
15 15
16int cmd_list(int argc __used, const char **argv __used, const char *prefix __used) 16int cmd_list(int argc __used, const char **argv __used, const char *prefix __used)
17{ 17{
18 setup_pager();
18 print_events(); 19 print_events();
19 return 0; 20 return 0;
20} 21}
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6da09928130f..89a5ddcd1ded 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -34,7 +34,9 @@ static int output;
34static const char *output_name = "perf.data"; 34static const char *output_name = "perf.data";
35static int group = 0; 35static int group = 0;
36static unsigned int realtime_prio = 0; 36static unsigned int realtime_prio = 0;
37static int raw_samples = 0;
37static int system_wide = 0; 38static int system_wide = 0;
39static int profile_cpu = -1;
38static pid_t target_pid = -1; 40static pid_t target_pid = -1;
39static int inherit = 1; 41static int inherit = 1;
40static int force = 0; 42static int force = 0;
@@ -203,46 +205,48 @@ static void sig_atexit(void)
203 kill(getpid(), signr); 205 kill(getpid(), signr);
204} 206}
205 207
206static void pid_synthesize_comm_event(pid_t pid, int full) 208static pid_t pid_synthesize_comm_event(pid_t pid, int full)
207{ 209{
208 struct comm_event comm_ev; 210 struct comm_event comm_ev;
209 char filename[PATH_MAX]; 211 char filename[PATH_MAX];
210 char bf[BUFSIZ]; 212 char bf[BUFSIZ];
211 int fd; 213 FILE *fp;
212 size_t size; 214 size_t size = 0;
213 char *field, *sep;
214 DIR *tasks; 215 DIR *tasks;
215 struct dirent dirent, *next; 216 struct dirent dirent, *next;
217 pid_t tgid = 0;
216 218
217 snprintf(filename, sizeof(filename), "/proc/%d/stat", pid); 219 snprintf(filename, sizeof(filename), "/proc/%d/status", pid);
218 220
219 fd = open(filename, O_RDONLY); 221 fp = fopen(filename, "r");
220 if (fd < 0) { 222 if (fp == NULL) {
221 /* 223 /*
222 * We raced with a task exiting - just return: 224 * We raced with a task exiting - just return:
223 */ 225 */
224 if (verbose) 226 if (verbose)
225 fprintf(stderr, "couldn't open %s\n", filename); 227 fprintf(stderr, "couldn't open %s\n", filename);
226 return; 228 return 0;
227 }
228 if (read(fd, bf, sizeof(bf)) < 0) {
229 fprintf(stderr, "couldn't read %s\n", filename);
230 exit(EXIT_FAILURE);
231 } 229 }
232 close(fd);
233 230
234 /* 9027 (cat) R 6747 9027 6747 34816 9027 ... */
235 memset(&comm_ev, 0, sizeof(comm_ev)); 231 memset(&comm_ev, 0, sizeof(comm_ev));
236 field = strchr(bf, '('); 232 while (!comm_ev.comm[0] || !comm_ev.pid) {
237 if (field == NULL) 233 if (fgets(bf, sizeof(bf), fp) == NULL)
238 goto out_failure; 234 goto out_failure;
239 sep = strchr(++field, ')'); 235
240 if (sep == NULL) 236 if (memcmp(bf, "Name:", 5) == 0) {
241 goto out_failure; 237 char *name = bf + 5;
242 size = sep - field; 238 while (*name && isspace(*name))
243 memcpy(comm_ev.comm, field, size++); 239 ++name;
244 240 size = strlen(name) - 1;
245 comm_ev.pid = pid; 241 memcpy(comm_ev.comm, name, size++);
242 } else if (memcmp(bf, "Tgid:", 5) == 0) {
243 char *tgids = bf + 5;
244 while (*tgids && isspace(*tgids))
245 ++tgids;
246 tgid = comm_ev.pid = atoi(tgids);
247 }
248 }
249
246 comm_ev.header.type = PERF_EVENT_COMM; 250 comm_ev.header.type = PERF_EVENT_COMM;
247 size = ALIGN(size, sizeof(u64)); 251 size = ALIGN(size, sizeof(u64));
248 comm_ev.header.size = sizeof(comm_ev) - (sizeof(comm_ev.comm) - size); 252 comm_ev.header.size = sizeof(comm_ev) - (sizeof(comm_ev.comm) - size);
@@ -251,7 +255,7 @@ static void pid_synthesize_comm_event(pid_t pid, int full)
251 comm_ev.tid = pid; 255 comm_ev.tid = pid;
252 256
253 write_output(&comm_ev, comm_ev.header.size); 257 write_output(&comm_ev, comm_ev.header.size);
254 return; 258 goto out_fclose;
255 } 259 }
256 260
257 snprintf(filename, sizeof(filename), "/proc/%d/task", pid); 261 snprintf(filename, sizeof(filename), "/proc/%d/task", pid);
@@ -268,7 +272,10 @@ static void pid_synthesize_comm_event(pid_t pid, int full)
268 write_output(&comm_ev, comm_ev.header.size); 272 write_output(&comm_ev, comm_ev.header.size);
269 } 273 }
270 closedir(tasks); 274 closedir(tasks);
271 return; 275
276out_fclose:
277 fclose(fp);
278 return tgid;
272 279
273out_failure: 280out_failure:
274 fprintf(stderr, "couldn't get COMM and pgid, malformed %s\n", 281 fprintf(stderr, "couldn't get COMM and pgid, malformed %s\n",
@@ -276,7 +283,7 @@ out_failure:
276 exit(EXIT_FAILURE); 283 exit(EXIT_FAILURE);
277} 284}
278 285
279static void pid_synthesize_mmap_samples(pid_t pid) 286static void pid_synthesize_mmap_samples(pid_t pid, pid_t tgid)
280{ 287{
281 char filename[PATH_MAX]; 288 char filename[PATH_MAX];
282 FILE *fp; 289 FILE *fp;
@@ -328,7 +335,7 @@ static void pid_synthesize_mmap_samples(pid_t pid)
328 mmap_ev.len -= mmap_ev.start; 335 mmap_ev.len -= mmap_ev.start;
329 mmap_ev.header.size = (sizeof(mmap_ev) - 336 mmap_ev.header.size = (sizeof(mmap_ev) -
330 (sizeof(mmap_ev.filename) - size)); 337 (sizeof(mmap_ev.filename) - size));
331 mmap_ev.pid = pid; 338 mmap_ev.pid = tgid;
332 mmap_ev.tid = pid; 339 mmap_ev.tid = pid;
333 340
334 write_output(&mmap_ev, mmap_ev.header.size); 341 write_output(&mmap_ev, mmap_ev.header.size);
@@ -347,14 +354,14 @@ static void synthesize_all(void)
347 354
348 while (!readdir_r(proc, &dirent, &next) && next) { 355 while (!readdir_r(proc, &dirent, &next) && next) {
349 char *end; 356 char *end;
350 pid_t pid; 357 pid_t pid, tgid;
351 358
352 pid = strtol(dirent.d_name, &end, 10); 359 pid = strtol(dirent.d_name, &end, 10);
353 if (*end) /* only interested in proper numerical dirents */ 360 if (*end) /* only interested in proper numerical dirents */
354 continue; 361 continue;
355 362
356 pid_synthesize_comm_event(pid, 1); 363 tgid = pid_synthesize_comm_event(pid, 1);
357 pid_synthesize_mmap_samples(pid); 364 pid_synthesize_mmap_samples(pid, tgid);
358 } 365 }
359 366
360 closedir(proc); 367 closedir(proc);
@@ -392,7 +399,7 @@ static void create_counter(int counter, int cpu, pid_t pid)
392 PERF_FORMAT_TOTAL_TIME_RUNNING | 399 PERF_FORMAT_TOTAL_TIME_RUNNING |
393 PERF_FORMAT_ID; 400 PERF_FORMAT_ID;
394 401
395 attr->sample_type = PERF_SAMPLE_IP | PERF_SAMPLE_TID; 402 attr->sample_type |= PERF_SAMPLE_IP | PERF_SAMPLE_TID;
396 403
397 if (freq) { 404 if (freq) {
398 attr->sample_type |= PERF_SAMPLE_PERIOD; 405 attr->sample_type |= PERF_SAMPLE_PERIOD;
@@ -412,6 +419,9 @@ static void create_counter(int counter, int cpu, pid_t pid)
412 if (call_graph) 419 if (call_graph)
413 attr->sample_type |= PERF_SAMPLE_CALLCHAIN; 420 attr->sample_type |= PERF_SAMPLE_CALLCHAIN;
414 421
422 if (raw_samples)
423 attr->sample_type |= PERF_SAMPLE_RAW;
424
415 attr->mmap = track; 425 attr->mmap = track;
416 attr->comm = track; 426 attr->comm = track;
417 attr->inherit = (cpu < 0) && inherit; 427 attr->inherit = (cpu < 0) && inherit;
@@ -425,6 +435,8 @@ try_again:
425 435
426 if (err == EPERM) 436 if (err == EPERM)
427 die("Permission error - are you root?\n"); 437 die("Permission error - are you root?\n");
438 else if (err == ENODEV && profile_cpu != -1)
439 die("No such device - did you specify an out-of-range profile CPU?\n");
428 440
429 /* 441 /*
430 * If it's cycles then fall back to hrtimer 442 * If it's cycles then fall back to hrtimer
@@ -524,10 +536,14 @@ static int __cmd_record(int argc, const char **argv)
524 signal(SIGCHLD, sig_handler); 536 signal(SIGCHLD, sig_handler);
525 signal(SIGINT, sig_handler); 537 signal(SIGINT, sig_handler);
526 538
527 if (!stat(output_name, &st) && !force && !append_file) { 539 if (!stat(output_name, &st) && st.st_size) {
528 fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n", 540 if (!force && !append_file) {
529 output_name); 541 fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
530 exit(-1); 542 output_name);
543 exit(-1);
544 }
545 } else {
546 append_file = 0;
531 } 547 }
532 548
533 flags = O_CREAT|O_RDWR; 549 flags = O_CREAT|O_RDWR;
@@ -554,16 +570,22 @@ static int __cmd_record(int argc, const char **argv)
554 if (pid == -1) 570 if (pid == -1)
555 pid = getpid(); 571 pid = getpid();
556 572
557 open_counters(-1, pid); 573 open_counters(profile_cpu, pid);
558 } else for (i = 0; i < nr_cpus; i++) 574 } else {
559 open_counters(i, target_pid); 575 if (profile_cpu != -1) {
576 open_counters(profile_cpu, target_pid);
577 } else {
578 for (i = 0; i < nr_cpus; i++)
579 open_counters(i, target_pid);
580 }
581 }
560 582
561 if (file_new) 583 if (file_new)
562 perf_header__write(header, output); 584 perf_header__write(header, output);
563 585
564 if (!system_wide) { 586 if (!system_wide) {
565 pid_synthesize_comm_event(pid, 0); 587 pid_t tgid = pid_synthesize_comm_event(pid, 0);
566 pid_synthesize_mmap_samples(pid); 588 pid_synthesize_mmap_samples(pid, tgid);
567 } else 589 } else
568 synthesize_all(); 590 synthesize_all();
569 591
@@ -631,10 +653,14 @@ static const struct option options[] = {
631 "record events on existing pid"), 653 "record events on existing pid"),
632 OPT_INTEGER('r', "realtime", &realtime_prio, 654 OPT_INTEGER('r', "realtime", &realtime_prio,
633 "collect data with this RT SCHED_FIFO priority"), 655 "collect data with this RT SCHED_FIFO priority"),
656 OPT_BOOLEAN('R', "raw-samples", &raw_samples,
657 "collect raw sample records from all opened counters"),
634 OPT_BOOLEAN('a', "all-cpus", &system_wide, 658 OPT_BOOLEAN('a', "all-cpus", &system_wide,
635 "system-wide collection from all CPUs"), 659 "system-wide collection from all CPUs"),
636 OPT_BOOLEAN('A', "append", &append_file, 660 OPT_BOOLEAN('A', "append", &append_file,
637 "append to the output file to do incremental profiling"), 661 "append to the output file to do incremental profiling"),
662 OPT_INTEGER('C', "profile_cpu", &profile_cpu,
663 "CPU to profile on"),
638 OPT_BOOLEAN('f', "force", &force, 664 OPT_BOOLEAN('f', "force", &force,
639 "overwrite existing data file"), 665 "overwrite existing data file"),
640 OPT_LONG('c', "count", &default_interval, 666 OPT_LONG('c', "count", &default_interval,
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index b20a4b6e31b7..8b2ec882e6e0 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -31,13 +31,14 @@
31static char const *input_name = "perf.data"; 31static char const *input_name = "perf.data";
32static char *vmlinux = NULL; 32static char *vmlinux = NULL;
33 33
34static char default_sort_order[] = "comm,dso"; 34static char default_sort_order[] = "comm,dso,symbol";
35static char *sort_order = default_sort_order; 35static char *sort_order = default_sort_order;
36static char *dso_list_str, *comm_list_str, *sym_list_str, 36static char *dso_list_str, *comm_list_str, *sym_list_str,
37 *col_width_list_str; 37 *col_width_list_str;
38static struct strlist *dso_list, *comm_list, *sym_list; 38static struct strlist *dso_list, *comm_list, *sym_list;
39static char *field_sep; 39static char *field_sep;
40 40
41static int force;
41static int input; 42static int input;
42static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV; 43static int show_mask = SHOW_KERNEL | SHOW_USER | SHOW_HV;
43 44
@@ -68,7 +69,7 @@ static int callchain;
68 69
69static 70static
70struct callchain_param callchain_param = { 71struct callchain_param callchain_param = {
71 .mode = CHAIN_GRAPH_ABS, 72 .mode = CHAIN_GRAPH_REL,
72 .min_percent = 0.5 73 .min_percent = 0.5
73}; 74};
74 75
@@ -99,6 +100,7 @@ struct comm_event {
99struct fork_event { 100struct fork_event {
100 struct perf_event_header header; 101 struct perf_event_header header;
101 u32 pid, ppid; 102 u32 pid, ppid;
103 u32 tid, ptid;
102}; 104};
103 105
104struct lost_event { 106struct lost_event {
@@ -111,7 +113,9 @@ struct read_event {
111 struct perf_event_header header; 113 struct perf_event_header header;
112 u32 pid,tid; 114 u32 pid,tid;
113 u64 value; 115 u64 value;
114 u64 format[3]; 116 u64 time_enabled;
117 u64 time_running;
118 u64 id;
115}; 119};
116 120
117typedef union event_union { 121typedef union event_union {
@@ -252,7 +256,7 @@ static int strcommon(const char *pathname)
252{ 256{
253 int n = 0; 257 int n = 0;
254 258
255 while (pathname[n] == cwd[n] && n < cwdlen) 259 while (n < cwdlen && pathname[n] == cwd[n])
256 ++n; 260 ++n;
257 261
258 return n; 262 return n;
@@ -697,7 +701,8 @@ sort__sym_print(FILE *fp, struct hist_entry *self, unsigned int width __used)
697 size_t ret = 0; 701 size_t ret = 0;
698 702
699 if (verbose) 703 if (verbose)
700 ret += repsep_fprintf(fp, "%#018llx ", (u64)self->ip); 704 ret += repsep_fprintf(fp, "%#018llx %c ", (u64)self->ip,
705 dso__symtab_origin(self->dso));
701 706
702 ret += repsep_fprintf(fp, "[%c] ", self->level); 707 ret += repsep_fprintf(fp, "[%c] ", self->level);
703 if (self->sym) { 708 if (self->sym) {
@@ -887,6 +892,21 @@ ipchain__fprintf_graph(FILE *fp, struct callchain_list *chain, int depth,
887 return ret; 892 return ret;
888} 893}
889 894
895static struct symbol *rem_sq_bracket;
896static struct callchain_list rem_hits;
897
898static void init_rem_hits(void)
899{
900 rem_sq_bracket = malloc(sizeof(*rem_sq_bracket) + 6);
901 if (!rem_sq_bracket) {
902 fprintf(stderr, "Not enough memory to display remaining hits\n");
903 return;
904 }
905
906 strcpy(rem_sq_bracket->name, "[...]");
907 rem_hits.sym = rem_sq_bracket;
908}
909
890static size_t 910static size_t
891callchain__fprintf_graph(FILE *fp, struct callchain_node *self, 911callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
892 u64 total_samples, int depth, int depth_mask) 912 u64 total_samples, int depth, int depth_mask)
@@ -896,25 +916,34 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
896 struct callchain_list *chain; 916 struct callchain_list *chain;
897 int new_depth_mask = depth_mask; 917 int new_depth_mask = depth_mask;
898 u64 new_total; 918 u64 new_total;
919 u64 remaining;
899 size_t ret = 0; 920 size_t ret = 0;
900 int i; 921 int i;
901 922
902 if (callchain_param.mode == CHAIN_GRAPH_REL) 923 if (callchain_param.mode == CHAIN_GRAPH_REL)
903 new_total = self->cumul_hit; 924 new_total = self->children_hit;
904 else 925 else
905 new_total = total_samples; 926 new_total = total_samples;
906 927
928 remaining = new_total;
929
907 node = rb_first(&self->rb_root); 930 node = rb_first(&self->rb_root);
908 while (node) { 931 while (node) {
932 u64 cumul;
933
909 child = rb_entry(node, struct callchain_node, rb_node); 934 child = rb_entry(node, struct callchain_node, rb_node);
935 cumul = cumul_hits(child);
936 remaining -= cumul;
910 937
911 /* 938 /*
912 * The depth mask manages the output of pipes that show 939 * The depth mask manages the output of pipes that show
913 * the depth. We don't want to keep the pipes of the current 940 * the depth. We don't want to keep the pipes of the current
914 * level for the last child of this depth 941 * level for the last child of this depth.
942 * Except if we have remaining filtered hits. They will
943 * supersede the last child
915 */ 944 */
916 next = rb_next(node); 945 next = rb_next(node);
917 if (!next) 946 if (!next && (callchain_param.mode != CHAIN_GRAPH_REL || !remaining))
918 new_depth_mask &= ~(1 << (depth - 1)); 947 new_depth_mask &= ~(1 << (depth - 1));
919 948
920 /* 949 /*
@@ -929,7 +958,7 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
929 ret += ipchain__fprintf_graph(fp, chain, depth, 958 ret += ipchain__fprintf_graph(fp, chain, depth,
930 new_depth_mask, i++, 959 new_depth_mask, i++,
931 new_total, 960 new_total,
932 child->cumul_hit); 961 cumul);
933 } 962 }
934 ret += callchain__fprintf_graph(fp, child, new_total, 963 ret += callchain__fprintf_graph(fp, child, new_total,
935 depth + 1, 964 depth + 1,
@@ -937,6 +966,19 @@ callchain__fprintf_graph(FILE *fp, struct callchain_node *self,
937 node = next; 966 node = next;
938 } 967 }
939 968
969 if (callchain_param.mode == CHAIN_GRAPH_REL &&
970 remaining && remaining != new_total) {
971
972 if (!rem_sq_bracket)
973 return ret;
974
975 new_depth_mask &= ~(1 << (depth - 1));
976
977 ret += ipchain__fprintf_graph(fp, &rem_hits, depth,
978 new_depth_mask, 0, new_total,
979 remaining);
980 }
981
940 return ret; 982 return ret;
941} 983}
942 984
@@ -1357,6 +1399,8 @@ static size_t output__fprintf(FILE *fp, u64 total_samples)
1357 unsigned int width; 1399 unsigned int width;
1358 char *col_width = col_width_list_str; 1400 char *col_width = col_width_list_str;
1359 1401
1402 init_rem_hits();
1403
1360 fprintf(fp, "# Samples: %Ld\n", (u64)total_samples); 1404 fprintf(fp, "# Samples: %Ld\n", (u64)total_samples);
1361 fprintf(fp, "#\n"); 1405 fprintf(fp, "#\n");
1362 1406
@@ -1423,11 +1467,13 @@ print_entries:
1423 if (sort_order == default_sort_order && 1467 if (sort_order == default_sort_order &&
1424 parent_pattern == default_parent_pattern) { 1468 parent_pattern == default_parent_pattern) {
1425 fprintf(fp, "#\n"); 1469 fprintf(fp, "#\n");
1426 fprintf(fp, "# (For more details, try: perf report --sort comm,dso,symbol)\n"); 1470 fprintf(fp, "# (For a higher level overview, try: perf report --sort comm,dso)\n");
1427 fprintf(fp, "#\n"); 1471 fprintf(fp, "#\n");
1428 } 1472 }
1429 fprintf(fp, "\n"); 1473 fprintf(fp, "\n");
1430 1474
1475 free(rem_sq_bracket);
1476
1431 return ret; 1477 return ret;
1432} 1478}
1433 1479
@@ -1481,11 +1527,11 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
1481 more_data += sizeof(u64); 1527 more_data += sizeof(u64);
1482 } 1528 }
1483 1529
1484 dprintf("%p [%p]: PERF_EVENT_SAMPLE (IP, %d): %d: %p period: %Ld\n", 1530 dprintf("%p [%p]: PERF_EVENT_SAMPLE (IP, %d): %d/%d: %p period: %Ld\n",
1485 (void *)(offset + head), 1531 (void *)(offset + head),
1486 (void *)(long)(event->header.size), 1532 (void *)(long)(event->header.size),
1487 event->header.misc, 1533 event->header.misc,
1488 event->ip.pid, 1534 event->ip.pid, event->ip.tid,
1489 (void *)(long)ip, 1535 (void *)(long)ip,
1490 (long long)period); 1536 (long long)period);
1491 1537
@@ -1545,10 +1591,11 @@ process_sample_event(event_t *event, unsigned long offset, unsigned long head)
1545 if (show & show_mask) { 1591 if (show & show_mask) {
1546 struct symbol *sym = resolve_symbol(thread, &map, &dso, &ip); 1592 struct symbol *sym = resolve_symbol(thread, &map, &dso, &ip);
1547 1593
1548 if (dso_list && dso && dso->name && !strlist__has_entry(dso_list, dso->name)) 1594 if (dso_list && (!dso || !dso->name ||
1595 !strlist__has_entry(dso_list, dso->name)))
1549 return 0; 1596 return 0;
1550 1597
1551 if (sym_list && sym && !strlist__has_entry(sym_list, sym->name)) 1598 if (sym_list && (!sym || !strlist__has_entry(sym_list, sym->name)))
1552 return 0; 1599 return 0;
1553 1600
1554 if (hist_entry__add(thread, map, dso, sym, ip, chain, level, period)) { 1601 if (hist_entry__add(thread, map, dso, sym, ip, chain, level, period)) {
@@ -1567,10 +1614,11 @@ process_mmap_event(event_t *event, unsigned long offset, unsigned long head)
1567 struct thread *thread = threads__findnew(event->mmap.pid); 1614 struct thread *thread = threads__findnew(event->mmap.pid);
1568 struct map *map = map__new(&event->mmap); 1615 struct map *map = map__new(&event->mmap);
1569 1616
1570 dprintf("%p [%p]: PERF_EVENT_MMAP %d: [%p(%p) @ %p]: %s\n", 1617 dprintf("%p [%p]: PERF_EVENT_MMAP %d/%d: [%p(%p) @ %p]: %s\n",
1571 (void *)(offset + head), 1618 (void *)(offset + head),
1572 (void *)(long)(event->header.size), 1619 (void *)(long)(event->header.size),
1573 event->mmap.pid, 1620 event->mmap.pid,
1621 event->mmap.tid,
1574 (void *)(long)event->mmap.start, 1622 (void *)(long)event->mmap.start,
1575 (void *)(long)event->mmap.len, 1623 (void *)(long)event->mmap.len,
1576 (void *)(long)event->mmap.pgoff, 1624 (void *)(long)event->mmap.pgoff,
@@ -1608,15 +1656,27 @@ process_comm_event(event_t *event, unsigned long offset, unsigned long head)
1608} 1656}
1609 1657
1610static int 1658static int
1611process_fork_event(event_t *event, unsigned long offset, unsigned long head) 1659process_task_event(event_t *event, unsigned long offset, unsigned long head)
1612{ 1660{
1613 struct thread *thread = threads__findnew(event->fork.pid); 1661 struct thread *thread = threads__findnew(event->fork.pid);
1614 struct thread *parent = threads__findnew(event->fork.ppid); 1662 struct thread *parent = threads__findnew(event->fork.ppid);
1615 1663
1616 dprintf("%p [%p]: PERF_EVENT_FORK: %d:%d\n", 1664 dprintf("%p [%p]: PERF_EVENT_%s: (%d:%d):(%d:%d)\n",
1617 (void *)(offset + head), 1665 (void *)(offset + head),
1618 (void *)(long)(event->header.size), 1666 (void *)(long)(event->header.size),
1619 event->fork.pid, event->fork.ppid); 1667 event->header.type == PERF_EVENT_FORK ? "FORK" : "EXIT",
1668 event->fork.pid, event->fork.tid,
1669 event->fork.ppid, event->fork.ptid);
1670
1671 /*
1672 * A thread clone will have the same PID for both
1673 * parent and child.
1674 */
1675 if (thread == parent)
1676 return 0;
1677
1678 if (event->header.type == PERF_EVENT_EXIT)
1679 return 0;
1620 1680
1621 if (!thread || !parent || thread__fork(thread, parent)) { 1681 if (!thread || !parent || thread__fork(thread, parent)) {
1622 dprintf("problem processing PERF_EVENT_FORK, skipping event.\n"); 1682 dprintf("problem processing PERF_EVENT_FORK, skipping event.\n");
@@ -1677,14 +1737,37 @@ static void trace_event(event_t *event)
1677 dprintf(".\n"); 1737 dprintf(".\n");
1678} 1738}
1679 1739
1740static struct perf_header *header;
1741
1742static struct perf_counter_attr *perf_header__find_attr(u64 id)
1743{
1744 int i;
1745
1746 for (i = 0; i < header->attrs; i++) {
1747 struct perf_header_attr *attr = header->attr[i];
1748 int j;
1749
1750 for (j = 0; j < attr->ids; j++) {
1751 if (attr->id[j] == id)
1752 return &attr->attr;
1753 }
1754 }
1755
1756 return NULL;
1757}
1758
1680static int 1759static int
1681process_read_event(event_t *event, unsigned long offset, unsigned long head) 1760process_read_event(event_t *event, unsigned long offset, unsigned long head)
1682{ 1761{
1683 dprintf("%p [%p]: PERF_EVENT_READ: %d %d %Lu\n", 1762 struct perf_counter_attr *attr = perf_header__find_attr(event->read.id);
1763
1764 dprintf("%p [%p]: PERF_EVENT_READ: %d %d %s %Lu\n",
1684 (void *)(offset + head), 1765 (void *)(offset + head),
1685 (void *)(long)(event->header.size), 1766 (void *)(long)(event->header.size),
1686 event->read.pid, 1767 event->read.pid,
1687 event->read.tid, 1768 event->read.tid,
1769 attr ? __event_name(attr->type, attr->config)
1770 : "FAIL",
1688 event->read.value); 1771 event->read.value);
1689 1772
1690 return 0; 1773 return 0;
@@ -1706,7 +1789,8 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1706 return process_comm_event(event, offset, head); 1789 return process_comm_event(event, offset, head);
1707 1790
1708 case PERF_EVENT_FORK: 1791 case PERF_EVENT_FORK:
1709 return process_fork_event(event, offset, head); 1792 case PERF_EVENT_EXIT:
1793 return process_task_event(event, offset, head);
1710 1794
1711 case PERF_EVENT_LOST: 1795 case PERF_EVENT_LOST:
1712 return process_lost_event(event, offset, head); 1796 return process_lost_event(event, offset, head);
@@ -1729,8 +1813,6 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
1729 return 0; 1813 return 0;
1730} 1814}
1731 1815
1732static struct perf_header *header;
1733
1734static u64 perf_header__sample_type(void) 1816static u64 perf_header__sample_type(void)
1735{ 1817{
1736 u64 sample_type = 0; 1818 u64 sample_type = 0;
@@ -1775,6 +1857,11 @@ static int __cmd_report(void)
1775 exit(-1); 1857 exit(-1);
1776 } 1858 }
1777 1859
1860 if (!force && (stat.st_uid != geteuid())) {
1861 fprintf(stderr, "file: %s not owned by current user\n", input_name);
1862 exit(-1);
1863 }
1864
1778 if (!stat.st_size) { 1865 if (!stat.st_size) {
1779 fprintf(stderr, "zero-sized file, nothing to do!\n"); 1866 fprintf(stderr, "zero-sized file, nothing to do!\n");
1780 exit(0); 1867 exit(0);
@@ -1798,6 +1885,13 @@ static int __cmd_report(void)
1798 " -g?\n"); 1885 " -g?\n");
1799 exit(-1); 1886 exit(-1);
1800 } 1887 }
1888 } else if (callchain_param.mode != CHAIN_NONE && !callchain) {
1889 callchain = 1;
1890 if (register_callchain_param(&callchain_param) < 0) {
1891 fprintf(stderr, "Can't register callchain"
1892 " params\n");
1893 exit(-1);
1894 }
1801 } 1895 }
1802 1896
1803 if (load_kernel() < 0) { 1897 if (load_kernel() < 0) {
@@ -1936,6 +2030,13 @@ parse_callchain_opt(const struct option *opt __used, const char *arg,
1936 else if (!strncmp(tok, "fractal", strlen(arg))) 2030 else if (!strncmp(tok, "fractal", strlen(arg)))
1937 callchain_param.mode = CHAIN_GRAPH_REL; 2031 callchain_param.mode = CHAIN_GRAPH_REL;
1938 2032
2033 else if (!strncmp(tok, "none", strlen(arg))) {
2034 callchain_param.mode = CHAIN_NONE;
2035 callchain = 0;
2036
2037 return 0;
2038 }
2039
1939 else 2040 else
1940 return -1; 2041 return -1;
1941 2042
@@ -1969,6 +2070,7 @@ static const struct option options[] = {
1969 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace, 2070 OPT_BOOLEAN('D', "dump-raw-trace", &dump_trace,
1970 "dump raw trace in ASCII"), 2071 "dump raw trace in ASCII"),
1971 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"), 2072 OPT_STRING('k', "vmlinux", &vmlinux, "file", "vmlinux pathname"),
2073 OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
1972 OPT_BOOLEAN('m', "modules", &modules, 2074 OPT_BOOLEAN('m', "modules", &modules,
1973 "load module symbols - WARNING: use only with -k and LIVE kernel"), 2075 "load module symbols - WARNING: use only with -k and LIVE kernel"),
1974 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples, 2076 OPT_BOOLEAN('n', "show-nr-samples", &show_nr_samples,
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index f9510eeeb6c7..b4b06c7903e1 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -496,7 +496,7 @@ static const struct option options[] = {
496 "stat events on existing pid"), 496 "stat events on existing pid"),
497 OPT_BOOLEAN('a', "all-cpus", &system_wide, 497 OPT_BOOLEAN('a', "all-cpus", &system_wide,
498 "system-wide collection from all CPUs"), 498 "system-wide collection from all CPUs"),
499 OPT_BOOLEAN('S', "scale", &scale, 499 OPT_BOOLEAN('c', "scale", &scale,
500 "scale/normalize counters"), 500 "scale/normalize counters"),
501 OPT_BOOLEAN('v', "verbose", &verbose, 501 OPT_BOOLEAN('v', "verbose", &verbose,
502 "be more verbose (show counter open errors, etc)"), 502 "be more verbose (show counter open errors, etc)"),
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index c0a423004e15..7de28ce9ca26 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -31,6 +31,8 @@
31#include <fcntl.h> 31#include <fcntl.h>
32 32
33#include <stdio.h> 33#include <stdio.h>
34#include <termios.h>
35#include <unistd.h>
34 36
35#include <errno.h> 37#include <errno.h>
36#include <time.h> 38#include <time.h>
@@ -54,7 +56,7 @@ static int system_wide = 0;
54 56
55static int default_interval = 100000; 57static int default_interval = 100000;
56 58
57static u64 count_filter = 5; 59static int count_filter = 5;
58static int print_entries = 15; 60static int print_entries = 15;
59 61
60static int target_pid = -1; 62static int target_pid = -1;
@@ -69,15 +71,28 @@ static int freq = 0;
69static int verbose = 0; 71static int verbose = 0;
70static char *vmlinux = NULL; 72static char *vmlinux = NULL;
71 73
72static char *sym_filter;
73static unsigned long filter_start;
74static unsigned long filter_end;
75
76static int delay_secs = 2; 74static int delay_secs = 2;
77static int zero; 75static int zero;
78static int dump_symtab; 76static int dump_symtab;
79 77
80/* 78/*
79 * Source
80 */
81
82struct source_line {
83 u64 eip;
84 unsigned long count[MAX_COUNTERS];
85 char *line;
86 struct source_line *next;
87};
88
89static char *sym_filter = NULL;
90struct sym_entry *sym_filter_entry = NULL;
91static int sym_pcnt_filter = 5;
92static int sym_counter = 0;
93static int display_weighted = -1;
94
95/*
81 * Symbols 96 * Symbols
82 */ 97 */
83 98
@@ -91,9 +106,237 @@ struct sym_entry {
91 unsigned long snap_count; 106 unsigned long snap_count;
92 double weight; 107 double weight;
93 int skip; 108 int skip;
109 struct source_line *source;
110 struct source_line *lines;
111 struct source_line **lines_tail;
112 pthread_mutex_t source_lock;
94}; 113};
95 114
96struct sym_entry *sym_filter_entry; 115/*
116 * Source functions
117 */
118
119static void parse_source(struct sym_entry *syme)
120{
121 struct symbol *sym;
122 struct module *module;
123 struct section *section = NULL;
124 FILE *file;
125 char command[PATH_MAX*2], *path = vmlinux;
126 u64 start, end, len;
127
128 if (!syme)
129 return;
130
131 if (syme->lines) {
132 pthread_mutex_lock(&syme->source_lock);
133 goto out_assign;
134 }
135
136 sym = (struct symbol *)(syme + 1);
137 module = sym->module;
138
139 if (module)
140 path = module->path;
141 if (!path)
142 return;
143
144 start = sym->obj_start;
145 if (!start)
146 start = sym->start;
147
148 if (module) {
149 section = module->sections->find_section(module->sections, ".text");
150 if (section)
151 start -= section->vma;
152 }
153
154 end = start + sym->end - sym->start + 1;
155 len = sym->end - sym->start;
156
157 sprintf(command, "objdump --start-address=0x%016Lx --stop-address=0x%016Lx -dS %s", start, end, path);
158
159 file = popen(command, "r");
160 if (!file)
161 return;
162
163 pthread_mutex_lock(&syme->source_lock);
164 syme->lines_tail = &syme->lines;
165 while (!feof(file)) {
166 struct source_line *src;
167 size_t dummy = 0;
168 char *c;
169
170 src = malloc(sizeof(struct source_line));
171 assert(src != NULL);
172 memset(src, 0, sizeof(struct source_line));
173
174 if (getline(&src->line, &dummy, file) < 0)
175 break;
176 if (!src->line)
177 break;
178
179 c = strchr(src->line, '\n');
180 if (c)
181 *c = 0;
182
183 src->next = NULL;
184 *syme->lines_tail = src;
185 syme->lines_tail = &src->next;
186
187 if (strlen(src->line)>8 && src->line[8] == ':') {
188 src->eip = strtoull(src->line, NULL, 16);
189 if (section)
190 src->eip += section->vma;
191 }
192 if (strlen(src->line)>8 && src->line[16] == ':') {
193 src->eip = strtoull(src->line, NULL, 16);
194 if (section)
195 src->eip += section->vma;
196 }
197 }
198 pclose(file);
199out_assign:
200 sym_filter_entry = syme;
201 pthread_mutex_unlock(&syme->source_lock);
202}
203
204static void __zero_source_counters(struct sym_entry *syme)
205{
206 int i;
207 struct source_line *line;
208
209 line = syme->lines;
210 while (line) {
211 for (i = 0; i < nr_counters; i++)
212 line->count[i] = 0;
213 line = line->next;
214 }
215}
216
217static void record_precise_ip(struct sym_entry *syme, int counter, u64 ip)
218{
219 struct source_line *line;
220
221 if (syme != sym_filter_entry)
222 return;
223
224 if (pthread_mutex_trylock(&syme->source_lock))
225 return;
226
227 if (!syme->source)
228 goto out_unlock;
229
230 for (line = syme->lines; line; line = line->next) {
231 if (line->eip == ip) {
232 line->count[counter]++;
233 break;
234 }
235 if (line->eip > ip)
236 break;
237 }
238out_unlock:
239 pthread_mutex_unlock(&syme->source_lock);
240}
241
242static void lookup_sym_source(struct sym_entry *syme)
243{
244 struct symbol *symbol = (struct symbol *)(syme + 1);
245 struct source_line *line;
246 char pattern[PATH_MAX];
247 char *idx;
248
249 sprintf(pattern, "<%s>:", symbol->name);
250
251 if (symbol->module) {
252 idx = strstr(pattern, "\t");
253 if (idx)
254 *idx = 0;
255 }
256
257 pthread_mutex_lock(&syme->source_lock);
258 for (line = syme->lines; line; line = line->next) {
259 if (strstr(line->line, pattern)) {
260 syme->source = line;
261 break;
262 }
263 }
264 pthread_mutex_unlock(&syme->source_lock);
265}
266
267static void show_lines(struct source_line *queue, int count, int total)
268{
269 int i;
270 struct source_line *line;
271
272 line = queue;
273 for (i = 0; i < count; i++) {
274 float pcnt = 100.0*(float)line->count[sym_counter]/(float)total;
275
276 printf("%8li %4.1f%%\t%s\n", line->count[sym_counter], pcnt, line->line);
277 line = line->next;
278 }
279}
280
281#define TRACE_COUNT 3
282
283static void show_details(struct sym_entry *syme)
284{
285 struct symbol *symbol;
286 struct source_line *line;
287 struct source_line *line_queue = NULL;
288 int displayed = 0;
289 int line_queue_count = 0, total = 0, more = 0;
290
291 if (!syme)
292 return;
293
294 if (!syme->source)
295 lookup_sym_source(syme);
296
297 if (!syme->source)
298 return;
299
300 symbol = (struct symbol *)(syme + 1);
301 printf("Showing %s for %s\n", event_name(sym_counter), symbol->name);
302 printf(" Events Pcnt (>=%d%%)\n", sym_pcnt_filter);
303
304 pthread_mutex_lock(&syme->source_lock);
305 line = syme->source;
306 while (line) {
307 total += line->count[sym_counter];
308 line = line->next;
309 }
310
311 line = syme->source;
312 while (line) {
313 float pcnt = 0.0;
314
315 if (!line_queue_count)
316 line_queue = line;
317 line_queue_count++;
318
319 if (line->count[sym_counter])
320 pcnt = 100.0 * line->count[sym_counter] / (float)total;
321 if (pcnt >= (float)sym_pcnt_filter) {
322 if (displayed <= print_entries)
323 show_lines(line_queue, line_queue_count, total);
324 else more++;
325 displayed += line_queue_count;
326 line_queue_count = 0;
327 line_queue = NULL;
328 } else if (line_queue_count > TRACE_COUNT) {
329 line_queue = line_queue->next;
330 line_queue_count--;
331 }
332
333 line->count[sym_counter] = zero ? 0 : line->count[sym_counter] * 7 / 8;
334 line = line->next;
335 }
336 pthread_mutex_unlock(&syme->source_lock);
337 if (more)
338 printf("%d lines not displayed, maybe increase display entries [e]\n", more);
339}
97 340
98struct dso *kernel_dso; 341struct dso *kernel_dso;
99 342
@@ -112,6 +355,9 @@ static double sym_weight(const struct sym_entry *sym)
112 double weight = sym->snap_count; 355 double weight = sym->snap_count;
113 int counter; 356 int counter;
114 357
358 if (!display_weighted)
359 return weight;
360
115 for (counter = 1; counter < nr_counters-1; counter++) 361 for (counter = 1; counter < nr_counters-1; counter++)
116 weight *= sym->count[counter]; 362 weight *= sym->count[counter];
117 363
@@ -159,7 +405,7 @@ static void rb_insert_active_sym(struct rb_root *tree, struct sym_entry *se)
159static void print_sym_table(void) 405static void print_sym_table(void)
160{ 406{
161 int printed = 0, j; 407 int printed = 0, j;
162 int counter; 408 int counter, snap = !display_weighted ? sym_counter : 0;
163 float samples_per_sec = samples/delay_secs; 409 float samples_per_sec = samples/delay_secs;
164 float ksamples_per_sec = (samples-userspace_samples)/delay_secs; 410 float ksamples_per_sec = (samples-userspace_samples)/delay_secs;
165 float sum_ksamples = 0.0; 411 float sum_ksamples = 0.0;
@@ -175,7 +421,7 @@ static void print_sym_table(void)
175 pthread_mutex_unlock(&active_symbols_lock); 421 pthread_mutex_unlock(&active_symbols_lock);
176 422
177 list_for_each_entry_safe_from(syme, n, &active_symbols, node) { 423 list_for_each_entry_safe_from(syme, n, &active_symbols, node) {
178 syme->snap_count = syme->count[0]; 424 syme->snap_count = syme->count[snap];
179 if (syme->snap_count != 0) { 425 if (syme->snap_count != 0) {
180 syme->weight = sym_weight(syme); 426 syme->weight = sym_weight(syme);
181 rb_insert_active_sym(&tmp, syme); 427 rb_insert_active_sym(&tmp, syme);
@@ -195,7 +441,7 @@ static void print_sym_table(void)
195 samples_per_sec, 441 samples_per_sec,
196 100.0 - (100.0*((samples_per_sec-ksamples_per_sec)/samples_per_sec))); 442 100.0 - (100.0*((samples_per_sec-ksamples_per_sec)/samples_per_sec)));
197 443
198 if (nr_counters == 1) { 444 if (nr_counters == 1 || !display_weighted) {
199 printf("%Ld", (u64)attrs[0].sample_period); 445 printf("%Ld", (u64)attrs[0].sample_period);
200 if (freq) 446 if (freq)
201 printf("Hz "); 447 printf("Hz ");
@@ -203,7 +449,9 @@ static void print_sym_table(void)
203 printf(" "); 449 printf(" ");
204 } 450 }
205 451
206 for (counter = 0; counter < nr_counters; counter++) { 452 if (!display_weighted)
453 printf("%s", event_name(sym_counter));
454 else for (counter = 0; counter < nr_counters; counter++) {
207 if (counter) 455 if (counter)
208 printf("/"); 456 printf("/");
209 457
@@ -228,6 +476,11 @@ static void print_sym_table(void)
228 476
229 printf("------------------------------------------------------------------------------\n\n"); 477 printf("------------------------------------------------------------------------------\n\n");
230 478
479 if (sym_filter_entry) {
480 show_details(sym_filter_entry);
481 return;
482 }
483
231 if (nr_counters == 1) 484 if (nr_counters == 1)
232 printf(" samples pcnt"); 485 printf(" samples pcnt");
233 else 486 else
@@ -242,13 +495,13 @@ static void print_sym_table(void)
242 struct symbol *sym = (struct symbol *)(syme + 1); 495 struct symbol *sym = (struct symbol *)(syme + 1);
243 double pcnt; 496 double pcnt;
244 497
245 if (++printed > print_entries || syme->snap_count < count_filter) 498 if (++printed > print_entries || (int)syme->snap_count < count_filter)
246 continue; 499 continue;
247 500
248 pcnt = 100.0 - (100.0 * ((sum_ksamples - syme->snap_count) / 501 pcnt = 100.0 - (100.0 * ((sum_ksamples - syme->snap_count) /
249 sum_ksamples)); 502 sum_ksamples));
250 503
251 if (nr_counters == 1) 504 if (nr_counters == 1 || !display_weighted)
252 printf("%20.2f - ", syme->weight); 505 printf("%20.2f - ", syme->weight);
253 else 506 else
254 printf("%9.1f %10ld - ", syme->weight, syme->snap_count); 507 printf("%9.1f %10ld - ", syme->weight, syme->snap_count);
@@ -261,19 +514,250 @@ static void print_sym_table(void)
261 } 514 }
262} 515}
263 516
517static void prompt_integer(int *target, const char *msg)
518{
519 char *buf = malloc(0), *p;
520 size_t dummy = 0;
521 int tmp;
522
523 fprintf(stdout, "\n%s: ", msg);
524 if (getline(&buf, &dummy, stdin) < 0)
525 return;
526
527 p = strchr(buf, '\n');
528 if (p)
529 *p = 0;
530
531 p = buf;
532 while(*p) {
533 if (!isdigit(*p))
534 goto out_free;
535 p++;
536 }
537 tmp = strtoul(buf, NULL, 10);
538 *target = tmp;
539out_free:
540 free(buf);
541}
542
543static void prompt_percent(int *target, const char *msg)
544{
545 int tmp = 0;
546
547 prompt_integer(&tmp, msg);
548 if (tmp >= 0 && tmp <= 100)
549 *target = tmp;
550}
551
552static void prompt_symbol(struct sym_entry **target, const char *msg)
553{
554 char *buf = malloc(0), *p;
555 struct sym_entry *syme = *target, *n, *found = NULL;
556 size_t dummy = 0;
557
558 /* zero counters of active symbol */
559 if (syme) {
560 pthread_mutex_lock(&syme->source_lock);
561 __zero_source_counters(syme);
562 *target = NULL;
563 pthread_mutex_unlock(&syme->source_lock);
564 }
565
566 fprintf(stdout, "\n%s: ", msg);
567 if (getline(&buf, &dummy, stdin) < 0)
568 goto out_free;
569
570 p = strchr(buf, '\n');
571 if (p)
572 *p = 0;
573
574 pthread_mutex_lock(&active_symbols_lock);
575 syme = list_entry(active_symbols.next, struct sym_entry, node);
576 pthread_mutex_unlock(&active_symbols_lock);
577
578 list_for_each_entry_safe_from(syme, n, &active_symbols, node) {
579 struct symbol *sym = (struct symbol *)(syme + 1);
580
581 if (!strcmp(buf, sym->name)) {
582 found = syme;
583 break;
584 }
585 }
586
587 if (!found) {
588 fprintf(stderr, "Sorry, %s is not active.\n", sym_filter);
589 sleep(1);
590 return;
591 } else
592 parse_source(found);
593
594out_free:
595 free(buf);
596}
597
598static void print_mapped_keys(void)
599{
600 char *name = NULL;
601
602 if (sym_filter_entry) {
603 struct symbol *sym = (struct symbol *)(sym_filter_entry+1);
604 name = sym->name;
605 }
606
607 fprintf(stdout, "\nMapped keys:\n");
608 fprintf(stdout, "\t[d] display refresh delay. \t(%d)\n", delay_secs);
609 fprintf(stdout, "\t[e] display entries (lines). \t(%d)\n", print_entries);
610
611 if (nr_counters > 1)
612 fprintf(stdout, "\t[E] active event counter. \t(%s)\n", event_name(sym_counter));
613
614 fprintf(stdout, "\t[f] profile display filter (count). \t(%d)\n", count_filter);
615
616 if (vmlinux) {
617 fprintf(stdout, "\t[F] annotate display filter (percent). \t(%d%%)\n", sym_pcnt_filter);
618 fprintf(stdout, "\t[s] annotate symbol. \t(%s)\n", name?: "NULL");
619 fprintf(stdout, "\t[S] stop annotation.\n");
620 }
621
622 if (nr_counters > 1)
623 fprintf(stdout, "\t[w] toggle display weighted/count[E]r. \t(%d)\n", display_weighted ? 1 : 0);
624
625 fprintf(stdout, "\t[z] toggle sample zeroing. \t(%d)\n", zero ? 1 : 0);
626 fprintf(stdout, "\t[qQ] quit.\n");
627}
628
629static int key_mapped(int c)
630{
631 switch (c) {
632 case 'd':
633 case 'e':
634 case 'f':
635 case 'z':
636 case 'q':
637 case 'Q':
638 return 1;
639 case 'E':
640 case 'w':
641 return nr_counters > 1 ? 1 : 0;
642 case 'F':
643 case 's':
644 case 'S':
645 return vmlinux ? 1 : 0;
646 }
647
648 return 0;
649}
650
651static void handle_keypress(int c)
652{
653 if (!key_mapped(c)) {
654 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
655 struct termios tc, save;
656
657 print_mapped_keys();
658 fprintf(stdout, "\nEnter selection, or unmapped key to continue: ");
659 fflush(stdout);
660
661 tcgetattr(0, &save);
662 tc = save;
663 tc.c_lflag &= ~(ICANON | ECHO);
664 tc.c_cc[VMIN] = 0;
665 tc.c_cc[VTIME] = 0;
666 tcsetattr(0, TCSANOW, &tc);
667
668 poll(&stdin_poll, 1, -1);
669 c = getc(stdin);
670
671 tcsetattr(0, TCSAFLUSH, &save);
672 if (!key_mapped(c))
673 return;
674 }
675
676 switch (c) {
677 case 'd':
678 prompt_integer(&delay_secs, "Enter display delay");
679 break;
680 case 'e':
681 prompt_integer(&print_entries, "Enter display entries (lines)");
682 break;
683 case 'E':
684 if (nr_counters > 1) {
685 int i;
686
687 fprintf(stderr, "\nAvailable events:");
688 for (i = 0; i < nr_counters; i++)
689 fprintf(stderr, "\n\t%d %s", i, event_name(i));
690
691 prompt_integer(&sym_counter, "Enter details event counter");
692
693 if (sym_counter >= nr_counters) {
694 fprintf(stderr, "Sorry, no such event, using %s.\n", event_name(0));
695 sym_counter = 0;
696 sleep(1);
697 }
698 } else sym_counter = 0;
699 break;
700 case 'f':
701 prompt_integer(&count_filter, "Enter display event count filter");
702 break;
703 case 'F':
704 prompt_percent(&sym_pcnt_filter, "Enter details display event filter (percent)");
705 break;
706 case 'q':
707 case 'Q':
708 printf("exiting.\n");
709 exit(0);
710 case 's':
711 prompt_symbol(&sym_filter_entry, "Enter details symbol");
712 break;
713 case 'S':
714 if (!sym_filter_entry)
715 break;
716 else {
717 struct sym_entry *syme = sym_filter_entry;
718
719 pthread_mutex_lock(&syme->source_lock);
720 sym_filter_entry = NULL;
721 __zero_source_counters(syme);
722 pthread_mutex_unlock(&syme->source_lock);
723 }
724 break;
725 case 'w':
726 display_weighted = ~display_weighted;
727 break;
728 case 'z':
729 zero = ~zero;
730 break;
731 }
732}
733
264static void *display_thread(void *arg __used) 734static void *display_thread(void *arg __used)
265{ 735{
266 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN }; 736 struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
267 int delay_msecs = delay_secs * 1000; 737 struct termios tc, save;
738 int delay_msecs, c;
739
740 tcgetattr(0, &save);
741 tc = save;
742 tc.c_lflag &= ~(ICANON | ECHO);
743 tc.c_cc[VMIN] = 0;
744 tc.c_cc[VTIME] = 0;
268 745
269 printf("PerfTop refresh period: %d seconds\n", delay_secs); 746repeat:
747 delay_msecs = delay_secs * 1000;
748 tcsetattr(0, TCSANOW, &tc);
749 /* trash return*/
750 getc(stdin);
270 751
271 do { 752 do {
272 print_sym_table(); 753 print_sym_table();
273 } while (!poll(&stdin_poll, 1, delay_msecs) == 1); 754 } while (!poll(&stdin_poll, 1, delay_msecs) == 1);
274 755
275 printf("key pressed - exiting.\n"); 756 c = getc(stdin);
276 exit(0); 757 tcsetattr(0, TCSAFLUSH, &save);
758
759 handle_keypress(c);
760 goto repeat;
277 761
278 return NULL; 762 return NULL;
279} 763}
@@ -285,6 +769,7 @@ static const char *skip_symbols[] = {
285 "enter_idle", 769 "enter_idle",
286 "exit_idle", 770 "exit_idle",
287 "mwait_idle", 771 "mwait_idle",
772 "mwait_idle_with_hints",
288 "ppc64_runlatch_off", 773 "ppc64_runlatch_off",
289 "pseries_dedicated_idle_sleep", 774 "pseries_dedicated_idle_sleep",
290 NULL 775 NULL
@@ -292,7 +777,6 @@ static const char *skip_symbols[] = {
292 777
293static int symbol_filter(struct dso *self, struct symbol *sym) 778static int symbol_filter(struct dso *self, struct symbol *sym)
294{ 779{
295 static int filter_match;
296 struct sym_entry *syme; 780 struct sym_entry *syme;
297 const char *name = sym->name; 781 const char *name = sym->name;
298 int i; 782 int i;
@@ -314,6 +798,10 @@ static int symbol_filter(struct dso *self, struct symbol *sym)
314 return 1; 798 return 1;
315 799
316 syme = dso__sym_priv(self, sym); 800 syme = dso__sym_priv(self, sym);
801 pthread_mutex_init(&syme->source_lock, NULL);
802 if (!sym_filter_entry && sym_filter && !strcmp(name, sym_filter))
803 sym_filter_entry = syme;
804
317 for (i = 0; skip_symbols[i]; i++) { 805 for (i = 0; skip_symbols[i]; i++) {
318 if (!strcmp(skip_symbols[i], name)) { 806 if (!strcmp(skip_symbols[i], name)) {
319 syme->skip = 1; 807 syme->skip = 1;
@@ -321,29 +809,6 @@ static int symbol_filter(struct dso *self, struct symbol *sym)
321 } 809 }
322 } 810 }
323 811
324 if (filter_match == 1) {
325 filter_end = sym->start;
326 filter_match = -1;
327 if (filter_end - filter_start > 10000) {
328 fprintf(stderr,
329 "hm, too large filter symbol <%s> - skipping.\n",
330 sym_filter);
331 fprintf(stderr, "symbol filter start: %016lx\n",
332 filter_start);
333 fprintf(stderr, " end: %016lx\n",
334 filter_end);
335 filter_end = filter_start = 0;
336 sym_filter = NULL;
337 sleep(1);
338 }
339 }
340
341 if (filter_match == 0 && sym_filter && !strcmp(name, sym_filter)) {
342 filter_match = 1;
343 filter_start = sym->start;
344 }
345
346
347 return 0; 812 return 0;
348} 813}
349 814
@@ -379,8 +844,6 @@ out_delete_dso:
379 return -1; 844 return -1;
380} 845}
381 846
382#define TRACE_COUNT 3
383
384/* 847/*
385 * Binary search in the histogram table and record the hit: 848 * Binary search in the histogram table and record the hit:
386 */ 849 */
@@ -393,6 +856,7 @@ static void record_ip(u64 ip, int counter)
393 856
394 if (!syme->skip) { 857 if (!syme->skip) {
395 syme->count[counter]++; 858 syme->count[counter]++;
859 record_precise_ip(syme, counter, ip);
396 pthread_mutex_lock(&active_symbols_lock); 860 pthread_mutex_lock(&active_symbols_lock);
397 if (list_empty(&syme->node) || !syme->node.next) 861 if (list_empty(&syme->node) || !syme->node.next)
398 __list_insert_active_sym(syme); 862 __list_insert_active_sym(syme);
@@ -689,8 +1153,8 @@ static const struct option options[] = {
689 "put the counters into a counter group"), 1153 "put the counters into a counter group"),
690 OPT_BOOLEAN('i', "inherit", &inherit, 1154 OPT_BOOLEAN('i', "inherit", &inherit,
691 "child tasks inherit counters"), 1155 "child tasks inherit counters"),
692 OPT_STRING('s', "sym-filter", &sym_filter, "pattern", 1156 OPT_STRING('s', "sym-annotate", &sym_filter, "symbol name",
693 "only display symbols matchig this pattern"), 1157 "symbol to annotate - requires -k option"),
694 OPT_BOOLEAN('z', "zero", &zero, 1158 OPT_BOOLEAN('z', "zero", &zero,
695 "zero history across updates"), 1159 "zero history across updates"),
696 OPT_INTEGER('F', "freq", &freq, 1160 OPT_INTEGER('F', "freq", &freq,
@@ -733,6 +1197,7 @@ int cmd_top(int argc, const char **argv, const char *prefix __used)
733 delay_secs = 1; 1197 delay_secs = 1;
734 1198
735 parse_symbols(); 1199 parse_symbols();
1200 parse_source(sym_filter_entry);
736 1201
737 /* 1202 /*
738 * Fill in the ones not specifically initialized via -c: 1203 * Fill in the ones not specifically initialized via -c:
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 9d3c8141b8c1..011473411642 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -13,6 +13,7 @@
13#include <stdio.h> 13#include <stdio.h>
14#include <stdbool.h> 14#include <stdbool.h>
15#include <errno.h> 15#include <errno.h>
16#include <math.h>
16 17
17#include "callchain.h" 18#include "callchain.h"
18 19
@@ -26,10 +27,14 @@ rb_insert_callchain(struct rb_root *root, struct callchain_node *chain,
26 struct rb_node **p = &root->rb_node; 27 struct rb_node **p = &root->rb_node;
27 struct rb_node *parent = NULL; 28 struct rb_node *parent = NULL;
28 struct callchain_node *rnode; 29 struct callchain_node *rnode;
30 u64 chain_cumul = cumul_hits(chain);
29 31
30 while (*p) { 32 while (*p) {
33 u64 rnode_cumul;
34
31 parent = *p; 35 parent = *p;
32 rnode = rb_entry(parent, struct callchain_node, rb_node); 36 rnode = rb_entry(parent, struct callchain_node, rb_node);
37 rnode_cumul = cumul_hits(rnode);
33 38
34 switch (mode) { 39 switch (mode) {
35 case CHAIN_FLAT: 40 case CHAIN_FLAT:
@@ -40,7 +45,7 @@ rb_insert_callchain(struct rb_root *root, struct callchain_node *chain,
40 break; 45 break;
41 case CHAIN_GRAPH_ABS: /* Falldown */ 46 case CHAIN_GRAPH_ABS: /* Falldown */
42 case CHAIN_GRAPH_REL: 47 case CHAIN_GRAPH_REL:
43 if (rnode->cumul_hit < chain->cumul_hit) 48 if (rnode_cumul < chain_cumul)
44 p = &(*p)->rb_left; 49 p = &(*p)->rb_left;
45 else 50 else
46 p = &(*p)->rb_right; 51 p = &(*p)->rb_right;
@@ -87,7 +92,7 @@ static void __sort_chain_graph_abs(struct callchain_node *node,
87 92
88 chain_for_each_child(child, node) { 93 chain_for_each_child(child, node) {
89 __sort_chain_graph_abs(child, min_hit); 94 __sort_chain_graph_abs(child, min_hit);
90 if (child->cumul_hit >= min_hit) 95 if (cumul_hits(child) >= min_hit)
91 rb_insert_callchain(&node->rb_root, child, 96 rb_insert_callchain(&node->rb_root, child,
92 CHAIN_GRAPH_ABS); 97 CHAIN_GRAPH_ABS);
93 } 98 }
@@ -108,11 +113,11 @@ static void __sort_chain_graph_rel(struct callchain_node *node,
108 u64 min_hit; 113 u64 min_hit;
109 114
110 node->rb_root = RB_ROOT; 115 node->rb_root = RB_ROOT;
111 min_hit = node->cumul_hit * min_percent / 100.0; 116 min_hit = ceil(node->children_hit * min_percent);
112 117
113 chain_for_each_child(child, node) { 118 chain_for_each_child(child, node) {
114 __sort_chain_graph_rel(child, min_percent); 119 __sort_chain_graph_rel(child, min_percent);
115 if (child->cumul_hit >= min_hit) 120 if (cumul_hits(child) >= min_hit)
116 rb_insert_callchain(&node->rb_root, child, 121 rb_insert_callchain(&node->rb_root, child,
117 CHAIN_GRAPH_REL); 122 CHAIN_GRAPH_REL);
118 } 123 }
@@ -122,7 +127,7 @@ static void
122sort_chain_graph_rel(struct rb_root *rb_root, struct callchain_node *chain_root, 127sort_chain_graph_rel(struct rb_root *rb_root, struct callchain_node *chain_root,
123 u64 min_hit __used, struct callchain_param *param) 128 u64 min_hit __used, struct callchain_param *param)
124{ 129{
125 __sort_chain_graph_rel(chain_root, param->min_percent); 130 __sort_chain_graph_rel(chain_root, param->min_percent / 100.0);
126 rb_root->rb_node = chain_root->rb_root.rb_node; 131 rb_root->rb_node = chain_root->rb_root.rb_node;
127} 132}
128 133
@@ -211,7 +216,8 @@ add_child(struct callchain_node *parent, struct ip_callchain *chain,
211 new = create_child(parent, false); 216 new = create_child(parent, false);
212 fill_node(new, chain, start, syms); 217 fill_node(new, chain, start, syms);
213 218
214 new->cumul_hit = new->hit = 1; 219 new->children_hit = 0;
220 new->hit = 1;
215} 221}
216 222
217/* 223/*
@@ -241,7 +247,8 @@ split_add_child(struct callchain_node *parent, struct ip_callchain *chain,
241 247
242 /* split the hits */ 248 /* split the hits */
243 new->hit = parent->hit; 249 new->hit = parent->hit;
244 new->cumul_hit = parent->cumul_hit; 250 new->children_hit = parent->children_hit;
251 parent->children_hit = cumul_hits(new);
245 new->val_nr = parent->val_nr - idx_local; 252 new->val_nr = parent->val_nr - idx_local;
246 parent->val_nr = idx_local; 253 parent->val_nr = idx_local;
247 254
@@ -249,6 +256,7 @@ split_add_child(struct callchain_node *parent, struct ip_callchain *chain,
249 if (idx_total < chain->nr) { 256 if (idx_total < chain->nr) {
250 parent->hit = 0; 257 parent->hit = 0;
251 add_child(parent, chain, idx_total, syms); 258 add_child(parent, chain, idx_total, syms);
259 parent->children_hit++;
252 } else { 260 } else {
253 parent->hit = 1; 261 parent->hit = 1;
254 } 262 }
@@ -269,13 +277,13 @@ __append_chain_children(struct callchain_node *root, struct ip_callchain *chain,
269 unsigned int ret = __append_chain(rnode, chain, start, syms); 277 unsigned int ret = __append_chain(rnode, chain, start, syms);
270 278
271 if (!ret) 279 if (!ret)
272 goto cumul; 280 goto inc_children_hit;
273 } 281 }
274 /* nothing in children, add to the current node */ 282 /* nothing in children, add to the current node */
275 add_child(root, chain, start, syms); 283 add_child(root, chain, start, syms);
276 284
277cumul: 285inc_children_hit:
278 root->cumul_hit++; 286 root->children_hit++;
279} 287}
280 288
281static int 289static int
@@ -317,8 +325,6 @@ __append_chain(struct callchain_node *root, struct ip_callchain *chain,
317 /* we match 100% of the path, increment the hit */ 325 /* we match 100% of the path, increment the hit */
318 if (i - start == root->val_nr && i == chain->nr) { 326 if (i - start == root->val_nr && i == chain->nr) {
319 root->hit++; 327 root->hit++;
320 root->cumul_hit++;
321
322 return 0; 328 return 0;
323 } 329 }
324 330
@@ -331,5 +337,7 @@ __append_chain(struct callchain_node *root, struct ip_callchain *chain,
331void append_chain(struct callchain_node *root, struct ip_callchain *chain, 337void append_chain(struct callchain_node *root, struct ip_callchain *chain,
332 struct symbol **syms) 338 struct symbol **syms)
333{ 339{
340 if (!chain->nr)
341 return;
334 __append_chain_children(root, chain, syms, 0); 342 __append_chain_children(root, chain, syms, 0);
335} 343}
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h
index 7812122bea1d..a926ae4f5a16 100644
--- a/tools/perf/util/callchain.h
+++ b/tools/perf/util/callchain.h
@@ -7,6 +7,7 @@
7#include "symbol.h" 7#include "symbol.h"
8 8
9enum chain_mode { 9enum chain_mode {
10 CHAIN_NONE,
10 CHAIN_FLAT, 11 CHAIN_FLAT,
11 CHAIN_GRAPH_ABS, 12 CHAIN_GRAPH_ABS,
12 CHAIN_GRAPH_REL 13 CHAIN_GRAPH_REL
@@ -21,7 +22,7 @@ struct callchain_node {
21 struct rb_root rb_root; /* sorted tree of children */ 22 struct rb_root rb_root; /* sorted tree of children */
22 unsigned int val_nr; 23 unsigned int val_nr;
23 u64 hit; 24 u64 hit;
24 u64 cumul_hit; /* hit + hits of children */ 25 u64 children_hit;
25}; 26};
26 27
27struct callchain_param; 28struct callchain_param;
@@ -48,6 +49,11 @@ static inline void callchain_init(struct callchain_node *node)
48 INIT_LIST_HEAD(&node->val); 49 INIT_LIST_HEAD(&node->val);
49} 50}
50 51
52static inline u64 cumul_hits(struct callchain_node *node)
53{
54 return node->hit + node->children_hit;
55}
56
51int register_callchain_param(struct callchain_param *param); 57int register_callchain_param(struct callchain_param *param);
52void append_chain(struct callchain_node *root, struct ip_callchain *chain, 58void append_chain(struct callchain_node *root, struct ip_callchain *chain,
53 struct symbol **syms); 59 struct symbol **syms);
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 450384b3bbe5..b92a457ca32e 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -185,6 +185,8 @@ static void do_read(int fd, void *buf, size_t size)
185 185
186 if (ret < 0) 186 if (ret < 0)
187 die("failed to read"); 187 die("failed to read");
188 if (ret == 0)
189 die("failed to read: missing data");
188 190
189 size -= ret; 191 size -= ret;
190 buf += ret; 192 buf += ret;
@@ -213,9 +215,10 @@ struct perf_header *perf_header__read(int fd)
213 215
214 for (i = 0; i < nr_attrs; i++) { 216 for (i = 0; i < nr_attrs; i++) {
215 struct perf_header_attr *attr; 217 struct perf_header_attr *attr;
216 off_t tmp = lseek(fd, 0, SEEK_CUR); 218 off_t tmp;
217 219
218 do_read(fd, &f_attr, sizeof(f_attr)); 220 do_read(fd, &f_attr, sizeof(f_attr));
221 tmp = lseek(fd, 0, SEEK_CUR);
219 222
220 attr = perf_header_attr__new(&f_attr.attr); 223 attr = perf_header_attr__new(&f_attr.attr);
221 224
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 7bdad8df22a6..044178408783 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -121,13 +121,29 @@ static unsigned long hw_cache_stat[C(MAX)] = {
121 (strcmp(sys_dirent.d_name, ".")) && \ 121 (strcmp(sys_dirent.d_name, ".")) && \
122 (strcmp(sys_dirent.d_name, ".."))) 122 (strcmp(sys_dirent.d_name, "..")))
123 123
124static int tp_event_has_id(struct dirent *sys_dir, struct dirent *evt_dir)
125{
126 char evt_path[MAXPATHLEN];
127 int fd;
128
129 snprintf(evt_path, MAXPATHLEN, "%s/%s/%s/id", debugfs_path,
130 sys_dir->d_name, evt_dir->d_name);
131 fd = open(evt_path, O_RDONLY);
132 if (fd < 0)
133 return -EINVAL;
134 close(fd);
135
136 return 0;
137}
138
124#define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next, file, st) \ 139#define for_each_event(sys_dirent, evt_dir, evt_dirent, evt_next, file, st) \
125 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \ 140 while (!readdir_r(evt_dir, &evt_dirent, &evt_next) && evt_next) \
126 if (snprintf(file, MAXPATHLEN, "%s/%s/%s", debugfs_path, \ 141 if (snprintf(file, MAXPATHLEN, "%s/%s/%s", debugfs_path, \
127 sys_dirent.d_name, evt_dirent.d_name) && \ 142 sys_dirent.d_name, evt_dirent.d_name) && \
128 (!stat(file, &st)) && (S_ISDIR(st.st_mode)) && \ 143 (!stat(file, &st)) && (S_ISDIR(st.st_mode)) && \
129 (strcmp(evt_dirent.d_name, ".")) && \ 144 (strcmp(evt_dirent.d_name, ".")) && \
130 (strcmp(evt_dirent.d_name, ".."))) 145 (strcmp(evt_dirent.d_name, "..")) && \
146 (!tp_event_has_id(&sys_dirent, &evt_dirent)))
131 147
132#define MAX_EVENT_LENGTH 30 148#define MAX_EVENT_LENGTH 30
133 149
@@ -223,9 +239,15 @@ char *event_name(int counter)
223{ 239{
224 u64 config = attrs[counter].config; 240 u64 config = attrs[counter].config;
225 int type = attrs[counter].type; 241 int type = attrs[counter].type;
242
243 return __event_name(type, config);
244}
245
246char *__event_name(int type, u64 config)
247{
226 static char buf[32]; 248 static char buf[32];
227 249
228 if (attrs[counter].type == PERF_TYPE_RAW) { 250 if (type == PERF_TYPE_RAW) {
229 sprintf(buf, "raw 0x%llx", config); 251 sprintf(buf, "raw 0x%llx", config);
230 return buf; 252 return buf;
231 } 253 }
@@ -357,6 +379,7 @@ static int parse_tracepoint_event(const char **strp,
357 struct perf_counter_attr *attr) 379 struct perf_counter_attr *attr)
358{ 380{
359 const char *evt_name; 381 const char *evt_name;
382 char *flags;
360 char sys_name[MAX_EVENT_LENGTH]; 383 char sys_name[MAX_EVENT_LENGTH];
361 char id_buf[4]; 384 char id_buf[4];
362 int fd; 385 int fd;
@@ -378,6 +401,15 @@ static int parse_tracepoint_event(const char **strp,
378 strncpy(sys_name, *strp, sys_length); 401 strncpy(sys_name, *strp, sys_length);
379 sys_name[sys_length] = '\0'; 402 sys_name[sys_length] = '\0';
380 evt_name = evt_name + 1; 403 evt_name = evt_name + 1;
404
405 flags = strchr(evt_name, ':');
406 if (flags) {
407 *flags = '\0';
408 flags++;
409 if (!strncmp(flags, "record", strlen(flags)))
410 attr->sample_type |= PERF_SAMPLE_RAW;
411 }
412
381 evt_length = strlen(evt_name); 413 evt_length = strlen(evt_name);
382 if (evt_length >= MAX_EVENT_LENGTH) 414 if (evt_length >= MAX_EVENT_LENGTH)
383 return 0; 415 return 0;
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 1ea5d09b6eb1..192a962e3a0f 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -10,6 +10,7 @@ extern int nr_counters;
10extern struct perf_counter_attr attrs[MAX_COUNTERS]; 10extern struct perf_counter_attr attrs[MAX_COUNTERS];
11 11
12extern char *event_name(int ctr); 12extern char *event_name(int ctr);
13extern char *__event_name(int type, u64 config);
13 14
14extern int parse_events(const struct option *opt, const char *str, int unset); 15extern int parse_events(const struct option *opt, const char *str, int unset);
15 16
diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c
index c6e5dc0dc82f..2726fe40eb5d 100644
--- a/tools/perf/util/quote.c
+++ b/tools/perf/util/quote.c
@@ -318,7 +318,7 @@ char *quote_path_relative(const char *in, int len,
318 strbuf_addch(out, '"'); 318 strbuf_addch(out, '"');
319 if (prefix) { 319 if (prefix) {
320 int off = 0; 320 int off = 0;
321 while (prefix[off] && off < len && prefix[off] == in[off]) 321 while (off < len && prefix[off] && prefix[off] == in[off])
322 if (prefix[off] == '/') { 322 if (prefix[off] == '/') {
323 prefix += off + 1; 323 prefix += off + 1;
324 in += off + 1; 324 in += off + 1;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 28106059bf12..5c0f42e6b33b 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -6,14 +6,18 @@
6#include <libelf.h> 6#include <libelf.h>
7#include <gelf.h> 7#include <gelf.h>
8#include <elf.h> 8#include <elf.h>
9#include <bfd.h>
10 9
11const char *sym_hist_filter; 10const char *sym_hist_filter;
12 11
13#ifndef DMGL_PARAMS 12enum dso_origin {
14#define DMGL_PARAMS (1 << 0) /* Include function args */ 13 DSO__ORIG_KERNEL = 0,
15#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ 14 DSO__ORIG_JAVA_JIT,
16#endif 15 DSO__ORIG_FEDORA,
16 DSO__ORIG_UBUNTU,
17 DSO__ORIG_BUILDID,
18 DSO__ORIG_DSO,
19 DSO__ORIG_NOT_FOUND,
20};
17 21
18static struct symbol *symbol__new(u64 start, u64 len, 22static struct symbol *symbol__new(u64 start, u64 len,
19 const char *name, unsigned int priv_size, 23 const char *name, unsigned int priv_size,
@@ -72,6 +76,7 @@ struct dso *dso__new(const char *name, unsigned int sym_priv_size)
72 self->sym_priv_size = sym_priv_size; 76 self->sym_priv_size = sym_priv_size;
73 self->find_symbol = dso__find_symbol; 77 self->find_symbol = dso__find_symbol;
74 self->slen_calculated = 0; 78 self->slen_calculated = 0;
79 self->origin = DSO__ORIG_NOT_FOUND;
75 } 80 }
76 81
77 return self; 82 return self;
@@ -565,7 +570,7 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
565 goto out_elf_end; 570 goto out_elf_end;
566 571
567 secstrs = elf_getdata(sec_strndx, NULL); 572 secstrs = elf_getdata(sec_strndx, NULL);
568 if (symstrs == NULL) 573 if (secstrs == NULL)
569 goto out_elf_end; 574 goto out_elf_end;
570 575
571 nr_syms = shdr.sh_size / shdr.sh_entsize; 576 nr_syms = shdr.sh_size / shdr.sh_entsize;
@@ -652,11 +657,85 @@ out_close:
652 return err; 657 return err;
653} 658}
654 659
660#define BUILD_ID_SIZE 128
661
662static char *dso__read_build_id(struct dso *self, int verbose)
663{
664 int i;
665 GElf_Ehdr ehdr;
666 GElf_Shdr shdr;
667 Elf_Data *build_id_data;
668 Elf_Scn *sec;
669 char *build_id = NULL, *bid;
670 unsigned char *raw;
671 Elf *elf;
672 int fd = open(self->name, O_RDONLY);
673
674 if (fd < 0)
675 goto out;
676
677 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
678 if (elf == NULL) {
679 if (verbose)
680 fprintf(stderr, "%s: cannot read %s ELF file.\n",
681 __func__, self->name);
682 goto out_close;
683 }
684
685 if (gelf_getehdr(elf, &ehdr) == NULL) {
686 if (verbose)
687 fprintf(stderr, "%s: cannot get elf header.\n", __func__);
688 goto out_elf_end;
689 }
690
691 sec = elf_section_by_name(elf, &ehdr, &shdr, ".note.gnu.build-id", NULL);
692 if (sec == NULL)
693 goto out_elf_end;
694
695 build_id_data = elf_getdata(sec, NULL);
696 if (build_id_data == NULL)
697 goto out_elf_end;
698 build_id = malloc(BUILD_ID_SIZE);
699 if (build_id == NULL)
700 goto out_elf_end;
701 raw = build_id_data->d_buf + 16;
702 bid = build_id;
703
704 for (i = 0; i < 20; ++i) {
705 sprintf(bid, "%02x", *raw);
706 ++raw;
707 bid += 2;
708 }
709 if (verbose >= 2)
710 printf("%s(%s): %s\n", __func__, self->name, build_id);
711out_elf_end:
712 elf_end(elf);
713out_close:
714 close(fd);
715out:
716 return build_id;
717}
718
719char dso__symtab_origin(const struct dso *self)
720{
721 static const char origin[] = {
722 [DSO__ORIG_KERNEL] = 'k',
723 [DSO__ORIG_JAVA_JIT] = 'j',
724 [DSO__ORIG_FEDORA] = 'f',
725 [DSO__ORIG_UBUNTU] = 'u',
726 [DSO__ORIG_BUILDID] = 'b',
727 [DSO__ORIG_DSO] = 'd',
728 };
729
730 if (self == NULL || self->origin == DSO__ORIG_NOT_FOUND)
731 return '!';
732 return origin[self->origin];
733}
734
655int dso__load(struct dso *self, symbol_filter_t filter, int verbose) 735int dso__load(struct dso *self, symbol_filter_t filter, int verbose)
656{ 736{
657 int size = strlen(self->name) + sizeof("/usr/lib/debug%s.debug"); 737 int size = PATH_MAX;
658 char *name = malloc(size); 738 char *name = malloc(size), *build_id = NULL;
659 int variant = 0;
660 int ret = -1; 739 int ret = -1;
661 int fd; 740 int fd;
662 741
@@ -665,26 +744,43 @@ int dso__load(struct dso *self, symbol_filter_t filter, int verbose)
665 744
666 self->adjust_symbols = 0; 745 self->adjust_symbols = 0;
667 746
668 if (strncmp(self->name, "/tmp/perf-", 10) == 0) 747 if (strncmp(self->name, "/tmp/perf-", 10) == 0) {
669 return dso__load_perf_map(self, filter, verbose); 748 ret = dso__load_perf_map(self, filter, verbose);
749 self->origin = ret > 0 ? DSO__ORIG_JAVA_JIT :
750 DSO__ORIG_NOT_FOUND;
751 return ret;
752 }
753
754 self->origin = DSO__ORIG_FEDORA - 1;
670 755
671more: 756more:
672 do { 757 do {
673 switch (variant) { 758 self->origin++;
674 case 0: /* Fedora */ 759 switch (self->origin) {
760 case DSO__ORIG_FEDORA:
675 snprintf(name, size, "/usr/lib/debug%s.debug", self->name); 761 snprintf(name, size, "/usr/lib/debug%s.debug", self->name);
676 break; 762 break;
677 case 1: /* Ubuntu */ 763 case DSO__ORIG_UBUNTU:
678 snprintf(name, size, "/usr/lib/debug%s", self->name); 764 snprintf(name, size, "/usr/lib/debug%s", self->name);
679 break; 765 break;
680 case 2: /* Sane people */ 766 case DSO__ORIG_BUILDID:
767 build_id = dso__read_build_id(self, verbose);
768 if (build_id != NULL) {
769 snprintf(name, size,
770 "/usr/lib/debug/.build-id/%.2s/%s.debug",
771 build_id, build_id + 2);
772 free(build_id);
773 break;
774 }
775 self->origin++;
776 /* Fall thru */
777 case DSO__ORIG_DSO:
681 snprintf(name, size, "%s", self->name); 778 snprintf(name, size, "%s", self->name);
682 break; 779 break;
683 780
684 default: 781 default:
685 goto out; 782 goto out;
686 } 783 }
687 variant++;
688 784
689 fd = open(name, O_RDONLY); 785 fd = open(name, O_RDONLY);
690 } while (fd < 0); 786 } while (fd < 0);
@@ -705,6 +801,8 @@ more:
705 } 801 }
706out: 802out:
707 free(name); 803 free(name);
804 if (ret < 0 && strstr(self->name, " (deleted)") != NULL)
805 return 0;
708 return ret; 806 return ret;
709} 807}
710 808
@@ -820,6 +918,9 @@ int dso__load_kernel(struct dso *self, const char *vmlinux,
820 if (err <= 0) 918 if (err <= 0)
821 err = dso__load_kallsyms(self, filter, verbose); 919 err = dso__load_kallsyms(self, filter, verbose);
822 920
921 if (err > 0)
922 self->origin = DSO__ORIG_KERNEL;
923
823 return err; 924 return err;
824} 925}
825 926
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 2f92b21c712d..b53bf0125c1b 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -7,6 +7,30 @@
7#include <linux/rbtree.h> 7#include <linux/rbtree.h>
8#include "module.h" 8#include "module.h"
9 9
10#ifdef HAVE_CPLUS_DEMANGLE
11extern char *cplus_demangle(const char *, int);
12
13static inline char *bfd_demangle(void __used *v, const char *c, int i)
14{
15 return cplus_demangle(c, i);
16}
17#else
18#ifdef NO_DEMANGLE
19static inline char *bfd_demangle(void __used *v, const char __used *c,
20 int __used i)
21{
22 return NULL;
23}
24#else
25#include <bfd.h>
26#endif
27#endif
28
29#ifndef DMGL_PARAMS
30#define DMGL_PARAMS (1 << 0) /* Include function args */
31#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */
32#endif
33
10struct symbol { 34struct symbol {
11 struct rb_node rb_node; 35 struct rb_node rb_node;
12 u64 start; 36 u64 start;
@@ -26,6 +50,7 @@ struct dso {
26 unsigned int sym_priv_size; 50 unsigned int sym_priv_size;
27 unsigned char adjust_symbols; 51 unsigned char adjust_symbols;
28 unsigned char slen_calculated; 52 unsigned char slen_calculated;
53 unsigned char origin;
29 char name[0]; 54 char name[0];
30}; 55};
31 56
@@ -49,6 +74,7 @@ int dso__load_modules(struct dso *self, symbol_filter_t filter, int verbose);
49int dso__load(struct dso *self, symbol_filter_t filter, int verbose); 74int dso__load(struct dso *self, symbol_filter_t filter, int verbose);
50 75
51size_t dso__fprintf(struct dso *self, FILE *fp); 76size_t dso__fprintf(struct dso *self, FILE *fp);
77char dso__symtab_origin(const struct dso *self);
52 78
53void symbol__init(void); 79void symbol__init(void);
54#endif /* _PERF_SYMBOL_ */ 80#endif /* _PERF_SYMBOL_ */
diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
index 1eddae94bab3..1150c6d5c7b8 100644
--- a/virt/kvm/ioapic.c
+++ b/virt/kvm/ioapic.c
@@ -95,8 +95,6 @@ static int ioapic_service(struct kvm_ioapic *ioapic, unsigned int idx)
95 if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG) 95 if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG)
96 pent->fields.remote_irr = 1; 96 pent->fields.remote_irr = 1;
97 } 97 }
98 if (!pent->fields.trig_mode)
99 ioapic->irr &= ~(1 << idx);
100 98
101 return injected; 99 return injected;
102} 100}
@@ -136,7 +134,8 @@ static void ioapic_write_indirect(struct kvm_ioapic *ioapic, u32 val)
136 mask_after = ioapic->redirtbl[index].fields.mask; 134 mask_after = ioapic->redirtbl[index].fields.mask;
137 if (mask_before != mask_after) 135 if (mask_before != mask_after)
138 kvm_fire_mask_notifiers(ioapic->kvm, index, mask_after); 136 kvm_fire_mask_notifiers(ioapic->kvm, index, mask_after);
139 if (ioapic->irr & (1 << index)) 137 if (ioapic->redirtbl[index].fields.trig_mode == IOAPIC_LEVEL_TRIG
138 && ioapic->irr & (1 << index))
140 ioapic_service(ioapic, index); 139 ioapic_service(ioapic, index);
141 break; 140 break;
142 } 141 }
@@ -184,9 +183,10 @@ int kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level)
184 if (!level) 183 if (!level)
185 ioapic->irr &= ~mask; 184 ioapic->irr &= ~mask;
186 else { 185 else {
186 int edge = (entry.fields.trig_mode == IOAPIC_EDGE_TRIG);
187 ioapic->irr |= mask; 187 ioapic->irr |= mask;
188 if ((!entry.fields.trig_mode && old_irr != ioapic->irr) 188 if ((edge && old_irr != ioapic->irr) ||
189 || !entry.fields.remote_irr) 189 (!edge && !entry.fields.remote_irr))
190 ret = ioapic_service(ioapic, irq); 190 ret = ioapic_service(ioapic, irq);
191 } 191 }
192 } 192 }
diff --git a/virt/kvm/irq_comm.c b/virt/kvm/irq_comm.c
index a8bd466d00cc..ddc17f0e2f35 100644
--- a/virt/kvm/irq_comm.c
+++ b/virt/kvm/irq_comm.c
@@ -160,7 +160,8 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin)
160 unsigned gsi = pin; 160 unsigned gsi = pin;
161 161
162 list_for_each_entry(e, &kvm->irq_routing, link) 162 list_for_each_entry(e, &kvm->irq_routing, link)
163 if (e->irqchip.irqchip == irqchip && 163 if (e->type == KVM_IRQ_ROUTING_IRQCHIP &&
164 e->irqchip.irqchip == irqchip &&
164 e->irqchip.pin == pin) { 165 e->irqchip.pin == pin) {
165 gsi = e->gsi; 166 gsi = e->gsi;
166 break; 167 break;
@@ -259,6 +260,7 @@ static int setup_routing_entry(struct kvm_kernel_irq_routing_entry *e,
259 int delta; 260 int delta;
260 261
261 e->gsi = ue->gsi; 262 e->gsi = ue->gsi;
263 e->type = ue->type;
262 switch (ue->type) { 264 switch (ue->type) {
263 case KVM_IRQ_ROUTING_IRQCHIP: 265 case KVM_IRQ_ROUTING_IRQCHIP:
264 delta = 0; 266 delta = 0;