aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/DocBook/libata.tmpl5
-rw-r--r--Documentation/feature-removal-schedule.txt21
-rw-r--r--Documentation/kernel-parameters.txt2
-rw-r--r--Documentation/power/freezing-of-tasks.txt8
-rw-r--r--Documentation/thinkpad-acpi.txt353
-rw-r--r--Documentation/x86_64/boot-options.txt14
-rw-r--r--Documentation/x86_64/machinecheck14
-rw-r--r--MAINTAINERS15
-rw-r--r--arch/arm/Kconfig9
-rw-r--r--arch/arm/Kconfig.debug18
-rw-r--r--arch/arm/Makefile3
-rw-r--r--arch/arm/boot/Makefile8
-rw-r--r--arch/arm/boot/compressed/Makefile2
-rw-r--r--arch/arm/boot/compressed/head.S2
-rw-r--r--arch/arm/configs/em_x270_defconfig1265
-rw-r--r--arch/arm/configs/s3c2410_defconfig10
-rw-r--r--arch/arm/mach-at91/at91rm9200_devices.c10
-rw-r--r--arch/arm/mach-davinci/time.c2
-rw-r--r--arch/arm/mach-imx/time.c1
-rw-r--r--arch/arm/mach-iop32x/Kconfig7
-rw-r--r--arch/arm/mach-iop32x/Makefile1
-rw-r--r--arch/arm/mach-iop32x/em7210.c215
-rw-r--r--arch/arm/mach-iop32x/irq.c3
-rw-r--r--arch/arm/mach-ixp4xx/common.c4
-rw-r--r--arch/arm/mach-ks8695/irq.c1
-rw-r--r--arch/arm/mach-mx3/Kconfig12
-rw-r--r--arch/arm/mach-mx3/Makefile8
-rw-r--r--arch/arm/mach-mx3/Makefile.boot3
-rw-r--r--arch/arm/mach-mx3/mm.c64
-rw-r--r--arch/arm/mach-mx3/mx31ads.c142
-rw-r--r--arch/arm/mach-mx3/time.c152
-rw-r--r--arch/arm/mach-ns9xxx/Makefile1
-rw-r--r--arch/arm/mach-ns9xxx/board-a9m9750dev.c7
-rw-r--r--arch/arm/mach-ns9xxx/generic.c2
-rw-r--r--arch/arm/mach-ns9xxx/irq.c11
-rw-r--r--arch/arm/mach-ns9xxx/mach-cc9p9360js.c2
-rw-r--r--arch/arm/mach-omap1/time.c1
-rw-r--r--arch/arm/mach-pxa/Kconfig4
-rw-r--r--arch/arm/mach-pxa/Makefile1
-rw-r--r--arch/arm/mach-pxa/devices.h22
-rw-r--r--arch/arm/mach-pxa/em-x270.c354
-rw-r--r--arch/arm/mach-pxa/generic.c32
-rw-r--r--arch/arm/mach-pxa/pm.c169
-rw-r--r--arch/arm/mach-pxa/pxa25x.c109
-rw-r--r--arch/arm/mach-pxa/pxa27x.c151
-rw-r--r--arch/arm/mach-pxa/sleep.S112
-rw-r--r--arch/arm/mach-pxa/time.c258
-rw-r--r--arch/arm/mach-rpc/riscpc.c2
-rw-r--r--arch/arm/mach-s3c2410/Kconfig1
-rw-r--r--arch/arm/mach-s3c2410/clock.c2
-rw-r--r--arch/arm/mach-s3c2410/dma.c8
-rw-r--r--arch/arm/mach-s3c2410/mach-amlm5900.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-bast.c6
-rw-r--r--arch/arm/mach-s3c2410/mach-h1940.c4
-rw-r--r--arch/arm/mach-s3c2410/mach-n30.c4
-rw-r--r--arch/arm/mach-s3c2410/mach-otom.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-qt2410.c6
-rw-r--r--arch/arm/mach-s3c2410/mach-smdk2410.c2
-rw-r--r--arch/arm/mach-s3c2410/mach-vr1000.c2
-rw-r--r--arch/arm/mach-s3c2410/s3c2410.c3
-rw-r--r--arch/arm/mach-s3c2410/sleep.S2
-rw-r--r--arch/arm/mach-s3c2412/Kconfig1
-rw-r--r--arch/arm/mach-s3c2412/clock.c2
-rw-r--r--arch/arm/mach-s3c2412/dma.c8
-rw-r--r--arch/arm/mach-s3c2412/mach-smdk2413.c4
-rw-r--r--arch/arm/mach-s3c2412/mach-vstms.c4
-rw-r--r--arch/arm/mach-s3c2412/s3c2412.c5
-rw-r--r--arch/arm/mach-s3c2440/Kconfig1
-rw-r--r--arch/arm/mach-s3c2440/dma.c8
-rw-r--r--arch/arm/mach-s3c2440/mach-anubis.c4
-rw-r--r--arch/arm/mach-s3c2440/mach-nexcoder.c2
-rw-r--r--arch/arm/mach-s3c2440/mach-osiris.c4
-rw-r--r--arch/arm/mach-s3c2440/mach-rx3715.c4
-rw-r--r--arch/arm/mach-s3c2440/mach-smdk2440.c2
-rw-r--r--arch/arm/mach-s3c2442/Kconfig1
-rw-r--r--arch/arm/mach-s3c2443/Kconfig1
-rw-r--r--arch/arm/mach-s3c2443/dma.c8
-rw-r--r--arch/arm/mach-s3c2443/mach-smdk2443.c2
-rw-r--r--arch/arm/mach-sa1100/Kconfig13
-rw-r--r--arch/arm/mach-sa1100/Makefile2
-rw-r--r--arch/arm/mach-sa1100/jornada720_ssp.c201
-rw-r--r--arch/arm/mach-sa1100/neponset.c2
-rw-r--r--arch/arm/mm/Kconfig18
-rw-r--r--arch/arm/mm/cache-l2x0.c6
-rw-r--r--arch/arm/mm/mmu.c14
-rw-r--r--arch/arm/mm/proc-syms.c2
-rw-r--r--arch/arm/mm/proc-v7.S33
-rw-r--r--arch/arm/plat-iop/time.c8
-rw-r--r--arch/arm/plat-mxc/Kconfig20
-rw-r--r--arch/arm/plat-mxc/Makefile10
-rw-r--r--arch/arm/plat-mxc/irq.c83
-rw-r--r--arch/arm/plat-omap/timer32k.c2
-rw-r--r--arch/arm/plat-s3c/Kconfig104
-rw-r--r--arch/arm/plat-s3c24xx/Kconfig60
-rw-r--r--arch/arm/plat-s3c24xx/common-smdk.c2
-rw-r--r--arch/arm/plat-s3c24xx/cpu.c2
-rw-r--r--arch/arm/plat-s3c24xx/devs.c6
-rw-r--r--arch/arm/plat-s3c24xx/pm.c2
-rw-r--r--arch/arm/plat-s3c24xx/s3c244x.c3
-rw-r--r--arch/arm/plat-s3c24xx/sleep.S2
-rw-r--r--arch/arm/plat-s3c24xx/time.c2
-rw-r--r--arch/arm/vfp/vfphw.S12
-rw-r--r--arch/arm/vfp/vfpmodule.c12
-rw-r--r--arch/arm26/kernel/armksyms.c2
-rw-r--r--arch/arm26/kernel/irq.c6
-rw-r--r--arch/avr32/boards/atngw100/setup.c31
-rw-r--r--arch/avr32/configs/atngw100_defconfig16
-rw-r--r--arch/i386/Kconfig21
-rw-r--r--arch/i386/defconfig264
-rw-r--r--arch/i386/kernel/Makefile1
-rw-r--r--arch/i386/kernel/acpi/boot.c44
-rw-r--r--arch/i386/kernel/alternative.c69
-rw-r--r--arch/i386/kernel/apic.c10
-rw-r--r--arch/i386/kernel/cpu/Makefile1
-rw-r--r--arch/i386/kernel/cpu/amd.c11
-rw-r--r--arch/i386/kernel/cpu/common.c2
-rw-r--r--arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c4
-rw-r--r--arch/i386/kernel/cpu/cpufreq/gx-suspmod.c2
-rw-r--r--arch/i386/kernel/cpu/cyrix.c2
-rw-r--r--arch/i386/kernel/cpu/intel_cacheinfo.c79
-rw-r--r--arch/i386/kernel/cpu/mcheck/mce.c14
-rw-r--r--arch/i386/kernel/cpu/mcheck/non-fatal.c4
-rw-r--r--arch/i386/kernel/cpu/mtrr/cyrix.c1
-rw-r--r--arch/i386/kernel/cpu/mtrr/generic.c2
-rw-r--r--arch/i386/kernel/cpu/mtrr/main.c2
-rw-r--r--arch/i386/kernel/cpu/mtrr/state.c1
-rw-r--r--arch/i386/kernel/cpu/perfctr-watchdog.c10
-rw-r--r--arch/i386/kernel/cpu/rise.c52
-rw-r--r--arch/i386/kernel/e820.c32
-rw-r--r--arch/i386/kernel/geode.c155
-rw-r--r--arch/i386/kernel/hpet.c98
-rw-r--r--arch/i386/kernel/i8253.c32
-rw-r--r--arch/i386/kernel/io_apic.c26
-rw-r--r--arch/i386/kernel/irq.c8
-rw-r--r--arch/i386/kernel/kprobes.c9
-rw-r--r--arch/i386/kernel/nmi.c2
-rw-r--r--arch/i386/kernel/paravirt.c18
-rw-r--r--arch/i386/kernel/process.c12
-rw-r--r--arch/i386/kernel/reboot.c9
-rw-r--r--arch/i386/kernel/setup.c11
-rw-r--r--arch/i386/kernel/signal.c7
-rw-r--r--arch/i386/kernel/smpboot.c2
-rw-r--r--arch/i386/kernel/sysenter.c4
-rw-r--r--arch/i386/kernel/time.c50
-rw-r--r--arch/i386/kernel/traps.c27
-rw-r--r--arch/i386/kernel/vmiclock.c2
-rw-r--r--arch/i386/lib/Makefile2
-rw-r--r--arch/i386/lib/string.c257
-rw-r--r--arch/i386/mm/fault.c10
-rw-r--r--arch/i386/mm/init.c21
-rw-r--r--arch/i386/mm/ioremap.c2
-rw-r--r--arch/i386/mm/pageattr.c20
-rw-r--r--arch/i386/mm/pgtable.c6
-rw-r--r--arch/i386/pci/acpi.c32
-rw-r--r--arch/i386/pci/common.c13
-rw-r--r--arch/i386/pci/mmconfig-shared.c48
-rw-r--r--arch/i386/xen/time.c3
-rw-r--r--arch/i386/xen/xen-head.S2
-rw-r--r--arch/ia64/ia32/binfmt_elf32.c2
-rw-r--r--arch/m68k/kernel/ints.c4
-rw-r--r--arch/powerpc/boot/ps3-head.S2
-rw-r--r--arch/powerpc/boot/ps3-hvcall.S2
-rw-r--r--arch/powerpc/configs/prpmc2800_defconfig2
-rw-r--r--arch/powerpc/kernel/pci-common.c2
-rw-r--r--arch/powerpc/kernel/prom.c2
-rw-r--r--arch/powerpc/kernel/smp.c7
-rw-r--r--arch/powerpc/mm/fault.c8
-rw-r--r--arch/powerpc/mm/hash_utils_64.c4
-rw-r--r--arch/powerpc/mm/tlb_32.c2
-rw-r--r--arch/powerpc/platforms/Kconfig.cputype2
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c4
-rw-r--r--arch/powerpc/platforms/embedded6xx/Kconfig2
-rw-r--r--arch/powerpc/platforms/ps3/Kconfig36
-rw-r--r--arch/powerpc/platforms/pseries/firmware.c19
-rw-r--r--arch/powerpc/platforms/pseries/pseries.h2
-rw-r--r--arch/powerpc/platforms/pseries/setup.c17
-rw-r--r--arch/powerpc/sysdev/mpic.c32
-rw-r--r--arch/powerpc/xmon/nonstdio.c5
-rw-r--r--arch/powerpc/xmon/nonstdio.h3
-rw-r--r--arch/powerpc/xmon/start.c2
-rw-r--r--arch/powerpc/xmon/xmon.c2
-rw-r--r--arch/ppc/syslib/mv64x60.c15
-rw-r--r--arch/sh/kernel/timers/timer-tmu.c1
-rw-r--r--arch/sparc/kernel/entry.S14
-rw-r--r--arch/sparc/kernel/irq.c27
-rw-r--r--arch/sparc/kernel/irq.h68
-rw-r--r--arch/sparc/kernel/pcic.c1
-rw-r--r--arch/sparc/kernel/smp.c2
-rw-r--r--arch/sparc/kernel/sparc_ksyms.c2
-rw-r--r--arch/sparc/kernel/sun4c_irq.c15
-rw-r--r--arch/sparc/kernel/sun4d_irq.c6
-rw-r--r--arch/sparc/kernel/sun4d_smp.c1
-rw-r--r--arch/sparc/kernel/sun4m_irq.c74
-rw-r--r--arch/sparc/kernel/sun4m_smp.c2
-rw-r--r--arch/sparc/kernel/tick14.c6
-rw-r--r--arch/sparc/kernel/time.c2
-rw-r--r--arch/sparc/mm/init.c3
-rw-r--r--arch/sparc/mm/srmmu.c2
-rw-r--r--arch/sparc/mm/sun4c.c2
-rw-r--r--arch/sparc64/Kconfig4
-rw-r--r--arch/sparc64/kernel/sparc64_ksyms.c1
-rw-r--r--arch/sparc64/kernel/time.c54
-rw-r--r--arch/x86_64/Kconfig12
-rw-r--r--arch/x86_64/Makefile3
-rw-r--r--arch/x86_64/boot/compressed/Makefile2
-rw-r--r--arch/x86_64/defconfig288
-rw-r--r--arch/x86_64/ia32/ia32_binfmt.c1
-rw-r--r--arch/x86_64/ia32/ia32entry.S5
-rw-r--r--arch/x86_64/kernel/aperture.c4
-rw-r--r--arch/x86_64/kernel/apic.c77
-rw-r--r--arch/x86_64/kernel/e820.c138
-rw-r--r--arch/x86_64/kernel/early-quirks.c1
-rw-r--r--arch/x86_64/kernel/entry.S6
-rw-r--r--arch/x86_64/kernel/head.S8
-rw-r--r--arch/x86_64/kernel/hpet.c8
-rw-r--r--arch/x86_64/kernel/i8259.c18
-rw-r--r--arch/x86_64/kernel/io_apic.c58
-rw-r--r--arch/x86_64/kernel/kprobes.c10
-rw-r--r--arch/x86_64/kernel/mce.c255
-rw-r--r--arch/x86_64/kernel/mce_amd.c6
-rw-r--r--arch/x86_64/kernel/mpparse.c21
-rw-r--r--arch/x86_64/kernel/nmi.c17
-rw-r--r--arch/x86_64/kernel/pci-calgary.c570
-rw-r--r--arch/x86_64/kernel/pci-dma.c7
-rw-r--r--arch/x86_64/kernel/pci-gart.c27
-rw-r--r--arch/x86_64/kernel/pci-nommu.c8
-rw-r--r--arch/x86_64/kernel/pci-swiotlb.c2
-rw-r--r--arch/x86_64/kernel/process.c21
-rw-r--r--arch/x86_64/kernel/reboot.c4
-rw-r--r--arch/x86_64/kernel/setup.c12
-rw-r--r--arch/x86_64/kernel/signal.c9
-rw-r--r--arch/x86_64/kernel/smp.c6
-rw-r--r--arch/x86_64/kernel/suspend.c20
-rw-r--r--arch/x86_64/kernel/tce.c12
-rw-r--r--arch/x86_64/kernel/time.c158
-rw-r--r--arch/x86_64/kernel/traps.c6
-rw-r--r--arch/x86_64/kernel/tsc.c39
-rw-r--r--arch/x86_64/kernel/vmlinux.lds.S27
-rw-r--r--arch/x86_64/kernel/vsyscall.c22
-rw-r--r--arch/x86_64/mm/fault.c23
-rw-r--r--arch/x86_64/mm/init.c58
-rw-r--r--arch/x86_64/mm/k8topology.c13
-rw-r--r--arch/x86_64/mm/numa.c15
-rw-r--r--arch/x86_64/mm/pageattr.c25
-rw-r--r--arch/x86_64/mm/srat.c97
-rw-r--r--arch/x86_64/pci/k8-bus.c6
-rw-r--r--arch/x86_64/vdso/Makefile49
-rw-r--r--arch/x86_64/vdso/vclock_gettime.c120
-rw-r--r--arch/x86_64/vdso/vdso-note.S12
-rw-r--r--arch/x86_64/vdso/vdso-start.S2
-rw-r--r--arch/x86_64/vdso/vdso.S2
-rw-r--r--arch/x86_64/vdso/vdso.lds.S77
-rw-r--r--arch/x86_64/vdso/vextern.h16
-rw-r--r--arch/x86_64/vdso/vgetcpu.c50
-rw-r--r--arch/x86_64/vdso/vma.c139
-rw-r--r--arch/x86_64/vdso/voffset.h1
-rw-r--r--arch/x86_64/vdso/vvar.c12
-rw-r--r--block/Kconfig2
-rw-r--r--block/bsg.c61
-rw-r--r--block/scsi_ioctl.c13
-rw-r--r--drivers/acpi/Kconfig23
-rw-r--r--drivers/acpi/battery.c673
-rw-r--r--drivers/acpi/bay.c19
-rw-r--r--drivers/acpi/bus.c4
-rw-r--r--drivers/acpi/dock.c127
-rw-r--r--drivers/acpi/ec.c247
-rw-r--r--drivers/acpi/event.c153
-rw-r--r--drivers/acpi/events/evgpeblk.c4
-rw-r--r--drivers/acpi/events/evrgnini.c1
-rw-r--r--drivers/acpi/glue.c2
-rw-r--r--drivers/acpi/numa.c31
-rw-r--r--drivers/acpi/osl.c40
-rw-r--r--drivers/acpi/pci_link.c2
-rw-r--r--drivers/acpi/processor_core.c6
-rw-r--r--drivers/acpi/processor_idle.c20
-rw-r--r--drivers/acpi/processor_throttling.c410
-rw-r--r--drivers/acpi/sbs.c33
-rw-r--r--drivers/acpi/sleep/main.c5
-rw-r--r--drivers/acpi/system.c165
-rw-r--r--drivers/acpi/tables/tbfadt.c44
-rw-r--r--drivers/acpi/utilities/uteval.c17
-rw-r--r--drivers/acpi/video.c124
-rw-r--r--drivers/base/power/trace.c5
-rw-r--r--drivers/block/Makefile1
-rw-r--r--drivers/block/ps3disk.c630
-rw-r--r--drivers/char/Makefile2
-rw-r--r--drivers/char/hvc_iseries.c8
-rw-r--r--drivers/char/hvc_rtas.c2
-rw-r--r--drivers/char/hvcs.c8
-rw-r--r--drivers/char/hw_random/Kconfig2
-rw-r--r--drivers/char/ps3flash.c440
-rw-r--r--drivers/char/rtc.c2
-rw-r--r--drivers/char/watchdog/Kconfig16
-rw-r--r--drivers/char/watchdog/Makefile1
-rw-r--r--drivers/char/watchdog/iop_wdt.c262
-rw-r--r--drivers/clocksource/acpi_pm.c2
-rw-r--r--drivers/firewire/fw-sbp2.c2
-rw-r--r--drivers/input/misc/pcspkr.c11
-rw-r--r--drivers/isdn/Kconfig12
-rw-r--r--drivers/isdn/act2000/Kconfig2
-rw-r--r--drivers/isdn/gigaset/Kconfig10
-rw-r--r--drivers/isdn/hisax/Kconfig1
-rw-r--r--drivers/isdn/i4l/Kconfig3
-rw-r--r--drivers/isdn/icn/Kconfig2
-rw-r--r--drivers/isdn/pcbit/Kconfig2
-rw-r--r--drivers/isdn/sc/Kconfig2
-rw-r--r--drivers/kvm/Kconfig1
-rw-r--r--drivers/kvm/mmu.c2
-rw-r--r--drivers/leds/Kconfig22
-rw-r--r--drivers/leds/Makefile1
-rw-r--r--drivers/leds/led-class.c49
-rw-r--r--drivers/leds/led-triggers.c27
-rw-r--r--drivers/leds/leds-gpio.c199
-rw-r--r--drivers/leds/leds-locomo.c2
-rw-r--r--drivers/leds/leds.h8
-rw-r--r--drivers/leds/ledtrig-timer.c49
-rw-r--r--drivers/lguest/lguest.c2
-rw-r--r--drivers/macintosh/rack-meter.c1
-rw-r--r--drivers/md/dm-crypt.c2
-rw-r--r--drivers/message/fusion/Kconfig1
-rw-r--r--drivers/message/fusion/mptbase.c382
-rw-r--r--drivers/message/fusion/mptbase.h9
-rw-r--r--drivers/message/fusion/mptfc.c3
-rw-r--r--drivers/message/fusion/mptsas.c72
-rw-r--r--drivers/message/fusion/mptscsih.c153
-rw-r--r--drivers/message/fusion/mptscsih.h1
-rw-r--r--drivers/message/fusion/mptspi.c9
-rw-r--r--drivers/misc/Kconfig14
-rw-r--r--drivers/misc/sony-laptop.c368
-rw-r--r--drivers/misc/thinkpad_acpi.c602
-rw-r--r--drivers/misc/thinkpad_acpi.h42
-rw-r--r--drivers/mmc/host/at91_mci.c13
-rw-r--r--drivers/mmc/host/sdhci.c2
-rw-r--r--drivers/mmc/host/sdhci.h1
-rw-r--r--drivers/net/Kconfig1
-rw-r--r--drivers/net/arm/ether1.c3
-rw-r--r--drivers/net/arm/ether3.c3
-rw-r--r--drivers/net/arm/etherh.c1
-rw-r--r--drivers/net/irda/Kconfig11
-rw-r--r--drivers/net/irda/Makefile1
-rw-r--r--drivers/net/irda/ep7211-sir.c89
-rw-r--r--drivers/pcmcia/m8xx_pcmcia.c2
-rw-r--r--drivers/rtc/Kconfig13
-rw-r--r--drivers/rtc/Makefile1
-rw-r--r--drivers/rtc/rtc-ds1553.c2
-rw-r--r--drivers/rtc/rtc-ds1742.c2
-rw-r--r--drivers/rtc/rtc-max6900.c96
-rw-r--r--drivers/rtc/rtc-stk17ta8.c420
-rw-r--r--drivers/s390/scsi/zfcp_aux.c9
-rw-r--r--drivers/s390/scsi/zfcp_def.h1
-rw-r--r--drivers/s390/scsi/zfcp_erp.c3
-rw-r--r--drivers/s390/scsi/zfcp_fsf.c2
-rw-r--r--drivers/s390/scsi/zfcp_qdio.c113
-rw-r--r--drivers/scsi/3w-9xxx.c67
-rw-r--r--drivers/scsi/3w-9xxx.h5
-rw-r--r--drivers/scsi/Kconfig10
-rw-r--r--drivers/scsi/Makefile1
-rw-r--r--drivers/scsi/a4000t.c3
-rw-r--r--drivers/scsi/aacraid/aachba.c140
-rw-r--r--drivers/scsi/aacraid/aacraid.h14
-rw-r--r--drivers/scsi/aacraid/commsup.c16
-rw-r--r--drivers/scsi/aic94xx/aic94xx_dev.c2
-rw-r--r--drivers/scsi/aic94xx/aic94xx_init.c3
-rw-r--r--drivers/scsi/aic94xx/aic94xx_task.c20
-rw-r--r--drivers/scsi/arm/cumana_1.c207
-rw-r--r--drivers/scsi/arm/ecoscsi.c152
-rw-r--r--drivers/scsi/arm/oak.c74
-rw-r--r--drivers/scsi/bvme6000_scsi.c3
-rw-r--r--drivers/scsi/esp_scsi.h2
-rw-r--r--drivers/scsi/libsas/Kconfig7
-rw-r--r--drivers/scsi/libsas/Makefile1
-rw-r--r--drivers/scsi/libsas/sas_ata.c817
-rw-r--r--drivers/scsi/libsas/sas_discover.c402
-rw-r--r--drivers/scsi/libsas/sas_expander.c230
-rw-r--r--drivers/scsi/libsas/sas_init.c1
-rw-r--r--drivers/scsi/libsas/sas_internal.h3
-rw-r--r--drivers/scsi/libsas/sas_scsi_host.c74
-rw-r--r--drivers/scsi/mvme16x_scsi.c3
-rw-r--r--drivers/scsi/pcmcia/Kconfig7
-rw-r--r--drivers/scsi/ps3rom.c533
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c33
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c1114
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.h38
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h22
-rw-r--r--drivers/scsi/qla2xxx/qla_fw.h36
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h6
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c82
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c136
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h4
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c10
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c55
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c58
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c380
-rw-r--r--drivers/scsi/qla2xxx/qla_sup.c35
-rw-r--r--drivers/scsi/qla2xxx/qla_version.h2
-rw-r--r--drivers/scsi/scsi_debug.c2
-rw-r--r--drivers/scsi/scsi_sysctl.c1
-rw-r--r--drivers/scsi/scsi_sysfs.c16
-rw-r--r--drivers/scsi/scsi_transport_fc.c2
-rw-r--r--drivers/scsi/scsi_transport_sas.c125
-rw-r--r--drivers/scsi/seagate.c2
-rw-r--r--drivers/scsi/sim710.c3
-rw-r--r--drivers/scsi/sr.c2
-rw-r--r--drivers/scsi/wd33c93.c4
-rw-r--r--drivers/scsi/zorro7xx.c3
-rw-r--r--drivers/serial/imx.c2
-rw-r--r--drivers/serial/s3c2410.c2
-rw-r--r--drivers/spi/spi.c3
-rw-r--r--drivers/usb/misc/appledisplay.c4
-rw-r--r--drivers/video/Kconfig20
-rw-r--r--drivers/video/Makefile3
-rw-r--r--drivers/video/atmel_lcdfb.c67
-rw-r--r--drivers/video/aty/aty128fb.c2
-rw-r--r--drivers/video/aty/atyfb_base.c2
-rw-r--r--drivers/video/aty/radeon_backlight.c4
-rw-r--r--drivers/video/backlight/Kconfig26
-rw-r--r--drivers/video/backlight/backlight.c125
-rw-r--r--drivers/video/backlight/cr_bllcd.c2
-rw-r--r--drivers/video/backlight/lcd.c112
-rw-r--r--drivers/video/console/vgacon.c6
-rw-r--r--drivers/video/nvidia/nv_backlight.c2
-rw-r--r--drivers/video/ps3fb.c2
-rw-r--r--drivers/video/riva/fbdev.c4
-rw-r--r--fs/binfmt_elf.c109
-rw-r--r--fs/coda/dir.c1
-rw-r--r--fs/coda/file.c65
-rw-r--r--fs/coda/upcall.c49
-rw-r--r--fs/nfs/super.c2
-rw-r--r--fs/nfsd/export.c4
-rw-r--r--fs/proc/proc_misc.c3
-rw-r--r--fs/udf/balloc.c420
-rw-r--r--fs/udf/crc.c4
-rw-r--r--fs/udf/dir.c60
-rw-r--r--fs/udf/directory.c68
-rw-r--r--fs/udf/ecma_167.h684
-rw-r--r--fs/udf/file.c72
-rw-r--r--fs/udf/fsync.c2
-rw-r--r--fs/udf/ialloc.c38
-rw-r--r--fs/udf/inode.c948
-rw-r--r--fs/udf/lowlevel.c4
-rw-r--r--fs/udf/misc.c87
-rw-r--r--fs/udf/namei.c410
-rw-r--r--fs/udf/osta_udf.h164
-rw-r--r--fs/udf/partition.c212
-rw-r--r--fs/udf/super.c1023
-rw-r--r--fs/udf/symlink.c14
-rw-r--r--fs/udf/truncate.c113
-rw-r--r--fs/udf/udf_i.h2
-rw-r--r--fs/udf/udf_sb.h26
-rw-r--r--fs/udf/udfdecl.h4
-rw-r--r--fs/udf/udfend.h20
-rw-r--r--fs/udf/udftime.c82
-rw-r--r--fs/udf/unicode.c155
-rw-r--r--include/acpi/acmacros.h63
-rw-r--r--include/acpi/acoutput.h4
-rw-r--r--include/acpi/acpi_bus.h3
-rw-r--r--include/acpi/acpi_numa.h1
-rw-r--r--include/acpi/platform/acenv.h2
-rw-r--r--include/acpi/platform/aclinux.h3
-rw-r--r--include/acpi/processor.h47
-rw-r--r--include/asm-alpha/irq.h4
-rw-r--r--include/asm-arm/arch-at91/at91_mci.h3
-rw-r--r--include/asm-arm/arch-iop13xx/iop13xx.h43
-rw-r--r--include/asm-arm/arch-iop13xx/system.h34
-rw-r--r--include/asm-arm/arch-iop13xx/uncompress.h3
-rw-r--r--include/asm-arm/arch-iop32x/uncompress.h2
-rw-r--r--include/asm-arm/arch-mxc/board-mx31ads.h142
-rw-r--r--include/asm-arm/arch-mxc/common.h20
-rw-r--r--include/asm-arm/arch-mxc/dma.h21
-rw-r--r--include/asm-arm/arch-mxc/entry-macro.S39
-rw-r--r--include/asm-arm/arch-mxc/hardware.h52
-rw-r--r--include/asm-arm/arch-mxc/io.h33
-rw-r--r--include/asm-arm/arch-mxc/irqs.h38
-rw-r--r--include/asm-arm/arch-mxc/memory.h36
-rw-r--r--include/asm-arm/arch-mxc/mx31.h335
-rw-r--r--include/asm-arm/arch-mxc/mxc.h149
-rw-r--r--include/asm-arm/arch-mxc/system.h50
-rw-r--r--include/asm-arm/arch-mxc/timex.h25
-rw-r--r--include/asm-arm/arch-mxc/uncompress.h79
-rw-r--r--include/asm-arm/arch-mxc/vmalloc.h36
-rw-r--r--include/asm-arm/arch-ns9xxx/regs-bbu.h28
-rw-r--r--include/asm-arm/arch-ns9xxx/regs-mem.h6
-rw-r--r--include/asm-arm/arch-ns9xxx/regs-sys.h2
-rw-r--r--include/asm-arm/arch-pxa/pm.h16
-rw-r--r--include/asm-arm/arch-s3c2400/map.h66
-rw-r--r--include/asm-arm/arch-s3c2400/memory.h23
-rw-r--r--include/asm-arm/arch-s3c2410/debug-macro.S84
-rw-r--r--include/asm-arm/arch-s3c2410/map.h85
-rw-r--r--include/asm-arm/arch-s3c2410/memory.h13
-rw-r--r--include/asm-arm/arch-s3c2410/regs-lcd.h2
-rw-r--r--include/asm-arm/arch-s3c2410/system.h2
-rw-r--r--include/asm-arm/arch-s3c2410/uncompress.h145
-rw-r--r--include/asm-arm/arch-sa1100/jornada720.h27
-rw-r--r--include/asm-arm/elf.h3
-rw-r--r--include/asm-arm/floppy.h18
-rw-r--r--include/asm-arm/hardware/iop3xx.h33
-rw-r--r--include/asm-arm/pgtable-nommu.h3
-rw-r--r--include/asm-arm/plat-s3c/debug-macro.S75
-rw-r--r--include/asm-arm/plat-s3c/iic.h (renamed from include/asm-arm/arch-s3c2410/iic.h)0
-rw-r--r--include/asm-arm/plat-s3c/map.h40
-rw-r--r--include/asm-arm/plat-s3c/nand.h (renamed from include/asm-arm/arch-s3c2410/nand.h)0
-rw-r--r--include/asm-arm/plat-s3c/regs-ac97.h (renamed from include/asm-arm/arch-s3c2410/regs-ac97.h)0
-rw-r--r--include/asm-arm/plat-s3c/regs-adc.h (renamed from include/asm-arm/arch-s3c2410/regs-adc.h)0
-rw-r--r--include/asm-arm/plat-s3c/regs-iic.h (renamed from include/asm-arm/arch-s3c2410/regs-iic.h)0
-rw-r--r--include/asm-arm/plat-s3c/regs-nand.h (renamed from include/asm-arm/arch-s3c2410/regs-nand.h)0
-rw-r--r--include/asm-arm/plat-s3c/regs-rtc.h (renamed from include/asm-arm/arch-s3c2410/regs-rtc.h)0
-rw-r--r--include/asm-arm/plat-s3c/regs-serial.h (renamed from include/asm-arm/arch-s3c2410/regs-serial.h)8
-rw-r--r--include/asm-arm/plat-s3c/regs-timer.h (renamed from include/asm-arm/arch-s3c2410/regs-timer.h)16
-rw-r--r--include/asm-arm/plat-s3c/regs-watchdog.h (renamed from include/asm-arm/arch-s3c2410/regs-watchdog.h)8
-rw-r--r--include/asm-arm/plat-s3c/uncompress.h155
-rw-r--r--include/asm-arm/plat-s3c24xx/regs-iis.h (renamed from include/asm-arm/arch-s3c2410/regs-iis.h)0
-rw-r--r--include/asm-arm/plat-s3c24xx/regs-spi.h (renamed from include/asm-arm/arch-s3c2410/regs-spi.h)0
-rw-r--r--include/asm-arm/plat-s3c24xx/regs-udc.h (renamed from include/asm-arm/arch-s3c2410/regs-udc.h)0
-rw-r--r--include/asm-arm/plat-s3c24xx/udc.h (renamed from include/asm-arm/arch-s3c2410/udc.h)0
-rw-r--r--include/asm-arm/thread_info.h1
-rw-r--r--include/asm-arm/unistd.h1
-rw-r--r--include/asm-arm/vfp.h4
-rw-r--r--include/asm-arm26/irq.h5
-rw-r--r--include/asm-h8300/irq.h3
-rw-r--r--include/asm-i386/alternative.h2
-rw-r--r--include/asm-i386/cmpxchg.h2
-rw-r--r--include/asm-i386/e820.h8
-rw-r--r--include/asm-i386/geode.h159
-rw-r--r--include/asm-i386/hpet.h126
-rw-r--r--include/asm-i386/i8253.h16
-rw-r--r--include/asm-i386/mach-default/do_timer.h2
-rw-r--r--include/asm-i386/mach-default/io_ports.h5
-rw-r--r--include/asm-i386/mach-default/mach_reboot.h25
-rw-r--r--include/asm-i386/mach-voyager/do_timer.h2
-rw-r--r--include/asm-i386/mc146818rtc.h5
-rw-r--r--include/asm-i386/mce.h4
-rw-r--r--include/asm-i386/nmi.h2
-rw-r--r--include/asm-i386/page.h1
-rw-r--r--include/asm-i386/pci.h5
-rw-r--r--include/asm-i386/processor-cyrix.h30
-rw-r--r--include/asm-i386/processor.h12
-rw-r--r--include/asm-i386/resume-trace.h13
-rw-r--r--include/asm-i386/string.h243
-rw-r--r--include/asm-i386/timer.h2
-rw-r--r--include/asm-i386/tlbflush.h6
-rw-r--r--include/asm-i386/topology.h2
-rw-r--r--include/asm-i386/uaccess.h2
-rw-r--r--include/asm-ia64/irq.h3
-rw-r--r--include/asm-m68k/irq.h3
-rw-r--r--include/asm-powerpc/mpic.h3
-rw-r--r--include/asm-powerpc/prom.h2
-rw-r--r--include/asm-ppc/system.h1
-rw-r--r--include/asm-sh64/irq.h4
-rw-r--r--include/asm-sparc/irq.h166
-rw-r--r--include/asm-sparc/pgtable.h3
-rw-r--r--include/asm-v850/irq.h10
-rw-r--r--include/asm-x86_64/acpi.h11
-rw-r--r--include/asm-x86_64/alternative.h2
-rw-r--r--include/asm-x86_64/apic.h6
-rw-r--r--include/asm-x86_64/auxvec.h2
-rw-r--r--include/asm-x86_64/calgary.h9
-rw-r--r--include/asm-x86_64/cmpxchg.h2
-rw-r--r--include/asm-x86_64/dmi.h5
-rw-r--r--include/asm-x86_64/elf.h13
-rw-r--r--include/asm-x86_64/fixmap.h6
-rw-r--r--include/asm-x86_64/hpet.h62
-rw-r--r--include/asm-x86_64/hw_irq.h20
-rw-r--r--include/asm-x86_64/hypertransport.h43
-rw-r--r--include/asm-x86_64/i8253.h6
-rw-r--r--include/asm-x86_64/iommu.h29
-rw-r--r--include/asm-x86_64/mce.h5
-rw-r--r--include/asm-x86_64/mmu.h1
-rw-r--r--include/asm-x86_64/msidef.h48
-rw-r--r--include/asm-x86_64/nmi.h2
-rw-r--r--include/asm-x86_64/pci.h19
-rw-r--r--include/asm-x86_64/pgalloc.h73
-rw-r--r--include/asm-x86_64/pgtable.h3
-rw-r--r--include/asm-x86_64/processor.h12
-rw-r--r--include/asm-x86_64/proto.h20
-rw-r--r--include/asm-x86_64/ptrace.h1
-rw-r--r--include/asm-x86_64/resume-trace.h13
-rw-r--r--include/asm-x86_64/string.h5
-rw-r--r--include/asm-x86_64/system.h36
-rw-r--r--include/asm-x86_64/thread_info.h2
-rw-r--r--include/asm-x86_64/timex.h1
-rw-r--r--include/asm-x86_64/tlbflush.h6
-rw-r--r--include/asm-x86_64/topology.h2
-rw-r--r--include/asm-x86_64/vgtod.h29
-rw-r--r--include/asm-x86_64/vsyscall.h3
-rw-r--r--include/linux/acpi.h5
-rw-r--r--include/linux/audit.h32
-rw-r--r--include/linux/backlight.h11
-rw-r--r--include/linux/blkdev.h5
-rw-r--r--include/linux/bsg.h4
-rw-r--r--include/linux/clockchips.h5
-rw-r--r--include/linux/coda_linux.h1
-rw-r--r--include/linux/coda_psdev.h3
-rw-r--r--include/linux/compiler-gcc4.h18
-rw-r--r--include/linux/compiler.h9
-rw-r--r--include/linux/init.h8
-rw-r--r--include/linux/interrupt.h2
-rw-r--r--include/linux/irda.h1
-rw-r--r--include/linux/kernel.h8
-rw-r--r--include/linux/lcd.h14
-rw-r--r--include/linux/leds.h17
-rw-r--r--include/linux/libata.h1
-rw-r--r--include/linux/netdevice.h2
-rw-r--r--include/linux/of_platform.h4
-rw-r--r--include/linux/pci_ids.h4
-rw-r--r--include/linux/resume-trace.h19
-rw-r--r--include/linux/signal.h3
-rw-r--r--include/linux/time.h3
-rw-r--r--include/linux/vmalloc.h7
-rw-r--r--include/scsi/libsas.h15
-rw-r--r--include/scsi/sas_ata.h60
-rw-r--r--include/scsi/scsi_host.h2
-rw-r--r--include/scsi/scsi_transport_sas.h11
-rw-r--r--kernel/auditfilter.c13
-rw-r--r--kernel/auditsc.c51
-rw-r--r--kernel/hrtimer.c15
-rw-r--r--kernel/irq/proc.c10
-rw-r--r--kernel/power/Kconfig2
-rw-r--r--kernel/signal.c10
-rw-r--r--kernel/sysctl.c10
-rw-r--r--kernel/time/ntp.c59
-rw-r--r--kernel/time/tick-broadcast.c35
-rw-r--r--kernel/time/tick-common.c16
-rw-r--r--kernel/time/tick-oneshot.c15
-rw-r--r--kernel/time/tick-sched.c7
-rw-r--r--lib/swiotlb.c5
-rw-r--r--mm/memory.c2
-rw-r--r--mm/nommu.c45
-rw-r--r--mm/slob.c21
-rw-r--r--mm/sparse.c2
-rw-r--r--net/core/dev.c4
-rw-r--r--net/core/sock.c3
-rw-r--r--net/ipv4/inetpeer.c4
-rw-r--r--net/ipv6/ip6_tunnel.c4
-rw-r--r--net/irda/irnetlink.c2
-rw-r--r--security/selinux/avc.c15
635 files changed, 20824 insertions, 8949 deletions
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl
index e2e24b4778d4..ba9975771503 100644
--- a/Documentation/DocBook/libata.tmpl
+++ b/Documentation/DocBook/libata.tmpl
@@ -456,8 +456,9 @@ void (*irq_clear) (struct ata_port *);
456 456
457 <sect2><title>SATA phy read/write</title> 457 <sect2><title>SATA phy read/write</title>
458 <programlisting> 458 <programlisting>
459u32 (*scr_read) (struct ata_port *ap, unsigned int sc_reg); 459int (*scr_read) (struct ata_port *ap, unsigned int sc_reg,
460void (*scr_write) (struct ata_port *ap, unsigned int sc_reg, 460 u32 *val);
461int (*scr_write) (struct ata_port *ap, unsigned int sc_reg,
461 u32 val); 462 u32 val);
462 </programlisting> 463 </programlisting>
463 464
diff --git a/Documentation/feature-removal-schedule.txt b/Documentation/feature-removal-schedule.txt
index a5cb7839a679..c175eedadb5f 100644
--- a/Documentation/feature-removal-schedule.txt
+++ b/Documentation/feature-removal-schedule.txt
@@ -180,24 +180,11 @@ Who: Adrian Bunk <bunk@stusta.de>
180 180
181--------------------------- 181---------------------------
182 182
183What: /sys/firmware/acpi/namespace
184When: 2.6.21
185Why: The ACPI namespace is effectively the symbol list for
186 the BIOS. The device names are completely arbitrary
187 and have no place being exposed to user-space.
188
189 For those interested in the BIOS ACPI namespace,
190 the BIOS can be extracted and disassembled with acpidump
191 and iasl as documented in the pmtools package here:
192 http://ftp.kernel.org/pub/linux/kernel/people/lenb/acpi/utils
193Who: Len Brown <len.brown@intel.com>
194
195---------------------------
196
197What: ACPI procfs interface 183What: ACPI procfs interface
198When: July 2007 184When: July 2008
199Why: After ACPI sysfs conversion, ACPI attributes will be duplicated 185Why: ACPI sysfs conversion should be finished by January 2008.
200 in sysfs and the ACPI procfs interface should be removed. 186 ACPI procfs interface will be removed in July 2008 so that
187 there is enough time for the user space to catch up.
201Who: Zhang Rui <rui.zhang@intel.com> 188Who: Zhang Rui <rui.zhang@intel.com>
202 189
203--------------------------- 190---------------------------
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 5fbe07706ae9..fb80e9ffea68 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -1882,7 +1882,7 @@ and is between 256 and 4096 characters. It is defined in the file
1882 usbhid.mousepoll= 1882 usbhid.mousepoll=
1883 [USBHID] The interval which mice are to be polled at. 1883 [USBHID] The interval which mice are to be polled at.
1884 1884
1885 vdso= [IA-32,SH] 1885 vdso= [IA-32,SH,x86-64]
1886 vdso=2: enable compat VDSO (default with COMPAT_VDSO) 1886 vdso=2: enable compat VDSO (default with COMPAT_VDSO)
1887 vdso=1: enable VDSO (default) 1887 vdso=1: enable VDSO (default)
1888 vdso=0: disable VDSO mapping 1888 vdso=0: disable VDSO mapping
diff --git a/Documentation/power/freezing-of-tasks.txt b/Documentation/power/freezing-of-tasks.txt
index af1a282c71a3..04dc1cf9d215 100644
--- a/Documentation/power/freezing-of-tasks.txt
+++ b/Documentation/power/freezing-of-tasks.txt
@@ -155,6 +155,8 @@ Suppose, however, that the firmware file is located on a filesystem accessible
155only through another device that hasn't been resumed yet. In that case, 155only through another device that hasn't been resumed yet. In that case,
156request_firmware() will fail regardless of whether or not the freezing of tasks 156request_firmware() will fail regardless of whether or not the freezing of tasks
157is used. Consequently, the problem is not really related to the freezing of 157is used. Consequently, the problem is not really related to the freezing of
158tasks, since it generally exists anyway. [The solution to this particular 158tasks, since it generally exists anyway.
159problem is to keep the firmware in memory after it's loaded for the first time 159
160and upload if from memory to the device whenever necessary.] 160A driver must have all firmwares it may need in RAM before suspend() is called.
161If keeping them is not practical, for example due to their size, they must be
162requested early enough using the suspend notifier API described in notifiers.txt.
diff --git a/Documentation/thinkpad-acpi.txt b/Documentation/thinkpad-acpi.txt
index 9e6b94face4b..6711fbcf4080 100644
--- a/Documentation/thinkpad-acpi.txt
+++ b/Documentation/thinkpad-acpi.txt
@@ -1,11 +1,11 @@
1 ThinkPad ACPI Extras Driver 1 ThinkPad ACPI Extras Driver
2 2
3 Version 0.14 3 Version 0.15
4 April 21st, 2007 4 July 1st, 2007
5 5
6 Borislav Deianov <borislav@users.sf.net> 6 Borislav Deianov <borislav@users.sf.net>
7 Henrique de Moraes Holschuh <hmh@hmh.eng.br> 7 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
8 http://ibm-acpi.sf.net/ 8 http://ibm-acpi.sf.net/
9 9
10 10
11This is a Linux driver for the IBM and Lenovo ThinkPad laptops. It 11This is a Linux driver for the IBM and Lenovo ThinkPad laptops. It
@@ -134,54 +134,68 @@ end of this document. Changes to the sysfs interface done by the kernel
134subsystems are not documented here, nor are they tracked by this 134subsystems are not documented here, nor are they tracked by this
135attribute. 135attribute.
136 136
137Changes to the thinkpad-acpi sysfs interface are only considered
138non-experimental when they are submitted to Linux mainline, at which
139point the changes in this interface are documented and interface_version
140may be updated. If you are using any thinkpad-acpi features not yet
141sent to mainline for merging, you do so on your own risk: these features
142may disappear, or be implemented in a different and incompatible way by
143the time they are merged in Linux mainline.
144
145Changes that are backwards-compatible by nature (e.g. the addition of
146attributes that do not change the way the other attributes work) do not
147always warrant an update of interface_version. Therefore, one must
148expect that an attribute might not be there, and deal with it properly
149(an attribute not being there *is* a valid way to make it clear that a
150feature is not available in sysfs).
151
137Hot keys 152Hot keys
138-------- 153--------
139 154
140procfs: /proc/acpi/ibm/hotkey 155procfs: /proc/acpi/ibm/hotkey
141sysfs device attribute: hotkey_* 156sysfs device attribute: hotkey_*
142 157
143Without this driver, only the Fn-F4 key (sleep button) generates an 158In a ThinkPad, the ACPI HKEY handler is responsible for comunicating
144ACPI event. With the driver loaded, the hotkey feature enabled and the 159some important events and also keyboard hot key presses to the operating
145mask set (see below), the various hot keys generate ACPI events in the 160system. Enabling the hotkey functionality of thinkpad-acpi signals the
161firmware that such a driver is present, and modifies how the ThinkPad
162firmware will behave in many situations.
163
164When the hotkey feature is enabled and the hot key mask is set (see
165below), the various hot keys either generate ACPI events in the
146following format: 166following format:
147 167
148 ibm/hotkey HKEY 00000080 0000xxxx 168 ibm/hotkey HKEY 00000080 0000xxxx
149 169
150The last four digits vary depending on the key combination pressed. 170or events over the input layer. The input layer support accepts the
151All labeled Fn-Fx key combinations generate distinct events. In 171standard IOCTLs to remap the keycodes assigned to each hotkey.
152addition, the lid microswitch and some docking station buttons may 172
153also generate such events. 173When the input device is open, the driver will suppress any ACPI hot key
154 174events that get translated into a meaningful input layer event, in order
155The bit mask allows some control over which hot keys generate ACPI 175to avoid sending duplicate events to userspace. Hot keys that are
156events. Not all bits in the mask can be modified. Not all bits that 176mapped to KEY_RESERVED in the keymap are not translated, and will always
157can be modified do anything. Not all hot keys can be individually 177generate an ACPI ibm/hotkey HKEY event, and no input layer events.
158controlled by the mask. Most recent ThinkPad models honor the 178
159following bits (assuming the hot keys feature has been enabled): 179The hot key bit mask allows some control over which hot keys generate
160 180events. If a key is "masked" (bit set to 0 in the mask), the firmware
161 key bit behavior when set behavior when unset 181will handle it. If it is "unmasked", it signals the firmware that
162 182thinkpad-acpi would prefer to handle it, if the firmware would be so
163 Fn-F3 always generates ACPI event 183kind to allow it (and it often doesn't!).
164 Fn-F4 always generates ACPI event 184
165 Fn-F5 0010 generate ACPI event enable/disable Bluetooth 185Not all bits in the mask can be modified. Not all bits that can be
166 Fn-F7 0040 generate ACPI event switch LCD and external display 186modified do anything. Not all hot keys can be individually controlled
167 Fn-F8 0080 generate ACPI event expand screen or none 187by the mask. Some models do not support the mask at all, and in those
168 Fn-F9 0100 generate ACPI event none 188models, hot keys cannot be controlled individually. The behaviour of
169 Fn-F12 always generates ACPI event 189the mask is, therefore, higly dependent on the ThinkPad model.
170 190
171Some models do not support all of the above. For example, the T30 does 191Note that unmasking some keys prevents their default behavior. For
172not support Fn-F5 and Fn-F9. Other models do not support the mask at 192example, if Fn+F5 is unmasked, that key will no longer enable/disable
173all. On those models, hot keys cannot be controlled individually. 193Bluetooth by itself.
174 194
175Note that enabling ACPI events for some keys prevents their default 195Note also that not all Fn key combinations are supported through ACPI.
176behavior. For example, if events for Fn-F5 are enabled, that key will 196For example, on the X40, the brightness, volume and "Access IBM" buttons
177no longer enable/disable Bluetooth by itself. This can still be done 197do not generate ACPI events even with this driver. They *can* be used
178from an acpid handler for the ibm/hotkey event. 198through the "ThinkPad Buttons" utility, see http://www.nongnu.org/tpb/
179
180Note also that not all Fn key combinations are supported through
181ACPI. For example, on the X40, the brightness, volume and "Access IBM"
182buttons do not generate ACPI events even with this driver. They *can*
183be used through the "ThinkPad Buttons" utility, see
184http://www.nongnu.org/tpb/
185 199
186procfs notes: 200procfs notes:
187 201
@@ -189,9 +203,9 @@ The following commands can be written to the /proc/acpi/ibm/hotkey file:
189 203
190 echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature 204 echo enable > /proc/acpi/ibm/hotkey -- enable the hot keys feature
191 echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature 205 echo disable > /proc/acpi/ibm/hotkey -- disable the hot keys feature
192 echo 0xffff > /proc/acpi/ibm/hotkey -- enable all possible hot keys 206 echo 0xffffffff > /proc/acpi/ibm/hotkey -- enable all hot keys
193 echo 0x0000 > /proc/acpi/ibm/hotkey -- disable all possible hot keys 207 echo 0 > /proc/acpi/ibm/hotkey -- disable all possible hot keys
194 ... any other 4-hex-digit mask ... 208 ... any other 8-hex-digit mask ...
195 echo reset > /proc/acpi/ibm/hotkey -- restore the original mask 209 echo reset > /proc/acpi/ibm/hotkey -- restore the original mask
196 210
197sysfs notes: 211sysfs notes:
@@ -202,7 +216,7 @@ sysfs notes:
202 key feature status will be restored to this value. 216 key feature status will be restored to this value.
203 217
204 0: hot keys were disabled 218 0: hot keys were disabled
205 1: hot keys were enabled 219 1: hot keys were enabled (unusual)
206 220
207 hotkey_bios_mask: 221 hotkey_bios_mask:
208 Returns the hot keys mask when thinkpad-acpi was loaded. 222 Returns the hot keys mask when thinkpad-acpi was loaded.
@@ -217,9 +231,182 @@ sysfs notes:
217 1: enables the hot keys feature / feature enabled 231 1: enables the hot keys feature / feature enabled
218 232
219 hotkey_mask: 233 hotkey_mask:
220 bit mask to enable ACPI event generation for each hot 234 bit mask to enable driver-handling and ACPI event
221 key (see above). Returns the current status of the hot 235 generation for each hot key (see above). Returns the
222 keys mask, and allows one to modify it. 236 current status of the hot keys mask, and allows one to
237 modify it.
238
239 hotkey_all_mask:
240 bit mask that should enable event reporting for all
241 supported hot keys, when echoed to hotkey_mask above.
242 Unless you know which events need to be handled
243 passively (because the firmware *will* handle them
244 anyway), do *not* use hotkey_all_mask. Use
245 hotkey_recommended_mask, instead. You have been warned.
246
247 hotkey_recommended_mask:
248 bit mask that should enable event reporting for all
249 supported hot keys, except those which are always
250 handled by the firmware anyway. Echo it to
251 hotkey_mask above, to use.
252
253 hotkey_radio_sw:
254 if the ThinkPad has a hardware radio switch, this
255 attribute will read 0 if the switch is in the "radios
256 disabled" postition, and 1 if the switch is in the
257 "radios enabled" position.
258
259input layer notes:
260
261A Hot key is mapped to a single input layer EV_KEY event, possibly
262followed by an EV_MSC MSC_SCAN event that shall contain that key's scan
263code. An EV_SYN event will always be generated to mark the end of the
264event block.
265
266Do not use the EV_MSC MSC_SCAN events to process keys. They are to be
267used as a helper to remap keys, only. They are particularly useful when
268remapping KEY_UNKNOWN keys.
269
270The events are available in an input device, with the following id:
271
272 Bus: BUS_HOST
273 vendor: 0x1014 (PCI_VENDOR_ID_IBM) or
274 0x17aa (PCI_VENDOR_ID_LENOVO)
275 product: 0x5054 ("TP")
276 version: 0x4101
277
278The version will have its LSB incremented if the keymap changes in a
279backwards-compatible way. The MSB shall always be 0x41 for this input
280device. If the MSB is not 0x41, do not use the device as described in
281this section, as it is either something else (e.g. another input device
282exported by a thinkpad driver, such as HDAPS) or its functionality has
283been changed in a non-backwards compatible way.
284
285Adding other event types for other functionalities shall be considered a
286backwards-compatible change for this input device.
287
288Thinkpad-acpi Hot Key event map (version 0x4101):
289
290ACPI Scan
291event code Key Notes
292
2930x1001 0x00 FN+F1 -
2940x1002 0x01 FN+F2 IBM: battery (rare)
295 Lenovo: Screen lock
296
2970x1003 0x02 FN+F3 Many IBM models always report
298 this hot key, even with hot keys
299 disabled or with Fn+F3 masked
300 off
301 IBM: screen lock
302 Lenovo: battery
303
3040x1004 0x03 FN+F4 Sleep button (ACPI sleep button
305 semanthics, i.e. sleep-to-RAM).
306 It is always generate some kind
307 of event, either the hot key
308 event or a ACPI sleep button
309 event. The firmware may
310 refuse to generate further FN+F4
311 key presses until a S3 or S4 ACPI
312 sleep cycle is performed or some
313 time passes.
314
3150x1005 0x04 FN+F5 Radio. Enables/disables
316 the internal BlueTooth hardware
317 and W-WAN card if left in control
318 of the firmware. Does not affect
319 the WLAN card.
320 Should be used to turn on/off all
321 radios (bluetooth+W-WAN+WLAN),
322 really.
323
3240x1006 0x05 FN+F6 -
325
3260x1007 0x06 FN+F7 Video output cycle.
327 Do you feel lucky today?
328
3290x1008 0x07 FN+F8 IBM: toggle screen expand
330 Lenovo: configure ultranav
331
3320x1009 0x08 FN+F9 -
333 .. .. ..
3340x100B 0x0A FN+F11 -
335
3360x100C 0x0B FN+F12 Sleep to disk. You are always
337 supposed to handle it yourself,
338 either through the ACPI event,
339 or through a hotkey event.
340 The firmware may refuse to
341 generate further FN+F4 key
342 press events until a S3 or S4
343 ACPI sleep cycle is performed,
344 or some time passes.
345
3460x100D 0x0C FN+BACKSPACE -
3470x100E 0x0D FN+INSERT -
3480x100F 0x0E FN+DELETE -
349
3500x1010 0x0F FN+HOME Brightness up. This key is
351 always handled by the firmware
352 in IBM ThinkPads, even when
353 unmasked. Just leave it alone.
354 For Lenovo ThinkPads with a new
355 BIOS, it has to be handled either
356 by the ACPI OSI, or by userspace.
3570x1011 0x10 FN+END Brightness down. See brightness
358 up for details.
359
3600x1012 0x11 FN+PGUP Thinklight toggle. This key is
361 always handled by the firmware,
362 even when unmasked.
363
3640x1013 0x12 FN+PGDOWN -
365
3660x1014 0x13 FN+SPACE Zoom key
367
3680x1015 0x14 VOLUME UP Internal mixer volume up. This
369 key is always handled by the
370 firmware, even when unmasked.
371 NOTE: Lenovo seems to be changing
372 this.
3730x1016 0x15 VOLUME DOWN Internal mixer volume up. This
374 key is always handled by the
375 firmware, even when unmasked.
376 NOTE: Lenovo seems to be changing
377 this.
3780x1017 0x16 MUTE Mute internal mixer. This
379 key is always handled by the
380 firmware, even when unmasked.
381
3820x1018 0x17 THINKPAD Thinkpad/Access IBM/Lenovo key
383
3840x1019 0x18 unknown
385.. .. ..
3860x1020 0x1F unknown
387
388The ThinkPad firmware does not allow one to differentiate when most hot
389keys are pressed or released (either that, or we don't know how to, yet).
390For these keys, the driver generates a set of events for a key press and
391immediately issues the same set of events for a key release. It is
392unknown by the driver if the ThinkPad firmware triggered these events on
393hot key press or release, but the firmware will do it for either one, not
394both.
395
396If a key is mapped to KEY_RESERVED, it generates no input events at all,
397and it may generate a legacy thinkpad-acpi ACPI hotkey event.
398
399If a key is mapped to KEY_UNKNOWN, it generates an input event that
400includes an scan code, and it may also generate a legacy thinkpad-acpi
401ACPI hotkey event.
402
403If a key is mapped to anything else, it will only generate legacy
404thinkpad-acpi ACPI hotkey events if nobody has opened the input device.
405
406Non hot-key ACPI HKEY event map:
4070x5001 Lid closed
4080x5002 Lid opened
4090x7000 Radio Switch may have changed state
223 410
224 411
225Bluetooth 412Bluetooth
@@ -437,27 +624,34 @@ CMOS control
437procfs: /proc/acpi/ibm/cmos 624procfs: /proc/acpi/ibm/cmos
438sysfs device attribute: cmos_command 625sysfs device attribute: cmos_command
439 626
440This feature is used internally by the ACPI firmware to control the 627This feature is mostly used internally by the ACPI firmware to keep the legacy
441ThinkLight on most newer ThinkPad models. It may also control LCD 628CMOS NVRAM bits in sync with the current machine state, and to record this
442brightness, sounds volume and more, but only on some models. 629state so that the ThinkPad will retain such settings across reboots.
630
631Some of these commands actually perform actions in some ThinkPad models, but
632this is expected to disappear more and more in newer models. As an example, in
633a T43 and in a X40, commands 12 and 13 still control the ThinkLight state for
634real, but commands 0 to 2 don't control the mixer anymore (they have been
635phased out) and just update the NVRAM.
443 636
444The range of valid cmos command numbers is 0 to 21, but not all have an 637The range of valid cmos command numbers is 0 to 21, but not all have an
445effect and the behavior varies from model to model. Here is the behavior 638effect and the behavior varies from model to model. Here is the behavior
446on the X40 (tpb is the ThinkPad Buttons utility): 639on the X40 (tpb is the ThinkPad Buttons utility):
447 640
448 0 - no effect but tpb reports "Volume down" 641 0 - Related to "Volume down" key press
449 1 - no effect but tpb reports "Volume up" 642 1 - Related to "Volume up" key press
450 2 - no effect but tpb reports "Mute on" 643 2 - Related to "Mute on" key press
451 3 - simulate pressing the "Access IBM" button 644 3 - Related to "Access IBM" key press
452 4 - LCD brightness up 645 4 - Related to "LCD brightness up" key pess
453 5 - LCD brightness down 646 5 - Related to "LCD brightness down" key press
454 11 - toggle screen expansion 647 11 - Related to "toggle screen expansion" key press/function
455 12 - ThinkLight on 648 12 - Related to "ThinkLight on"
456 13 - ThinkLight off 649 13 - Related to "ThinkLight off"
457 14 - no effect but tpb reports ThinkLight status change 650 14 - Related to "ThinkLight" key press (toggle thinklight)
458 651
459The cmos command interface is prone to firmware split-brain problems, as 652The cmos command interface is prone to firmware split-brain problems, as
460in newer ThinkPads it is just a compatibility layer. 653in newer ThinkPads it is just a compatibility layer. Do not use it, it is
654exported just as a debug tool.
461 655
462LED control -- /proc/acpi/ibm/led 656LED control -- /proc/acpi/ibm/led
463--------------------------------- 657---------------------------------
@@ -516,23 +710,15 @@ Temperature sensors
516procfs: /proc/acpi/ibm/thermal 710procfs: /proc/acpi/ibm/thermal
517sysfs device attributes: (hwmon) temp*_input 711sysfs device attributes: (hwmon) temp*_input
518 712
519Most ThinkPads include six or more separate temperature sensors but 713Most ThinkPads include six or more separate temperature sensors but only
520only expose the CPU temperature through the standard ACPI methods. 714expose the CPU temperature through the standard ACPI methods. This
521This feature shows readings from up to eight different sensors on older 715feature shows readings from up to eight different sensors on older
522ThinkPads, and it has experimental support for up to sixteen different 716ThinkPads, and up to sixteen different sensors on newer ThinkPads.
523sensors on newer ThinkPads.
524
525EXPERIMENTAL: The 16-sensors feature is marked EXPERIMENTAL because the
526implementation directly accesses hardware registers and may not work as
527expected. USE WITH CAUTION! To use this feature, you need to supply the
528experimental=1 parameter when loading the module. When EXPERIMENTAL
529mode is enabled, reading the first 8 sensors on newer ThinkPads will
530also use an new experimental thermal sensor access mode.
531 717
532For example, on the X40, a typical output may be: 718For example, on the X40, a typical output may be:
533temperatures: 42 42 45 41 36 -128 33 -128 719temperatures: 42 42 45 41 36 -128 33 -128
534 720
535EXPERIMENTAL: On the T43/p, a typical output may be: 721On the T43/p, a typical output may be:
536temperatures: 48 48 36 52 38 -128 31 -128 48 52 48 -128 -128 -128 -128 -128 722temperatures: 48 48 36 52 38 -128 31 -128 48 52 48 -128 -128 -128 -128 -128
537 723
538The mapping of thermal sensors to physical locations varies depending on 724The mapping of thermal sensors to physical locations varies depending on
@@ -562,7 +748,8 @@ http://thinkwiki.org/wiki/Thermal_Sensors#ThinkPad_T43.2C_T43p
5622: System board, left side (near PCMCIA slot), reported as HDAPS temp 7482: System board, left side (near PCMCIA slot), reported as HDAPS temp
5633: PCMCIA slot 7493: PCMCIA slot
5649: MCH (northbridge) to DRAM Bus 7509: MCH (northbridge) to DRAM Bus
56510: ICH (southbridge), under Mini-PCI card, under touchpad 75110: Clock-generator, mini-pci card and ICH (southbridge), under Mini-PCI
752 card, under touchpad
56611: Power regulator, underside of system board, below F2 key 75311: Power regulator, underside of system board, below F2 key
567 754
568The A31 has a very atypical layout for the thermal sensors 755The A31 has a very atypical layout for the thermal sensors
@@ -681,6 +868,12 @@ cannot be controlled.
681The backlight control has eight levels, ranging from 0 to 7. Some of the 868The backlight control has eight levels, ranging from 0 to 7. Some of the
682levels may not be distinct. 869levels may not be distinct.
683 870
871There are two interfaces to the firmware for brightness control, EC and CMOS.
872To select which one should be used, use the brightness_mode module parameter:
873brightness_mode=1 selects EC mode, brightness_mode=2 selects CMOS mode,
874brightness_mode=3 selects both EC and CMOS. The driver tries to autodetect
875which interface to use.
876
684Procfs notes: 877Procfs notes:
685 878
686 The available commands are: 879 The available commands are:
@@ -976,3 +1169,9 @@ Sysfs interface changelog:
976 1169
9770x000100: Initial sysfs support, as a single platform driver and 11700x000100: Initial sysfs support, as a single platform driver and
978 device. 1171 device.
11720x000200: Hot key support for 32 hot keys, and radio slider switch
1173 support.
11740x010000: Hot keys are now handled by default over the input
1175 layer, the radio switch generates input event EV_RADIO,
1176 and the driver enables hot key handling by default in
1177 the firmware.
diff --git a/Documentation/x86_64/boot-options.txt b/Documentation/x86_64/boot-options.txt
index 6177d881983f..945311840a10 100644
--- a/Documentation/x86_64/boot-options.txt
+++ b/Documentation/x86_64/boot-options.txt
@@ -14,9 +14,11 @@ Machine check
14 mce=nobootlog 14 mce=nobootlog
15 Disable boot machine check logging. 15 Disable boot machine check logging.
16 mce=tolerancelevel (number) 16 mce=tolerancelevel (number)
17 0: always panic, 1: panic if deadlock possible, 17 0: always panic on uncorrected errors, log corrected errors
18 2: try to avoid panic, 3: never panic or exit (for testing) 18 1: panic or SIGBUS on uncorrected errors, log corrected errors
19 default is 1 19 2: SIGBUS or log uncorrected errors, log corrected errors
20 3: never panic or SIGBUS, log all errors (for testing only)
21 Default is 1
20 Can be also set using sysfs which is preferable. 22 Can be also set using sysfs which is preferable.
21 23
22 nomce (for compatibility with i386): same as mce=off 24 nomce (for compatibility with i386): same as mce=off
@@ -134,12 +136,6 @@ Non Executable Mappings
134 136
135SMP 137SMP
136 138
137 nosmp Only use a single CPU
138
139 maxcpus=NUMBER only use upto NUMBER CPUs
140
141 cpumask=MASK only use cpus with bits set in mask
142
143 additional_cpus=NUM Allow NUM more CPUs for hotplug 139 additional_cpus=NUM Allow NUM more CPUs for hotplug
144 (defaults are specified by the BIOS, see Documentation/x86_64/cpu-hotplug-spec) 140 (defaults are specified by the BIOS, see Documentation/x86_64/cpu-hotplug-spec)
145 141
diff --git a/Documentation/x86_64/machinecheck b/Documentation/x86_64/machinecheck
index feaeaf6f6e4d..a05e58e7b159 100644
--- a/Documentation/x86_64/machinecheck
+++ b/Documentation/x86_64/machinecheck
@@ -49,12 +49,14 @@ tolerant
49 Since machine check exceptions can happen any time it is sometimes 49 Since machine check exceptions can happen any time it is sometimes
50 risky for the kernel to kill a process because it defies 50 risky for the kernel to kill a process because it defies
51 normal kernel locking rules. The tolerance level configures 51 normal kernel locking rules. The tolerance level configures
52 how hard the kernel tries to recover even at some risk of deadlock. 52 how hard the kernel tries to recover even at some risk of
53 53 deadlock. Higher tolerant values trade potentially better uptime
54 0: always panic, 54 with the risk of a crash or even corruption (for tolerant >= 3).
55 1: panic if deadlock possible, 55
56 2: try to avoid panic, 56 0: always panic on uncorrected errors, log corrected errors
57 3: never panic or exit (for testing only) 57 1: panic or SIGBUS on uncorrected errors, log corrected errors
58 2: SIGBUS or log uncorrected errors, log corrected errors
59 3: never panic or SIGBUS, log all errors (for testing only)
58 60
59 Default: 1 61 Default: 1
60 62
diff --git a/MAINTAINERS b/MAINTAINERS
index f49c5563f060..01f222e51871 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -225,15 +225,15 @@ T: git kernel.org:/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6.git
225S: Supported 225S: Supported
226 226
227ACPI BATTERY DRIVERS 227ACPI BATTERY DRIVERS
228P: Vladimir P. Lebedev 228P: Alexey Starikovskiy
229M: vladimir.p.lebedev@intel.com 229M: astarikovskiy@suse.de
230L: linux-acpi@vger.kernel.org 230L: linux-acpi@vger.kernel.org
231W: http://acpi.sourceforge.net/ 231W: http://acpi.sourceforge.net/
232S: Supported 232S: Supported
233 233
234ACPI EC DRIVER 234ACPI EC DRIVER
235P: Alexey Starikovskiy 235P: Alexey Starikovskiy
236M: alexey.y.starikovskiy@linux.intel.com 236M: astarikovskiy@suse.de
237L: linux-acpi@vger.kernel.org 237L: linux-acpi@vger.kernel.org
238W: http://acpi.sourceforge.net/ 238W: http://acpi.sourceforge.net/
239S: Supported 239S: Supported
@@ -463,7 +463,7 @@ S: Maintained
463 463
464ARM/HP JORNADA 7XX MACHINE SUPPORT 464ARM/HP JORNADA 7XX MACHINE SUPPORT
465P: Kristoffer Ericson 465P: Kristoffer Ericson
466M: kristoffer_e1@hotmail.com 466M: kristoffer.ericson@gmail.com
467W: www.jlime.com 467W: www.jlime.com
468S: Maintained 468S: Maintained
469 469
@@ -651,7 +651,12 @@ W: http://linux-atm.sourceforge.net
651S: Maintained 651S: Maintained
652 652
653ATMEL AT91 MCI DRIVER 653ATMEL AT91 MCI DRIVER
654S: Orphan 654P: Nicolas Ferre
655M: nicolas.ferre@rfo.atmel.com
656L: linux-arm-kernel@lists.arm.linux.org.uk (subscribers-only)
657W: http://www.atmel.com/products/AT91/
658W: http://www.at91.com/
659S: Maintained
655 660
656ATMEL MACB ETHERNET DRIVER 661ATMEL MACB ETHERNET DRIVER
657P: Haavard Skinnemoen 662P: Haavard Skinnemoen
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a44c6da9bf83..85016313bd11 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -324,6 +324,12 @@ config ARCH_NS9XXX
324 324
325 <http://www.digi.com/products/microprocessors/index.jsp> 325 <http://www.digi.com/products/microprocessors/index.jsp>
326 326
327config ARCH_MXC
328 bool "Freescale MXC/iMX-based"
329 select ARCH_MTD_XIP
330 help
331 Support for Freescale MXC/iMX-based family of processors
332
327config ARCH_PNX4008 333config ARCH_PNX4008
328 bool "Philips Nexperia PNX4008 Mobile" 334 bool "Philips Nexperia PNX4008 Mobile"
329 help 335 help
@@ -432,6 +438,7 @@ source "arch/arm/mach-omap1/Kconfig"
432source "arch/arm/mach-omap2/Kconfig" 438source "arch/arm/mach-omap2/Kconfig"
433 439
434source "arch/arm/plat-s3c24xx/Kconfig" 440source "arch/arm/plat-s3c24xx/Kconfig"
441source "arch/arm/plat-s3c/Kconfig"
435 442
436if ARCH_S3C2410 443if ARCH_S3C2410
437source "arch/arm/mach-s3c2400/Kconfig" 444source "arch/arm/mach-s3c2400/Kconfig"
@@ -456,6 +463,8 @@ source "arch/arm/mach-realview/Kconfig"
456 463
457source "arch/arm/mach-at91/Kconfig" 464source "arch/arm/mach-at91/Kconfig"
458 465
466source "arch/arm/plat-mxc/Kconfig"
467
459source "arch/arm/mach-netx/Kconfig" 468source "arch/arm/mach-netx/Kconfig"
460 469
461source "arch/arm/mach-ns9xxx/Kconfig" 470source "arch/arm/mach-ns9xxx/Kconfig"
diff --git a/arch/arm/Kconfig.debug b/arch/arm/Kconfig.debug
index 40c5eb1f55c7..18101f5f5f24 100644
--- a/arch/arm/Kconfig.debug
+++ b/arch/arm/Kconfig.debug
@@ -82,24 +82,24 @@ config DEBUG_CLPS711X_UART2
82 output to the second serial port on these devices. Saying N will 82 output to the second serial port on these devices. Saying N will
83 cause the debug messages to appear on the first serial port. 83 cause the debug messages to appear on the first serial port.
84 84
85config DEBUG_S3C2410_PORT 85config DEBUG_S3C_PORT
86 depends on DEBUG_LL && ARCH_S3C2410 86 depends on DEBUG_LL && PLAT_S3C
87 bool "Kernel low-level debugging messages via S3C2410 UART" 87 bool "Kernel low-level debugging messages via S3C UART"
88 help 88 help
89 Say Y here if you want debug print routines to go to one of the 89 Say Y here if you want debug print routines to go to one of the
90 S3C2410 internal UARTs. The chosen UART must have been configured 90 S3C internal UARTs. The chosen UART must have been configured
91 before it is used. 91 before it is used.
92 92
93config DEBUG_S3C2410_UART 93config DEBUG_S3C_UART
94 depends on ARCH_S3C2410 94 depends on PLAT_S3C
95 int "S3C2410 UART to use for low-level debug" 95 int "S3C UART to use for low-level debug"
96 default "0" 96 default "0"
97 help 97 help
98 Choice for UART for kernel low-level using S3C2410 UARTS, 98 Choice for UART for kernel low-level using S3C UARTS,
99 should be between zero and two. The port must have been 99 should be between zero and two. The port must have been
100 initialised by the boot-loader before use. 100 initialised by the boot-loader before use.
101 101
102 The uncompressor code port configuration is now handled 102 The uncompressor code port configuration is now handled
103 by CONFIG_S3C2410_LOWLEVEL_UART_PORT. 103 by CONFIG_S3C_LOWLEVEL_UART_PORT.
104 104
105endmenu 105endmenu
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index cbd5010d3bc3..fa4ea9ff0797 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -137,6 +137,8 @@ endif
137 textofs-$(CONFIG_ARCH_NS9XXX) := 0x00108000 137 textofs-$(CONFIG_ARCH_NS9XXX) := 0x00108000
138 machine-$(CONFIG_ARCH_DAVINCI) := davinci 138 machine-$(CONFIG_ARCH_DAVINCI) := davinci
139 machine-$(CONFIG_ARCH_KS8695) := ks8695 139 machine-$(CONFIG_ARCH_KS8695) := ks8695
140 incdir-$(CONFIG_ARCH_MXC) := mxc
141 machine-$(CONFIG_ARCH_MX3) := mx3
140 142
141ifeq ($(CONFIG_ARCH_EBSA110),y) 143ifeq ($(CONFIG_ARCH_EBSA110),y)
142# This is what happens if you forget the IOCS16 line. 144# This is what happens if you forget the IOCS16 line.
@@ -183,6 +185,7 @@ core-$(CONFIG_VFP) += arch/arm/vfp/
183core-$(CONFIG_PLAT_IOP) += arch/arm/plat-iop/ 185core-$(CONFIG_PLAT_IOP) += arch/arm/plat-iop/
184core-$(CONFIG_ARCH_OMAP) += arch/arm/plat-omap/ 186core-$(CONFIG_ARCH_OMAP) += arch/arm/plat-omap/
185core-$(CONFIG_PLAT_S3C24XX) += arch/arm/plat-s3c24xx/ 187core-$(CONFIG_PLAT_S3C24XX) += arch/arm/plat-s3c24xx/
188core-$(CONFIG_ARCH_MXC) += arch/arm/plat-mxc/
186 189
187drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/ 190drivers-$(CONFIG_OPROFILE) += arch/arm/oprofile/
188drivers-$(CONFIG_ARCH_CLPS7500) += drivers/acorn/char/ 191drivers-$(CONFIG_ARCH_CLPS7500) += drivers/acorn/char/
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index ec9c400c7f82..25f12303b106 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -91,4 +91,12 @@ zinstall: $(obj)/zImage
91 $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \ 91 $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
92 $(obj)/zImage System.map "$(INSTALL_PATH)" 92 $(obj)/zImage System.map "$(INSTALL_PATH)"
93 93
94zi:
95 $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
96 $(obj)/zImage System.map "$(INSTALL_PATH)"
97
98i:
99 $(CONFIG_SHELL) $(srctree)/$(src)/install.sh $(KERNELRELEASE) \
100 $(obj)/Image System.map "$(INSTALL_PATH)"
101
94subdir- := bootp compressed 102subdir- := bootp compressed
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index a1f1691b67fe..6b8cbd69f249 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -73,7 +73,7 @@ SEDFLAGS = s/TEXT_START/$(ZTEXTADDR)/;s/BSS_START/$(ZBSSADDR)/
73 73
74targets := vmlinux vmlinux.lds piggy.gz piggy.o font.o font.c \ 74targets := vmlinux vmlinux.lds piggy.gz piggy.o font.o font.c \
75 head.o misc.o $(OBJS) 75 head.o misc.o $(OBJS)
76EXTRA_CFLAGS := -fpic 76EXTRA_CFLAGS := -fpic -fno-builtin
77EXTRA_AFLAGS := 77EXTRA_AFLAGS :=
78 78
79# Supply ZRELADDR, INITRD_PHYS and PARAMS_PHYS to the decompressor via 79# Supply ZRELADDR, INITRD_PHYS and PARAMS_PHYS to the decompressor via
diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index d7fb5ee1637e..b9b03eda70e5 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -55,7 +55,7 @@
55#elif defined(CONFIG_ARCH_S3C2410) 55#elif defined(CONFIG_ARCH_S3C2410)
56 .macro loadsp, rb 56 .macro loadsp, rb
57 mov \rb, #0x50000000 57 mov \rb, #0x50000000
58 add \rb, \rb, #0x4000 * CONFIG_S3C2410_LOWLEVEL_UART_PORT 58 add \rb, \rb, #0x4000 * CONFIG_S3C_LOWLEVEL_UART_PORT
59 .endm 59 .endm
60#else 60#else
61 .macro loadsp, rb 61 .macro loadsp, rb
diff --git a/arch/arm/configs/em_x270_defconfig b/arch/arm/configs/em_x270_defconfig
new file mode 100644
index 000000000000..6bea0901bdf0
--- /dev/null
+++ b/arch/arm/configs/em_x270_defconfig
@@ -0,0 +1,1265 @@
1#
2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22
4# Mon Jul 9 15:18:20 2007
5#
6CONFIG_ARM=y
7CONFIG_SYS_SUPPORTS_APM_EMULATION=y
8CONFIG_GENERIC_GPIO=y
9CONFIG_GENERIC_TIME=y
10# CONFIG_GENERIC_CLOCKEVENTS is not set
11CONFIG_MMU=y
12# CONFIG_NO_IOPORT is not set
13CONFIG_GENERIC_HARDIRQS=y
14CONFIG_STACKTRACE_SUPPORT=y
15CONFIG_LOCKDEP_SUPPORT=y
16CONFIG_TRACE_IRQFLAGS_SUPPORT=y
17CONFIG_HARDIRQS_SW_RESEND=y
18CONFIG_GENERIC_IRQ_PROBE=y
19CONFIG_RWSEM_GENERIC_SPINLOCK=y
20# CONFIG_ARCH_HAS_ILOG2_U32 is not set
21# CONFIG_ARCH_HAS_ILOG2_U64 is not set
22CONFIG_GENERIC_HWEIGHT=y
23CONFIG_GENERIC_CALIBRATE_DELAY=y
24CONFIG_ZONE_DMA=y
25CONFIG_ARCH_MTD_XIP=y
26CONFIG_VECTORS_BASE=0xffff0000
27CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
28
29#
30# Code maturity level options
31#
32CONFIG_EXPERIMENTAL=y
33CONFIG_BROKEN_ON_SMP=y
34CONFIG_INIT_ENV_ARG_LIMIT=32
35
36#
37# General setup
38#
39CONFIG_LOCALVERSION="-em-x270"
40# CONFIG_LOCALVERSION_AUTO is not set
41CONFIG_SWAP=y
42CONFIG_SYSVIPC=y
43# CONFIG_IPC_NS is not set
44CONFIG_SYSVIPC_SYSCTL=y
45# CONFIG_POSIX_MQUEUE is not set
46# CONFIG_BSD_PROCESS_ACCT is not set
47# CONFIG_TASKSTATS is not set
48# CONFIG_UTS_NS is not set
49# CONFIG_AUDIT is not set
50CONFIG_IKCONFIG=y
51CONFIG_IKCONFIG_PROC=y
52CONFIG_LOG_BUF_SHIFT=17
53CONFIG_SYSFS_DEPRECATED=y
54# CONFIG_RELAY is not set
55CONFIG_BLK_DEV_INITRD=y
56CONFIG_INITRAMFS_SOURCE=""
57CONFIG_CC_OPTIMIZE_FOR_SIZE=y
58CONFIG_SYSCTL=y
59CONFIG_EMBEDDED=y
60CONFIG_UID16=y
61CONFIG_SYSCTL_SYSCALL=y
62CONFIG_KALLSYMS=y
63# CONFIG_KALLSYMS_ALL is not set
64# CONFIG_KALLSYMS_EXTRA_PASS is not set
65CONFIG_HOTPLUG=y
66CONFIG_PRINTK=y
67CONFIG_BUG=y
68CONFIG_ELF_CORE=y
69CONFIG_BASE_FULL=y
70CONFIG_FUTEX=y
71CONFIG_ANON_INODES=y
72CONFIG_EPOLL=y
73CONFIG_SIGNALFD=y
74CONFIG_TIMERFD=y
75CONFIG_EVENTFD=y
76CONFIG_SHMEM=y
77CONFIG_VM_EVENT_COUNTERS=y
78CONFIG_SLAB=y
79# CONFIG_SLUB is not set
80# CONFIG_SLOB is not set
81CONFIG_RT_MUTEXES=y
82# CONFIG_TINY_SHMEM is not set
83CONFIG_BASE_SMALL=0
84
85#
86# Loadable module support
87#
88CONFIG_MODULES=y
89CONFIG_MODULE_UNLOAD=y
90CONFIG_MODULE_FORCE_UNLOAD=y
91# CONFIG_MODVERSIONS is not set
92# CONFIG_MODULE_SRCVERSION_ALL is not set
93CONFIG_KMOD=y
94
95#
96# Block layer
97#
98CONFIG_BLOCK=y
99# CONFIG_LBD is not set
100# CONFIG_BLK_DEV_IO_TRACE is not set
101# CONFIG_LSF is not set
102
103#
104# IO Schedulers
105#
106CONFIG_IOSCHED_NOOP=y
107CONFIG_IOSCHED_AS=y
108CONFIG_IOSCHED_DEADLINE=y
109CONFIG_IOSCHED_CFQ=y
110CONFIG_DEFAULT_AS=y
111# CONFIG_DEFAULT_DEADLINE is not set
112# CONFIG_DEFAULT_CFQ is not set
113# CONFIG_DEFAULT_NOOP is not set
114CONFIG_DEFAULT_IOSCHED="anticipatory"
115
116#
117# System Type
118#
119# CONFIG_ARCH_AAEC2000 is not set
120# CONFIG_ARCH_INTEGRATOR is not set
121# CONFIG_ARCH_REALVIEW is not set
122# CONFIG_ARCH_VERSATILE is not set
123# CONFIG_ARCH_AT91 is not set
124# CONFIG_ARCH_CLPS7500 is not set
125# CONFIG_ARCH_CLPS711X is not set
126# CONFIG_ARCH_CO285 is not set
127# CONFIG_ARCH_EBSA110 is not set
128# CONFIG_ARCH_EP93XX is not set
129# CONFIG_ARCH_FOOTBRIDGE is not set
130# CONFIG_ARCH_NETX is not set
131# CONFIG_ARCH_H720X is not set
132# CONFIG_ARCH_IMX is not set
133# CONFIG_ARCH_IOP13XX is not set
134# CONFIG_ARCH_IOP32X is not set
135# CONFIG_ARCH_IOP33X is not set
136# CONFIG_ARCH_IXP23XX is not set
137# CONFIG_ARCH_IXP2000 is not set
138# CONFIG_ARCH_IXP4XX is not set
139# CONFIG_ARCH_L7200 is not set
140# CONFIG_ARCH_KS8695 is not set
141# CONFIG_ARCH_NS9XXX is not set
142# CONFIG_ARCH_PNX4008 is not set
143CONFIG_ARCH_PXA=y
144# CONFIG_ARCH_RPC is not set
145# CONFIG_ARCH_SA1100 is not set
146# CONFIG_ARCH_S3C2410 is not set
147# CONFIG_ARCH_SHARK is not set
148# CONFIG_ARCH_LH7A40X is not set
149# CONFIG_ARCH_DAVINCI is not set
150# CONFIG_ARCH_OMAP is not set
151
152#
153# Intel PXA2xx Implementations
154#
155# CONFIG_ARCH_LUBBOCK is not set
156# CONFIG_MACH_LOGICPD_PXA270 is not set
157# CONFIG_MACH_MAINSTONE is not set
158# CONFIG_ARCH_PXA_IDP is not set
159# CONFIG_PXA_SHARPSL is not set
160# CONFIG_MACH_TRIZEPS4 is not set
161CONFIG_MACH_EM_X270=y
162CONFIG_PXA27x=y
163
164#
165# Processor Type
166#
167CONFIG_CPU_32=y
168CONFIG_CPU_XSCALE=y
169CONFIG_CPU_32v5=y
170CONFIG_CPU_ABRT_EV5T=y
171CONFIG_CPU_CACHE_VIVT=y
172CONFIG_CPU_TLB_V4WBI=y
173CONFIG_CPU_CP15=y
174CONFIG_CPU_CP15_MMU=y
175
176#
177# Processor Features
178#
179CONFIG_ARM_THUMB=y
180# CONFIG_CPU_DCACHE_DISABLE is not set
181# CONFIG_OUTER_CACHE is not set
182CONFIG_IWMMXT=y
183CONFIG_XSCALE_PMU=y
184
185#
186# Bus support
187#
188# CONFIG_ARCH_SUPPORTS_MSI is not set
189
190#
191# PCCARD (PCMCIA/CardBus) support
192#
193# CONFIG_PCCARD is not set
194
195#
196# Kernel Features
197#
198# CONFIG_TICK_ONESHOT is not set
199# CONFIG_PREEMPT is not set
200# CONFIG_NO_IDLE_HZ is not set
201CONFIG_HZ=100
202CONFIG_AEABI=y
203CONFIG_OABI_COMPAT=y
204# CONFIG_ARCH_DISCONTIGMEM_ENABLE is not set
205CONFIG_SELECT_MEMORY_MODEL=y
206CONFIG_FLATMEM_MANUAL=y
207# CONFIG_DISCONTIGMEM_MANUAL is not set
208# CONFIG_SPARSEMEM_MANUAL is not set
209CONFIG_FLATMEM=y
210CONFIG_FLAT_NODE_MEM_MAP=y
211# CONFIG_SPARSEMEM_STATIC is not set
212CONFIG_SPLIT_PTLOCK_CPUS=4096
213# CONFIG_RESOURCES_64BIT is not set
214CONFIG_ZONE_DMA_FLAG=1
215CONFIG_ALIGNMENT_TRAP=y
216
217#
218# Boot options
219#
220CONFIG_ZBOOT_ROM_TEXT=0x0
221CONFIG_ZBOOT_ROM_BSS=0x0
222CONFIG_CMDLINE=""
223# CONFIG_XIP_KERNEL is not set
224# CONFIG_KEXEC is not set
225
226#
227# Floating point emulation
228#
229
230#
231# At least one emulation must be selected
232#
233CONFIG_FPE_NWFPE=y
234# CONFIG_FPE_NWFPE_XP is not set
235# CONFIG_FPE_FASTFPE is not set
236
237#
238# Userspace binary formats
239#
240CONFIG_BINFMT_ELF=y
241# CONFIG_BINFMT_AOUT is not set
242# CONFIG_BINFMT_MISC is not set
243
244#
245# Power management options
246#
247CONFIG_PM=y
248CONFIG_PM_LEGACY=y
249# CONFIG_PM_DEBUG is not set
250# CONFIG_PM_SYSFS_DEPRECATED is not set
251CONFIG_APM_EMULATION=m
252
253#
254# Networking
255#
256CONFIG_NET=y
257
258#
259# Networking options
260#
261CONFIG_PACKET=y
262# CONFIG_PACKET_MMAP is not set
263CONFIG_UNIX=y
264CONFIG_XFRM=y
265# CONFIG_XFRM_USER is not set
266# CONFIG_XFRM_SUB_POLICY is not set
267# CONFIG_XFRM_MIGRATE is not set
268# CONFIG_NET_KEY is not set
269CONFIG_INET=y
270# CONFIG_IP_MULTICAST is not set
271# CONFIG_IP_ADVANCED_ROUTER is not set
272CONFIG_IP_FIB_HASH=y
273CONFIG_IP_PNP=y
274CONFIG_IP_PNP_DHCP=y
275CONFIG_IP_PNP_BOOTP=y
276# CONFIG_IP_PNP_RARP is not set
277# CONFIG_NET_IPIP is not set
278# CONFIG_NET_IPGRE is not set
279# CONFIG_ARPD is not set
280# CONFIG_SYN_COOKIES is not set
281# CONFIG_INET_AH is not set
282# CONFIG_INET_ESP is not set
283# CONFIG_INET_IPCOMP is not set
284# CONFIG_INET_XFRM_TUNNEL is not set
285# CONFIG_INET_TUNNEL is not set
286CONFIG_INET_XFRM_MODE_TRANSPORT=y
287CONFIG_INET_XFRM_MODE_TUNNEL=y
288CONFIG_INET_XFRM_MODE_BEET=y
289CONFIG_INET_DIAG=y
290CONFIG_INET_TCP_DIAG=y
291# CONFIG_TCP_CONG_ADVANCED is not set
292CONFIG_TCP_CONG_CUBIC=y
293CONFIG_DEFAULT_TCP_CONG="cubic"
294# CONFIG_TCP_MD5SIG is not set
295# CONFIG_IPV6 is not set
296# CONFIG_INET6_XFRM_TUNNEL is not set
297# CONFIG_INET6_TUNNEL is not set
298# CONFIG_NETWORK_SECMARK is not set
299# CONFIG_NETFILTER is not set
300# CONFIG_IP_DCCP is not set
301# CONFIG_IP_SCTP is not set
302# CONFIG_TIPC is not set
303# CONFIG_ATM is not set
304# CONFIG_BRIDGE is not set
305# CONFIG_VLAN_8021Q is not set
306# CONFIG_DECNET is not set
307# CONFIG_LLC2 is not set
308# CONFIG_IPX is not set
309# CONFIG_ATALK is not set
310# CONFIG_X25 is not set
311# CONFIG_LAPB is not set
312# CONFIG_ECONET is not set
313# CONFIG_WAN_ROUTER is not set
314
315#
316# QoS and/or fair queueing
317#
318# CONFIG_NET_SCHED is not set
319
320#
321# Network testing
322#
323# CONFIG_NET_PKTGEN is not set
324# CONFIG_HAMRADIO is not set
325# CONFIG_IRDA is not set
326CONFIG_BT=m
327CONFIG_BT_L2CAP=m
328CONFIG_BT_SCO=m
329CONFIG_BT_RFCOMM=m
330# CONFIG_BT_RFCOMM_TTY is not set
331CONFIG_BT_BNEP=m
332# CONFIG_BT_BNEP_MC_FILTER is not set
333# CONFIG_BT_BNEP_PROTO_FILTER is not set
334CONFIG_BT_HIDP=m
335
336#
337# Bluetooth device drivers
338#
339CONFIG_BT_HCIUSB=m
340# CONFIG_BT_HCIUSB_SCO is not set
341CONFIG_BT_HCIUART=m
342# CONFIG_BT_HCIUART_H4 is not set
343# CONFIG_BT_HCIUART_BCSP is not set
344CONFIG_BT_HCIBCM203X=m
345CONFIG_BT_HCIBPA10X=m
346CONFIG_BT_HCIBFUSB=m
347# CONFIG_BT_HCIVHCI is not set
348# CONFIG_AF_RXRPC is not set
349
350#
351# Wireless
352#
353# CONFIG_CFG80211 is not set
354# CONFIG_WIRELESS_EXT is not set
355# CONFIG_MAC80211 is not set
356CONFIG_IEEE80211=m
357# CONFIG_IEEE80211_DEBUG is not set
358CONFIG_IEEE80211_CRYPT_WEP=m
359CONFIG_IEEE80211_CRYPT_CCMP=m
360# CONFIG_IEEE80211_CRYPT_TKIP is not set
361# CONFIG_IEEE80211_SOFTMAC is not set
362# CONFIG_RFKILL is not set
363
364#
365# Device Drivers
366#
367
368#
369# Generic Driver Options
370#
371CONFIG_STANDALONE=y
372CONFIG_PREVENT_FIRMWARE_BUILD=y
373CONFIG_FW_LOADER=y
374# CONFIG_DEBUG_DRIVER is not set
375# CONFIG_DEBUG_DEVRES is not set
376# CONFIG_SYS_HYPERVISOR is not set
377
378#
379# Connector - unified userspace <-> kernelspace linker
380#
381# CONFIG_CONNECTOR is not set
382CONFIG_MTD=y
383# CONFIG_MTD_DEBUG is not set
384CONFIG_MTD_CONCAT=y
385CONFIG_MTD_PARTITIONS=y
386# CONFIG_MTD_REDBOOT_PARTS is not set
387# CONFIG_MTD_CMDLINE_PARTS is not set
388# CONFIG_MTD_AFS_PARTS is not set
389
390#
391# User Modules And Translation Layers
392#
393CONFIG_MTD_CHAR=y
394CONFIG_MTD_BLKDEVS=y
395CONFIG_MTD_BLOCK=y
396# CONFIG_FTL is not set
397# CONFIG_NFTL is not set
398# CONFIG_INFTL is not set
399# CONFIG_RFD_FTL is not set
400# CONFIG_SSFDC is not set
401
402#
403# RAM/ROM/Flash chip drivers
404#
405# CONFIG_MTD_CFI is not set
406# CONFIG_MTD_JEDECPROBE is not set
407# CONFIG_MTD_CFI_NOSWAP is not set
408# CONFIG_MTD_CFI_BE_BYTE_SWAP is not set
409# CONFIG_MTD_CFI_LE_BYTE_SWAP is not set
410CONFIG_MTD_MAP_BANK_WIDTH_1=y
411CONFIG_MTD_MAP_BANK_WIDTH_2=y
412CONFIG_MTD_MAP_BANK_WIDTH_4=y
413# CONFIG_MTD_MAP_BANK_WIDTH_8 is not set
414# CONFIG_MTD_MAP_BANK_WIDTH_16 is not set
415# CONFIG_MTD_MAP_BANK_WIDTH_32 is not set
416CONFIG_MTD_CFI_I1=y
417CONFIG_MTD_CFI_I2=y
418# CONFIG_MTD_CFI_I4 is not set
419# CONFIG_MTD_CFI_I8 is not set
420# CONFIG_MTD_RAM is not set
421# CONFIG_MTD_ROM is not set
422# CONFIG_MTD_ABSENT is not set
423
424#
425# Mapping drivers for chip access
426#
427# CONFIG_MTD_COMPLEX_MAPPINGS is not set
428# CONFIG_MTD_SHARP_SL is not set
429# CONFIG_MTD_PLATRAM is not set
430
431#
432# Self-contained MTD device drivers
433#
434# CONFIG_MTD_SLRAM is not set
435# CONFIG_MTD_PHRAM is not set
436# CONFIG_MTD_MTDRAM is not set
437# CONFIG_MTD_BLOCK2MTD is not set
438
439#
440# Disk-On-Chip Device Drivers
441#
442# CONFIG_MTD_DOC2000 is not set
443# CONFIG_MTD_DOC2001 is not set
444# CONFIG_MTD_DOC2001PLUS is not set
445CONFIG_MTD_NAND=y
446# CONFIG_MTD_NAND_VERIFY_WRITE is not set
447# CONFIG_MTD_NAND_ECC_SMC is not set
448# CONFIG_MTD_NAND_MUSEUM_IDS is not set
449# CONFIG_MTD_NAND_H1900 is not set
450CONFIG_MTD_NAND_IDS=y
451# CONFIG_MTD_NAND_DISKONCHIP is not set
452# CONFIG_MTD_NAND_SHARPSL is not set
453# CONFIG_MTD_NAND_NANDSIM is not set
454CONFIG_MTD_NAND_PLATFORM=y
455# CONFIG_MTD_ONENAND is not set
456
457#
458# UBI - Unsorted block images
459#
460# CONFIG_MTD_UBI is not set
461
462#
463# Parallel port support
464#
465# CONFIG_PARPORT is not set
466
467#
468# Plug and Play support
469#
470# CONFIG_PNPACPI is not set
471
472#
473# Block devices
474#
475# CONFIG_BLK_DEV_COW_COMMON is not set
476CONFIG_BLK_DEV_LOOP=y
477# CONFIG_BLK_DEV_CRYPTOLOOP is not set
478# CONFIG_BLK_DEV_NBD is not set
479# CONFIG_BLK_DEV_UB is not set
480CONFIG_BLK_DEV_RAM=y
481CONFIG_BLK_DEV_RAM_COUNT=16
482CONFIG_BLK_DEV_RAM_SIZE=12000
483CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
484# CONFIG_CDROM_PKTCDVD is not set
485# CONFIG_ATA_OVER_ETH is not set
486# CONFIG_IDE is not set
487
488#
489# SCSI device support
490#
491# CONFIG_RAID_ATTRS is not set
492CONFIG_SCSI=y
493# CONFIG_SCSI_TGT is not set
494# CONFIG_SCSI_NETLINK is not set
495# CONFIG_SCSI_PROC_FS is not set
496
497#
498# SCSI support type (disk, tape, CD-ROM)
499#
500CONFIG_BLK_DEV_SD=y
501# CONFIG_CHR_DEV_ST is not set
502# CONFIG_CHR_DEV_OSST is not set
503# CONFIG_BLK_DEV_SR is not set
504# CONFIG_CHR_DEV_SG is not set
505# CONFIG_CHR_DEV_SCH is not set
506
507#
508# Some SCSI devices (e.g. CD jukebox) support multiple LUNs
509#
510# CONFIG_SCSI_MULTI_LUN is not set
511# CONFIG_SCSI_CONSTANTS is not set
512# CONFIG_SCSI_LOGGING is not set
513# CONFIG_SCSI_SCAN_ASYNC is not set
514CONFIG_SCSI_WAIT_SCAN=m
515
516#
517# SCSI Transports
518#
519# CONFIG_SCSI_SPI_ATTRS is not set
520# CONFIG_SCSI_FC_ATTRS is not set
521# CONFIG_SCSI_ISCSI_ATTRS is not set
522# CONFIG_SCSI_SAS_ATTRS is not set
523# CONFIG_SCSI_SAS_LIBSAS is not set
524
525#
526# SCSI low-level drivers
527#
528# CONFIG_ISCSI_TCP is not set
529# CONFIG_SCSI_DEBUG is not set
530# CONFIG_ATA is not set
531
532#
533# Multi-device support (RAID and LVM)
534#
535# CONFIG_MD is not set
536
537#
538# Network device support
539#
540CONFIG_NETDEVICES=y
541# CONFIG_DUMMY is not set
542# CONFIG_BONDING is not set
543# CONFIG_EQUALIZER is not set
544# CONFIG_TUN is not set
545# CONFIG_PHYLIB is not set
546
547#
548# Ethernet (10 or 100Mbit)
549#
550CONFIG_NET_ETHERNET=y
551CONFIG_MII=y
552# CONFIG_SMC91X is not set
553CONFIG_DM9000=y
554# CONFIG_SMC911X is not set
555# CONFIG_NETDEV_1000 is not set
556# CONFIG_NETDEV_10000 is not set
557
558#
559# Wireless LAN
560#
561# CONFIG_WLAN_PRE80211 is not set
562# CONFIG_WLAN_80211 is not set
563
564#
565# USB Network Adapters
566#
567# CONFIG_USB_CATC is not set
568# CONFIG_USB_KAWETH is not set
569# CONFIG_USB_PEGASUS is not set
570# CONFIG_USB_RTL8150 is not set
571# CONFIG_USB_USBNET_MII is not set
572# CONFIG_USB_USBNET is not set
573# CONFIG_WAN is not set
574# CONFIG_PPP is not set
575# CONFIG_SLIP is not set
576# CONFIG_SHAPER is not set
577# CONFIG_NETCONSOLE is not set
578# CONFIG_NETPOLL is not set
579# CONFIG_NET_POLL_CONTROLLER is not set
580
581#
582# ISDN subsystem
583#
584# CONFIG_ISDN is not set
585
586#
587# Input device support
588#
589CONFIG_INPUT=y
590# CONFIG_INPUT_FF_MEMLESS is not set
591# CONFIG_INPUT_POLLDEV is not set
592
593#
594# Userland interfaces
595#
596CONFIG_INPUT_MOUSEDEV=y
597# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
598CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
599CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
600# CONFIG_INPUT_JOYDEV is not set
601# CONFIG_INPUT_TSDEV is not set
602CONFIG_INPUT_EVDEV=y
603# CONFIG_INPUT_EVBUG is not set
604
605#
606# Input Device Drivers
607#
608CONFIG_INPUT_KEYBOARD=y
609# CONFIG_KEYBOARD_ATKBD is not set
610# CONFIG_KEYBOARD_SUNKBD is not set
611# CONFIG_KEYBOARD_LKKBD is not set
612# CONFIG_KEYBOARD_XTKBD is not set
613# CONFIG_KEYBOARD_NEWTON is not set
614# CONFIG_KEYBOARD_STOWAWAY is not set
615CONFIG_KEYBOARD_PXA27x=m
616# CONFIG_KEYBOARD_GPIO is not set
617# CONFIG_INPUT_MOUSE is not set
618# CONFIG_INPUT_JOYSTICK is not set
619# CONFIG_INPUT_TABLET is not set
620CONFIG_INPUT_TOUCHSCREEN=y
621# CONFIG_TOUCHSCREEN_GUNZE is not set
622# CONFIG_TOUCHSCREEN_ELO is not set
623# CONFIG_TOUCHSCREEN_MTOUCH is not set
624# CONFIG_TOUCHSCREEN_MK712 is not set
625# CONFIG_TOUCHSCREEN_PENMOUNT is not set
626# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
627# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
628# CONFIG_TOUCHSCREEN_UCB1400 is not set
629# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
630# CONFIG_INPUT_MISC is not set
631
632#
633# Hardware I/O ports
634#
635CONFIG_SERIO=y
636# CONFIG_SERIO_SERPORT is not set
637CONFIG_SERIO_LIBPS2=y
638# CONFIG_SERIO_RAW is not set
639# CONFIG_GAMEPORT is not set
640
641#
642# Character devices
643#
644CONFIG_VT=y
645CONFIG_VT_CONSOLE=y
646CONFIG_HW_CONSOLE=y
647# CONFIG_VT_HW_CONSOLE_BINDING is not set
648# CONFIG_SERIAL_NONSTANDARD is not set
649
650#
651# Serial drivers
652#
653# CONFIG_SERIAL_8250 is not set
654
655#
656# Non-8250 serial port support
657#
658CONFIG_SERIAL_PXA=y
659CONFIG_SERIAL_PXA_CONSOLE=y
660CONFIG_SERIAL_CORE=y
661CONFIG_SERIAL_CORE_CONSOLE=y
662CONFIG_UNIX98_PTYS=y
663CONFIG_LEGACY_PTYS=y
664CONFIG_LEGACY_PTY_COUNT=256
665
666#
667# IPMI
668#
669# CONFIG_IPMI_HANDLER is not set
670# CONFIG_WATCHDOG is not set
671CONFIG_HW_RANDOM=m
672# CONFIG_NVRAM is not set
673# CONFIG_R3964 is not set
674# CONFIG_RAW_DRIVER is not set
675
676#
677# TPM devices
678#
679# CONFIG_TCG_TPM is not set
680# CONFIG_I2C is not set
681
682#
683# SPI support
684#
685# CONFIG_SPI is not set
686# CONFIG_SPI_MASTER is not set
687
688#
689# Dallas's 1-wire bus
690#
691# CONFIG_W1 is not set
692# CONFIG_HWMON is not set
693
694#
695# Misc devices
696#
697
698#
699# Multifunction device drivers
700#
701# CONFIG_MFD_SM501 is not set
702
703#
704# LED devices
705#
706# CONFIG_NEW_LEDS is not set
707
708#
709# LED drivers
710#
711
712#
713# LED Triggers
714#
715
716#
717# Multimedia devices
718#
719# CONFIG_VIDEO_DEV is not set
720# CONFIG_DVB_CORE is not set
721# CONFIG_DAB is not set
722
723#
724# Graphics support
725#
726# CONFIG_BACKLIGHT_LCD_SUPPORT is not set
727
728#
729# Display device support
730#
731# CONFIG_DISPLAY_SUPPORT is not set
732# CONFIG_VGASTATE is not set
733CONFIG_FB=y
734# CONFIG_FIRMWARE_EDID is not set
735# CONFIG_FB_DDC is not set
736CONFIG_FB_CFB_FILLRECT=y
737CONFIG_FB_CFB_COPYAREA=y
738CONFIG_FB_CFB_IMAGEBLIT=y
739# CONFIG_FB_SYS_FILLRECT is not set
740# CONFIG_FB_SYS_COPYAREA is not set
741# CONFIG_FB_SYS_IMAGEBLIT is not set
742# CONFIG_FB_SYS_FOPS is not set
743CONFIG_FB_DEFERRED_IO=y
744# CONFIG_FB_SVGALIB is not set
745# CONFIG_FB_MACMODES is not set
746# CONFIG_FB_BACKLIGHT is not set
747# CONFIG_FB_MODE_HELPERS is not set
748# CONFIG_FB_TILEBLITTING is not set
749
750#
751# Frame buffer hardware drivers
752#
753# CONFIG_FB_S1D13XXX is not set
754CONFIG_FB_PXA=y
755# CONFIG_FB_PXA_PARAMETERS is not set
756# CONFIG_FB_MBX is not set
757# CONFIG_FB_VIRTUAL is not set
758
759#
760# Console display driver support
761#
762# CONFIG_VGA_CONSOLE is not set
763CONFIG_DUMMY_CONSOLE=y
764CONFIG_FRAMEBUFFER_CONSOLE=y
765# CONFIG_FRAMEBUFFER_CONSOLE_ROTATION is not set
766# CONFIG_FONTS is not set
767CONFIG_FONT_8x8=y
768CONFIG_FONT_8x16=y
769CONFIG_LOGO=y
770CONFIG_LOGO_LINUX_MONO=y
771CONFIG_LOGO_LINUX_VGA16=y
772CONFIG_LOGO_LINUX_CLUT224=y
773
774#
775# Sound
776#
777CONFIG_SOUND=m
778
779#
780# Advanced Linux Sound Architecture
781#
782CONFIG_SND=m
783CONFIG_SND_TIMER=m
784CONFIG_SND_PCM=m
785# CONFIG_SND_SEQUENCER is not set
786CONFIG_SND_OSSEMUL=y
787CONFIG_SND_MIXER_OSS=m
788CONFIG_SND_PCM_OSS=m
789CONFIG_SND_PCM_OSS_PLUGINS=y
790# CONFIG_SND_DYNAMIC_MINORS is not set
791CONFIG_SND_SUPPORT_OLD_API=y
792CONFIG_SND_VERBOSE_PROCFS=y
793# CONFIG_SND_VERBOSE_PRINTK is not set
794# CONFIG_SND_DEBUG is not set
795
796#
797# Generic devices
798#
799CONFIG_SND_AC97_CODEC=m
800# CONFIG_SND_DUMMY is not set
801# CONFIG_SND_MTPAV is not set
802# CONFIG_SND_SERIAL_U16550 is not set
803# CONFIG_SND_MPU401 is not set
804
805#
806# ALSA ARM devices
807#
808CONFIG_SND_PXA2XX_PCM=m
809CONFIG_SND_PXA2XX_AC97=m
810
811#
812# USB devices
813#
814# CONFIG_SND_USB_AUDIO is not set
815# CONFIG_SND_USB_CAIAQ is not set
816
817#
818# System on Chip audio support
819#
820# CONFIG_SND_SOC is not set
821
822#
823# Open Sound System
824#
825# CONFIG_SOUND_PRIME is not set
826CONFIG_AC97_BUS=m
827
828#
829# HID Devices
830#
831CONFIG_HID=y
832# CONFIG_HID_DEBUG is not set
833
834#
835# USB Input Devices
836#
837CONFIG_USB_HID=y
838# CONFIG_USB_HIDINPUT_POWERBOOK is not set
839# CONFIG_HID_FF is not set
840# CONFIG_USB_HIDDEV is not set
841
842#
843# USB support
844#
845CONFIG_USB_ARCH_HAS_HCD=y
846CONFIG_USB_ARCH_HAS_OHCI=y
847# CONFIG_USB_ARCH_HAS_EHCI is not set
848CONFIG_USB=y
849# CONFIG_USB_DEBUG is not set
850
851#
852# Miscellaneous USB options
853#
854CONFIG_USB_DEVICEFS=y
855# CONFIG_USB_DEVICE_CLASS is not set
856# CONFIG_USB_DYNAMIC_MINORS is not set
857# CONFIG_USB_SUSPEND is not set
858# CONFIG_USB_OTG is not set
859
860#
861# USB Host Controller Drivers
862#
863# CONFIG_USB_ISP116X_HCD is not set
864CONFIG_USB_OHCI_HCD=y
865# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
866# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set
867CONFIG_USB_OHCI_LITTLE_ENDIAN=y
868# CONFIG_USB_SL811_HCD is not set
869
870#
871# USB Device Class drivers
872#
873# CONFIG_USB_ACM is not set
874# CONFIG_USB_PRINTER is not set
875
876#
877# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support'
878#
879
880#
881# may also be needed; see USB_STORAGE Help for more information
882#
883CONFIG_USB_STORAGE=y
884# CONFIG_USB_STORAGE_DEBUG is not set
885# CONFIG_USB_STORAGE_DATAFAB is not set
886# CONFIG_USB_STORAGE_FREECOM is not set
887# CONFIG_USB_STORAGE_DPCM is not set
888# CONFIG_USB_STORAGE_USBAT is not set
889# CONFIG_USB_STORAGE_SDDR09 is not set
890# CONFIG_USB_STORAGE_SDDR55 is not set
891# CONFIG_USB_STORAGE_JUMPSHOT is not set
892# CONFIG_USB_STORAGE_ALAUDA is not set
893# CONFIG_USB_STORAGE_KARMA is not set
894# CONFIG_USB_LIBUSUAL is not set
895
896#
897# USB Imaging devices
898#
899# CONFIG_USB_MDC800 is not set
900# CONFIG_USB_MICROTEK is not set
901# CONFIG_USB_MON is not set
902
903#
904# USB port drivers
905#
906
907#
908# USB Serial Converter support
909#
910# CONFIG_USB_SERIAL is not set
911
912#
913# USB Miscellaneous drivers
914#
915# CONFIG_USB_EMI62 is not set
916# CONFIG_USB_EMI26 is not set
917# CONFIG_USB_ADUTUX is not set
918# CONFIG_USB_AUERSWALD is not set
919# CONFIG_USB_RIO500 is not set
920# CONFIG_USB_LEGOTOWER is not set
921# CONFIG_USB_LCD is not set
922# CONFIG_USB_BERRY_CHARGE is not set
923# CONFIG_USB_LED is not set
924# CONFIG_USB_CYPRESS_CY7C63 is not set
925# CONFIG_USB_CYTHERM is not set
926# CONFIG_USB_PHIDGET is not set
927# CONFIG_USB_IDMOUSE is not set
928# CONFIG_USB_FTDI_ELAN is not set
929# CONFIG_USB_APPLEDISPLAY is not set
930# CONFIG_USB_LD is not set
931# CONFIG_USB_TRANCEVIBRATOR is not set
932# CONFIG_USB_IOWARRIOR is not set
933# CONFIG_USB_TEST is not set
934
935#
936# USB DSL modem support
937#
938
939#
940# USB Gadget Support
941#
942# CONFIG_USB_GADGET is not set
943CONFIG_MMC=m
944# CONFIG_MMC_DEBUG is not set
945# CONFIG_MMC_UNSAFE_RESUME is not set
946
947#
948# MMC/SD Card Drivers
949#
950CONFIG_MMC_BLOCK=m
951
952#
953# MMC/SD Host Controller Drivers
954#
955CONFIG_MMC_PXA=m
956
957#
958# Real Time Clock
959#
960CONFIG_RTC_LIB=y
961CONFIG_RTC_CLASS=m
962
963#
964# RTC interfaces
965#
966CONFIG_RTC_INTF_SYSFS=y
967CONFIG_RTC_INTF_PROC=y
968CONFIG_RTC_INTF_DEV=y
969# CONFIG_RTC_INTF_DEV_UIE_EMUL is not set
970# CONFIG_RTC_DRV_TEST is not set
971
972#
973# I2C RTC drivers
974#
975
976#
977# SPI RTC drivers
978#
979
980#
981# Platform RTC drivers
982#
983# CONFIG_RTC_DRV_CMOS is not set
984# CONFIG_RTC_DRV_DS1553 is not set
985# CONFIG_RTC_DRV_DS1742 is not set
986# CONFIG_RTC_DRV_M48T86 is not set
987CONFIG_RTC_DRV_V3020=m
988
989#
990# on-CPU RTC drivers
991#
992CONFIG_RTC_DRV_SA1100=m
993
994#
995# File systems
996#
997CONFIG_EXT2_FS=y
998# CONFIG_EXT2_FS_XATTR is not set
999# CONFIG_EXT2_FS_XIP is not set
1000CONFIG_EXT3_FS=y
1001CONFIG_EXT3_FS_XATTR=y
1002# CONFIG_EXT3_FS_POSIX_ACL is not set
1003# CONFIG_EXT3_FS_SECURITY is not set
1004# CONFIG_EXT4DEV_FS is not set
1005CONFIG_JBD=y
1006# CONFIG_JBD_DEBUG is not set
1007CONFIG_FS_MBCACHE=y
1008# CONFIG_REISERFS_FS is not set
1009# CONFIG_JFS_FS is not set
1010# CONFIG_FS_POSIX_ACL is not set
1011# CONFIG_XFS_FS is not set
1012# CONFIG_GFS2_FS is not set
1013# CONFIG_OCFS2_FS is not set
1014# CONFIG_MINIX_FS is not set
1015# CONFIG_ROMFS_FS is not set
1016CONFIG_INOTIFY=y
1017CONFIG_INOTIFY_USER=y
1018# CONFIG_QUOTA is not set
1019CONFIG_DNOTIFY=y
1020# CONFIG_AUTOFS_FS is not set
1021# CONFIG_AUTOFS4_FS is not set
1022# CONFIG_FUSE_FS is not set
1023
1024#
1025# CD-ROM/DVD Filesystems
1026#
1027# CONFIG_ISO9660_FS is not set
1028# CONFIG_UDF_FS is not set
1029
1030#
1031# DOS/FAT/NT Filesystems
1032#
1033CONFIG_FAT_FS=y
1034CONFIG_MSDOS_FS=y
1035CONFIG_VFAT_FS=y
1036CONFIG_FAT_DEFAULT_CODEPAGE=437
1037CONFIG_FAT_DEFAULT_IOCHARSET="iso8859-1"
1038# CONFIG_NTFS_FS is not set
1039
1040#
1041# Pseudo filesystems
1042#
1043CONFIG_PROC_FS=y
1044CONFIG_PROC_SYSCTL=y
1045CONFIG_SYSFS=y
1046CONFIG_TMPFS=y
1047# CONFIG_TMPFS_POSIX_ACL is not set
1048# CONFIG_HUGETLB_PAGE is not set
1049CONFIG_RAMFS=y
1050# CONFIG_CONFIGFS_FS is not set
1051
1052#
1053# Miscellaneous filesystems
1054#
1055# CONFIG_ADFS_FS is not set
1056# CONFIG_AFFS_FS is not set
1057# CONFIG_HFS_FS is not set
1058# CONFIG_HFSPLUS_FS is not set
1059# CONFIG_BEFS_FS is not set
1060# CONFIG_BFS_FS is not set
1061# CONFIG_EFS_FS is not set
1062CONFIG_JFFS2_FS=y
1063CONFIG_JFFS2_FS_DEBUG=0
1064CONFIG_JFFS2_FS_WRITEBUFFER=y
1065CONFIG_JFFS2_SUMMARY=y
1066# CONFIG_JFFS2_FS_XATTR is not set
1067# CONFIG_JFFS2_COMPRESSION_OPTIONS is not set
1068CONFIG_JFFS2_ZLIB=y
1069CONFIG_JFFS2_RTIME=y
1070# CONFIG_JFFS2_RUBIN is not set
1071# CONFIG_CRAMFS is not set
1072# CONFIG_VXFS_FS is not set
1073# CONFIG_HPFS_FS is not set
1074# CONFIG_QNX4FS_FS is not set
1075# CONFIG_SYSV_FS is not set
1076# CONFIG_UFS_FS is not set
1077
1078#
1079# Network File Systems
1080#
1081CONFIG_NFS_FS=y
1082CONFIG_NFS_V3=y
1083# CONFIG_NFS_V3_ACL is not set
1084# CONFIG_NFS_V4 is not set
1085# CONFIG_NFS_DIRECTIO is not set
1086# CONFIG_NFSD is not set
1087CONFIG_ROOT_NFS=y
1088CONFIG_LOCKD=y
1089CONFIG_LOCKD_V4=y
1090CONFIG_NFS_COMMON=y
1091CONFIG_SUNRPC=y
1092# CONFIG_SUNRPC_BIND34 is not set
1093# CONFIG_RPCSEC_GSS_KRB5 is not set
1094# CONFIG_RPCSEC_GSS_SPKM3 is not set
1095CONFIG_SMB_FS=y
1096# CONFIG_SMB_NLS_DEFAULT is not set
1097# CONFIG_CIFS is not set
1098# CONFIG_NCP_FS is not set
1099# CONFIG_CODA_FS is not set
1100# CONFIG_AFS_FS is not set
1101# CONFIG_9P_FS is not set
1102
1103#
1104# Partition Types
1105#
1106# CONFIG_PARTITION_ADVANCED is not set
1107CONFIG_MSDOS_PARTITION=y
1108
1109#
1110# Native Language Support
1111#
1112CONFIG_NLS=y
1113CONFIG_NLS_DEFAULT="iso8859-1"
1114CONFIG_NLS_CODEPAGE_437=y
1115# CONFIG_NLS_CODEPAGE_737 is not set
1116# CONFIG_NLS_CODEPAGE_775 is not set
1117# CONFIG_NLS_CODEPAGE_850 is not set
1118# CONFIG_NLS_CODEPAGE_852 is not set
1119# CONFIG_NLS_CODEPAGE_855 is not set
1120# CONFIG_NLS_CODEPAGE_857 is not set
1121# CONFIG_NLS_CODEPAGE_860 is not set
1122# CONFIG_NLS_CODEPAGE_861 is not set
1123# CONFIG_NLS_CODEPAGE_862 is not set
1124# CONFIG_NLS_CODEPAGE_863 is not set
1125# CONFIG_NLS_CODEPAGE_864 is not set
1126# CONFIG_NLS_CODEPAGE_865 is not set
1127# CONFIG_NLS_CODEPAGE_866 is not set
1128# CONFIG_NLS_CODEPAGE_869 is not set
1129# CONFIG_NLS_CODEPAGE_936 is not set
1130# CONFIG_NLS_CODEPAGE_950 is not set
1131# CONFIG_NLS_CODEPAGE_932 is not set
1132# CONFIG_NLS_CODEPAGE_949 is not set
1133# CONFIG_NLS_CODEPAGE_874 is not set
1134# CONFIG_NLS_ISO8859_8 is not set
1135# CONFIG_NLS_CODEPAGE_1250 is not set
1136# CONFIG_NLS_CODEPAGE_1251 is not set
1137# CONFIG_NLS_ASCII is not set
1138CONFIG_NLS_ISO8859_1=y
1139# CONFIG_NLS_ISO8859_2 is not set
1140# CONFIG_NLS_ISO8859_3 is not set
1141# CONFIG_NLS_ISO8859_4 is not set
1142# CONFIG_NLS_ISO8859_5 is not set
1143# CONFIG_NLS_ISO8859_6 is not set
1144# CONFIG_NLS_ISO8859_7 is not set
1145# CONFIG_NLS_ISO8859_9 is not set
1146# CONFIG_NLS_ISO8859_13 is not set
1147# CONFIG_NLS_ISO8859_14 is not set
1148# CONFIG_NLS_ISO8859_15 is not set
1149# CONFIG_NLS_KOI8_R is not set
1150# CONFIG_NLS_KOI8_U is not set
1151CONFIG_NLS_UTF8=y
1152
1153#
1154# Distributed Lock Manager
1155#
1156# CONFIG_DLM is not set
1157
1158#
1159# Profiling support
1160#
1161# CONFIG_PROFILING is not set
1162
1163#
1164# Kernel hacking
1165#
1166# CONFIG_PRINTK_TIME is not set
1167CONFIG_ENABLE_MUST_CHECK=y
1168CONFIG_MAGIC_SYSRQ=y
1169# CONFIG_UNUSED_SYMBOLS is not set
1170# CONFIG_DEBUG_FS is not set
1171# CONFIG_HEADERS_CHECK is not set
1172CONFIG_DEBUG_KERNEL=y
1173# CONFIG_DEBUG_SHIRQ is not set
1174# CONFIG_DETECT_SOFTLOCKUP is not set
1175# CONFIG_SCHEDSTATS is not set
1176# CONFIG_TIMER_STATS is not set
1177# CONFIG_DEBUG_SLAB is not set
1178# CONFIG_DEBUG_RT_MUTEXES is not set
1179# CONFIG_RT_MUTEX_TESTER is not set
1180# CONFIG_DEBUG_SPINLOCK is not set
1181# CONFIG_DEBUG_MUTEXES is not set
1182# CONFIG_DEBUG_LOCK_ALLOC is not set
1183# CONFIG_PROVE_LOCKING is not set
1184# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1185# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1186# CONFIG_DEBUG_KOBJECT is not set
1187# CONFIG_DEBUG_BUGVERBOSE is not set
1188CONFIG_DEBUG_INFO=y
1189# CONFIG_DEBUG_VM is not set
1190# CONFIG_DEBUG_LIST is not set
1191CONFIG_FRAME_POINTER=y
1192CONFIG_FORCED_INLINING=y
1193# CONFIG_RCU_TORTURE_TEST is not set
1194# CONFIG_FAULT_INJECTION is not set
1195CONFIG_DEBUG_USER=y
1196CONFIG_DEBUG_ERRORS=y
1197CONFIG_DEBUG_LL=y
1198# CONFIG_DEBUG_ICEDCC is not set
1199
1200#
1201# Security options
1202#
1203# CONFIG_KEYS is not set
1204# CONFIG_SECURITY is not set
1205
1206#
1207# Cryptographic options
1208#
1209CONFIG_CRYPTO=y
1210CONFIG_CRYPTO_ALGAPI=m
1211CONFIG_CRYPTO_BLKCIPHER=m
1212CONFIG_CRYPTO_MANAGER=m
1213# CONFIG_CRYPTO_HMAC is not set
1214# CONFIG_CRYPTO_XCBC is not set
1215# CONFIG_CRYPTO_NULL is not set
1216# CONFIG_CRYPTO_MD4 is not set
1217# CONFIG_CRYPTO_MD5 is not set
1218# CONFIG_CRYPTO_SHA1 is not set
1219# CONFIG_CRYPTO_SHA256 is not set
1220# CONFIG_CRYPTO_SHA512 is not set
1221# CONFIG_CRYPTO_WP512 is not set
1222# CONFIG_CRYPTO_TGR192 is not set
1223# CONFIG_CRYPTO_GF128MUL is not set
1224CONFIG_CRYPTO_ECB=m
1225CONFIG_CRYPTO_CBC=m
1226CONFIG_CRYPTO_PCBC=m
1227# CONFIG_CRYPTO_LRW is not set
1228# CONFIG_CRYPTO_CRYPTD is not set
1229# CONFIG_CRYPTO_DES is not set
1230# CONFIG_CRYPTO_FCRYPT is not set
1231# CONFIG_CRYPTO_BLOWFISH is not set
1232# CONFIG_CRYPTO_TWOFISH is not set
1233# CONFIG_CRYPTO_SERPENT is not set
1234CONFIG_CRYPTO_AES=m
1235# CONFIG_CRYPTO_CAST5 is not set
1236# CONFIG_CRYPTO_CAST6 is not set
1237# CONFIG_CRYPTO_TEA is not set
1238CONFIG_CRYPTO_ARC4=m
1239# CONFIG_CRYPTO_KHAZAD is not set
1240# CONFIG_CRYPTO_ANUBIS is not set
1241# CONFIG_CRYPTO_DEFLATE is not set
1242# CONFIG_CRYPTO_MICHAEL_MIC is not set
1243# CONFIG_CRYPTO_CRC32C is not set
1244# CONFIG_CRYPTO_CAMELLIA is not set
1245# CONFIG_CRYPTO_TEST is not set
1246
1247#
1248# Hardware crypto devices
1249#
1250
1251#
1252# Library routines
1253#
1254CONFIG_BITREVERSE=y
1255# CONFIG_CRC_CCITT is not set
1256# CONFIG_CRC16 is not set
1257# CONFIG_CRC_ITU_T is not set
1258CONFIG_CRC32=y
1259# CONFIG_LIBCRC32C is not set
1260CONFIG_ZLIB_INFLATE=y
1261CONFIG_ZLIB_DEFLATE=y
1262CONFIG_PLIST=y
1263CONFIG_HAS_IOMEM=y
1264CONFIG_HAS_IOPORT=y
1265CONFIG_HAS_DMA=y
diff --git a/arch/arm/configs/s3c2410_defconfig b/arch/arm/configs/s3c2410_defconfig
index 1d5150e4d6b3..f8a1645b3d4a 100644
--- a/arch/arm/configs/s3c2410_defconfig
+++ b/arch/arm/configs/s3c2410_defconfig
@@ -138,11 +138,11 @@ CONFIG_ARCH_S3C2410=y
138CONFIG_PLAT_S3C24XX=y 138CONFIG_PLAT_S3C24XX=y
139CONFIG_CPU_S3C244X=y 139CONFIG_CPU_S3C244X=y
140CONFIG_PM_SIMTEC=y 140CONFIG_PM_SIMTEC=y
141# CONFIG_S3C2410_BOOT_WATCHDOG is not set 141# CONFIG_S3C_BOOT_WATCHDOG is not set
142# CONFIG_S3C2410_BOOT_ERROR_RESET is not set 142# CONFIG_S3C_BOOT_ERROR_RESET is not set
143# CONFIG_S3C2410_PM_DEBUG is not set 143# CONFIG_S3C2410_PM_DEBUG is not set
144# CONFIG_S3C2410_PM_CHECK is not set 144# CONFIG_S3C2410_PM_CHECK is not set
145CONFIG_S3C2410_LOWLEVEL_UART_PORT=0 145CONFIG_S3C_LOWLEVEL_UART_PORT=0
146CONFIG_S3C2410_DMA=y 146CONFIG_S3C2410_DMA=y
147# CONFIG_S3C2410_DMA_DEBUG is not set 147# CONFIG_S3C2410_DMA_DEBUG is not set
148CONFIG_MACH_SMDK=y 148CONFIG_MACH_SMDK=y
@@ -1392,8 +1392,8 @@ CONFIG_DEBUG_USER=y
1392# CONFIG_DEBUG_ERRORS is not set 1392# CONFIG_DEBUG_ERRORS is not set
1393CONFIG_DEBUG_LL=y 1393CONFIG_DEBUG_LL=y
1394# CONFIG_DEBUG_ICEDCC is not set 1394# CONFIG_DEBUG_ICEDCC is not set
1395CONFIG_DEBUG_S3C2410_PORT=y 1395CONFIG_DEBUG_S3C_PORT=y
1396CONFIG_DEBUG_S3C2410_UART=0 1396CONFIG_DEBUG_S3C_UART=0
1397 1397
1398# 1398#
1399# Security options 1399# Security options
diff --git a/arch/arm/mach-at91/at91rm9200_devices.c b/arch/arm/mach-at91/at91rm9200_devices.c
index 70599bcf451c..0417c165d50d 100644
--- a/arch/arm/mach-at91/at91rm9200_devices.c
+++ b/arch/arm/mach-at91/at91rm9200_devices.c
@@ -477,7 +477,7 @@ void __init at91_add_device_i2c(void) {}
477 * SPI 477 * SPI
478 * -------------------------------------------------------------------- */ 478 * -------------------------------------------------------------------- */
479 479
480#if defined(CONFIG_SPI_AT91) || defined(CONFIG_SPI_AT91_MODULE) || defined(CONFIG_AT91_SPI) || defined(CONFIG_AT91_SPI_MODULE) 480#if defined(CONFIG_SPI_ATMEL) || defined(CONFIG_SPI_ATMEL_MODULE)
481static u64 spi_dmamask = 0xffffffffUL; 481static u64 spi_dmamask = 0xffffffffUL;
482 482
483static struct resource spi_resources[] = { 483static struct resource spi_resources[] = {
@@ -494,7 +494,7 @@ static struct resource spi_resources[] = {
494}; 494};
495 495
496static struct platform_device at91rm9200_spi_device = { 496static struct platform_device at91rm9200_spi_device = {
497 .name = "at91_spi", 497 .name = "atmel_spi",
498 .id = 0, 498 .id = 0,
499 .dev = { 499 .dev = {
500 .dma_mask = &spi_dmamask, 500 .dma_mask = &spi_dmamask,
@@ -522,18 +522,14 @@ void __init at91_add_device_spi(struct spi_board_info *devices, int nr_devices)
522 else 522 else
523 cs_pin = spi_standard_cs[devices[i].chip_select]; 523 cs_pin = spi_standard_cs[devices[i].chip_select];
524 524
525#ifdef CONFIG_SPI_AT91_MANUAL_CS 525 /* enable chip-select pin */
526 at91_set_gpio_output(cs_pin, 1); 526 at91_set_gpio_output(cs_pin, 1);
527#else
528 at91_set_A_periph(cs_pin, 0);
529#endif
530 527
531 /* pass chip-select pin to driver */ 528 /* pass chip-select pin to driver */
532 devices[i].controller_data = (void *) cs_pin; 529 devices[i].controller_data = (void *) cs_pin;
533 } 530 }
534 531
535 spi_register_board_info(devices, nr_devices); 532 spi_register_board_info(devices, nr_devices);
536 at91_clock_associate("spi_clk", &at91rm9200_spi_device.dev, "spi");
537 platform_device_register(&at91rm9200_spi_device); 533 platform_device_register(&at91rm9200_spi_device);
538} 534}
539#else 535#else
diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c
index 4d8425de6922..e96a3dcdc1a7 100644
--- a/arch/arm/mach-davinci/time.c
+++ b/arch/arm/mach-davinci/time.c
@@ -285,6 +285,8 @@ static void davinci_set_mode(enum clock_event_mode mode,
285 case CLOCK_EVT_MODE_SHUTDOWN: 285 case CLOCK_EVT_MODE_SHUTDOWN:
286 t->opts = TIMER_OPTS_DISABLED; 286 t->opts = TIMER_OPTS_DISABLED;
287 break; 287 break;
288 case CLOCK_EVT_MODE_RESUME:
289 break;
288 } 290 }
289} 291}
290 292
diff --git a/arch/arm/mach-imx/time.c b/arch/arm/mach-imx/time.c
index 010f6fa984a6..d86d124aea22 100644
--- a/arch/arm/mach-imx/time.c
+++ b/arch/arm/mach-imx/time.c
@@ -159,6 +159,7 @@ static void imx_set_mode(enum clock_event_mode mode, struct clock_event_device *
159 break; 159 break;
160 case CLOCK_EVT_MODE_SHUTDOWN: 160 case CLOCK_EVT_MODE_SHUTDOWN:
161 case CLOCK_EVT_MODE_UNUSED: 161 case CLOCK_EVT_MODE_UNUSED:
162 case CLOCK_EVT_MODE_RESUME:
162 /* Left event sources disabled, no more interrupts appears */ 163 /* Left event sources disabled, no more interrupts appears */
163 break; 164 break;
164 } 165 }
diff --git a/arch/arm/mach-iop32x/Kconfig b/arch/arm/mach-iop32x/Kconfig
index 9bb02b6d7ae1..dbe07c9472ed 100644
--- a/arch/arm/mach-iop32x/Kconfig
+++ b/arch/arm/mach-iop32x/Kconfig
@@ -42,6 +42,13 @@ config IOP3XX_ATU
42 Say N if the IOP is an add in card, the host system owns the PCI 42 Say N if the IOP is an add in card, the host system owns the PCI
43 bus in this case. 43 bus in this case.
44 44
45config MACH_EM7210
46 bool "Enable support for the Lanner EM7210"
47 help
48 Say Y here if you want to run your kernel on the Lanner EM7210
49 board. Say also Y here if you have a SS4000e Baxter Creek NAS
50 appliance."
51
45endmenu 52endmenu
46 53
47endif 54endif
diff --git a/arch/arm/mach-iop32x/Makefile b/arch/arm/mach-iop32x/Makefile
index 7b05b37e1f94..cfdf8a137c2b 100644
--- a/arch/arm/mach-iop32x/Makefile
+++ b/arch/arm/mach-iop32x/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_MACH_GLANTANK) += glantank.o
11obj-$(CONFIG_ARCH_IQ80321) += iq80321.o 11obj-$(CONFIG_ARCH_IQ80321) += iq80321.o
12obj-$(CONFIG_ARCH_IQ31244) += iq31244.o 12obj-$(CONFIG_ARCH_IQ31244) += iq31244.o
13obj-$(CONFIG_MACH_N2100) += n2100.o 13obj-$(CONFIG_MACH_N2100) += n2100.o
14obj-$(CONFIG_MACH_EM7210) += em7210.o
diff --git a/arch/arm/mach-iop32x/em7210.c b/arch/arm/mach-iop32x/em7210.c
new file mode 100644
index 000000000000..c947152f9a3c
--- /dev/null
+++ b/arch/arm/mach-iop32x/em7210.c
@@ -0,0 +1,215 @@
1/*
2 * arch/arm/mach-iop32x/em7210.c
3 *
4 * Board support code for the Lanner EM7210 platforms.
5 *
6 * Based on arch/arm/mach-iop32x/iq31244.c file.
7 *
8 * Copyright (C) 2007 Arnaud Patard <arnaud.patard@rtp-net.org>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 */
15
16#include <linux/mm.h>
17#include <linux/init.h>
18#include <linux/kernel.h>
19#include <linux/pci.h>
20#include <linux/pm.h>
21#include <linux/serial_core.h>
22#include <linux/serial_8250.h>
23#include <linux/mtd/physmap.h>
24#include <linux/platform_device.h>
25#include <linux/i2c.h>
26#include <asm/hardware.h>
27#include <linux/io.h>
28#include <linux/irq.h>
29#include <asm/mach/arch.h>
30#include <asm/mach/map.h>
31#include <asm/mach/pci.h>
32#include <asm/mach/time.h>
33#include <asm/mach-types.h>
34#include <asm/arch/time.h>
35
36static void __init em7210_timer_init(void)
37{
38 /* http://www.kwaak.net/fotos/fotos-nas/slide_24.html */
39 /* 33.333 MHz crystal. */
40 iop_init_time(200000000);
41}
42
43static struct sys_timer em7210_timer = {
44 .init = em7210_timer_init,
45 .offset = iop_gettimeoffset,
46};
47
48/*
49 * EM7210 RTC
50 */
51static struct i2c_board_info __initdata em7210_i2c_devices[] = {
52 {
53 I2C_BOARD_INFO("rtc-rs5c372", 0x32),
54 .type = "rs5c372a",
55 },
56};
57
58/*
59 * EM7210 I/O
60 */
61static struct map_desc em7210_io_desc[] __initdata = {
62 { /* on-board devices */
63 .virtual = IQ31244_UART,
64 .pfn = __phys_to_pfn(IQ31244_UART),
65 .length = 0x00100000,
66 .type = MT_DEVICE,
67 },
68};
69
70void __init em7210_map_io(void)
71{
72 iop3xx_map_io();
73 iotable_init(em7210_io_desc, ARRAY_SIZE(em7210_io_desc));
74}
75
76
77/*
78 * EM7210 PCI
79 */
80#define INTA IRQ_IOP32X_XINT0
81#define INTB IRQ_IOP32X_XINT1
82#define INTC IRQ_IOP32X_XINT2
83#define INTD IRQ_IOP32X_XINT3
84
85static int __init
86em7210_pci_map_irq(struct pci_dev *dev, u8 slot, u8 pin)
87{
88 static int pci_irq_table[][4] = {
89 /*
90 * PCI IDSEL/INTPIN->INTLINE
91 * A B C D
92 */
93 {INTB, INTB, INTB, INTB}, /* console / uart */
94 {INTA, INTA, INTA, INTA}, /* 1st 82541 */
95 {INTD, INTD, INTD, INTD}, /* 2nd 82541 */
96 {INTC, INTC, INTC, INTC}, /* GD31244 */
97 {INTD, INTA, INTA, INTA}, /* mini-PCI */
98 {INTD, INTC, INTA, INTA}, /* NEC USB */
99 };
100
101 if (pin < 1 || pin > 4)
102 return -1;
103
104 return pci_irq_table[slot % 6][pin - 1];
105}
106
107static struct hw_pci em7210_pci __initdata = {
108 .swizzle = pci_std_swizzle,
109 .nr_controllers = 1,
110 .setup = iop3xx_pci_setup,
111 .preinit = iop3xx_pci_preinit,
112 .scan = iop3xx_pci_scan_bus,
113 .map_irq = em7210_pci_map_irq,
114};
115
116static int __init em7210_pci_init(void)
117{
118 if (machine_is_em7210())
119 pci_common_init(&em7210_pci);
120
121 return 0;
122}
123
124subsys_initcall(em7210_pci_init);
125
126
127/*
128 * EM7210 Flash
129 */
130static struct physmap_flash_data em7210_flash_data = {
131 .width = 2,
132};
133
134static struct resource em7210_flash_resource = {
135 .start = 0xf0000000,
136 .end = 0xf1ffffff,
137 .flags = IORESOURCE_MEM,
138};
139
140static struct platform_device em7210_flash_device = {
141 .name = "physmap-flash",
142 .id = 0,
143 .dev = {
144 .platform_data = &em7210_flash_data,
145 },
146 .num_resources = 1,
147 .resource = &em7210_flash_resource,
148};
149
150
151/*
152 * EM7210 UART
153 * The physical address of the serial port is 0xfe800000,
154 * so it can be used for physical and virtual address.
155 */
156static struct plat_serial8250_port em7210_serial_port[] = {
157 {
158 .mapbase = IQ31244_UART,
159 .membase = (char *)IQ31244_UART,
160 .irq = IRQ_IOP32X_XINT1,
161 .flags = UPF_SKIP_TEST,
162 .iotype = UPIO_MEM,
163 .regshift = 0,
164 .uartclk = 1843200,
165 },
166 { },
167};
168
169static struct resource em7210_uart_resource = {
170 .start = IQ31244_UART,
171 .end = IQ31244_UART + 7,
172 .flags = IORESOURCE_MEM,
173};
174
175static struct platform_device em7210_serial_device = {
176 .name = "serial8250",
177 .id = PLAT8250_DEV_PLATFORM,
178 .dev = {
179 .platform_data = em7210_serial_port,
180 },
181 .num_resources = 1,
182 .resource = &em7210_uart_resource,
183};
184
185void em7210_power_off(void)
186{
187 *IOP3XX_GPOE &= 0xfe;
188 *IOP3XX_GPOD |= 0x01;
189}
190
191static void __init em7210_init_machine(void)
192{
193 platform_device_register(&em7210_serial_device);
194 platform_device_register(&iop3xx_i2c0_device);
195 platform_device_register(&iop3xx_i2c1_device);
196 platform_device_register(&em7210_flash_device);
197 platform_device_register(&iop3xx_dma_0_channel);
198 platform_device_register(&iop3xx_dma_1_channel);
199
200 i2c_register_board_info(0, em7210_i2c_devices,
201 ARRAY_SIZE(em7210_i2c_devices));
202
203
204 pm_power_off = em7210_power_off;
205}
206
207MACHINE_START(EM7210, "Lanner EM7210")
208 .phys_io = IQ31244_UART,
209 .io_pg_offst = ((IQ31244_UART) >> 18) & 0xfffc,
210 .boot_params = 0xa0000100,
211 .map_io = em7210_map_io,
212 .init_irq = iop32x_init_irq,
213 .timer = &em7210_timer,
214 .init_machine = em7210_init_machine,
215MACHINE_END
diff --git a/arch/arm/mach-iop32x/irq.c b/arch/arm/mach-iop32x/irq.c
index c971171c2905..55cf0162e8c1 100644
--- a/arch/arm/mach-iop32x/irq.c
+++ b/arch/arm/mach-iop32x/irq.c
@@ -63,7 +63,8 @@ void __init iop32x_init_irq(void)
63 if (machine_is_glantank() || 63 if (machine_is_glantank() ||
64 machine_is_iq80321() || 64 machine_is_iq80321() ||
65 machine_is_iq31244() || 65 machine_is_iq31244() ||
66 machine_is_n2100()) 66 machine_is_n2100() ||
67 machine_is_em7210())
67 *IOP3XX_PCIIRSR = 0x0f; 68 *IOP3XX_PCIIRSR = 0x0f;
68 69
69 for (i = 0; i < NR_IRQS; i++) { 70 for (i = 0; i < NR_IRQS; i++) {
diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c
index 8112f726ffa0..c1271c449246 100644
--- a/arch/arm/mach-ixp4xx/common.c
+++ b/arch/arm/mach-ixp4xx/common.c
@@ -188,7 +188,7 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type)
188 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE)); 188 *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE));
189 189
190 /* Configure the line as an input */ 190 /* Configure the line as an input */
191 gpio_line_config(line, IXP4XX_GPIO_IN); 191 gpio_line_config(irq2gpio[irq], IXP4XX_GPIO_IN);
192 192
193 return 0; 193 return 0;
194} 194}
@@ -459,6 +459,8 @@ static void ixp4xx_set_mode(enum clock_event_mode mode,
459 default: 459 default:
460 osrt = opts = 0; 460 osrt = opts = 0;
461 break; 461 break;
462 case CLOCK_EVT_MODE_RESUME:
463 break;
462 } 464 }
463 465
464 *IXP4XX_OSRT1 = osrt | opts; 466 *IXP4XX_OSRT1 = osrt | opts;
diff --git a/arch/arm/mach-ks8695/irq.c b/arch/arm/mach-ks8695/irq.c
index 2407bba00547..4c3ab43e1046 100644
--- a/arch/arm/mach-ks8695/irq.c
+++ b/arch/arm/mach-ks8695/irq.c
@@ -23,7 +23,6 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/ioport.h> 25#include <linux/ioport.h>
26#include <linux/ptrace.h>
27#include <linux/sysdev.h> 26#include <linux/sysdev.h>
28 27
29#include <asm/hardware.h> 28#include <asm/hardware.h>
diff --git a/arch/arm/mach-mx3/Kconfig b/arch/arm/mach-mx3/Kconfig
new file mode 100644
index 000000000000..5fe8606cac08
--- /dev/null
+++ b/arch/arm/mach-mx3/Kconfig
@@ -0,0 +1,12 @@
1menu "MX3 Options"
2 depends on ARCH_MX3
3
4config MACH_MX31ADS
5 bool "Support MX31ADS platforms"
6 default y
7 help
8 Include support for MX31ADS platform. This includes specific
9 configurations for the board and its peripherals.
10
11endmenu
12
diff --git a/arch/arm/mach-mx3/Makefile b/arch/arm/mach-mx3/Makefile
new file mode 100644
index 000000000000..cbec997f332a
--- /dev/null
+++ b/arch/arm/mach-mx3/Makefile
@@ -0,0 +1,8 @@
1#
2# Makefile for the linux kernel.
3#
4
5# Object file lists.
6
7obj-y := mm.o time.o
8obj-$(CONFIG_MACH_MX31ADS) += mx31ads.o
diff --git a/arch/arm/mach-mx3/Makefile.boot b/arch/arm/mach-mx3/Makefile.boot
new file mode 100644
index 000000000000..e1dd366f836b
--- /dev/null
+++ b/arch/arm/mach-mx3/Makefile.boot
@@ -0,0 +1,3 @@
1 zreladdr-y := 0x80008000
2params_phys-y := 0x80000100
3initrd_phys-y := 0x80800000
diff --git a/arch/arm/mach-mx3/mm.c b/arch/arm/mach-mx3/mm.c
new file mode 100644
index 000000000000..41dad485ded9
--- /dev/null
+++ b/arch/arm/mach-mx3/mm.c
@@ -0,0 +1,64 @@
1/*
2 * Copyright (C) 1999,2000 Arm Limited
3 * Copyright (C) 2000 Deep Blue Solutions Ltd
4 * Copyright (C) 2002 Shane Nay (shane@minirl.com)
5 * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
6 * - add MX31 specific definitions
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
23#include <linux/mm.h>
24#include <linux/init.h>
25#include <asm/hardware.h>
26#include <asm/pgtable.h>
27#include <asm/mach/map.h>
28#include <asm/arch/common.h>
29
30/*!
31 * @file mm.c
32 *
33 * @brief This file creates static virtual to physical mappings, common to all MX3 boards.
34 *
35 * @ingroup Memory
36 */
37
38/*!
39 * This table defines static virtual address mappings for I/O regions.
40 * These are the mappings common across all MX3 boards.
41 */
42static struct map_desc mxc_io_desc[] __initdata = {
43 {
44 .virtual = X_MEMC_BASE_ADDR_VIRT,
45 .pfn = __phys_to_pfn(X_MEMC_BASE_ADDR),
46 .length = X_MEMC_SIZE,
47 .type = MT_DEVICE
48 }, {
49 .virtual = AVIC_BASE_ADDR_VIRT,
50 .pfn = __phys_to_pfn(AVIC_BASE_ADDR),
51 .length = AVIC_SIZE,
52 .type = MT_NONSHARED_DEVICE
53 },
54};
55
56/*!
57 * This function initializes the memory map. It is called during the
58 * system startup to create static physical to virtual memory mappings
59 * for the IO modules.
60 */
61void __init mxc_map_io(void)
62{
63 iotable_init(mxc_io_desc, ARRAY_SIZE(mxc_io_desc));
64}
diff --git a/arch/arm/mach-mx3/mx31ads.c b/arch/arm/mach-mx3/mx31ads.c
new file mode 100644
index 000000000000..7e89bdc23a9f
--- /dev/null
+++ b/arch/arm/mach-mx3/mx31ads.c
@@ -0,0 +1,142 @@
1/*
2 * Copyright (C) 2000 Deep Blue Solutions Ltd
3 * Copyright (C) 2002 Shane Nay (shane@minirl.com)
4 * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/types.h>
22#include <linux/init.h>
23#include <linux/clk.h>
24#include <linux/serial_8250.h>
25
26#include <asm/hardware.h>
27#include <asm/mach-types.h>
28#include <asm/mach/arch.h>
29#include <asm/memory.h>
30#include <asm/mach/map.h>
31#include <asm/arch/common.h>
32
33/*!
34 * @file mx31ads.c
35 *
36 * @brief This file contains the board-specific initialization routines.
37 *
38 * @ingroup System
39 */
40
41#if defined(CONFIG_SERIAL_8250) || defined(CONFIG_SERIAL_8250_MODULE)
42/*!
43 * The serial port definition structure.
44 */
45static struct plat_serial8250_port serial_platform_data[] = {
46 {
47 .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTA),
48 .mapbase = (unsigned long)(CS4_BASE_ADDR + PBC_SC16C652_UARTA),
49 .irq = EXPIO_INT_XUART_INTA,
50 .uartclk = 14745600,
51 .regshift = 0,
52 .iotype = UPIO_MEM,
53 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ,
54 }, {
55 .membase = (void *)(PBC_BASE_ADDRESS + PBC_SC16C652_UARTB),
56 .mapbase = (unsigned long)(CS4_BASE_ADDR + PBC_SC16C652_UARTB),
57 .irq = EXPIO_INT_XUART_INTB,
58 .uartclk = 14745600,
59 .regshift = 0,
60 .iotype = UPIO_MEM,
61 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_AUTO_IRQ,
62 },
63 {},
64};
65
66static struct platform_device serial_device = {
67 .name = "serial8250",
68 .id = 0,
69 .dev = {
70 .platform_data = serial_platform_data,
71 },
72};
73
74static int __init mxc_init_extuart(void)
75{
76 return platform_device_register(&serial_device);
77}
78#else
79static inline int mxc_init_extuart(void)
80{
81 return 0;
82}
83#endif
84
85/*!
86 * This structure defines static mappings for the i.MX31ADS board.
87 */
88static struct map_desc mx31ads_io_desc[] __initdata = {
89 {
90 .virtual = AIPS1_BASE_ADDR_VIRT,
91 .pfn = __phys_to_pfn(AIPS1_BASE_ADDR),
92 .length = AIPS1_SIZE,
93 .type = MT_NONSHARED_DEVICE
94 }, {
95 .virtual = SPBA0_BASE_ADDR_VIRT,
96 .pfn = __phys_to_pfn(SPBA0_BASE_ADDR),
97 .length = SPBA0_SIZE,
98 .type = MT_NONSHARED_DEVICE
99 }, {
100 .virtual = AIPS2_BASE_ADDR_VIRT,
101 .pfn = __phys_to_pfn(AIPS2_BASE_ADDR),
102 .length = AIPS2_SIZE,
103 .type = MT_NONSHARED_DEVICE
104 }, {
105 .virtual = CS4_BASE_ADDR_VIRT,
106 .pfn = __phys_to_pfn(CS4_BASE_ADDR),
107 .length = CS4_SIZE / 2,
108 .type = MT_DEVICE
109 },
110};
111
112/*!
113 * Set up static virtual mappings.
114 */
115void __init mx31ads_map_io(void)
116{
117 mxc_map_io();
118 iotable_init(mx31ads_io_desc, ARRAY_SIZE(mx31ads_io_desc));
119}
120
121/*!
122 * Board specific initialization.
123 */
124static void __init mxc_board_init(void)
125{
126 mxc_init_extuart();
127}
128
129/*
130 * The following uses standard kernel macros defined in arch.h in order to
131 * initialize __mach_desc_MX31ADS data structure.
132 */
133MACHINE_START(MX31ADS, "Freescale MX31ADS")
134 /* Maintainer: Freescale Semiconductor, Inc. */
135 .phys_io = AIPS1_BASE_ADDR,
136 .io_pg_offst = ((AIPS1_BASE_ADDR_VIRT) >> 18) & 0xfffc,
137 .boot_params = PHYS_OFFSET + 0x100,
138 .map_io = mx31ads_map_io,
139 .init_irq = mxc_init_irq,
140 .init_machine = mxc_board_init,
141 .timer = &mxc_timer,
142MACHINE_END
diff --git a/arch/arm/mach-mx3/time.c b/arch/arm/mach-mx3/time.c
new file mode 100644
index 000000000000..e81fb5c5d7c3
--- /dev/null
+++ b/arch/arm/mach-mx3/time.c
@@ -0,0 +1,152 @@
1/*
2 * System Timer Interrupt reconfigured to run in free-run mode.
3 * Author: Vitaly Wool
4 * Copyright 2004 MontaVista Software Inc.
5 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14/*!
15 * @file time.c
16 * @brief This file contains OS tick and wdog timer implementations.
17 *
18 * This file contains OS tick and wdog timer implementations.
19 *
20 * @ingroup Timers
21 */
22
23#include <linux/module.h>
24#include <linux/init.h>
25#include <linux/interrupt.h>
26#include <linux/irq.h>
27#include <asm/hardware.h>
28#include <asm/mach/time.h>
29#include <asm/io.h>
30#include <asm/arch/common.h>
31
32/*!
33 * This is the timer interrupt service routine to do required tasks.
34 * It also services the WDOG timer at the frequency of twice per WDOG
35 * timeout value. For example, if the WDOG's timeout value is 4 (2
36 * seconds since the WDOG runs at 0.5Hz), it will be serviced once
37 * every 2/2=1 second.
38 *
39 * @param irq GPT interrupt source number (not used)
40 * @param dev_id this parameter is not used
41 * @return always returns \b IRQ_HANDLED as defined in
42 * include/linux/interrupt.h.
43 */
44static irqreturn_t mxc_timer_interrupt(int irq, void *dev_id)
45{
46 unsigned int next_match;
47
48 write_seqlock(&xtime_lock);
49
50 if (__raw_readl(MXC_GPT_GPTSR) & GPTSR_OF1) {
51 do {
52 timer_tick();
53 next_match = __raw_readl(MXC_GPT_GPTOCR1) + LATCH;
54 __raw_writel(GPTSR_OF1, MXC_GPT_GPTSR);
55 __raw_writel(next_match, MXC_GPT_GPTOCR1);
56 } while ((signed long)(next_match -
57 __raw_readl(MXC_GPT_GPTCNT)) <= 0);
58 }
59
60 write_sequnlock(&xtime_lock);
61
62 return IRQ_HANDLED;
63}
64
65/*!
66 * This function is used to obtain the number of microseconds since the last
67 * timer interrupt. Note that interrupts is disabled by do_gettimeofday().
68 *
69 * @return the number of microseconds since the last timer interrupt.
70 */
71static unsigned long mxc_gettimeoffset(void)
72{
73 unsigned long ticks_to_match, elapsed, usec, tick_usec, i;
74
75 /* Get ticks before next timer match */
76 ticks_to_match =
77 __raw_readl(MXC_GPT_GPTOCR1) - __raw_readl(MXC_GPT_GPTCNT);
78
79 /* We need elapsed ticks since last match */
80 elapsed = LATCH - ticks_to_match;
81
82 /* Now convert them to usec */
83 /* Insure no overflow when calculating the usec below */
84 for (i = 1, tick_usec = tick_nsec / 1000;; i *= 2) {
85 tick_usec /= i;
86 if ((0xFFFFFFFF / tick_usec) > elapsed)
87 break;
88 }
89 usec = (unsigned long)(elapsed * tick_usec) / (LATCH / i);
90
91 return usec;
92}
93
94/*!
95 * The OS tick timer interrupt structure.
96 */
97static struct irqaction timer_irq = {
98 .name = "MXC Timer Tick",
99 .flags = IRQF_DISABLED | IRQF_TIMER,
100 .handler = mxc_timer_interrupt
101};
102
103/*!
104 * This function is used to initialize the GPT to produce an interrupt
105 * based on HZ. It is called by start_kernel() during system startup.
106 */
107void __init mxc_init_time(void)
108{
109 u32 reg, v;
110 reg = __raw_readl(MXC_GPT_GPTCR);
111 reg &= ~GPTCR_ENABLE;
112 __raw_writel(reg, MXC_GPT_GPTCR);
113 reg |= GPTCR_SWR;
114 __raw_writel(reg, MXC_GPT_GPTCR);
115
116 while ((__raw_readl(MXC_GPT_GPTCR) & GPTCR_SWR) != 0)
117 cpu_relax();
118
119 reg = GPTCR_FRR | GPTCR_CLKSRC_HIGHFREQ;
120 __raw_writel(reg, MXC_GPT_GPTCR);
121
122 /* TODO: get timer rate from clk driver */
123 v = 66500000;
124
125 __raw_writel((v / CLOCK_TICK_RATE) - 1, MXC_GPT_GPTPR);
126
127 if ((v % CLOCK_TICK_RATE) != 0) {
128 pr_info("\nWARNING: Can't generate CLOCK_TICK_RATE at %d Hz\n",
129 CLOCK_TICK_RATE);
130 }
131 pr_info("Actual CLOCK_TICK_RATE is %d Hz\n",
132 v / ((__raw_readl(MXC_GPT_GPTPR) & 0xFFF) + 1));
133
134 reg = __raw_readl(MXC_GPT_GPTCNT);
135 reg += LATCH;
136 __raw_writel(reg, MXC_GPT_GPTOCR1);
137
138 setup_irq(MXC_INT_GPT, &timer_irq);
139
140 reg = __raw_readl(MXC_GPT_GPTCR);
141 reg =
142 GPTCR_FRR | GPTCR_CLKSRC_HIGHFREQ | GPTCR_STOPEN | GPTCR_DOZEN |
143 GPTCR_WAITEN | GPTCR_ENMOD | GPTCR_ENABLE;
144 __raw_writel(reg, MXC_GPT_GPTCR);
145
146 __raw_writel(GPTIR_OF1IE, MXC_GPT_GPTIR);
147}
148
149struct sys_timer mxc_timer = {
150 .init = mxc_init_time,
151 .offset = mxc_gettimeoffset,
152};
diff --git a/arch/arm/mach-ns9xxx/Makefile b/arch/arm/mach-ns9xxx/Makefile
index 53213a69f601..4476411b8140 100644
--- a/arch/arm/mach-ns9xxx/Makefile
+++ b/arch/arm/mach-ns9xxx/Makefile
@@ -1,6 +1,7 @@
1obj-y := irq.o time.o generic.o 1obj-y := irq.o time.o generic.o
2 2
3obj-$(CONFIG_MACH_CC9P9360DEV) += mach-cc9p9360dev.o 3obj-$(CONFIG_MACH_CC9P9360DEV) += mach-cc9p9360dev.o
4obj-$(CONFIG_MACH_CC9P9360JS) += mach-cc9p9360js.o
4 5
5obj-$(CONFIG_BOARD_A9M9750DEV) += board-a9m9750dev.o 6obj-$(CONFIG_BOARD_A9M9750DEV) += board-a9m9750dev.o
6obj-$(CONFIG_BOARD_JSCC9P9360) += board-jscc9p9360.o 7obj-$(CONFIG_BOARD_JSCC9P9360) += board-jscc9p9360.o
diff --git a/arch/arm/mach-ns9xxx/board-a9m9750dev.c b/arch/arm/mach-ns9xxx/board-a9m9750dev.c
index 25289884a607..925048e7adfe 100644
--- a/arch/arm/mach-ns9xxx/board-a9m9750dev.c
+++ b/arch/arm/mach-ns9xxx/board-a9m9750dev.c
@@ -77,7 +77,7 @@ static void a9m9750dev_fpga_demux_handler(unsigned int irq,
77 77
78 desc = irq_desc + FPGA_IRQ(irqno); 78 desc = irq_desc + FPGA_IRQ(irqno);
79 79
80 desc_handle_irq(irqno, desc); 80 desc_handle_irq(FPGA_IRQ(irqno), desc);
81 } 81 }
82} 82}
83 83
@@ -91,7 +91,7 @@ void __init board_a9m9750dev_init_irq(void)
91 * use GPIO 11, because GPIO 32 is used for the LCD 91 * use GPIO 11, because GPIO 32 is used for the LCD
92 */ 92 */
93 /* XXX: proper GPIO handling */ 93 /* XXX: proper GPIO handling */
94 BBU_GC(2) &= ~0x2000; 94 BBU_GCONFb1(1) &= ~0x2000;
95 95
96 for (i = FPGA_IRQ(0); i <= FPGA_IRQ(7); ++i) { 96 for (i = FPGA_IRQ(0); i <= FPGA_IRQ(7); ++i) {
97 set_irq_chip(i, &a9m9750dev_fpga_chip); 97 set_irq_chip(i, &a9m9750dev_fpga_chip);
@@ -178,7 +178,7 @@ void __init board_a9m9750dev_init_machine(void)
178 178
179 /* setup static CS0: memory configuration */ 179 /* setup static CS0: memory configuration */
180 reg = MEM_SMC(0); 180 reg = MEM_SMC(0);
181 REGSET(reg, MEM_SMC, WSMC, OFF); 181 REGSET(reg, MEM_SMC, PSMC, OFF);
182 REGSET(reg, MEM_SMC, BSMC, OFF); 182 REGSET(reg, MEM_SMC, BSMC, OFF);
183 REGSET(reg, MEM_SMC, EW, OFF); 183 REGSET(reg, MEM_SMC, EW, OFF);
184 REGSET(reg, MEM_SMC, PB, 1); 184 REGSET(reg, MEM_SMC, PB, 1);
@@ -196,4 +196,3 @@ void __init board_a9m9750dev_init_machine(void)
196 platform_add_devices(board_a9m9750dev_devices, 196 platform_add_devices(board_a9m9750dev_devices,
197 ARRAY_SIZE(board_a9m9750dev_devices)); 197 ARRAY_SIZE(board_a9m9750dev_devices));
198} 198}
199
diff --git a/arch/arm/mach-ns9xxx/generic.c b/arch/arm/mach-ns9xxx/generic.c
index 83e2b6532b22..d742c921e34d 100644
--- a/arch/arm/mach-ns9xxx/generic.c
+++ b/arch/arm/mach-ns9xxx/generic.c
@@ -18,6 +18,8 @@
18#include <asm/arch-ns9xxx/regs-mem.h> 18#include <asm/arch-ns9xxx/regs-mem.h>
19#include <asm/arch-ns9xxx/board.h> 19#include <asm/arch-ns9xxx/board.h>
20 20
21#include "generic.h"
22
21static struct map_desc standard_io_desc[] __initdata = { 23static struct map_desc standard_io_desc[] __initdata = {
22 { /* BBus */ 24 { /* BBus */
23 .virtual = io_p2v(0x90000000), 25 .virtual = io_p2v(0x90000000),
diff --git a/arch/arm/mach-ns9xxx/irq.c b/arch/arm/mach-ns9xxx/irq.c
index 83d92724a971..b8c7b00522e6 100644
--- a/arch/arm/mach-ns9xxx/irq.c
+++ b/arch/arm/mach-ns9xxx/irq.c
@@ -21,6 +21,15 @@ static void ns9xxx_ack_irq_timer(unsigned int irq)
21{ 21{
22 u32 tc = SYS_TC(irq - IRQ_TIMER0); 22 u32 tc = SYS_TC(irq - IRQ_TIMER0);
23 23
24 /*
25 * If the timer is programmed to halt on terminal count, the
26 * timer must be disabled before clearing the interrupt.
27 */
28 if (REGGET(tc, SYS_TCx, REN) == 0) {
29 REGSET(tc, SYS_TCx, TEN, DIS);
30 SYS_TC(irq - IRQ_TIMER0) = tc;
31 }
32
24 REGSET(tc, SYS_TCx, INTC, SET); 33 REGSET(tc, SYS_TCx, INTC, SET);
25 SYS_TC(irq - IRQ_TIMER0) = tc; 34 SYS_TC(irq - IRQ_TIMER0) = tc;
26 35
@@ -28,7 +37,7 @@ static void ns9xxx_ack_irq_timer(unsigned int irq)
28 SYS_TC(irq - IRQ_TIMER0) = tc; 37 SYS_TC(irq - IRQ_TIMER0) = tc;
29} 38}
30 39
31void (*ns9xxx_ack_irq_functions[NR_IRQS])(unsigned int) = { 40static void (*ns9xxx_ack_irq_functions[NR_IRQS])(unsigned int) = {
32 [IRQ_TIMER0] = ns9xxx_ack_irq_timer, 41 [IRQ_TIMER0] = ns9xxx_ack_irq_timer,
33 [IRQ_TIMER1] = ns9xxx_ack_irq_timer, 42 [IRQ_TIMER1] = ns9xxx_ack_irq_timer,
34 [IRQ_TIMER2] = ns9xxx_ack_irq_timer, 43 [IRQ_TIMER2] = ns9xxx_ack_irq_timer,
diff --git a/arch/arm/mach-ns9xxx/mach-cc9p9360js.c b/arch/arm/mach-ns9xxx/mach-cc9p9360js.c
index d09d5fa5620a..85c8b41105c9 100644
--- a/arch/arm/mach-ns9xxx/mach-cc9p9360js.c
+++ b/arch/arm/mach-ns9xxx/mach-cc9p9360js.c
@@ -20,7 +20,7 @@ static void __init mach_cc9p9360js_init_machine(void)
20 board_jscc9p9360_init_machine(); 20 board_jscc9p9360_init_machine();
21} 21}
22 22
23MACHINE_START(CC9P9360DEV, "Digi ConnectCore 9P 9360 on an JSCC9P9360 Devboard") 23MACHINE_START(CC9P9360JS, "Digi ConnectCore 9P 9360 on an JSCC9P9360 Devboard")
24 .map_io = ns9xxx_map_io, 24 .map_io = ns9xxx_map_io,
25 .init_irq = ns9xxx_init_irq, 25 .init_irq = ns9xxx_init_irq,
26 .init_machine = mach_cc9p9360js_init_machine, 26 .init_machine = mach_cc9p9360js_init_machine,
diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c
index 3705d20c4e5c..237651ebae5d 100644
--- a/arch/arm/mach-omap1/time.c
+++ b/arch/arm/mach-omap1/time.c
@@ -156,6 +156,7 @@ static void omap_mpu_set_mode(enum clock_event_mode mode,
156 break; 156 break;
157 case CLOCK_EVT_MODE_UNUSED: 157 case CLOCK_EVT_MODE_UNUSED:
158 case CLOCK_EVT_MODE_SHUTDOWN: 158 case CLOCK_EVT_MODE_SHUTDOWN:
159 case CLOCK_EVT_MODE_RESUME:
159 break; 160 break;
160 } 161 }
161} 162}
diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig
index 5c0a10041cd1..5ebec6d88b51 100644
--- a/arch/arm/mach-pxa/Kconfig
+++ b/arch/arm/mach-pxa/Kconfig
@@ -37,6 +37,10 @@ config MACH_TRIZEPS4
37 bool "Keith und Koep Trizeps4 DIMM-Module" 37 bool "Keith und Koep Trizeps4 DIMM-Module"
38 select PXA27x 38 select PXA27x
39 39
40config MACH_EM_X270
41 bool "CompuLab EM-x270 platform"
42 select PXA27x
43
40endchoice 44endchoice
41 45
42if PXA_SHARPSL 46if PXA_SHARPSL
diff --git a/arch/arm/mach-pxa/Makefile b/arch/arm/mach-pxa/Makefile
index 9093eb1c94eb..7d6ab5c59ab9 100644
--- a/arch/arm/mach-pxa/Makefile
+++ b/arch/arm/mach-pxa/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_PXA_SHARP_Cxx00) += spitz.o corgi_ssp.o corgi_lcd.o sharpsl_pm.o sp
18obj-$(CONFIG_MACH_AKITA) += akita-ioexp.o 18obj-$(CONFIG_MACH_AKITA) += akita-ioexp.o
19obj-$(CONFIG_MACH_POODLE) += poodle.o corgi_ssp.o 19obj-$(CONFIG_MACH_POODLE) += poodle.o corgi_ssp.o
20obj-$(CONFIG_MACH_TOSA) += tosa.o 20obj-$(CONFIG_MACH_TOSA) += tosa.o
21obj-$(CONFIG_MACH_EM_X270) += em-x270.o
21 22
22# Support for blinky lights 23# Support for blinky lights
23led-y := leds.o 24led-y := leds.o
diff --git a/arch/arm/mach-pxa/devices.h b/arch/arm/mach-pxa/devices.h
index 9a6faff8e5a7..636fdb1c049c 100644
--- a/arch/arm/mach-pxa/devices.h
+++ b/arch/arm/mach-pxa/devices.h
@@ -1,11 +1,11 @@
1extern struct platform_device pxamci_device; 1extern struct platform_device pxa_device_mci;
2extern struct platform_device pxaudc_device; 2extern struct platform_device pxa_device_udc;
3extern struct platform_device pxafb_device; 3extern struct platform_device pxa_device_fb;
4extern struct platform_device ffuart_device; 4extern struct platform_device pxa_device_ffuart;
5extern struct platform_device btuart_device; 5extern struct platform_device pxa_device_btuart;
6extern struct platform_device stuart_device; 6extern struct platform_device pxa_device_stuart;
7extern struct platform_device hwuart_device; 7extern struct platform_device pxa_device_hwuart;
8extern struct platform_device pxai2c_device; 8extern struct platform_device pxa_device_i2c;
9extern struct platform_device pxai2s_device; 9extern struct platform_device pxa_device_i2s;
10extern struct platform_device pxaficp_device; 10extern struct platform_device pxa_device_ficp;
11extern struct platform_device pxartc_device; 11extern struct platform_device pxa_device_rtc;
diff --git a/arch/arm/mach-pxa/em-x270.c b/arch/arm/mach-pxa/em-x270.c
new file mode 100644
index 000000000000..3d0ad5065ee5
--- /dev/null
+++ b/arch/arm/mach-pxa/em-x270.c
@@ -0,0 +1,354 @@
1/*
2 * Support for CompuLab EM-x270 platform
3 *
4 * Copyright (C) 2007 CompuLab, Ltd.
5 * Author: Mike Rapoport <mike@compulab.co.il>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#include <linux/irq.h>
13#include <linux/platform_device.h>
14
15#include <linux/dm9000.h>
16#include <linux/rtc-v3020.h>
17
18#include <linux/mtd/nand.h>
19#include <linux/mtd/partitions.h>
20
21#include <asm/mach-types.h>
22
23#include <asm/mach/arch.h>
24
25#include <asm/arch/pxa-regs.h>
26#include <asm/arch/pxafb.h>
27#include <asm/arch/ohci.h>
28#include <asm/arch/mmc.h>
29#include <asm/arch/bitfield.h>
30
31#include "generic.h"
32
33/* GPIO IRQ usage */
34#define EM_X270_MMC_PD (105)
35#define EM_X270_ETHIRQ IRQ_GPIO(41)
36#define EM_X270_MMC_IRQ IRQ_GPIO(13)
37
38static struct resource em_x270_dm9k_resource[] = {
39 [0] = {
40 .start = PXA_CS2_PHYS,
41 .end = PXA_CS2_PHYS + 3,
42 .flags = IORESOURCE_MEM,
43 },
44 [1] = {
45 .start = PXA_CS2_PHYS + 8,
46 .end = PXA_CS2_PHYS + 8 + 0x3f,
47 .flags = IORESOURCE_MEM,
48 },
49 [2] = {
50 .start = EM_X270_ETHIRQ,
51 .end = EM_X270_ETHIRQ,
52 .flags = IORESOURCE_IRQ,
53 }
54};
55
56/* for the moment we limit ourselves to 32bit IO until some
57 * better IO routines can be written and tested
58 */
59static struct dm9000_plat_data em_x270_dm9k_platdata = {
60 .flags = DM9000_PLATF_32BITONLY,
61};
62
63/* Ethernet device */
64static struct platform_device em_x270_dm9k = {
65 .name = "dm9000",
66 .id = 0,
67 .num_resources = ARRAY_SIZE(em_x270_dm9k_resource),
68 .resource = em_x270_dm9k_resource,
69 .dev = {
70 .platform_data = &em_x270_dm9k_platdata,
71 }
72};
73
74/* audio device */
75static struct platform_device em_x270_audio = {
76 .name = "pxa2xx-ac97",
77 .id = -1,
78};
79
80/* WM9712 touchscreen controller. Hopefully the driver will make it to
81 * the mainstream sometime */
82static struct platform_device em_x270_ts = {
83 .name = "wm97xx-ts",
84 .id = -1,
85};
86
87/* RTC */
88static struct resource em_x270_v3020_resource[] = {
89 [0] = {
90 .start = PXA_CS4_PHYS,
91 .end = PXA_CS4_PHYS + 3,
92 .flags = IORESOURCE_MEM,
93 },
94};
95
96static struct v3020_platform_data em_x270_v3020_platdata = {
97 .leftshift = 0,
98};
99
100static struct platform_device em_x270_rtc = {
101 .name = "v3020",
102 .num_resources = ARRAY_SIZE(em_x270_v3020_resource),
103 .resource = em_x270_v3020_resource,
104 .id = -1,
105 .dev = {
106 .platform_data = &em_x270_v3020_platdata,
107 }
108};
109
110/* NAND flash */
111#define GPIO_NAND_CS (11)
112#define GPIO_NAND_RB (56)
113
114static inline void nand_cs_on(void)
115{
116 GPCR(GPIO_NAND_CS) = GPIO_bit(GPIO_NAND_CS);
117}
118
119static void nand_cs_off(void)
120{
121 dsb();
122
123 GPSR(GPIO_NAND_CS) = GPIO_bit(GPIO_NAND_CS);
124}
125
126/* hardware specific access to control-lines */
127static void em_x270_nand_cmd_ctl(struct mtd_info *mtd, int dat,
128 unsigned int ctrl)
129{
130 struct nand_chip *this = mtd->priv;
131 unsigned long nandaddr = (unsigned long)this->IO_ADDR_W;
132
133 dsb();
134
135 if (ctrl & NAND_CTRL_CHANGE) {
136 if (ctrl & NAND_ALE)
137 nandaddr |= (1 << 3);
138 else
139 nandaddr &= ~(1 << 3);
140 if (ctrl & NAND_CLE)
141 nandaddr |= (1 << 2);
142 else
143 nandaddr &= ~(1 << 2);
144 if (ctrl & NAND_NCE)
145 nand_cs_on();
146 else
147 nand_cs_off();
148 }
149
150 dsb();
151 this->IO_ADDR_W = (void __iomem *)nandaddr;
152 if (dat != NAND_CMD_NONE)
153 writel(dat, this->IO_ADDR_W);
154
155 dsb();
156}
157
158/* read device ready pin */
159static int em_x270_nand_device_ready(struct mtd_info *mtd)
160{
161 dsb();
162
163 return GPLR(GPIO_NAND_RB) & GPIO_bit(GPIO_NAND_RB);
164}
165
166static struct mtd_partition em_x270_partition_info[] = {
167 [0] = {
168 .name = "em_x270-0",
169 .offset = 0,
170 .size = SZ_4M,
171 },
172 [1] = {
173 .name = "em_x270-1",
174 .offset = MTDPART_OFS_APPEND,
175 .size = MTDPART_SIZ_FULL
176 },
177};
178
179static const char *em_x270_part_probes[] = { "cmdlinepart", NULL };
180
181struct platform_nand_data em_x270_nand_platdata = {
182 .chip = {
183 .nr_chips = 1,
184 .chip_offset = 0,
185 .nr_partitions = ARRAY_SIZE(em_x270_partition_info),
186 .partitions = em_x270_partition_info,
187 .chip_delay = 20,
188 .part_probe_types = em_x270_part_probes,
189 },
190 .ctrl = {
191 .hwcontrol = 0,
192 .dev_ready = em_x270_nand_device_ready,
193 .select_chip = 0,
194 .cmd_ctrl = em_x270_nand_cmd_ctl,
195 },
196};
197
198static struct resource em_x270_nand_resource[] = {
199 [0] = {
200 .start = PXA_CS1_PHYS,
201 .end = PXA_CS1_PHYS + 12,
202 .flags = IORESOURCE_MEM,
203 },
204};
205
206static struct platform_device em_x270_nand = {
207 .name = "gen_nand",
208 .num_resources = ARRAY_SIZE(em_x270_nand_resource),
209 .resource = em_x270_nand_resource,
210 .id = -1,
211 .dev = {
212 .platform_data = &em_x270_nand_platdata,
213 }
214};
215
216/* platform devices */
217static struct platform_device *platform_devices[] __initdata = {
218 &em_x270_dm9k,
219 &em_x270_audio,
220 &em_x270_ts,
221 &em_x270_rtc,
222 &em_x270_nand,
223};
224
225
226/* PXA27x OHCI controller setup */
227static int em_x270_ohci_init(struct device *dev)
228{
229 /* Set the Power Control Polarity Low */
230 UHCHR = (UHCHR | UHCHR_PCPL) &
231 ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSE);
232
233 /* enable port 2 transiever */
234 UP2OCR = UP2OCR_HXS | UP2OCR_HXOE;
235
236 return 0;
237}
238
239static struct pxaohci_platform_data em_x270_ohci_platform_data = {
240 .port_mode = PMM_PERPORT_MODE,
241 .init = em_x270_ohci_init,
242};
243
244
245static int em_x270_mci_init(struct device *dev,
246 irq_handler_t em_x270_detect_int,
247 void *data)
248{
249 int err;
250
251 /* setup GPIO for PXA27x MMC controller */
252 pxa_gpio_mode(GPIO32_MMCCLK_MD);
253 pxa_gpio_mode(GPIO112_MMCCMD_MD);
254 pxa_gpio_mode(GPIO92_MMCDAT0_MD);
255 pxa_gpio_mode(GPIO109_MMCDAT1_MD);
256 pxa_gpio_mode(GPIO110_MMCDAT2_MD);
257 pxa_gpio_mode(GPIO111_MMCDAT3_MD);
258
259 /* EM-X270 uses GPIO13 as SD power enable */
260 pxa_gpio_mode(EM_X270_MMC_PD | GPIO_OUT);
261
262 err = request_irq(EM_X270_MMC_IRQ, em_x270_detect_int,
263 IRQF_DISABLED | IRQF_TRIGGER_FALLING,
264 "MMC card detect", data);
265 if (err) {
266 printk(KERN_ERR "%s: can't request MMC card detect IRQ: %d\n",
267 __FUNCTION__, err);
268 return err;
269 }
270
271 return 0;
272}
273
274static void em_x270_mci_setpower(struct device *dev, unsigned int vdd)
275{
276 /*
277 FIXME: current hardware implementation does not allow to
278 enable/disable MMC power. This will be fixed in next HW releases,
279 and we'll need to add implmentation here.
280 */
281 return;
282}
283
284static void em_x270_mci_exit(struct device *dev, void *data)
285{
286 free_irq(EM_X270_MMC_IRQ, data);
287}
288
289static struct pxamci_platform_data em_x270_mci_platform_data = {
290 .ocr_mask = MMC_VDD_28_29|MMC_VDD_29_30|MMC_VDD_30_31,
291 .init = em_x270_mci_init,
292 .setpower = em_x270_mci_setpower,
293 .exit = em_x270_mci_exit,
294};
295
296/* LCD 480x640 */
297static struct pxafb_mode_info em_x270_lcd_mode = {
298 .pixclock = 50000,
299 .bpp = 16,
300 .xres = 480,
301 .yres = 640,
302 .hsync_len = 8,
303 .vsync_len = 2,
304 .left_margin = 8,
305 .upper_margin = 0,
306 .right_margin = 24,
307 .lower_margin = 4,
308 .cmap_greyscale = 0,
309};
310
311static struct pxafb_mach_info em_x270_lcd = {
312 .modes = &em_x270_lcd_mode,
313 .num_modes = 1,
314 .cmap_inverse = 0,
315 .cmap_static = 0,
316 .lccr0 = LCCR0_PAS,
317 .lccr3 = LCCR3_PixClkDiv(0x01) | LCCR3_Acb(0xff),
318};
319
320static void __init em_x270_init(void)
321{
322 /* setup LCD */
323 set_pxa_fb_info(&em_x270_lcd);
324
325 /* register EM-X270 platform devices */
326 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
327
328 /* set MCI and OHCI platform parameters */
329 pxa_set_mci_info(&em_x270_mci_platform_data);
330 pxa_set_ohci_info(&em_x270_ohci_platform_data);
331
332 /* setup STUART GPIOs */
333 pxa_gpio_mode(GPIO46_STRXD_MD);
334 pxa_gpio_mode(GPIO47_STTXD_MD);
335
336 /* setup BTUART GPIOs */
337 pxa_gpio_mode(GPIO42_BTRXD_MD);
338 pxa_gpio_mode(GPIO43_BTTXD_MD);
339 pxa_gpio_mode(GPIO44_BTCTS_MD);
340 pxa_gpio_mode(GPIO45_BTRTS_MD);
341
342 /* Setup interrupt for dm9000 */
343 set_irq_type(EM_X270_ETHIRQ, IRQT_RISING);
344}
345
346MACHINE_START(EM_X270, "Compulab EM-x270")
347 .boot_params = 0xa0000100,
348 .phys_io = 0x40000000,
349 .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
350 .map_io = pxa_map_io,
351 .init_irq = pxa27x_init_irq,
352 .timer = &pxa_timer,
353 .init_machine = em_x270_init,
354MACHINE_END
diff --git a/arch/arm/mach-pxa/generic.c b/arch/arm/mach-pxa/generic.c
index 296539b6359c..5510f6fdce55 100644
--- a/arch/arm/mach-pxa/generic.c
+++ b/arch/arm/mach-pxa/generic.c
@@ -243,7 +243,7 @@ static struct resource pxamci_resources[] = {
243 243
244static u64 pxamci_dmamask = 0xffffffffUL; 244static u64 pxamci_dmamask = 0xffffffffUL;
245 245
246struct platform_device pxamci_device = { 246struct platform_device pxa_device_mci = {
247 .name = "pxa2xx-mci", 247 .name = "pxa2xx-mci",
248 .id = -1, 248 .id = -1,
249 .dev = { 249 .dev = {
@@ -256,7 +256,7 @@ struct platform_device pxamci_device = {
256 256
257void __init pxa_set_mci_info(struct pxamci_platform_data *info) 257void __init pxa_set_mci_info(struct pxamci_platform_data *info)
258{ 258{
259 pxamci_device.dev.platform_data = info; 259 pxa_device_mci.dev.platform_data = info;
260} 260}
261 261
262 262
@@ -282,7 +282,7 @@ static struct resource pxa2xx_udc_resources[] = {
282 282
283static u64 udc_dma_mask = ~(u32)0; 283static u64 udc_dma_mask = ~(u32)0;
284 284
285struct platform_device pxaudc_device = { 285struct platform_device pxa_device_udc = {
286 .name = "pxa2xx-udc", 286 .name = "pxa2xx-udc",
287 .id = -1, 287 .id = -1,
288 .resource = pxa2xx_udc_resources, 288 .resource = pxa2xx_udc_resources,
@@ -308,7 +308,7 @@ static struct resource pxafb_resources[] = {
308 308
309static u64 fb_dma_mask = ~(u64)0; 309static u64 fb_dma_mask = ~(u64)0;
310 310
311struct platform_device pxafb_device = { 311struct platform_device pxa_device_fb = {
312 .name = "pxa2xx-fb", 312 .name = "pxa2xx-fb",
313 .id = -1, 313 .id = -1,
314 .dev = { 314 .dev = {
@@ -321,27 +321,27 @@ struct platform_device pxafb_device = {
321 321
322void __init set_pxa_fb_info(struct pxafb_mach_info *info) 322void __init set_pxa_fb_info(struct pxafb_mach_info *info)
323{ 323{
324 pxafb_device.dev.platform_data = info; 324 pxa_device_fb.dev.platform_data = info;
325} 325}
326 326
327void __init set_pxa_fb_parent(struct device *parent_dev) 327void __init set_pxa_fb_parent(struct device *parent_dev)
328{ 328{
329 pxafb_device.dev.parent = parent_dev; 329 pxa_device_fb.dev.parent = parent_dev;
330} 330}
331 331
332struct platform_device ffuart_device = { 332struct platform_device pxa_device_ffuart= {
333 .name = "pxa2xx-uart", 333 .name = "pxa2xx-uart",
334 .id = 0, 334 .id = 0,
335}; 335};
336struct platform_device btuart_device = { 336struct platform_device pxa_device_btuart = {
337 .name = "pxa2xx-uart", 337 .name = "pxa2xx-uart",
338 .id = 1, 338 .id = 1,
339}; 339};
340struct platform_device stuart_device = { 340struct platform_device pxa_device_stuart = {
341 .name = "pxa2xx-uart", 341 .name = "pxa2xx-uart",
342 .id = 2, 342 .id = 2,
343}; 343};
344struct platform_device hwuart_device = { 344struct platform_device pxa_device_hwuart = {
345 .name = "pxa2xx-uart", 345 .name = "pxa2xx-uart",
346 .id = 3, 346 .id = 3,
347}; 347};
@@ -358,7 +358,7 @@ static struct resource pxai2c_resources[] = {
358 }, 358 },
359}; 359};
360 360
361struct platform_device pxai2c_device = { 361struct platform_device pxa_device_i2c = {
362 .name = "pxa2xx-i2c", 362 .name = "pxa2xx-i2c",
363 .id = 0, 363 .id = 0,
364 .resource = pxai2c_resources, 364 .resource = pxai2c_resources,
@@ -367,7 +367,7 @@ struct platform_device pxai2c_device = {
367 367
368void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info) 368void __init pxa_set_i2c_info(struct i2c_pxa_platform_data *info)
369{ 369{
370 pxai2c_device.dev.platform_data = info; 370 pxa_device_i2c.dev.platform_data = info;
371} 371}
372 372
373static struct resource pxai2s_resources[] = { 373static struct resource pxai2s_resources[] = {
@@ -382,7 +382,7 @@ static struct resource pxai2s_resources[] = {
382 }, 382 },
383}; 383};
384 384
385struct platform_device pxai2s_device = { 385struct platform_device pxa_device_i2s = {
386 .name = "pxa2xx-i2s", 386 .name = "pxa2xx-i2s",
387 .id = -1, 387 .id = -1,
388 .resource = pxai2s_resources, 388 .resource = pxai2s_resources,
@@ -391,7 +391,7 @@ struct platform_device pxai2s_device = {
391 391
392static u64 pxaficp_dmamask = ~(u32)0; 392static u64 pxaficp_dmamask = ~(u32)0;
393 393
394struct platform_device pxaficp_device = { 394struct platform_device pxa_device_ficp = {
395 .name = "pxa2xx-ir", 395 .name = "pxa2xx-ir",
396 .id = -1, 396 .id = -1,
397 .dev = { 397 .dev = {
@@ -402,10 +402,10 @@ struct platform_device pxaficp_device = {
402 402
403void __init pxa_set_ficp_info(struct pxaficp_platform_data *info) 403void __init pxa_set_ficp_info(struct pxaficp_platform_data *info)
404{ 404{
405 pxaficp_device.dev.platform_data = info; 405 pxa_device_ficp.dev.platform_data = info;
406} 406}
407 407
408struct platform_device pxartc_device = { 408struct platform_device pxa_device_rtc = {
409 .name = "sa1100-rtc", 409 .name = "sa1100-rtc",
410 .id = -1, 410 .id = -1,
411}; 411};
diff --git a/arch/arm/mach-pxa/pm.c b/arch/arm/mach-pxa/pm.c
index e66dbc26add1..b59a81a8e7d3 100644
--- a/arch/arm/mach-pxa/pm.c
+++ b/arch/arm/mach-pxa/pm.c
@@ -24,61 +24,13 @@
24#include <asm/arch/lubbock.h> 24#include <asm/arch/lubbock.h>
25#include <asm/mach/time.h> 25#include <asm/mach/time.h>
26 26
27 27struct pxa_cpu_pm_fns *pxa_cpu_pm_fns;
28/* 28static unsigned long *sleep_save;
29 * Debug macros
30 */
31#undef DEBUG
32
33#define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
34#define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
35
36#define RESTORE_GPLEVEL(n) do { \
37 GPSR##n = sleep_save[SLEEP_SAVE_GPLR##n]; \
38 GPCR##n = ~sleep_save[SLEEP_SAVE_GPLR##n]; \
39} while (0)
40
41/*
42 * List of global PXA peripheral registers to preserve.
43 * More ones like CP and general purpose register values are preserved
44 * with the stack pointer in sleep.S.
45 */
46enum { SLEEP_SAVE_START = 0,
47
48 SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2, SLEEP_SAVE_GPLR3,
49 SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2, SLEEP_SAVE_GPDR3,
50 SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2, SLEEP_SAVE_GRER3,
51 SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2, SLEEP_SAVE_GFER3,
52 SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
53
54 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
55 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
56 SLEEP_SAVE_GAFR2_L, SLEEP_SAVE_GAFR2_U,
57 SLEEP_SAVE_GAFR3_L, SLEEP_SAVE_GAFR3_U,
58
59 SLEEP_SAVE_PSTR,
60
61 SLEEP_SAVE_ICMR,
62 SLEEP_SAVE_CKEN,
63
64#ifdef CONFIG_PXA27x
65 SLEEP_SAVE_MDREFR,
66 SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER,
67 SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR,
68#endif
69
70 SLEEP_SAVE_CKSUM,
71
72 SLEEP_SAVE_SIZE
73};
74
75 29
76int pxa_pm_enter(suspend_state_t state) 30int pxa_pm_enter(suspend_state_t state)
77{ 31{
78 unsigned long sleep_save[SLEEP_SAVE_SIZE]; 32 unsigned long sleep_save_checksum = 0, checksum = 0;
79 unsigned long checksum = 0;
80 int i; 33 int i;
81 extern void pxa_cpu_pm_enter(suspend_state_t state);
82 34
83#ifdef CONFIG_IWMMXT 35#ifdef CONFIG_IWMMXT
84 /* force any iWMMXt context to ram **/ 36 /* force any iWMMXt context to ram **/
@@ -86,100 +38,35 @@ int pxa_pm_enter(suspend_state_t state)
86 iwmmxt_task_disable(NULL); 38 iwmmxt_task_disable(NULL);
87#endif 39#endif
88 40
89 SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2); 41 pxa_cpu_pm_fns->save(sleep_save);
90 SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2);
91 SAVE(GRER0); SAVE(GRER1); SAVE(GRER2);
92 SAVE(GFER0); SAVE(GFER1); SAVE(GFER2);
93 SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2);
94
95 SAVE(GAFR0_L); SAVE(GAFR0_U);
96 SAVE(GAFR1_L); SAVE(GAFR1_U);
97 SAVE(GAFR2_L); SAVE(GAFR2_U);
98
99#ifdef CONFIG_PXA27x
100 SAVE(MDREFR);
101 SAVE(GPLR3); SAVE(GPDR3); SAVE(GRER3); SAVE(GFER3); SAVE(PGSR3);
102 SAVE(GAFR3_L); SAVE(GAFR3_U);
103 SAVE(PWER); SAVE(PCFR); SAVE(PRER);
104 SAVE(PFER); SAVE(PKWR);
105#endif
106
107 SAVE(ICMR);
108 ICMR = 0;
109
110 SAVE(CKEN);
111 SAVE(PSTR);
112
113 /* Note: wake up source are set up in each machine specific files */
114
115 /* clear GPIO transition detect bits */
116 GEDR0 = GEDR0; GEDR1 = GEDR1; GEDR2 = GEDR2;
117#ifdef CONFIG_PXA27x
118 GEDR3 = GEDR3;
119#endif
120 42
121 /* Clear sleep reset status */ 43 /* Clear sleep reset status */
122 RCSR = RCSR_SMR; 44 RCSR = RCSR_SMR;
123 45
124 /* before sleeping, calculate and save a checksum */ 46 /* before sleeping, calculate and save a checksum */
125 for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++) 47 for (i = 0; i < pxa_cpu_pm_fns->save_size - 1; i++)
126 checksum += sleep_save[i]; 48 sleep_save_checksum += sleep_save[i];
127 sleep_save[SLEEP_SAVE_CKSUM] = checksum;
128 49
129 /* *** go zzz *** */ 50 /* *** go zzz *** */
130 pxa_cpu_pm_enter(state); 51 pxa_cpu_pm_fns->enter(state);
131
132 cpu_init(); 52 cpu_init();
133 53
134 /* after sleeping, validate the checksum */ 54 /* after sleeping, validate the checksum */
135 checksum = 0; 55 for (i = 0; i < pxa_cpu_pm_fns->save_size - 1; i++)
136 for (i = 0; i < SLEEP_SAVE_SIZE - 1; i++)
137 checksum += sleep_save[i]; 56 checksum += sleep_save[i];
138 57
139 /* if invalid, display message and wait for a hardware reset */ 58 /* if invalid, display message and wait for a hardware reset */
140 if (checksum != sleep_save[SLEEP_SAVE_CKSUM]) { 59 if (checksum != sleep_save_checksum) {
141#ifdef CONFIG_ARCH_LUBBOCK 60#ifdef CONFIG_ARCH_LUBBOCK
142 LUB_HEXLED = 0xbadbadc5; 61 LUB_HEXLED = 0xbadbadc5;
143#endif 62#endif
144 while (1) 63 while (1)
145 pxa_cpu_pm_enter(state); 64 pxa_cpu_pm_fns->enter(state);
146 } 65 }
147 66
148 /* ensure not to come back here if it wasn't intended */ 67 pxa_cpu_pm_fns->restore(sleep_save);
149 PSPR = 0;
150
151 /* restore registers */
152 RESTORE_GPLEVEL(0); RESTORE_GPLEVEL(1); RESTORE_GPLEVEL(2);
153 RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2);
154 RESTORE(GAFR0_L); RESTORE(GAFR0_U);
155 RESTORE(GAFR1_L); RESTORE(GAFR1_U);
156 RESTORE(GAFR2_L); RESTORE(GAFR2_U);
157 RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
158 RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
159 RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2);
160
161#ifdef CONFIG_PXA27x
162 RESTORE(MDREFR);
163 RESTORE_GPLEVEL(3); RESTORE(GPDR3);
164 RESTORE(GAFR3_L); RESTORE(GAFR3_U);
165 RESTORE(GRER3); RESTORE(GFER3); RESTORE(PGSR3);
166 RESTORE(PWER); RESTORE(PCFR); RESTORE(PRER);
167 RESTORE(PFER); RESTORE(PKWR);
168#endif
169
170 PSSR = PSSR_RDH | PSSR_PH;
171
172 RESTORE(CKEN);
173
174 ICLR = 0;
175 ICCR = 1;
176 RESTORE(ICMR);
177 68
178 RESTORE(PSTR); 69 pr_debug("*** made it back from resume\n");
179
180#ifdef DEBUG
181 printk(KERN_DEBUG "*** made it back from resume\n");
182#endif
183 70
184 return 0; 71 return 0;
185} 72}
@@ -190,3 +77,35 @@ unsigned long sleep_phys_sp(void *sp)
190{ 77{
191 return virt_to_phys(sp); 78 return virt_to_phys(sp);
192} 79}
80
81static int pxa_pm_valid(suspend_state_t state)
82{
83 if (pxa_cpu_pm_fns)
84 return pxa_cpu_pm_fns->valid(state);
85
86 return -EINVAL;
87}
88
89static struct pm_ops pxa_pm_ops = {
90 .valid = pxa_pm_valid,
91 .enter = pxa_pm_enter,
92};
93
94static int __init pxa_pm_init(void)
95{
96 if (!pxa_cpu_pm_fns) {
97 printk(KERN_ERR "no valid pxa_cpu_pm_fns defined\n");
98 return -EINVAL;
99 }
100
101 sleep_save = kmalloc(pxa_cpu_pm_fns->save_size, GFP_KERNEL);
102 if (!sleep_save) {
103 printk(KERN_ERR "failed to alloc memory for pm save\n");
104 return -ENOMEM;
105 }
106
107 pm_set_ops(&pxa_pm_ops);
108 return 0;
109}
110
111device_initcall(pxa_pm_init);
diff --git a/arch/arm/mach-pxa/pxa25x.c b/arch/arm/mach-pxa/pxa25x.c
index f36ca448338e..6dfcca72e90f 100644
--- a/arch/arm/mach-pxa/pxa25x.c
+++ b/arch/arm/mach-pxa/pxa25x.c
@@ -110,26 +110,99 @@ EXPORT_SYMBOL(get_lcdclk_frequency_10khz);
110 110
111#ifdef CONFIG_PM 111#ifdef CONFIG_PM
112 112
113void pxa_cpu_pm_enter(suspend_state_t state) 113#define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
114#define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
115
116#define RESTORE_GPLEVEL(n) do { \
117 GPSR##n = sleep_save[SLEEP_SAVE_GPLR##n]; \
118 GPCR##n = ~sleep_save[SLEEP_SAVE_GPLR##n]; \
119} while (0)
120
121/*
122 * List of global PXA peripheral registers to preserve.
123 * More ones like CP and general purpose register values are preserved
124 * with the stack pointer in sleep.S.
125 */
126enum { SLEEP_SAVE_START = 0,
127
128 SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2,
129 SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2,
130 SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2,
131 SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2,
132 SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2,
133
134 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
135 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
136 SLEEP_SAVE_GAFR2_L, SLEEP_SAVE_GAFR2_U,
137
138 SLEEP_SAVE_PSTR,
139
140 SLEEP_SAVE_ICMR,
141 SLEEP_SAVE_CKEN,
142
143 SLEEP_SAVE_SIZE
144};
145
146
147static void pxa25x_cpu_pm_save(unsigned long *sleep_save)
148{
149 SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2);
150 SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2);
151 SAVE(GRER0); SAVE(GRER1); SAVE(GRER2);
152 SAVE(GFER0); SAVE(GFER1); SAVE(GFER2);
153 SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2);
154
155 SAVE(GAFR0_L); SAVE(GAFR0_U);
156 SAVE(GAFR1_L); SAVE(GAFR1_U);
157 SAVE(GAFR2_L); SAVE(GAFR2_U);
158
159 SAVE(ICMR);
160 SAVE(CKEN);
161 SAVE(PSTR);
162}
163
164static void pxa25x_cpu_pm_restore(unsigned long *sleep_save)
114{ 165{
115 extern void pxa_cpu_suspend(unsigned int); 166 /* restore registers */
116 extern void pxa_cpu_resume(void); 167 RESTORE_GPLEVEL(0); RESTORE_GPLEVEL(1); RESTORE_GPLEVEL(2);
168 RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2);
169 RESTORE(GAFR0_L); RESTORE(GAFR0_U);
170 RESTORE(GAFR1_L); RESTORE(GAFR1_U);
171 RESTORE(GAFR2_L); RESTORE(GAFR2_U);
172 RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2);
173 RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2);
174 RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2);
175
176 RESTORE(CKEN);
177 RESTORE(ICMR);
178 RESTORE(PSTR);
179}
117 180
181static void pxa25x_cpu_pm_enter(suspend_state_t state)
182{
118 CKEN = 0; 183 CKEN = 0;
119 184
120 switch (state) { 185 switch (state) {
121 case PM_SUSPEND_MEM: 186 case PM_SUSPEND_MEM:
122 /* set resume return address */ 187 /* set resume return address */
123 PSPR = virt_to_phys(pxa_cpu_resume); 188 PSPR = virt_to_phys(pxa_cpu_resume);
124 pxa_cpu_suspend(PWRMODE_SLEEP); 189 pxa25x_cpu_suspend(PWRMODE_SLEEP);
125 break; 190 break;
126 } 191 }
127} 192}
128 193
129static struct pm_ops pxa25x_pm_ops = { 194static struct pxa_cpu_pm_fns pxa25x_cpu_pm_fns = {
130 .enter = pxa_pm_enter, 195 .save_size = SLEEP_SAVE_SIZE,
131 .valid = pm_valid_only_mem, 196 .valid = pm_valid_only_mem,
197 .save = pxa25x_cpu_pm_save,
198 .restore = pxa25x_cpu_pm_restore,
199 .enter = pxa25x_cpu_pm_enter,
132}; 200};
201
202static void __init pxa25x_init_pm(void)
203{
204 pxa_cpu_pm_fns = &pxa25x_cpu_pm_fns;
205}
133#endif 206#endif
134 207
135void __init pxa25x_init_irq(void) 208void __init pxa25x_init_irq(void)
@@ -139,16 +212,16 @@ void __init pxa25x_init_irq(void)
139} 212}
140 213
141static struct platform_device *pxa25x_devices[] __initdata = { 214static struct platform_device *pxa25x_devices[] __initdata = {
142 &pxamci_device, 215 &pxa_device_mci,
143 &pxaudc_device, 216 &pxa_device_udc,
144 &pxafb_device, 217 &pxa_device_fb,
145 &ffuart_device, 218 &pxa_device_ffuart,
146 &btuart_device, 219 &pxa_device_btuart,
147 &stuart_device, 220 &pxa_device_stuart,
148 &pxai2c_device, 221 &pxa_device_i2c,
149 &pxai2s_device, 222 &pxa_device_i2s,
150 &pxaficp_device, 223 &pxa_device_ficp,
151 &pxartc_device, 224 &pxa_device_rtc,
152}; 225};
153 226
154static int __init pxa25x_init(void) 227static int __init pxa25x_init(void)
@@ -159,14 +232,14 @@ static int __init pxa25x_init(void)
159 if ((ret = pxa_init_dma(16))) 232 if ((ret = pxa_init_dma(16)))
160 return ret; 233 return ret;
161#ifdef CONFIG_PM 234#ifdef CONFIG_PM
162 pm_set_ops(&pxa25x_pm_ops); 235 pxa25x_init_pm();
163#endif 236#endif
164 ret = platform_add_devices(pxa25x_devices, 237 ret = platform_add_devices(pxa25x_devices,
165 ARRAY_SIZE(pxa25x_devices)); 238 ARRAY_SIZE(pxa25x_devices));
166 } 239 }
167 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */ 240 /* Only add HWUART for PXA255/26x; PXA210/250/27x do not have it. */
168 if (cpu_is_pxa25x()) 241 if (cpu_is_pxa25x())
169 ret = platform_device_register(&hwuart_device); 242 ret = platform_device_register(&pxa_device_hwuart);
170 243
171 return ret; 244 return ret;
172} 245}
diff --git a/arch/arm/mach-pxa/pxa27x.c b/arch/arm/mach-pxa/pxa27x.c
index aa5bb02c897b..203371ab19db 100644
--- a/arch/arm/mach-pxa/pxa27x.c
+++ b/arch/arm/mach-pxa/pxa27x.c
@@ -126,14 +126,107 @@ EXPORT_SYMBOL(get_lcdclk_frequency_10khz);
126 126
127#ifdef CONFIG_PM 127#ifdef CONFIG_PM
128 128
129void pxa_cpu_pm_enter(suspend_state_t state) 129#define SAVE(x) sleep_save[SLEEP_SAVE_##x] = x
130#define RESTORE(x) x = sleep_save[SLEEP_SAVE_##x]
131
132#define RESTORE_GPLEVEL(n) do { \
133 GPSR##n = sleep_save[SLEEP_SAVE_GPLR##n]; \
134 GPCR##n = ~sleep_save[SLEEP_SAVE_GPLR##n]; \
135} while (0)
136
137/*
138 * List of global PXA peripheral registers to preserve.
139 * More ones like CP and general purpose register values are preserved
140 * with the stack pointer in sleep.S.
141 */
142enum { SLEEP_SAVE_START = 0,
143
144 SLEEP_SAVE_GPLR0, SLEEP_SAVE_GPLR1, SLEEP_SAVE_GPLR2, SLEEP_SAVE_GPLR3,
145 SLEEP_SAVE_GPDR0, SLEEP_SAVE_GPDR1, SLEEP_SAVE_GPDR2, SLEEP_SAVE_GPDR3,
146 SLEEP_SAVE_GRER0, SLEEP_SAVE_GRER1, SLEEP_SAVE_GRER2, SLEEP_SAVE_GRER3,
147 SLEEP_SAVE_GFER0, SLEEP_SAVE_GFER1, SLEEP_SAVE_GFER2, SLEEP_SAVE_GFER3,
148 SLEEP_SAVE_PGSR0, SLEEP_SAVE_PGSR1, SLEEP_SAVE_PGSR2, SLEEP_SAVE_PGSR3,
149
150 SLEEP_SAVE_GAFR0_L, SLEEP_SAVE_GAFR0_U,
151 SLEEP_SAVE_GAFR1_L, SLEEP_SAVE_GAFR1_U,
152 SLEEP_SAVE_GAFR2_L, SLEEP_SAVE_GAFR2_U,
153 SLEEP_SAVE_GAFR3_L, SLEEP_SAVE_GAFR3_U,
154
155 SLEEP_SAVE_PSTR,
156
157 SLEEP_SAVE_ICMR,
158 SLEEP_SAVE_CKEN,
159
160 SLEEP_SAVE_MDREFR,
161 SLEEP_SAVE_PWER, SLEEP_SAVE_PCFR, SLEEP_SAVE_PRER,
162 SLEEP_SAVE_PFER, SLEEP_SAVE_PKWR,
163
164 SLEEP_SAVE_SIZE
165};
166
167void pxa27x_cpu_pm_save(unsigned long *sleep_save)
168{
169 SAVE(GPLR0); SAVE(GPLR1); SAVE(GPLR2); SAVE(GPLR3);
170 SAVE(GPDR0); SAVE(GPDR1); SAVE(GPDR2); SAVE(GPDR3);
171 SAVE(GRER0); SAVE(GRER1); SAVE(GRER2); SAVE(GRER3);
172 SAVE(GFER0); SAVE(GFER1); SAVE(GFER2); SAVE(GFER3);
173 SAVE(PGSR0); SAVE(PGSR1); SAVE(PGSR2); SAVE(PGSR3);
174
175 SAVE(GAFR0_L); SAVE(GAFR0_U);
176 SAVE(GAFR1_L); SAVE(GAFR1_U);
177 SAVE(GAFR2_L); SAVE(GAFR2_U);
178 SAVE(GAFR3_L); SAVE(GAFR3_U);
179
180 SAVE(MDREFR);
181 SAVE(PWER); SAVE(PCFR); SAVE(PRER);
182 SAVE(PFER); SAVE(PKWR);
183
184 SAVE(ICMR); ICMR = 0;
185 SAVE(CKEN);
186 SAVE(PSTR);
187
188 /* Clear GPIO transition detect bits */
189 GEDR0 = GEDR0; GEDR1 = GEDR1; GEDR2 = GEDR2; GEDR3 = GEDR3;
190}
191
192void pxa27x_cpu_pm_restore(unsigned long *sleep_save)
193{
194 /* ensure not to come back here if it wasn't intended */
195 PSPR = 0;
196
197 /* restore registers */
198 RESTORE_GPLEVEL(0); RESTORE_GPLEVEL(1);
199 RESTORE_GPLEVEL(2); RESTORE_GPLEVEL(3);
200 RESTORE(GPDR0); RESTORE(GPDR1); RESTORE(GPDR2); RESTORE(GPDR3);
201 RESTORE(GAFR0_L); RESTORE(GAFR0_U);
202 RESTORE(GAFR1_L); RESTORE(GAFR1_U);
203 RESTORE(GAFR2_L); RESTORE(GAFR2_U);
204 RESTORE(GAFR3_L); RESTORE(GAFR3_U);
205 RESTORE(GRER0); RESTORE(GRER1); RESTORE(GRER2); RESTORE(GRER3);
206 RESTORE(GFER0); RESTORE(GFER1); RESTORE(GFER2); RESTORE(GFER3);
207 RESTORE(PGSR0); RESTORE(PGSR1); RESTORE(PGSR2); RESTORE(PGSR3);
208
209 RESTORE(MDREFR);
210 RESTORE(PWER); RESTORE(PCFR); RESTORE(PRER);
211 RESTORE(PFER); RESTORE(PKWR);
212
213 PSSR = PSSR_RDH | PSSR_PH;
214
215 RESTORE(CKEN);
216
217 ICLR = 0;
218 ICCR = 1;
219 RESTORE(ICMR);
220 RESTORE(PSTR);
221}
222
223void pxa27x_cpu_pm_enter(suspend_state_t state)
130{ 224{
131 extern void pxa_cpu_standby(void); 225 extern void pxa_cpu_standby(void);
132 extern void pxa_cpu_suspend(unsigned int);
133 extern void pxa_cpu_resume(void);
134 226
135 if (state == PM_SUSPEND_STANDBY) 227 if (state == PM_SUSPEND_STANDBY)
136 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER) | (1 << CKEN_LCD) | (1 << CKEN_PWM0); 228 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER) |
229 (1 << CKEN_LCD) | (1 << CKEN_PWM0);
137 else 230 else
138 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER); 231 CKEN = (1 << CKEN_MEMC) | (1 << CKEN_OSTIMER);
139 232
@@ -150,20 +243,28 @@ void pxa_cpu_pm_enter(suspend_state_t state)
150 case PM_SUSPEND_MEM: 243 case PM_SUSPEND_MEM:
151 /* set resume return address */ 244 /* set resume return address */
152 PSPR = virt_to_phys(pxa_cpu_resume); 245 PSPR = virt_to_phys(pxa_cpu_resume);
153 pxa_cpu_suspend(PWRMODE_SLEEP); 246 pxa27x_cpu_suspend(PWRMODE_SLEEP);
154 break; 247 break;
155 } 248 }
156} 249}
157 250
158static int pxa27x_pm_valid(suspend_state_t state) 251static int pxa27x_cpu_pm_valid(suspend_state_t state)
159{ 252{
160 return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY; 253 return state == PM_SUSPEND_MEM || state == PM_SUSPEND_STANDBY;
161} 254}
162 255
163static struct pm_ops pxa27x_pm_ops = { 256static struct pxa_cpu_pm_fns pxa27x_cpu_pm_fns = {
164 .enter = pxa_pm_enter, 257 .save_size = SLEEP_SAVE_SIZE,
165 .valid = pxa27x_pm_valid, 258 .save = pxa27x_cpu_pm_save,
259 .restore = pxa27x_cpu_pm_restore,
260 .valid = pxa27x_cpu_pm_valid,
261 .enter = pxa27x_cpu_pm_enter,
166}; 262};
263
264static void __init pxa27x_init_pm(void)
265{
266 pxa_cpu_pm_fns = &pxa27x_cpu_pm_fns;
267}
167#endif 268#endif
168 269
169/* 270/*
@@ -185,7 +286,7 @@ static struct resource pxa27x_ohci_resources[] = {
185 }, 286 },
186}; 287};
187 288
188static struct platform_device pxaohci_device = { 289static struct platform_device pxa27x_device_ohci = {
189 .name = "pxa27x-ohci", 290 .name = "pxa27x-ohci",
190 .id = -1, 291 .id = -1,
191 .dev = { 292 .dev = {
@@ -198,7 +299,7 @@ static struct platform_device pxaohci_device = {
198 299
199void __init pxa_set_ohci_info(struct pxaohci_platform_data *info) 300void __init pxa_set_ohci_info(struct pxaohci_platform_data *info)
200{ 301{
201 pxaohci_device.dev.platform_data = info; 302 pxa27x_device_ohci.dev.platform_data = info;
202} 303}
203 304
204static struct resource i2c_power_resources[] = { 305static struct resource i2c_power_resources[] = {
@@ -213,7 +314,7 @@ static struct resource i2c_power_resources[] = {
213 }, 314 },
214}; 315};
215 316
216static struct platform_device pxai2c_power_device = { 317static struct platform_device pxa27x_device_i2c_power = {
217 .name = "pxa2xx-i2c", 318 .name = "pxa2xx-i2c",
218 .id = 1, 319 .id = 1,
219 .resource = i2c_power_resources, 320 .resource = i2c_power_resources,
@@ -221,18 +322,18 @@ static struct platform_device pxai2c_power_device = {
221}; 322};
222 323
223static struct platform_device *devices[] __initdata = { 324static struct platform_device *devices[] __initdata = {
224 &pxamci_device, 325 &pxa_device_mci,
225 &pxaudc_device, 326 &pxa_device_udc,
226 &pxafb_device, 327 &pxa_device_fb,
227 &ffuart_device, 328 &pxa_device_ffuart,
228 &btuart_device, 329 &pxa_device_btuart,
229 &stuart_device, 330 &pxa_device_stuart,
230 &pxai2c_device, 331 &pxa_device_i2c,
231 &pxai2c_power_device, 332 &pxa_device_i2s,
232 &pxai2s_device, 333 &pxa_device_ficp,
233 &pxaficp_device, 334 &pxa_device_rtc,
234 &pxartc_device, 335 &pxa27x_device_i2c_power,
235 &pxaohci_device, 336 &pxa27x_device_ohci,
236}; 337};
237 338
238void __init pxa27x_init_irq(void) 339void __init pxa27x_init_irq(void)
@@ -249,7 +350,7 @@ static int __init pxa27x_init(void)
249 if ((ret = pxa_init_dma(32))) 350 if ((ret = pxa_init_dma(32)))
250 return ret; 351 return ret;
251#ifdef CONFIG_PM 352#ifdef CONFIG_PM
252 pm_set_ops(&pxa27x_pm_ops); 353 pxa27x_init_pm();
253#endif 354#endif
254 ret = platform_add_devices(devices, ARRAY_SIZE(devices)); 355 ret = platform_add_devices(devices, ARRAY_SIZE(devices));
255 } 356 }
diff --git a/arch/arm/mach-pxa/sleep.S b/arch/arm/mach-pxa/sleep.S
index 15874b360e51..aff71fec618a 100644
--- a/arch/arm/mach-pxa/sleep.S
+++ b/arch/arm/mach-pxa/sleep.S
@@ -17,28 +17,12 @@
17 17
18#include <asm/arch/pxa-regs.h> 18#include <asm/arch/pxa-regs.h>
19 19
20#ifdef CONFIG_PXA27x // workaround for Errata 50
21#define MDREFR_KDIV 0x200a4000 // all banks 20#define MDREFR_KDIV 0x200a4000 // all banks
22#define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0 21#define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0
23#endif
24 22
25 .text 23 .text
26 24
27/* 25pxa_cpu_save_cp:
28 * pxa_cpu_suspend()
29 *
30 * Forces CPU into sleep state.
31 *
32 * r0 = value for PWRMODE M field for desired sleep state
33 */
34
35ENTRY(pxa_cpu_suspend)
36
37#ifndef CONFIG_IWMMXT
38 mra r2, r3, acc0
39#endif
40 stmfd sp!, {r2 - r12, lr} @ save registers on stack
41
42 @ get coprocessor registers 26 @ get coprocessor registers
43 mrc p14, 0, r3, c6, c0, 0 @ clock configuration, for turbo mode 27 mrc p14, 0, r3, c6, c0, 0 @ clock configuration, for turbo mode
44 mrc p15, 0, r4, c15, c1, 0 @ CP access reg 28 mrc p15, 0, r4, c15, c1, 0 @ CP access reg
@@ -54,12 +38,36 @@ ENTRY(pxa_cpu_suspend)
54 mov r10, sp 38 mov r10, sp
55 stmfd sp!, {r3 - r10} 39 stmfd sp!, {r3 - r10}
56 40
57 mov r5, r0 @ save sleep mode 41 mov pc, lr
42
43pxa_cpu_save_sp:
58 @ preserve phys address of stack 44 @ preserve phys address of stack
59 mov r0, sp 45 mov r0, sp
46 mov r2, lr
60 bl sleep_phys_sp 47 bl sleep_phys_sp
61 ldr r1, =sleep_save_sp 48 ldr r1, =sleep_save_sp
62 str r0, [r1] 49 str r0, [r1]
50 mov pc, r2
51
52/*
53 * pxa27x_cpu_suspend()
54 *
55 * Forces CPU into sleep state.
56 *
57 * r0 = value for PWRMODE M field for desired sleep state
58 */
59
60ENTRY(pxa27x_cpu_suspend)
61
62#ifndef CONFIG_IWMMXT
63 mra r2, r3, acc0
64#endif
65 stmfd sp!, {r2 - r12, lr} @ save registers on stack
66
67 bl pxa_cpu_save_cp
68
69 mov r5, r0 @ save sleep mode
70 bl pxa_cpu_save_sp
63 71
64 @ clean data cache 72 @ clean data cache
65 bl xscale_flush_kern_cache_all 73 bl xscale_flush_kern_cache_all
@@ -80,13 +88,55 @@ ENTRY(pxa_cpu_suspend)
80 @ enable SDRAM self-refresh mode 88 @ enable SDRAM self-refresh mode
81 orr r5, r5, #MDREFR_SLFRSH 89 orr r5, r5, #MDREFR_SLFRSH
82 90
83#ifdef CONFIG_PXA27x
84 @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50) 91 @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
85 ldr r6, =MDREFR_KDIV 92 ldr r6, =MDREFR_KDIV
86 orr r5, r5, r6 93 orr r5, r5, r6
87#endif
88 94
89#ifdef CONFIG_PXA25x 95 @ Intel PXA270 Specification Update notes problems sleeping
96 @ with core operating above 91 MHz
97 @ (see Errata 50, ...processor does not exit from sleep...)
98
99 ldr r6, =CCCR
100 ldr r8, [r6] @ keep original value for resume
101
102 ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value
103 mov r0, #0x2 @ prepare value for CLKCFG
104
105 @ align execution to a cache line
106 b pxa_cpu_do_suspend
107
108/*
109 * pxa27x_cpu_suspend()
110 *
111 * Forces CPU into sleep state.
112 *
113 * r0 = value for PWRMODE M field for desired sleep state
114 */
115
116ENTRY(pxa25x_cpu_suspend)
117 stmfd sp!, {r2 - r12, lr} @ save registers on stack
118
119 bl pxa_cpu_save_cp
120
121 mov r5, r0 @ save sleep mode
122 bl pxa_cpu_save_sp
123
124 @ clean data cache
125 bl xscale_flush_kern_cache_all
126
127 @ prepare value for sleep mode
128 mov r1, r5 @ sleep mode
129
130 @ prepare pointer to physical address 0 (virtual mapping in generic.c)
131 mov r2, #UNCACHED_PHYS_0
132
133 @ prepare SDRAM refresh settings
134 ldr r4, =MDREFR
135 ldr r5, [r4]
136
137 @ enable SDRAM self-refresh mode
138 orr r5, r5, #MDREFR_SLFRSH
139
90 @ Intel PXA255 Specification Update notes problems 140 @ Intel PXA255 Specification Update notes problems
91 @ about suspending with PXBus operating above 133MHz 141 @ about suspending with PXBus operating above 133MHz
92 @ (see Errata 31, GPIO output signals, ... unpredictable in sleep 142 @ (see Errata 31, GPIO output signals, ... unpredictable in sleep
@@ -118,30 +168,15 @@ ENTRY(pxa_cpu_suspend)
118 mov r0, #0 168 mov r0, #0
119 mcr p14, 0, r0, c6, c0, 0 169 mcr p14, 0, r0, c6, c0, 0
120 orr r0, r0, #2 @ initiate change bit 170 orr r0, r0, #2 @ initiate change bit
121#endif 171 b pxa_cpu_do_suspend
122#ifdef CONFIG_PXA27x
123 @ Intel PXA270 Specification Update notes problems sleeping
124 @ with core operating above 91 MHz
125 @ (see Errata 50, ...processor does not exit from sleep...)
126
127 ldr r6, =CCCR
128 ldr r8, [r6] @ keep original value for resume
129
130 ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value
131 mov r0, #0x2 @ prepare value for CLKCFG
132#endif
133
134 @ align execution to a cache line
135 b 1f
136 172
137 .ltorg 173 .ltorg
138 .align 5 174 .align 5
1391: 175pxa_cpu_do_suspend:
140 176
141 @ All needed values are now in registers. 177 @ All needed values are now in registers.
142 @ These last instructions should be in cache 178 @ These last instructions should be in cache
143 179
144#if defined(CONFIG_PXA25x) || defined(CONFIG_PXA27x)
145 @ initiate the frequency change... 180 @ initiate the frequency change...
146 str r7, [r6] 181 str r7, [r6]
147 mcr p14, 0, r0, c6, c0, 0 182 mcr p14, 0, r0, c6, c0, 0
@@ -155,7 +190,6 @@ ENTRY(pxa_cpu_suspend)
155 mov r0, #42 190 mov r0, #42
15610: subs r0, r0, #1 19110: subs r0, r0, #1
157 bne 10b 192 bne 10b
158#endif
159 193
160 @ Do not reorder... 194 @ Do not reorder...
161 @ Intel PXA270 Specification Update notes problems performing 195 @ Intel PXA270 Specification Update notes problems performing
diff --git a/arch/arm/mach-pxa/time.c b/arch/arm/mach-pxa/time.c
index 6f91fd2d061a..98d27e646b09 100644
--- a/arch/arm/mach-pxa/time.c
+++ b/arch/arm/mach-pxa/time.c
@@ -1,9 +1,11 @@
1/* 1/*
2 * arch/arm/mach-pxa/time.c 2 * arch/arm/mach-pxa/time.c
3 * 3 *
4 * Author: Nicolas Pitre 4 * PXA clocksource, clockevents, and OST interrupt handlers.
5 * Created: Jun 15, 2001 5 * Copyright (c) 2007 by Bill Gatliff <bgat@billgatliff.com>.
6 * Copyright: MontaVista Software Inc. 6 *
7 * Derived from Nicolas Pitre's PXA timer handler Copyright (c) 2001
8 * by MontaVista Software, Inc. (Nico, your code rocks!)
7 * 9 *
8 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
@@ -12,164 +14,160 @@
12 14
13#include <linux/kernel.h> 15#include <linux/kernel.h>
14#include <linux/init.h> 16#include <linux/init.h>
15#include <linux/delay.h>
16#include <linux/interrupt.h> 17#include <linux/interrupt.h>
17#include <linux/time.h> 18#include <linux/clockchips.h>
18#include <linux/signal.h> 19
19#include <linux/errno.h>
20#include <linux/sched.h>
21#include <linux/clocksource.h>
22
23#include <asm/system.h>
24#include <asm/hardware.h>
25#include <asm/io.h>
26#include <asm/leds.h>
27#include <asm/irq.h>
28#include <asm/mach/irq.h> 20#include <asm/mach/irq.h>
29#include <asm/mach/time.h> 21#include <asm/mach/time.h>
30#include <asm/arch/pxa-regs.h> 22#include <asm/arch/pxa-regs.h>
31 23
32
33static int pxa_set_rtc(void)
34{
35 unsigned long current_time = xtime.tv_sec;
36
37 if (RTSR & RTSR_ALE) {
38 /* make sure not to forward the clock over an alarm */
39 unsigned long alarm = RTAR;
40 if (current_time >= alarm && alarm >= RCNR)
41 return -ERESTARTSYS;
42 }
43 RCNR = current_time;
44 return 0;
45}
46
47#ifdef CONFIG_NO_IDLE_HZ
48static unsigned long initial_match;
49static int match_posponed;
50#endif
51
52static irqreturn_t 24static irqreturn_t
53pxa_timer_interrupt(int irq, void *dev_id) 25pxa_ost0_interrupt(int irq, void *dev_id)
54{ 26{
55 int next_match; 27 int next_match;
56 28 struct clock_event_device *c = dev_id;
57 write_seqlock(&xtime_lock); 29
58 30 if (c->mode == CLOCK_EVT_MODE_ONESHOT) {
59#ifdef CONFIG_NO_IDLE_HZ 31 /* Disarm the compare/match, signal the event. */
60 if (match_posponed) { 32 OIER &= ~OIER_E0;
61 match_posponed = 0; 33 c->event_handler(c);
62 OSMR0 = initial_match; 34 } else if (c->mode == CLOCK_EVT_MODE_PERIODIC) {
63 } 35 /* Call the event handler as many times as necessary
64#endif 36 * to recover missed events, if any (if we update
65 37 * OSMR0 and OSCR0 is still ahead of us, we've missed
66 /* Loop until we get ahead of the free running timer. 38 * the event). As we're dealing with that, re-arm the
67 * This ensures an exact clock tick count and time accuracy. 39 * compare/match for the next event.
68 * Since IRQs are disabled at this point, coherence between 40 *
69 * lost_ticks(updated in do_timer()) and the match reg value is 41 * HACK ALERT:
70 * ensured, hence we can use do_gettimeofday() from interrupt 42 *
71 * handlers. 43 * There's a latency between the instruction that
72 * 44 * writes to OSMR0 and the actual commit to the
73 * HACK ALERT: it seems that the PXA timer regs aren't updated right 45 * physical hardware, because the CPU doesn't (have
74 * away in all cases when a write occurs. We therefore compare with 46 * to) run at bus speed, there's a write buffer
75 * 8 instead of 0 in the while() condition below to avoid missing a 47 * between the CPU and the bus, etc. etc. So if the
76 * match if OSCR has already reached the next OSMR value. 48 * target OSCR0 is "very close", to the OSMR0 load
77 * Experience has shown that up to 6 ticks are needed to work around 49 * value, the update to OSMR0 might not get to the
78 * this problem, but let's use 8 to be conservative. Note that this 50 * hardware in time and we'll miss that interrupt.
79 * affect things only when the timer IRQ has been delayed by nearly 51 *
80 * exactly one tick period which should be a pretty rare event. 52 * To be safe, if the new OSMR0 is "very close" to the
53 * target OSCR0 value, we call the event_handler as
54 * though the event actually happened. According to
55 * Nico's comment in the previous version of this
56 * code, experience has shown that 6 OSCR ticks is
57 * "very close" but he went with 8. We will use 16,
58 * based on the results of testing on PXA270.
59 *
60 * To be doubly sure, we also tell clkevt via
61 * clockevents_register_device() not to ask for
62 * anything that might put us "very close".
81 */ 63 */
64#define MIN_OSCR_DELTA 16
82 do { 65 do {
83 timer_tick(); 66 OSSR = OSSR_M0;
84 OSSR = OSSR_M0; /* Clear match on timer 0 */
85 next_match = (OSMR0 += LATCH); 67 next_match = (OSMR0 += LATCH);
86 } while( (signed long)(next_match - OSCR) <= 8 ); 68 c->event_handler(c);
87 69 } while (((signed long)(next_match - OSCR) <= MIN_OSCR_DELTA)
88 write_sequnlock(&xtime_lock); 70 && (c->mode == CLOCK_EVT_MODE_PERIODIC));
71 }
89 72
90 return IRQ_HANDLED; 73 return IRQ_HANDLED;
91} 74}
92 75
93static struct irqaction pxa_timer_irq = { 76static int
94 .name = "PXA Timer Tick", 77pxa_osmr0_set_next_event(unsigned long delta, struct clock_event_device *dev)
95 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 78{
96 .handler = pxa_timer_interrupt, 79 unsigned long irqflags;
80
81 raw_local_irq_save(irqflags);
82 OSMR0 = OSCR + delta;
83 OSSR = OSSR_M0;
84 OIER |= OIER_E0;
85 raw_local_irq_restore(irqflags);
86 return 0;
87}
88
89static void
90pxa_osmr0_set_mode(enum clock_event_mode mode, struct clock_event_device *dev)
91{
92 unsigned long irqflags;
93
94 switch (mode) {
95 case CLOCK_EVT_MODE_PERIODIC:
96 raw_local_irq_save(irqflags);
97 OSMR0 = OSCR + LATCH;
98 OSSR = OSSR_M0;
99 OIER |= OIER_E0;
100 raw_local_irq_restore(irqflags);
101 break;
102
103 case CLOCK_EVT_MODE_ONESHOT:
104 raw_local_irq_save(irqflags);
105 OIER &= ~OIER_E0;
106 raw_local_irq_restore(irqflags);
107 break;
108
109 case CLOCK_EVT_MODE_UNUSED:
110 case CLOCK_EVT_MODE_SHUTDOWN:
111 /* initializing, released, or preparing for suspend */
112 raw_local_irq_save(irqflags);
113 OIER &= ~OIER_E0;
114 raw_local_irq_restore(irqflags);
115 break;
116 }
117}
118
119static struct clock_event_device ckevt_pxa_osmr0 = {
120 .name = "osmr0",
121 .features = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT,
122 .shift = 32,
123 .rating = 200,
124 .cpumask = CPU_MASK_CPU0,
125 .set_next_event = pxa_osmr0_set_next_event,
126 .set_mode = pxa_osmr0_set_mode,
97}; 127};
98 128
99static cycle_t pxa_get_cycles(void) 129static cycle_t pxa_read_oscr(void)
100{ 130{
101 return OSCR; 131 return OSCR;
102} 132}
103 133
104static struct clocksource clocksource_pxa = { 134static struct clocksource cksrc_pxa_oscr0 = {
105 .name = "pxa_timer", 135 .name = "oscr0",
106 .rating = 200, 136 .rating = 200,
107 .read = pxa_get_cycles, 137 .read = pxa_read_oscr,
108 .mask = CLOCKSOURCE_MASK(32), 138 .mask = CLOCKSOURCE_MASK(32),
109 .shift = 20, 139 .shift = 20,
110 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 140 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
111}; 141};
112 142
143static struct irqaction pxa_ost0_irq = {
144 .name = "ost0",
145 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
146 .handler = pxa_ost0_interrupt,
147 .dev_id = &ckevt_pxa_osmr0,
148};
149
113static void __init pxa_timer_init(void) 150static void __init pxa_timer_init(void)
114{ 151{
115 struct timespec tv; 152 OIER = 0;
116 unsigned long flags; 153 OSSR = OSSR_M0 | OSSR_M1 | OSSR_M2 | OSSR_M3;
117 154
118 set_rtc = pxa_set_rtc; 155 ckevt_pxa_osmr0.mult =
156 div_sc(CLOCK_TICK_RATE, NSEC_PER_SEC, ckevt_pxa_osmr0.shift);
157 ckevt_pxa_osmr0.max_delta_ns =
158 clockevent_delta2ns(0x7fffffff, &ckevt_pxa_osmr0);
159 ckevt_pxa_osmr0.min_delta_ns =
160 clockevent_delta2ns(MIN_OSCR_DELTA, &ckevt_pxa_osmr0) + 1;
119 161
120 OIER = 0; /* disable any timer interrupts */ 162 cksrc_pxa_oscr0.mult =
121 OSSR = 0xf; /* clear status on all timers */ 163 clocksource_hz2mult(CLOCK_TICK_RATE, cksrc_pxa_oscr0.shift);
122 setup_irq(IRQ_OST0, &pxa_timer_irq);
123 local_irq_save(flags);
124 OIER = OIER_E0; /* enable match on timer 0 to cause interrupts */
125 OSMR0 = OSCR + LATCH; /* set initial match */
126 local_irq_restore(flags);
127
128 /*
129 * OSCR runs continuously on PXA and is not written to,
130 * so we can use it as clock source directly.
131 */
132 clocksource_pxa.mult =
133 clocksource_hz2mult(CLOCK_TICK_RATE, clocksource_pxa.shift);
134 clocksource_register(&clocksource_pxa);
135}
136
137#ifdef CONFIG_NO_IDLE_HZ
138static int pxa_dyn_tick_enable_disable(void)
139{
140 /* nothing to do */
141 return 0;
142}
143 164
144static void pxa_dyn_tick_reprogram(unsigned long ticks) 165 setup_irq(IRQ_OST0, &pxa_ost0_irq);
145{
146 if (ticks > 1) {
147 initial_match = OSMR0;
148 OSMR0 = initial_match + ticks * LATCH;
149 match_posponed = 1;
150 }
151}
152 166
153static irqreturn_t 167 clocksource_register(&cksrc_pxa_oscr0);
154pxa_dyn_tick_handler(int irq, void *dev_id) 168 clockevents_register_device(&ckevt_pxa_osmr0);
155{
156 if (match_posponed) {
157 match_posponed = 0;
158 OSMR0 = initial_match;
159 if ( (signed long)(initial_match - OSCR) <= 8 )
160 return pxa_timer_interrupt(irq, dev_id);
161 }
162 return IRQ_NONE;
163} 169}
164 170
165static struct dyn_tick_timer pxa_dyn_tick = {
166 .enable = pxa_dyn_tick_enable_disable,
167 .disable = pxa_dyn_tick_enable_disable,
168 .reprogram = pxa_dyn_tick_reprogram,
169 .handler = pxa_dyn_tick_handler,
170};
171#endif
172
173#ifdef CONFIG_PM 171#ifdef CONFIG_PM
174static unsigned long osmr[4], oier; 172static unsigned long osmr[4], oier;
175 173
@@ -191,7 +189,10 @@ static void pxa_timer_resume(void)
191 OIER = oier; 189 OIER = oier;
192 190
193 /* 191 /*
194 * OSMR0 is the system timer: make sure OSCR is sufficiently behind 192 * OSCR0 is the system timer, which has to increase
193 * monotonically until it rolls over in hardware. The value
194 * (OSMR0 - LATCH) is OSCR0 at the most recent system tick,
195 * which is a handy value to restore to OSCR0.
195 */ 196 */
196 OSCR = OSMR0 - LATCH; 197 OSCR = OSMR0 - LATCH;
197} 198}
@@ -204,7 +205,4 @@ struct sys_timer pxa_timer = {
204 .init = pxa_timer_init, 205 .init = pxa_timer_init,
205 .suspend = pxa_timer_suspend, 206 .suspend = pxa_timer_suspend,
206 .resume = pxa_timer_resume, 207 .resume = pxa_timer_resume,
207#ifdef CONFIG_NO_IDLE_HZ
208 .dyn_tick = &pxa_dyn_tick,
209#endif
210}; 208};
diff --git a/arch/arm/mach-rpc/riscpc.c b/arch/arm/mach-rpc/riscpc.c
index 570cf937e73b..a454451c97c3 100644
--- a/arch/arm/mach-rpc/riscpc.c
+++ b/arch/arm/mach-rpc/riscpc.c
@@ -87,7 +87,7 @@ static void __init rpc_map_io(void)
87 /* 87 /*
88 * Turn off floppy. 88 * Turn off floppy.
89 */ 89 */
90 outb(0xc, 0x3f2); 90 writeb(0xc, PCIO_BASE + (0x3f2 << 2));
91 91
92 /* 92 /*
93 * RiscPC can't handle half-word loads and stores 93 * RiscPC can't handle half-word loads and stores
diff --git a/arch/arm/mach-s3c2410/Kconfig b/arch/arm/mach-s3c2410/Kconfig
index d4b013b283c3..e2079cf9266f 100644
--- a/arch/arm/mach-s3c2410/Kconfig
+++ b/arch/arm/mach-s3c2410/Kconfig
@@ -9,6 +9,7 @@ config CPU_S3C2410
9 depends on ARCH_S3C2410 9 depends on ARCH_S3C2410
10 select S3C2410_CLOCK 10 select S3C2410_CLOCK
11 select S3C2410_GPIO 11 select S3C2410_GPIO
12 select CPU_LLSERIAL_S3C2410
12 select S3C2410_PM if PM 13 select S3C2410_PM if PM
13 help 14 help
14 Support for S3C2410 and S3C2410A family from the S3C24XX line 15 Support for S3C2410 and S3C2410A family from the S3C24XX line
diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c
index 5b4831c4c1d8..cab9d6265e9e 100644
--- a/arch/arm/mach-s3c2410/clock.c
+++ b/arch/arm/mach-s3c2410/clock.c
@@ -37,7 +37,7 @@
37#include <asm/hardware.h> 37#include <asm/hardware.h>
38#include <asm/io.h> 38#include <asm/io.h>
39 39
40#include <asm/arch/regs-serial.h> 40#include <asm/plat-s3c/regs-serial.h>
41#include <asm/arch/regs-clock.h> 41#include <asm/arch/regs-clock.h>
42#include <asm/arch/regs-gpio.h> 42#include <asm/arch/regs-gpio.h>
43 43
diff --git a/arch/arm/mach-s3c2410/dma.c b/arch/arm/mach-s3c2410/dma.c
index 67d1ad363973..80d83739ab9f 100644
--- a/arch/arm/mach-s3c2410/dma.c
+++ b/arch/arm/mach-s3c2410/dma.c
@@ -23,14 +23,14 @@
23#include <asm/plat-s3c24xx/cpu.h> 23#include <asm/plat-s3c24xx/cpu.h>
24#include <asm/plat-s3c24xx/dma.h> 24#include <asm/plat-s3c24xx/dma.h>
25 25
26#include <asm/arch/regs-serial.h> 26#include <asm/plat-s3c/regs-serial.h>
27#include <asm/arch/regs-gpio.h> 27#include <asm/arch/regs-gpio.h>
28#include <asm/arch/regs-ac97.h> 28#include <asm/plat-s3c/regs-ac97.h>
29#include <asm/arch/regs-mem.h> 29#include <asm/arch/regs-mem.h>
30#include <asm/arch/regs-lcd.h> 30#include <asm/arch/regs-lcd.h>
31#include <asm/arch/regs-sdi.h> 31#include <asm/arch/regs-sdi.h>
32#include <asm/arch/regs-iis.h> 32#include <asm/plat-s3c24xx/regs-iis.h>
33#include <asm/arch/regs-spi.h> 33#include <asm/plat-s3c24xx/regs-spi.h>
34 34
35static struct s3c24xx_dma_map __initdata s3c2410_dma_mappings[] = { 35static struct s3c24xx_dma_map __initdata s3c2410_dma_mappings[] = {
36 [DMACH_XD0] = { 36 [DMACH_XD0] = {
diff --git a/arch/arm/mach-s3c2410/mach-amlm5900.c b/arch/arm/mach-s3c2410/mach-amlm5900.c
index 435adcce6482..43bb5e106302 100644
--- a/arch/arm/mach-s3c2410/mach-amlm5900.c
+++ b/arch/arm/mach-s3c2410/mach-amlm5900.c
@@ -48,7 +48,7 @@
48#include <asm/mach-types.h> 48#include <asm/mach-types.h>
49#include <asm/arch/fb.h> 49#include <asm/arch/fb.h>
50 50
51#include <asm/arch/regs-serial.h> 51#include <asm/plat-s3c/regs-serial.h>
52#include <asm/arch/regs-lcd.h> 52#include <asm/arch/regs-lcd.h>
53#include <asm/arch/regs-gpio.h> 53#include <asm/arch/regs-gpio.h>
54 54
diff --git a/arch/arm/mach-s3c2410/mach-bast.c b/arch/arm/mach-s3c2410/mach-bast.c
index 8b52ea95d4f6..bc926992b4e4 100644
--- a/arch/arm/mach-s3c2410/mach-bast.c
+++ b/arch/arm/mach-s3c2410/mach-bast.c
@@ -36,13 +36,13 @@
36#include <asm/mach-types.h> 36#include <asm/mach-types.h>
37 37
38//#include <asm/debug-ll.h> 38//#include <asm/debug-ll.h>
39#include <asm/arch/regs-serial.h> 39#include <asm/plat-s3c/regs-serial.h>
40#include <asm/arch/regs-gpio.h> 40#include <asm/arch/regs-gpio.h>
41#include <asm/arch/regs-mem.h> 41#include <asm/arch/regs-mem.h>
42#include <asm/arch/regs-lcd.h> 42#include <asm/arch/regs-lcd.h>
43 43
44#include <asm/arch/nand.h> 44#include <asm/plat-s3c/nand.h>
45#include <asm/arch/iic.h> 45#include <asm/plat-s3c/iic.h>
46#include <asm/arch/fb.h> 46#include <asm/arch/fb.h>
47 47
48#include <linux/mtd/mtd.h> 48#include <linux/mtd/mtd.h>
diff --git a/arch/arm/mach-s3c2410/mach-h1940.c b/arch/arm/mach-s3c2410/mach-h1940.c
index 5c9bcea74767..9a172b4ad720 100644
--- a/arch/arm/mach-s3c2410/mach-h1940.c
+++ b/arch/arm/mach-s3c2410/mach-h1940.c
@@ -30,7 +30,7 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31#include <asm/mach-types.h> 31#include <asm/mach-types.h>
32 32
33#include <asm/arch/regs-serial.h> 33#include <asm/plat-s3c/regs-serial.h>
34#include <asm/arch/regs-lcd.h> 34#include <asm/arch/regs-lcd.h>
35#include <asm/arch/regs-gpio.h> 35#include <asm/arch/regs-gpio.h>
36#include <asm/arch/regs-clock.h> 36#include <asm/arch/regs-clock.h>
@@ -38,7 +38,7 @@
38#include <asm/arch/h1940.h> 38#include <asm/arch/h1940.h>
39#include <asm/arch/h1940-latch.h> 39#include <asm/arch/h1940-latch.h>
40#include <asm/arch/fb.h> 40#include <asm/arch/fb.h>
41#include <asm/arch/udc.h> 41#include <asm/plat-s3c24xx/udc.h>
42 42
43#include <asm/plat-s3c24xx/clock.h> 43#include <asm/plat-s3c24xx/clock.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <asm/plat-s3c24xx/devs.h>
diff --git a/arch/arm/mach-s3c2410/mach-n30.c b/arch/arm/mach-s3c2410/mach-n30.c
index 412e50c3d28a..621f548da610 100644
--- a/arch/arm/mach-s3c2410/mach-n30.c
+++ b/arch/arm/mach-s3c2410/mach-n30.c
@@ -33,9 +33,9 @@
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35 35
36#include <asm/arch/regs-serial.h> 36#include <asm/plat-s3c/regs-serial.h>
37#include <asm/arch/regs-gpio.h> 37#include <asm/arch/regs-gpio.h>
38#include <asm/arch/iic.h> 38#include <asm/plat-s3c/iic.h>
39 39
40#include <asm/plat-s3c24xx/s3c2410.h> 40#include <asm/plat-s3c24xx/s3c2410.h>
41#include <asm/plat-s3c24xx/clock.h> 41#include <asm/plat-s3c24xx/clock.h>
diff --git a/arch/arm/mach-s3c2410/mach-otom.c b/arch/arm/mach-s3c2410/mach-otom.c
index 1f899fa588df..717af40e4477 100644
--- a/arch/arm/mach-s3c2410/mach-otom.c
+++ b/arch/arm/mach-s3c2410/mach-otom.c
@@ -29,7 +29,7 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30#include <asm/mach-types.h> 30#include <asm/mach-types.h>
31 31
32#include <asm/arch/regs-serial.h> 32#include <asm/plat-s3c/regs-serial.h>
33#include <asm/arch/regs-gpio.h> 33#include <asm/arch/regs-gpio.h>
34 34
35#include <asm/plat-s3c24xx/s3c2410.h> 35#include <asm/plat-s3c24xx/s3c2410.h>
diff --git a/arch/arm/mach-s3c2410/mach-qt2410.c b/arch/arm/mach-s3c2410/mach-qt2410.c
index d86e6f18bac9..e670b1e1631b 100644
--- a/arch/arm/mach-s3c2410/mach-qt2410.c
+++ b/arch/arm/mach-s3c2410/mach-qt2410.c
@@ -49,10 +49,10 @@
49 49
50#include <asm/arch/regs-gpio.h> 50#include <asm/arch/regs-gpio.h>
51#include <asm/arch/leds-gpio.h> 51#include <asm/arch/leds-gpio.h>
52#include <asm/arch/regs-serial.h> 52#include <asm/plat-s3c/regs-serial.h>
53#include <asm/arch/fb.h> 53#include <asm/arch/fb.h>
54#include <asm/arch/nand.h> 54#include <asm/plat-s3c/nand.h>
55#include <asm/arch/udc.h> 55#include <asm/plat-s3c24xx/udc.h>
56#include <asm/arch/spi.h> 56#include <asm/arch/spi.h>
57#include <asm/arch/spi-gpio.h> 57#include <asm/arch/spi-gpio.h>
58 58
diff --git a/arch/arm/mach-s3c2410/mach-smdk2410.c b/arch/arm/mach-s3c2410/mach-smdk2410.c
index 5852d300d52f..226550504c85 100644
--- a/arch/arm/mach-s3c2410/mach-smdk2410.c
+++ b/arch/arm/mach-s3c2410/mach-smdk2410.c
@@ -47,7 +47,7 @@
47#include <asm/irq.h> 47#include <asm/irq.h>
48#include <asm/mach-types.h> 48#include <asm/mach-types.h>
49 49
50#include <asm/arch/regs-serial.h> 50#include <asm/plat-s3c/regs-serial.h>
51 51
52#include <asm/plat-s3c24xx/devs.h> 52#include <asm/plat-s3c24xx/devs.h>
53#include <asm/plat-s3c24xx/cpu.h> 53#include <asm/plat-s3c24xx/cpu.h>
diff --git a/arch/arm/mach-s3c2410/mach-vr1000.c b/arch/arm/mach-s3c2410/mach-vr1000.c
index 7b624bb00490..9f43f3f124f5 100644
--- a/arch/arm/mach-s3c2410/mach-vr1000.c
+++ b/arch/arm/mach-s3c2410/mach-vr1000.c
@@ -39,7 +39,7 @@
39#include <asm/irq.h> 39#include <asm/irq.h>
40#include <asm/mach-types.h> 40#include <asm/mach-types.h>
41 41
42#include <asm/arch/regs-serial.h> 42#include <asm/plat-s3c/regs-serial.h>
43#include <asm/arch/regs-gpio.h> 43#include <asm/arch/regs-gpio.h>
44#include <asm/arch/leds-gpio.h> 44#include <asm/arch/leds-gpio.h>
45 45
diff --git a/arch/arm/mach-s3c2410/s3c2410.c b/arch/arm/mach-s3c2410/s3c2410.c
index 1a86a9803753..e580303cb0ab 100644
--- a/arch/arm/mach-s3c2410/s3c2410.c
+++ b/arch/arm/mach-s3c2410/s3c2410.c
@@ -29,7 +29,7 @@
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#include <asm/arch/regs-clock.h> 31#include <asm/arch/regs-clock.h>
32#include <asm/arch/regs-serial.h> 32#include <asm/plat-s3c/regs-serial.h>
33 33
34#include <asm/plat-s3c24xx/s3c2410.h> 34#include <asm/plat-s3c24xx/s3c2410.h>
35#include <asm/plat-s3c24xx/cpu.h> 35#include <asm/plat-s3c24xx/cpu.h>
@@ -40,7 +40,6 @@
40 40
41static struct map_desc s3c2410_iodesc[] __initdata = { 41static struct map_desc s3c2410_iodesc[] __initdata = {
42 IODESC_ENT(CLKPWR), 42 IODESC_ENT(CLKPWR),
43 IODESC_ENT(LCD),
44 IODESC_ENT(TIMER), 43 IODESC_ENT(TIMER),
45 IODESC_ENT(WATCHDOG), 44 IODESC_ENT(WATCHDOG),
46}; 45};
diff --git a/arch/arm/mach-s3c2410/sleep.S b/arch/arm/mach-s3c2410/sleep.S
index d1eeed2ad47c..8a9c5a2bb252 100644
--- a/arch/arm/mach-s3c2410/sleep.S
+++ b/arch/arm/mach-s3c2410/sleep.S
@@ -32,7 +32,7 @@
32#include <asm/arch/regs-gpio.h> 32#include <asm/arch/regs-gpio.h>
33#include <asm/arch/regs-clock.h> 33#include <asm/arch/regs-clock.h>
34#include <asm/arch/regs-mem.h> 34#include <asm/arch/regs-mem.h>
35#include <asm/arch/regs-serial.h> 35#include <asm/plat-s3c/regs-serial.h>
36 36
37 /* s3c2410_cpu_suspend 37 /* s3c2410_cpu_suspend
38 * 38 *
diff --git a/arch/arm/mach-s3c2412/Kconfig b/arch/arm/mach-s3c2412/Kconfig
index d5be5d053264..8e8fe48ea47f 100644
--- a/arch/arm/mach-s3c2412/Kconfig
+++ b/arch/arm/mach-s3c2412/Kconfig
@@ -7,6 +7,7 @@
7config CPU_S3C2412 7config CPU_S3C2412
8 bool 8 bool
9 depends on ARCH_S3C2410 9 depends on ARCH_S3C2410
10 select CPU_LLSERIAL_S3C2440
10 select S3C2412_PM if PM 11 select S3C2412_PM if PM
11 select S3C2412_DMA if S3C2410_DMA 12 select S3C2412_DMA if S3C2410_DMA
12 help 13 help
diff --git a/arch/arm/mach-s3c2412/clock.c b/arch/arm/mach-s3c2412/clock.c
index 6a8e4448770b..8543dd6df391 100644
--- a/arch/arm/mach-s3c2412/clock.c
+++ b/arch/arm/mach-s3c2412/clock.c
@@ -37,7 +37,7 @@
37#include <asm/hardware.h> 37#include <asm/hardware.h>
38#include <asm/io.h> 38#include <asm/io.h>
39 39
40#include <asm/arch/regs-serial.h> 40#include <asm/plat-s3c/regs-serial.h>
41#include <asm/arch/regs-clock.h> 41#include <asm/arch/regs-clock.h>
42#include <asm/arch/regs-gpio.h> 42#include <asm/arch/regs-gpio.h>
43 43
diff --git a/arch/arm/mach-s3c2412/dma.c b/arch/arm/mach-s3c2412/dma.c
index 668cccefe7b0..4b9425c1bf72 100644
--- a/arch/arm/mach-s3c2412/dma.c
+++ b/arch/arm/mach-s3c2412/dma.c
@@ -24,14 +24,14 @@
24#include <asm/plat-s3c24xx/dma.h> 24#include <asm/plat-s3c24xx/dma.h>
25#include <asm/plat-s3c24xx/cpu.h> 25#include <asm/plat-s3c24xx/cpu.h>
26 26
27#include <asm/arch/regs-serial.h> 27#include <asm/plat-s3c/regs-serial.h>
28#include <asm/arch/regs-gpio.h> 28#include <asm/arch/regs-gpio.h>
29#include <asm/arch/regs-ac97.h> 29#include <asm/plat-s3c/regs-ac97.h>
30#include <asm/arch/regs-mem.h> 30#include <asm/arch/regs-mem.h>
31#include <asm/arch/regs-lcd.h> 31#include <asm/arch/regs-lcd.h>
32#include <asm/arch/regs-sdi.h> 32#include <asm/arch/regs-sdi.h>
33#include <asm/arch/regs-iis.h> 33#include <asm/plat-s3c24xx/regs-iis.h>
34#include <asm/arch/regs-spi.h> 34#include <asm/plat-s3c24xx/regs-spi.h>
35 35
36#define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID } 36#define MAP(x) { (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID, (x)| DMA_CH_VALID }
37 37
diff --git a/arch/arm/mach-s3c2412/mach-smdk2413.c b/arch/arm/mach-s3c2412/mach-smdk2413.c
index 063af09f899d..b126a530daa6 100644
--- a/arch/arm/mach-s3c2412/mach-smdk2413.c
+++ b/arch/arm/mach-s3c2412/mach-smdk2413.c
@@ -32,12 +32,12 @@
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34//#include <asm/debug-ll.h> 34//#include <asm/debug-ll.h>
35#include <asm/arch/regs-serial.h> 35#include <asm/plat-s3c/regs-serial.h>
36#include <asm/arch/regs-gpio.h> 36#include <asm/arch/regs-gpio.h>
37#include <asm/arch/regs-lcd.h> 37#include <asm/arch/regs-lcd.h>
38 38
39#include <asm/arch/idle.h> 39#include <asm/arch/idle.h>
40#include <asm/arch/udc.h> 40#include <asm/plat-s3c24xx/udc.h>
41#include <asm/arch/fb.h> 41#include <asm/arch/fb.h>
42 42
43#include <asm/plat-s3c24xx/s3c2410.h> 43#include <asm/plat-s3c24xx/s3c2410.h>
diff --git a/arch/arm/mach-s3c2412/mach-vstms.c b/arch/arm/mach-s3c2412/mach-vstms.c
index f2fbd65956ac..32982547cd63 100644
--- a/arch/arm/mach-s3c2412/mach-vstms.c
+++ b/arch/arm/mach-s3c2412/mach-vstms.c
@@ -33,14 +33,14 @@
33#include <asm/irq.h> 33#include <asm/irq.h>
34#include <asm/mach-types.h> 34#include <asm/mach-types.h>
35 35
36#include <asm/arch/regs-serial.h> 36#include <asm/plat-s3c/regs-serial.h>
37#include <asm/arch/regs-gpio.h> 37#include <asm/arch/regs-gpio.h>
38#include <asm/arch/regs-lcd.h> 38#include <asm/arch/regs-lcd.h>
39 39
40#include <asm/arch/idle.h> 40#include <asm/arch/idle.h>
41#include <asm/arch/fb.h> 41#include <asm/arch/fb.h>
42 42
43#include <asm/arch/nand.h> 43#include <asm/plat-s3c/nand.h>
44 44
45#include <asm/plat-s3c24xx/s3c2410.h> 45#include <asm/plat-s3c24xx/s3c2410.h>
46#include <asm/plat-s3c24xx/s3c2412.h> 46#include <asm/plat-s3c24xx/s3c2412.h>
diff --git a/arch/arm/mach-s3c2412/s3c2412.c b/arch/arm/mach-s3c2412/s3c2412.c
index 782b5814ced2..e0ccb404623f 100644
--- a/arch/arm/mach-s3c2412/s3c2412.c
+++ b/arch/arm/mach-s3c2412/s3c2412.c
@@ -34,12 +34,12 @@
34#include <asm/arch/idle.h> 34#include <asm/arch/idle.h>
35 35
36#include <asm/arch/regs-clock.h> 36#include <asm/arch/regs-clock.h>
37#include <asm/arch/regs-serial.h> 37#include <asm/plat-s3c/regs-serial.h>
38#include <asm/arch/regs-power.h> 38#include <asm/arch/regs-power.h>
39#include <asm/arch/regs-gpio.h> 39#include <asm/arch/regs-gpio.h>
40#include <asm/arch/regs-gpioj.h> 40#include <asm/arch/regs-gpioj.h>
41#include <asm/arch/regs-dsc.h> 41#include <asm/arch/regs-dsc.h>
42#include <asm/arch/regs-spi.h> 42#include <asm/plat-s3c24xx/regs-spi.h>
43#include <asm/arch/regs-s3c2412.h> 43#include <asm/arch/regs-s3c2412.h>
44 44
45#include <asm/plat-s3c24xx/s3c2412.h> 45#include <asm/plat-s3c24xx/s3c2412.h>
@@ -63,7 +63,6 @@ static inline void s3c2412_init_gpio2(void)
63 63
64static struct map_desc s3c2412_iodesc[] __initdata = { 64static struct map_desc s3c2412_iodesc[] __initdata = {
65 IODESC_ENT(CLKPWR), 65 IODESC_ENT(CLKPWR),
66 IODESC_ENT(LCD),
67 IODESC_ENT(TIMER), 66 IODESC_ENT(TIMER),
68 IODESC_ENT(WATCHDOG), 67 IODESC_ENT(WATCHDOG),
69}; 68};
diff --git a/arch/arm/mach-s3c2440/Kconfig b/arch/arm/mach-s3c2440/Kconfig
index e3bfda098c0f..f1915bd61d15 100644
--- a/arch/arm/mach-s3c2440/Kconfig
+++ b/arch/arm/mach-s3c2440/Kconfig
@@ -12,6 +12,7 @@ config CPU_S3C2440
12 select S3C2410_GPIO 12 select S3C2410_GPIO
13 select S3C2440_DMA if S3C2410_DMA 13 select S3C2440_DMA if S3C2410_DMA
14 select CPU_S3C244X 14 select CPU_S3C244X
15 select CPU_LLSERIAL_S3C2440
15 help 16 help
16 Support for S3C2440 Samsung Mobile CPU based systems. 17 Support for S3C2440 Samsung Mobile CPU based systems.
17 18
diff --git a/arch/arm/mach-s3c2440/dma.c b/arch/arm/mach-s3c2440/dma.c
index cd035a3ec878..f509f062e749 100644
--- a/arch/arm/mach-s3c2440/dma.c
+++ b/arch/arm/mach-s3c2440/dma.c
@@ -23,14 +23,14 @@
23#include <asm/plat-s3c24xx/dma.h> 23#include <asm/plat-s3c24xx/dma.h>
24#include <asm/plat-s3c24xx/cpu.h> 24#include <asm/plat-s3c24xx/cpu.h>
25 25
26#include <asm/arch/regs-serial.h> 26#include <asm/plat-s3c/regs-serial.h>
27#include <asm/arch/regs-gpio.h> 27#include <asm/arch/regs-gpio.h>
28#include <asm/arch/regs-ac97.h> 28#include <asm/plat-s3c/regs-ac97.h>
29#include <asm/arch/regs-mem.h> 29#include <asm/arch/regs-mem.h>
30#include <asm/arch/regs-lcd.h> 30#include <asm/arch/regs-lcd.h>
31#include <asm/arch/regs-sdi.h> 31#include <asm/arch/regs-sdi.h>
32#include <asm/arch/regs-iis.h> 32#include <asm/plat-s3c24xx/regs-iis.h>
33#include <asm/arch/regs-spi.h> 33#include <asm/plat-s3c24xx/regs-spi.h>
34 34
35static struct s3c24xx_dma_map __initdata s3c2440_dma_mappings[] = { 35static struct s3c24xx_dma_map __initdata s3c2440_dma_mappings[] = {
36 [DMACH_XD0] = { 36 [DMACH_XD0] = {
diff --git a/arch/arm/mach-s3c2440/mach-anubis.c b/arch/arm/mach-s3c2440/mach-anubis.c
index 29c163d300d4..3d3dfa95db8e 100644
--- a/arch/arm/mach-s3c2440/mach-anubis.c
+++ b/arch/arm/mach-s3c2440/mach-anubis.c
@@ -34,11 +34,11 @@
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/mach-types.h> 35#include <asm/mach-types.h>
36 36
37#include <asm/arch/regs-serial.h> 37#include <asm/plat-s3c/regs-serial.h>
38#include <asm/arch/regs-gpio.h> 38#include <asm/arch/regs-gpio.h>
39#include <asm/arch/regs-mem.h> 39#include <asm/arch/regs-mem.h>
40#include <asm/arch/regs-lcd.h> 40#include <asm/arch/regs-lcd.h>
41#include <asm/arch/nand.h> 41#include <asm/plat-s3c/nand.h>
42 42
43#include <linux/mtd/mtd.h> 43#include <linux/mtd/mtd.h>
44#include <linux/mtd/nand.h> 44#include <linux/mtd/nand.h>
diff --git a/arch/arm/mach-s3c2440/mach-nexcoder.c b/arch/arm/mach-s3c2440/mach-nexcoder.c
index 5e61f2166c76..afe0d7b7e389 100644
--- a/arch/arm/mach-s3c2440/mach-nexcoder.c
+++ b/arch/arm/mach-s3c2440/mach-nexcoder.c
@@ -36,7 +36,7 @@
36 36
37//#include <asm/debug-ll.h> 37//#include <asm/debug-ll.h>
38#include <asm/arch/regs-gpio.h> 38#include <asm/arch/regs-gpio.h>
39#include <asm/arch/regs-serial.h> 39#include <asm/plat-s3c/regs-serial.h>
40 40
41#include <asm/plat-s3c24xx/s3c2410.h> 41#include <asm/plat-s3c24xx/s3c2410.h>
42#include <asm/plat-s3c24xx/s3c2440.h> 42#include <asm/plat-s3c24xx/s3c2440.h>
diff --git a/arch/arm/mach-s3c2440/mach-osiris.c b/arch/arm/mach-s3c2440/mach-osiris.c
index 89f4c9c5777b..0ba7e9060c7b 100644
--- a/arch/arm/mach-s3c2440/mach-osiris.c
+++ b/arch/arm/mach-s3c2440/mach-osiris.c
@@ -31,11 +31,11 @@
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34#include <asm/arch/regs-serial.h> 34#include <asm/plat-s3c/regs-serial.h>
35#include <asm/arch/regs-gpio.h> 35#include <asm/arch/regs-gpio.h>
36#include <asm/arch/regs-mem.h> 36#include <asm/arch/regs-mem.h>
37#include <asm/arch/regs-lcd.h> 37#include <asm/arch/regs-lcd.h>
38#include <asm/arch/nand.h> 38#include <asm/plat-s3c/nand.h>
39 39
40#include <linux/mtd/mtd.h> 40#include <linux/mtd/mtd.h>
41#include <linux/mtd/nand.h> 41#include <linux/mtd/nand.h>
diff --git a/arch/arm/mach-s3c2440/mach-rx3715.c b/arch/arm/mach-s3c2440/mach-rx3715.c
index 866ff71c01dd..b59e6d39f2f2 100644
--- a/arch/arm/mach-s3c2440/mach-rx3715.c
+++ b/arch/arm/mach-s3c2440/mach-rx3715.c
@@ -38,12 +38,12 @@
38#include <asm/irq.h> 38#include <asm/irq.h>
39#include <asm/mach-types.h> 39#include <asm/mach-types.h>
40 40
41#include <asm/arch/regs-serial.h> 41#include <asm/plat-s3c/regs-serial.h>
42#include <asm/arch/regs-gpio.h> 42#include <asm/arch/regs-gpio.h>
43#include <asm/arch/regs-lcd.h> 43#include <asm/arch/regs-lcd.h>
44 44
45#include <asm/arch/h1940.h> 45#include <asm/arch/h1940.h>
46#include <asm/arch/nand.h> 46#include <asm/plat-s3c/nand.h>
47#include <asm/arch/fb.h> 47#include <asm/arch/fb.h>
48 48
49#include <asm/plat-s3c24xx/clock.h> 49#include <asm/plat-s3c24xx/clock.h>
diff --git a/arch/arm/mach-s3c2440/mach-smdk2440.c b/arch/arm/mach-s3c2440/mach-smdk2440.c
index e167254e232e..670115b8a12e 100644
--- a/arch/arm/mach-s3c2440/mach-smdk2440.c
+++ b/arch/arm/mach-s3c2440/mach-smdk2440.c
@@ -31,7 +31,7 @@
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34#include <asm/arch/regs-serial.h> 34#include <asm/plat-s3c/regs-serial.h>
35#include <asm/arch/regs-gpio.h> 35#include <asm/arch/regs-gpio.h>
36#include <asm/arch/regs-lcd.h> 36#include <asm/arch/regs-lcd.h>
37 37
diff --git a/arch/arm/mach-s3c2442/Kconfig b/arch/arm/mach-s3c2442/Kconfig
index bf8d87abfab3..88d5fd34fe3b 100644
--- a/arch/arm/mach-s3c2442/Kconfig
+++ b/arch/arm/mach-s3c2442/Kconfig
@@ -11,6 +11,7 @@ config CPU_S3C2442
11 select S3C2410_GPIO 11 select S3C2410_GPIO
12 select S3C2410_PM if PM 12 select S3C2410_PM if PM
13 select CPU_S3C244X 13 select CPU_S3C244X
14 select CPU_LLSERIAL_S3C2440
14 help 15 help
15 Support for S3C2442 Samsung Mobile CPU based systems. 16 Support for S3C2442 Samsung Mobile CPU based systems.
16 17
diff --git a/arch/arm/mach-s3c2443/Kconfig b/arch/arm/mach-s3c2443/Kconfig
index c649bb2e7ce8..14252f573754 100644
--- a/arch/arm/mach-s3c2443/Kconfig
+++ b/arch/arm/mach-s3c2443/Kconfig
@@ -8,6 +8,7 @@ config CPU_S3C2443
8 bool 8 bool
9 depends on ARCH_S3C2410 9 depends on ARCH_S3C2410
10 select S3C2443_DMA if S3C2410_DMA 10 select S3C2443_DMA if S3C2410_DMA
11 select CPU_LLSERIAL_S3C2440
11 help 12 help
12 Support for the S3C2443 SoC from the S3C24XX line 13 Support for the S3C2443 SoC from the S3C24XX line
13 14
diff --git a/arch/arm/mach-s3c2443/dma.c b/arch/arm/mach-s3c2443/dma.c
index f70e8ccffc3d..fc3ede82af8f 100644
--- a/arch/arm/mach-s3c2443/dma.c
+++ b/arch/arm/mach-s3c2443/dma.c
@@ -24,14 +24,14 @@
24#include <asm/plat-s3c24xx/dma.h> 24#include <asm/plat-s3c24xx/dma.h>
25#include <asm/plat-s3c24xx/cpu.h> 25#include <asm/plat-s3c24xx/cpu.h>
26 26
27#include <asm/arch/regs-serial.h> 27#include <asm/plat-s3c/regs-serial.h>
28#include <asm/arch/regs-gpio.h> 28#include <asm/arch/regs-gpio.h>
29#include <asm/arch/regs-ac97.h> 29#include <asm/plat-s3c/regs-ac97.h>
30#include <asm/arch/regs-mem.h> 30#include <asm/arch/regs-mem.h>
31#include <asm/arch/regs-lcd.h> 31#include <asm/arch/regs-lcd.h>
32#include <asm/arch/regs-sdi.h> 32#include <asm/arch/regs-sdi.h>
33#include <asm/arch/regs-iis.h> 33#include <asm/plat-s3c24xx/regs-iis.h>
34#include <asm/arch/regs-spi.h> 34#include <asm/plat-s3c24xx/regs-spi.h>
35 35
36#define MAP(x) { \ 36#define MAP(x) { \
37 [0] = (x) | DMA_CH_VALID, \ 37 [0] = (x) | DMA_CH_VALID, \
diff --git a/arch/arm/mach-s3c2443/mach-smdk2443.c b/arch/arm/mach-s3c2443/mach-smdk2443.c
index b1eb709ee65a..8cd93130ef36 100644
--- a/arch/arm/mach-s3c2443/mach-smdk2443.c
+++ b/arch/arm/mach-s3c2443/mach-smdk2443.c
@@ -31,7 +31,7 @@
31#include <asm/irq.h> 31#include <asm/irq.h>
32#include <asm/mach-types.h> 32#include <asm/mach-types.h>
33 33
34#include <asm/arch/regs-serial.h> 34#include <asm/plat-s3c/regs-serial.h>
35#include <asm/arch/regs-gpio.h> 35#include <asm/arch/regs-gpio.h>
36#include <asm/arch/regs-lcd.h> 36#include <asm/arch/regs-lcd.h>
37 37
diff --git a/arch/arm/mach-sa1100/Kconfig b/arch/arm/mach-sa1100/Kconfig
index cd67ab1b217b..f99d9013905f 100644
--- a/arch/arm/mach-sa1100/Kconfig
+++ b/arch/arm/mach-sa1100/Kconfig
@@ -101,6 +101,16 @@ config SA1100_JORNADA720
101 handheld computer. See <http://www.hp.com/jornada/products/720> 101 handheld computer. See <http://www.hp.com/jornada/products/720>
102 for details. 102 for details.
103 103
104config SA1100_JORNADA720_SSP
105 bool "HP Jornada 720 Extended SSP driver"
106 select SA1100_SSP
107 depends on SA1100_JORNADA720
108 help
109 Say Y here if you have a HP Jornada 7xx handheld computer and you
110 want to access devices connected to the MCU. Those include the
111 keyboard, touchscreen, backlight and battery. This driver also activates
112 the generic SSP which it extends.
113
104config SA1100_HACKKIT 114config SA1100_HACKKIT
105 bool "HackKit Core CPU Board" 115 bool "HackKit Core CPU Board"
106 help 116 help
@@ -145,8 +155,7 @@ config SA1100_SSP
145 help 155 help
146 Say Y here to enable support for the generic PIO SSP driver. 156 Say Y here to enable support for the generic PIO SSP driver.
147 This isn't for audio support, but for attached sensors and 157 This isn't for audio support, but for attached sensors and
148 other devices, eg for BadgePAD 4 sensor support, or Jornada 158 other devices, eg for BadgePAD 4 sensor support.
149 720 touchscreen support.
150 159
151config H3600_SLEEVE 160config H3600_SLEEVE
152 tristate "Compaq iPAQ Handheld sleeve support" 161 tristate "Compaq iPAQ Handheld sleeve support"
diff --git a/arch/arm/mach-sa1100/Makefile b/arch/arm/mach-sa1100/Makefile
index e27f15042a22..7a61e8d33ab7 100644
--- a/arch/arm/mach-sa1100/Makefile
+++ b/arch/arm/mach-sa1100/Makefile
@@ -31,6 +31,7 @@ obj-$(CONFIG_SA1100_HACKKIT) += hackkit.o
31led-$(CONFIG_SA1100_HACKKIT) += leds-hackkit.o 31led-$(CONFIG_SA1100_HACKKIT) += leds-hackkit.o
32 32
33obj-$(CONFIG_SA1100_JORNADA720) += jornada720.o 33obj-$(CONFIG_SA1100_JORNADA720) += jornada720.o
34obj-$(CONFIG_SA1100_JORNADA720_SSP) += jornada720_ssp.o
34 35
35obj-$(CONFIG_SA1100_LART) += lart.o 36obj-$(CONFIG_SA1100_LART) += lart.o
36led-$(CONFIG_SA1100_LART) += leds-lart.o 37led-$(CONFIG_SA1100_LART) += leds-lart.o
@@ -51,3 +52,4 @@ obj-$(CONFIG_LEDS) += $(led-y)
51# Miscelaneous functions 52# Miscelaneous functions
52obj-$(CONFIG_PM) += pm.o sleep.o 53obj-$(CONFIG_PM) += pm.o sleep.o
53obj-$(CONFIG_SA1100_SSP) += ssp.o 54obj-$(CONFIG_SA1100_SSP) += ssp.o
55
diff --git a/arch/arm/mach-sa1100/jornada720_ssp.c b/arch/arm/mach-sa1100/jornada720_ssp.c
new file mode 100644
index 000000000000..0a45e1ac8ad6
--- /dev/null
+++ b/arch/arm/mach-sa1100/jornada720_ssp.c
@@ -0,0 +1,201 @@
1/**
2 * arch/arm/mac-sa1100/jornada720_ssp.c
3 *
4 * Copyright (C) 2006/2007 Kristoffer Ericson <Kristoffer.Ericson@gmail.com>
5 * Copyright (C) 2006 Filip Zyzniewski <filip.zyzniewski@tefnet.pl>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * SSP driver for the HP Jornada 710/720/728
12 */
13
14#include <linux/delay.h>
15#include <linux/errno.h>
16#include <linux/init.h>
17#include <linux/kernel.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/sched.h>
21#include <linux/slab.h>
22
23#include <asm/hardware.h>
24#include <asm/hardware/ssp.h>
25#include <asm/arch/jornada720.h>
26
27static DEFINE_SPINLOCK(jornada_ssp_lock);
28static unsigned long jornada_ssp_flags;
29
30/**
31 * jornada_ssp_reverse - reverses input byte
32 *
33 * we need to reverse all data we recieve from the mcu due to its physical location
34 * returns : 01110111 -> 11101110
35 */
36u8 inline jornada_ssp_reverse(u8 byte)
37{
38 return
39 ((0x80 & byte) >> 7) |
40 ((0x40 & byte) >> 5) |
41 ((0x20 & byte) >> 3) |
42 ((0x10 & byte) >> 1) |
43 ((0x08 & byte) << 1) |
44 ((0x04 & byte) << 3) |
45 ((0x02 & byte) << 5) |
46 ((0x01 & byte) << 7);
47};
48EXPORT_SYMBOL(jornada_ssp_reverse);
49
50/**
51 * jornada_ssp_byte - waits for ready ssp bus and sends byte
52 *
53 * waits for fifo buffer to clear and then transmits, if it doesn't then we will
54 * timeout after <timeout> rounds. Needs mcu running before its called.
55 *
56 * returns : %mcu output on success
57 * : %-ETIMEOUT on timeout
58 */
59int jornada_ssp_byte(u8 byte)
60{
61 int timeout = 400000;
62 u16 ret;
63
64 while ((GPLR & GPIO_GPIO10)) {
65 if (!--timeout) {
66 printk(KERN_WARNING "SSP: timeout while waiting for transmit\n");
67 return -ETIMEDOUT;
68 }
69 cpu_relax();
70 }
71
72 ret = jornada_ssp_reverse(byte) << 8;
73
74 ssp_write_word(ret);
75 ssp_read_word(&ret);
76
77 return jornada_ssp_reverse(ret);
78};
79EXPORT_SYMBOL(jornada_ssp_byte);
80
81/**
82 * jornada_ssp_inout - decide if input is command or trading byte
83 *
84 * returns : (jornada_ssp_byte(byte)) on success
85 * : %-ETIMEOUT on timeout failure
86 */
87int jornada_ssp_inout(u8 byte)
88{
89 int ret, i;
90
91 /* true means command byte */
92 if (byte != TXDUMMY) {
93 ret = jornada_ssp_byte(byte);
94 /* Proper return to commands is TxDummy */
95 if (ret != TXDUMMY) {
96 for (i = 0; i < 256; i++)/* flushing bus */
97 if (jornada_ssp_byte(TXDUMMY) == -1)
98 break;
99 return -ETIMEDOUT;
100 }
101 } else /* Exchange TxDummy for data */
102 ret = jornada_ssp_byte(TXDUMMY);
103
104 return ret;
105};
106EXPORT_SYMBOL(jornada_ssp_inout);
107
108/**
109 * jornada_ssp_start - enable mcu
110 *
111 */
112int jornada_ssp_start()
113{
114 spin_lock_irqsave(&jornada_ssp_lock, jornada_ssp_flags);
115 GPCR = GPIO_GPIO25;
116 udelay(50);
117 return 0;
118};
119EXPORT_SYMBOL(jornada_ssp_start);
120
121/**
122 * jornada_ssp_end - disable mcu and turn off lock
123 *
124 */
125int jornada_ssp_end()
126{
127 GPSR = GPIO_GPIO25;
128 spin_unlock_irqrestore(&jornada_ssp_lock, jornada_ssp_flags);
129 return 0;
130};
131EXPORT_SYMBOL(jornada_ssp_end);
132
133static int __init jornada_ssp_probe(struct platform_device *dev)
134{
135 int ret;
136
137 GPSR = GPIO_GPIO25;
138
139 ret = ssp_init();
140
141 /* worked fine, lets not bother with anything else */
142 if (!ret) {
143 printk(KERN_INFO "SSP: device initialized with irq\n");
144 return ret;
145 }
146
147 printk(KERN_WARNING "SSP: initialization failed, trying non-irq solution \n");
148
149 /* init of Serial 4 port */
150 Ser4MCCR0 = 0;
151 Ser4SSCR0 = 0x0387;
152 Ser4SSCR1 = 0x18;
153
154 /* clear out any left over data */
155 ssp_flush();
156
157 /* enable MCU */
158 jornada_ssp_start();
159
160 /* see if return value makes sense */
161 ret = jornada_ssp_inout(GETBRIGHTNESS);
162
163 /* seems like it worked, just feed it with TxDummy to get rid of data */
164 if (ret == TxDummy)
165 jornada_ssp_inout(TXDUMMY);
166
167 jornada_ssp_end();
168
169 /* failed, lets just kill everything */
170 if (ret == -ETIMEDOUT) {
171 printk(KERN_WARNING "SSP: attempts failed, bailing\n");
172 ssp_exit();
173 return -ENODEV;
174 }
175
176 /* all fine */
177 printk(KERN_INFO "SSP: device initialized\n");
178 return 0;
179};
180
181static int jornada_ssp_remove(struct platform_device *dev)
182{
183 /* Note that this doesnt actually remove the driver, since theres nothing to remove
184 * It just makes sure everything is turned off */
185 GPSR = GPIO_GPIO25;
186 ssp_exit();
187 return 0;
188};
189
190struct platform_driver jornadassp_driver = {
191 .probe = jornada_ssp_probe,
192 .remove = jornada_ssp_remove,
193 .driver = {
194 .name = "jornada_ssp",
195 },
196};
197
198static int __init jornada_ssp_init(void)
199{
200 return platform_driver_register(&jornadassp_driver);
201}
diff --git a/arch/arm/mach-sa1100/neponset.c b/arch/arm/mach-sa1100/neponset.c
index 3a0a1ee2542d..9f1ed1509301 100644
--- a/arch/arm/mach-sa1100/neponset.c
+++ b/arch/arm/mach-sa1100/neponset.c
@@ -292,6 +292,8 @@ static struct platform_device *devices[] __initdata = {
292 &smc91x_device, 292 &smc91x_device,
293}; 293};
294 294
295extern void sa1110_mb_disable(void);
296
295static int __init neponset_init(void) 297static int __init neponset_init(void)
296{ 298{
297 platform_driver_register(&neponset_device_driver); 299 platform_driver_register(&neponset_device_driver);
diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
index e7904bc92c73..12161ae445da 100644
--- a/arch/arm/mm/Kconfig
+++ b/arch/arm/mm/Kconfig
@@ -345,13 +345,14 @@ config CPU_XSC3
345# ARMv6 345# ARMv6
346config CPU_V6 346config CPU_V6
347 bool "Support ARM V6 processor" 347 bool "Support ARM V6 processor"
348 depends on ARCH_INTEGRATOR || MACH_REALVIEW_EB || ARCH_OMAP2 348 depends on ARCH_INTEGRATOR || MACH_REALVIEW_EB || ARCH_OMAP2 || ARCH_MX3
349 default y if ARCH_MX3
349 select CPU_32v6 350 select CPU_32v6
350 select CPU_ABRT_EV6 351 select CPU_ABRT_EV6
351 select CPU_CACHE_V6 352 select CPU_CACHE_V6
352 select CPU_CACHE_VIPT 353 select CPU_CACHE_VIPT
353 select CPU_CP15_MMU 354 select CPU_CP15_MMU
354 select CPU_HAS_ASID 355 select CPU_HAS_ASID if MMU
355 select CPU_COPY_V6 if MMU 356 select CPU_COPY_V6 if MMU
356 select CPU_TLB_V6 if MMU 357 select CPU_TLB_V6 if MMU
357 358
@@ -359,7 +360,7 @@ config CPU_V6
359config CPU_32v6K 360config CPU_32v6K
360 bool "Support ARM V6K processor extensions" if !SMP 361 bool "Support ARM V6K processor extensions" if !SMP
361 depends on CPU_V6 362 depends on CPU_V6
362 default y if SMP 363 default y if SMP && !ARCH_MX3
363 help 364 help
364 Say Y here if your ARMv6 processor supports the 'K' extension. 365 Say Y here if your ARMv6 processor supports the 'K' extension.
365 This enables the kernel to use some instructions not present 366 This enables the kernel to use some instructions not present
@@ -377,7 +378,7 @@ config CPU_V7
377 select CPU_CACHE_V7 378 select CPU_CACHE_V7
378 select CPU_CACHE_VIPT 379 select CPU_CACHE_VIPT
379 select CPU_CP15_MMU 380 select CPU_CP15_MMU
380 select CPU_HAS_ASID 381 select CPU_HAS_ASID if MMU
381 select CPU_COPY_V6 if MMU 382 select CPU_COPY_V6 if MMU
382 select CPU_TLB_V7 if MMU 383 select CPU_TLB_V7 if MMU
383 384
@@ -405,6 +406,7 @@ config CPU_32v5
405 406
406config CPU_32v6 407config CPU_32v6
407 bool 408 bool
409 select TLS_REG_EMUL if !CPU_32v6K && !MMU
408 410
409config CPU_32v7 411config CPU_32v7
410 bool 412 bool
@@ -598,7 +600,7 @@ config CPU_DCACHE_SIZE
598 600
599config CPU_DCACHE_WRITETHROUGH 601config CPU_DCACHE_WRITETHROUGH
600 bool "Force write through D-cache" 602 bool "Force write through D-cache"
601 depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020 || CPU_V6) && !CPU_DCACHE_DISABLE 603 depends on (CPU_ARM740T || CPU_ARM920T || CPU_ARM922T || CPU_ARM925T || CPU_ARM926T || CPU_ARM940T || CPU_ARM946E || CPU_ARM1020) && !CPU_DCACHE_DISABLE
602 default y if CPU_ARM925T 604 default y if CPU_ARM925T
603 help 605 help
604 Say Y here to use the data cache in writethrough mode. Unless you 606 Say Y here to use the data cache in writethrough mode. Unless you
@@ -611,12 +613,6 @@ config CPU_CACHE_ROUND_ROBIN
611 Say Y here to use the predictable round-robin cache replacement 613 Say Y here to use the predictable round-robin cache replacement
612 policy. Unless you specifically require this or are unsure, say N. 614 policy. Unless you specifically require this or are unsure, say N.
613 615
614config CPU_L2CACHE_DISABLE
615 bool "Disable level 2 cache"
616 depends on CPU_V7
617 help
618 Say Y here to disable the level 2 cache. If unsure, say N.
619
620config CPU_BPREDICT_DISABLE 616config CPU_BPREDICT_DISABLE
621 bool "Disable branch prediction" 617 bool "Disable branch prediction"
622 depends on CPU_ARM1020 || CPU_V6 || CPU_XSC3 || CPU_V7 618 depends on CPU_ARM1020 || CPU_V6 || CPU_XSC3 || CPU_V7
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
index 08a36f1b35d2..b4e9b734e0bd 100644
--- a/arch/arm/mm/cache-l2x0.c
+++ b/arch/arm/mm/cache-l2x0.c
@@ -17,6 +17,7 @@
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */ 18 */
19#include <linux/init.h> 19#include <linux/init.h>
20#include <linux/spinlock.h>
20 21
21#include <asm/cacheflush.h> 22#include <asm/cacheflush.h>
22#include <asm/io.h> 23#include <asm/io.h>
@@ -25,14 +26,19 @@
25#define CACHE_LINE_SIZE 32 26#define CACHE_LINE_SIZE 32
26 27
27static void __iomem *l2x0_base; 28static void __iomem *l2x0_base;
29static DEFINE_SPINLOCK(l2x0_lock);
28 30
29static inline void sync_writel(unsigned long val, unsigned long reg, 31static inline void sync_writel(unsigned long val, unsigned long reg,
30 unsigned long complete_mask) 32 unsigned long complete_mask)
31{ 33{
34 unsigned long flags;
35
36 spin_lock_irqsave(&l2x0_lock, flags);
32 writel(val, l2x0_base + reg); 37 writel(val, l2x0_base + reg);
33 /* wait for the operation to complete */ 38 /* wait for the operation to complete */
34 while (readl(l2x0_base + reg) & complete_mask) 39 while (readl(l2x0_base + reg) & complete_mask)
35 ; 40 ;
41 spin_unlock_irqrestore(&l2x0_lock, flags);
36} 42}
37 43
38static inline void cache_sync(void) 44static inline void cache_sync(void)
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 3b5e47dc0c97..e5d61ee3d4a1 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -114,6 +114,10 @@ static void __init early_cachepolicy(char **p)
114 } 114 }
115 if (i == ARRAY_SIZE(cache_policies)) 115 if (i == ARRAY_SIZE(cache_policies))
116 printk(KERN_ERR "ERROR: unknown or unsupported cache policy\n"); 116 printk(KERN_ERR "ERROR: unknown or unsupported cache policy\n");
117 if (cpu_architecture() >= CPU_ARCH_ARMv6) {
118 printk(KERN_WARNING "Only cachepolicy=writeback supported on ARMv6 and later\n");
119 cachepolicy = CPOLICY_WRITEBACK;
120 }
117 flush_cache_all(); 121 flush_cache_all();
118 set_cr(cr_alignment); 122 set_cr(cr_alignment);
119} 123}
@@ -252,13 +256,15 @@ static void __init build_mem_type_table(void)
252 int cpu_arch = cpu_architecture(); 256 int cpu_arch = cpu_architecture();
253 int i; 257 int i;
254 258
259 if (cpu_arch < CPU_ARCH_ARMv6) {
255#if defined(CONFIG_CPU_DCACHE_DISABLE) 260#if defined(CONFIG_CPU_DCACHE_DISABLE)
256 if (cachepolicy > CPOLICY_BUFFERED) 261 if (cachepolicy > CPOLICY_BUFFERED)
257 cachepolicy = CPOLICY_BUFFERED; 262 cachepolicy = CPOLICY_BUFFERED;
258#elif defined(CONFIG_CPU_DCACHE_WRITETHROUGH) 263#elif defined(CONFIG_CPU_DCACHE_WRITETHROUGH)
259 if (cachepolicy > CPOLICY_WRITETHROUGH) 264 if (cachepolicy > CPOLICY_WRITETHROUGH)
260 cachepolicy = CPOLICY_WRITETHROUGH; 265 cachepolicy = CPOLICY_WRITETHROUGH;
261#endif 266#endif
267 }
262 if (cpu_arch < CPU_ARCH_ARMv5) { 268 if (cpu_arch < CPU_ARCH_ARMv5) {
263 if (cachepolicy >= CPOLICY_WRITEALLOC) 269 if (cachepolicy >= CPOLICY_WRITEALLOC)
264 cachepolicy = CPOLICY_WRITEBACK; 270 cachepolicy = CPOLICY_WRITEBACK;
diff --git a/arch/arm/mm/proc-syms.c b/arch/arm/mm/proc-syms.c
index 9f396b4fa0b7..2b5ba396e3a6 100644
--- a/arch/arm/mm/proc-syms.c
+++ b/arch/arm/mm/proc-syms.c
@@ -31,12 +31,14 @@ EXPORT_SYMBOL(__cpuc_coherent_kern_range);
31EXPORT_SYMBOL(cpu_cache); 31EXPORT_SYMBOL(cpu_cache);
32#endif 32#endif
33 33
34#ifdef CONFIG_MMU
34#ifndef MULTI_USER 35#ifndef MULTI_USER
35EXPORT_SYMBOL(__cpu_clear_user_page); 36EXPORT_SYMBOL(__cpu_clear_user_page);
36EXPORT_SYMBOL(__cpu_copy_user_page); 37EXPORT_SYMBOL(__cpu_copy_user_page);
37#else 38#else
38EXPORT_SYMBOL(cpu_user); 39EXPORT_SYMBOL(cpu_user);
39#endif 40#endif
41#endif
40 42
41/* 43/*
42 * No module should need to touch the TLB (and currently 44 * No module should need to touch the TLB (and currently
diff --git a/arch/arm/mm/proc-v7.S b/arch/arm/mm/proc-v7.S
index 718f4782ee8b..e0acc5ae6f6f 100644
--- a/arch/arm/mm/proc-v7.S
+++ b/arch/arm/mm/proc-v7.S
@@ -77,6 +77,7 @@ ENTRY(cpu_v7_dcache_clean_area)
77 * - we are not using split page tables 77 * - we are not using split page tables
78 */ 78 */
79ENTRY(cpu_v7_switch_mm) 79ENTRY(cpu_v7_switch_mm)
80#ifdef CONFIG_MMU
80 mov r2, #0 81 mov r2, #0
81 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id 82 ldr r1, [r1, #MM_CONTEXT_ID] @ get mm->context.id
82 orr r0, r0, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB 83 orr r0, r0, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
@@ -86,6 +87,7 @@ ENTRY(cpu_v7_switch_mm)
86 isb 87 isb
87 mcr p15, 0, r1, c13, c0, 1 @ set context ID 88 mcr p15, 0, r1, c13, c0, 1 @ set context ID
88 isb 89 isb
90#endif
89 mov pc, lr 91 mov pc, lr
90 92
91/* 93/*
@@ -109,6 +111,7 @@ ENTRY(cpu_v7_switch_mm)
109 * 1111 0 1 1 r/w r/w 111 * 1111 0 1 1 r/w r/w
110 */ 112 */
111ENTRY(cpu_v7_set_pte_ext) 113ENTRY(cpu_v7_set_pte_ext)
114#ifdef CONFIG_MMU
112 str r1, [r0], #-2048 @ linux version 115 str r1, [r0], #-2048 @ linux version
113 116
114 bic r3, r1, #0x000003f0 117 bic r3, r1, #0x000003f0
@@ -136,6 +139,7 @@ ENTRY(cpu_v7_set_pte_ext)
136 139
137 str r3, [r0] 140 str r3, [r0]
138 mcr p15, 0, r0, c7, c10, 1 @ flush_pte 141 mcr p15, 0, r0, c7, c10, 1 @ flush_pte
142#endif
139 mov pc, lr 143 mov pc, lr
140 144
141cpu_v7_name: 145cpu_v7_name:
@@ -169,6 +173,7 @@ __v7_setup:
169 mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate 173 mcr p15, 0, r10, c7, c5, 0 @ I+BTB cache invalidate
170#endif 174#endif
171 dsb 175 dsb
176#ifdef CONFIG_MMU
172 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs 177 mcr p15, 0, r10, c8, c7, 0 @ invalidate I + D TLBs
173 mcr p15, 0, r10, c2, c0, 2 @ TTB control register 178 mcr p15, 0, r10, c2, c0, 2 @ TTB control register
174 orr r4, r4, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB 179 orr r4, r4, #TTB_RGN_OC_WB @ mark PTWs outer cacheable, WB
@@ -176,21 +181,12 @@ __v7_setup:
176 mcr p15, 0, r4, c2, c0, 1 @ load TTB1 181 mcr p15, 0, r4, c2, c0, 1 @ load TTB1
177 mov r10, #0x1f @ domains 0, 1 = manager 182 mov r10, #0x1f @ domains 0, 1 = manager
178 mcr p15, 0, r10, c3, c0, 0 @ load domain access register 183 mcr p15, 0, r10, c3, c0, 0 @ load domain access register
179#ifndef CONFIG_CPU_L2CACHE_DISABLE
180 @ L2 cache configuration in the L2 aux control register
181 mrc p15, 1, r10, c9, c0, 2
182 bic r10, r10, #(1 << 16) @ L2 outer cache
183 mcr p15, 1, r10, c9, c0, 2
184 @ L2 cache is enabled in the aux control register
185 mrc p15, 0, r10, c1, c0, 1
186 orr r10, r10, #2
187 mcr p15, 0, r10, c1, c0, 1
188#endif 184#endif
189 mrc p15, 0, r0, c1, c0, 0 @ read control register 185 adr r5, v7_crval
190 ldr r10, cr1_clear @ get mask for bits to clear 186 ldmia r5, {r5, r6}
191 bic r0, r0, r10 @ clear bits them 187 mrc p15, 0, r0, c1, c0, 0 @ read control register
192 ldr r10, cr1_set @ get mask for bits to set 188 bic r0, r0, r5 @ clear bits them
193 orr r0, r0, r10 @ set them 189 orr r0, r0, r6 @ set them
194 mov pc, lr @ return to head.S:__ret 190 mov pc, lr @ return to head.S:__ret
195 191
196 /* 192 /*
@@ -199,12 +195,9 @@ __v7_setup:
199 * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced 195 * rrrr rrrx xxx0 0101 xxxx xxxx x111 xxxx < forced
200 * 0 110 0011 1.00 .111 1101 < we want 196 * 0 110 0011 1.00 .111 1101 < we want
201 */ 197 */
202 .type cr1_clear, #object 198 .type v7_crval, #object
203 .type cr1_set, #object 199v7_crval:
204cr1_clear: 200 crval clear=0x0120c302, mmuset=0x00c0387d, ucset=0x00c0187c
205 .word 0x0120c302
206cr1_set:
207 .word 0x00c0387d
208 201
209__v7_setup_stack: 202__v7_setup_stack:
210 .space 4 * 11 @ 11 registers 203 .space 4 * 11 @ 11 registers
diff --git a/arch/arm/plat-iop/time.c b/arch/arm/plat-iop/time.c
index 100d57ad98ed..ba3d21d8fba3 100644
--- a/arch/arm/plat-iop/time.c
+++ b/arch/arm/plat-iop/time.c
@@ -78,6 +78,13 @@ static struct irqaction iop_timer_irq = {
78 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL, 78 .flags = IRQF_DISABLED | IRQF_TIMER | IRQF_IRQPOLL,
79}; 79};
80 80
81static unsigned long iop_tick_rate;
82unsigned long get_iop_tick_rate(void)
83{
84 return iop_tick_rate;
85}
86EXPORT_SYMBOL(get_iop_tick_rate);
87
81void __init iop_init_time(unsigned long tick_rate) 88void __init iop_init_time(unsigned long tick_rate)
82{ 89{
83 u32 timer_ctl; 90 u32 timer_ctl;
@@ -85,6 +92,7 @@ void __init iop_init_time(unsigned long tick_rate)
85 ticks_per_jiffy = (tick_rate + HZ/2) / HZ; 92 ticks_per_jiffy = (tick_rate + HZ/2) / HZ;
86 ticks_per_usec = tick_rate / 1000000; 93 ticks_per_usec = tick_rate / 1000000;
87 next_jiffy_time = 0xffffffff; 94 next_jiffy_time = 0xffffffff;
95 iop_tick_rate = tick_rate;
88 96
89 timer_ctl = IOP_TMR_EN | IOP_TMR_PRIVILEGED | 97 timer_ctl = IOP_TMR_EN | IOP_TMR_PRIVILEGED |
90 IOP_TMR_RELOAD | IOP_TMR_RATIO_1_1; 98 IOP_TMR_RELOAD | IOP_TMR_RATIO_1_1;
diff --git a/arch/arm/plat-mxc/Kconfig b/arch/arm/plat-mxc/Kconfig
new file mode 100644
index 000000000000..03a65c0dfb60
--- /dev/null
+++ b/arch/arm/plat-mxc/Kconfig
@@ -0,0 +1,20 @@
1if ARCH_MXC
2
3menu "Freescale MXC Implementations"
4
5choice
6 prompt "MXC/iMX System Type"
7 default 0
8
9config ARCH_MX3
10 bool "MX3-based"
11 help
12 This enables support for systems based on the Freescale i.MX3 family
13
14endchoice
15
16source "arch/arm/mach-mx3/Kconfig"
17
18endmenu
19
20endif
diff --git a/arch/arm/plat-mxc/Makefile b/arch/arm/plat-mxc/Makefile
new file mode 100644
index 000000000000..66ad9c2b6d64
--- /dev/null
+++ b/arch/arm/plat-mxc/Makefile
@@ -0,0 +1,10 @@
1#
2# Makefile for the linux kernel.
3#
4
5# Common support
6obj-y := irq.o
7
8obj-m :=
9obj-n :=
10obj- :=
diff --git a/arch/arm/plat-mxc/irq.c b/arch/arm/plat-mxc/irq.c
new file mode 100644
index 000000000000..87d253bc3d3c
--- /dev/null
+++ b/arch/arm/plat-mxc/irq.c
@@ -0,0 +1,83 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#include <linux/module.h>
12#include <linux/moduleparam.h>
13#include <linux/init.h>
14#include <linux/device.h>
15#include <linux/errno.h>
16#include <asm/hardware.h>
17#include <asm/io.h>
18#include <asm/irq.h>
19#include <asm/mach/irq.h>
20#include <asm/arch/common.h>
21
22/*!
23 * Disable interrupt number "irq" in the AVIC
24 *
25 * @param irq interrupt source number
26 */
27static void mxc_mask_irq(unsigned int irq)
28{
29 __raw_writel(irq, AVIC_INTDISNUM);
30}
31
32/*!
33 * Enable interrupt number "irq" in the AVIC
34 *
35 * @param irq interrupt source number
36 */
37static void mxc_unmask_irq(unsigned int irq)
38{
39 __raw_writel(irq, AVIC_INTENNUM);
40}
41
42static struct irq_chip mxc_avic_chip = {
43 .mask_ack = mxc_mask_irq,
44 .mask = mxc_mask_irq,
45 .unmask = mxc_unmask_irq,
46};
47
48/*!
49 * This function initializes the AVIC hardware and disables all the
50 * interrupts. It registers the interrupt enable and disable functions
51 * to the kernel for each interrupt source.
52 */
53void __init mxc_init_irq(void)
54{
55 int i;
56 u32 reg;
57
58 /* put the AVIC into the reset value with
59 * all interrupts disabled
60 */
61 __raw_writel(0, AVIC_INTCNTL);
62 __raw_writel(0x1f, AVIC_NIMASK);
63
64 /* disable all interrupts */
65 __raw_writel(0, AVIC_INTENABLEH);
66 __raw_writel(0, AVIC_INTENABLEL);
67
68 /* all IRQ no FIQ */
69 __raw_writel(0, AVIC_INTTYPEH);
70 __raw_writel(0, AVIC_INTTYPEL);
71 for (i = 0; i < MXC_MAX_INT_LINES; i++) {
72 set_irq_chip(i, &mxc_avic_chip);
73 set_irq_handler(i, handle_level_irq);
74 set_irq_flags(i, IRQF_VALID);
75 }
76
77 /* Set WDOG2's interrupt the highest priority level (bit 28-31) */
78 reg = __raw_readl(AVIC_NIPRIORITY6);
79 reg |= (0xF << 28);
80 __raw_writel(reg, AVIC_NIPRIORITY6);
81
82 printk(KERN_INFO "MXC IRQ initialized\n");
83}
diff --git a/arch/arm/plat-omap/timer32k.c b/arch/arm/plat-omap/timer32k.c
index 2feceec8eccd..b0af014b0e2c 100644
--- a/arch/arm/plat-omap/timer32k.c
+++ b/arch/arm/plat-omap/timer32k.c
@@ -156,6 +156,8 @@ static void omap_32k_timer_set_mode(enum clock_event_mode mode,
156 case CLOCK_EVT_MODE_SHUTDOWN: 156 case CLOCK_EVT_MODE_SHUTDOWN:
157 omap_32k_timer_stop(); 157 omap_32k_timer_stop();
158 break; 158 break;
159 case CLOCK_EVT_MODE_RESUME:
160 break;
159 } 161 }
160} 162}
161 163
diff --git a/arch/arm/plat-s3c/Kconfig b/arch/arm/plat-s3c/Kconfig
new file mode 100644
index 000000000000..31656c33e05e
--- /dev/null
+++ b/arch/arm/plat-s3c/Kconfig
@@ -0,0 +1,104 @@
1# arch/arm/plat-s3c/Kconfig
2#
3# Copyright 2007 Simtec Electronics
4#
5# Licensed under GPLv2
6
7config PLAT_S3C
8 bool
9 depends on ARCH_S3C2410
10 default y if ARCH_S3C2410
11 select NO_IOPORT
12 help
13 Base platform code for any Samsung S3C device
14
15# low-level serial option nodes
16
17config CPU_LLSERIAL_S3C2410_ONLY
18 bool
19 depends on ARCH_S3C2410
20 default y if CPU_LLSERIAL_S3C2410 && !CPU_LLSERIAL_S3C2440
21
22config CPU_LLSERIAL_S3C2440_ONLY
23 bool
24 depends on ARCH_S3C2410
25 default y if CPU_LLSERIAL_S3C2440 && !CPU_LLSERIAL_S3C2410
26
27config CPU_LLSERIAL_S3C2410
28 bool
29 depends on ARCH_S3C2410
30 help
31 Selected if there is an S3C2410 (or register compatible) serial
32 low-level implementation needed
33
34config CPU_LLSERIAL_S3C2440
35 bool
36 depends on ARCH_S3C2410
37 help
38 Selected if there is an S3C2440 (or register compatible) serial
39 low-level implementation needed
40
41# boot configurations
42
43comment "Boot options"
44
45config S3C_BOOT_WATCHDOG
46 bool "S3C Initialisation watchdog"
47 depends on PLAT_S3C && S3C2410_WATCHDOG
48 help
49 Say y to enable the watchdog during the kernel decompression
50 stage. If the kernel fails to uncompress, then the watchdog
51 will trigger a reset and the system should restart.
52
53config S3C_BOOT_ERROR_RESET
54 bool "S3C Reboot on decompression error"
55 depends on PLAT_S3C
56 help
57 Say y here to use the watchdog to reset the system if the
58 kernel decompressor detects an error during decompression.
59
60comment "Power management"
61
62config S3C2410_PM_DEBUG
63 bool "S3C2410 PM Suspend debug"
64 depends on PLAT_S3C && PM
65 help
66 Say Y here if you want verbose debugging from the PM Suspend and
67 Resume code. See <file:Documentation/arm/Samsung-S3C24XX/Suspend.txt>
68 for more information.
69
70config S3C2410_PM_CHECK
71 bool "S3C2410 PM Suspend Memory CRC"
72 depends on PLAT_S3C && PM && CRC32
73 help
74 Enable the PM code's memory area checksum over sleep. This option
75 will generate CRCs of all blocks of memory, and store them before
76 going to sleep. The blocks are then checked on resume for any
77 errors.
78
79 Note, this can take several seconds depending on memory size
80 and CPU speed.
81
82 See <file:Documentation/arm/Samsung-S3C24XX/Suspend.txt>
83
84config S3C2410_PM_CHECK_CHUNKSIZE
85 int "S3C2410 PM Suspend CRC Chunksize (KiB)"
86 depends on PLAT_S3C && PM && S3C2410_PM_CHECK
87 default 64
88 help
89 Set the chunksize in Kilobytes of the CRC for checking memory
90 corruption over suspend and resume. A smaller value will mean that
91 the CRC data block will take more memory, but wil identify any
92 faults with better precision.
93
94 See <file:Documentation/arm/Samsung-S3C24XX/Suspend.txt>
95
96config S3C_LOWLEVEL_UART_PORT
97 int "S3C UART to use for low-level messages"
98 depends on PLAT_S3C
99 default 0
100 help
101 Choice of which UART port to use for the low-level messages,
102 such as the `Uncompressing...` at start time. The value of
103 this configuration should be between zero and two. The port
104 must have been initialised by the boot-loader before use.
diff --git a/arch/arm/plat-s3c24xx/Kconfig b/arch/arm/plat-s3c24xx/Kconfig
index b972f36d547c..b66fb3c4e228 100644
--- a/arch/arm/plat-s3c24xx/Kconfig
+++ b/arch/arm/plat-s3c24xx/Kconfig
@@ -10,7 +10,7 @@ config PLAT_S3C24XX
10 default y if ARCH_S3C2410 10 default y if ARCH_S3C2410
11 select NO_IOPORT 11 select NO_IOPORT
12 help 12 help
13 Base platform code for any Samsung S3C device 13 Base platform code for any Samsung S3C24XX device
14 14
15if PLAT_S3C24XX 15if PLAT_S3C24XX
16 16
@@ -26,64 +26,6 @@ config PM_SIMTEC
26 Common power management code for systems that are 26 Common power management code for systems that are
27 compatible with the Simtec style of power management 27 compatible with the Simtec style of power management
28 28
29config S3C2410_BOOT_WATCHDOG
30 bool "S3C2410 Initialisation watchdog"
31 depends on ARCH_S3C2410 && S3C2410_WATCHDOG
32 help
33 Say y to enable the watchdog during the kernel decompression
34 stage. If the kernel fails to uncompress, then the watchdog
35 will trigger a reset and the system should restart.
36
37config S3C2410_BOOT_ERROR_RESET
38 bool "S3C2410 Reboot on decompression error"
39 depends on ARCH_S3C2410
40 help
41 Say y here to use the watchdog to reset the system if the
42 kernel decompressor detects an error during decompression.
43
44config S3C2410_PM_DEBUG
45 bool "S3C2410 PM Suspend debug"
46 depends on ARCH_S3C2410 && PM
47 help
48 Say Y here if you want verbose debugging from the PM Suspend and
49 Resume code. See <file:Documentation/arm/Samsung-S3C24XX/Suspend.txt>
50 for more information.
51
52config S3C2410_PM_CHECK
53 bool "S3C2410 PM Suspend Memory CRC"
54 depends on ARCH_S3C2410 && PM && CRC32
55 help
56 Enable the PM code's memory area checksum over sleep. This option
57 will generate CRCs of all blocks of memory, and store them before
58 going to sleep. The blocks are then checked on resume for any
59 errors.
60
61 Note, this can take several seconds depending on memory size
62 and CPU speed.
63
64 See <file:Documentation/arm/Samsung-S3C24XX/Suspend.txt>
65
66config S3C2410_PM_CHECK_CHUNKSIZE
67 int "S3C2410 PM Suspend CRC Chunksize (KiB)"
68 depends on ARCH_S3C2410 && PM && S3C2410_PM_CHECK
69 default 64
70 help
71 Set the chunksize in Kilobytes of the CRC for checking memory
72 corruption over suspend and resume. A smaller value will mean that
73 the CRC data block will take more memory, but wil identify any
74 faults with better precision.
75
76 See <file:Documentation/arm/Samsung-S3C24XX/Suspend.txt>
77
78config S3C2410_LOWLEVEL_UART_PORT
79 int "S3C2410 UART to use for low-level messages"
80 default 0
81 help
82 Choice of which UART port to use for the low-level messages,
83 such as the `Uncompressing...` at start time. The value of
84 this configuration should be between zero and two. The port
85 must have been initialised by the boot-loader before use.
86
87config S3C2410_DMA 29config S3C2410_DMA
88 bool "S3C2410 DMA support" 30 bool "S3C2410 DMA support"
89 depends on ARCH_S3C2410 31 depends on ARCH_S3C2410
diff --git a/arch/arm/plat-s3c24xx/common-smdk.c b/arch/arm/plat-s3c24xx/common-smdk.c
index 7ed19b23ce56..398c7ac25296 100644
--- a/arch/arm/plat-s3c24xx/common-smdk.c
+++ b/arch/arm/plat-s3c24xx/common-smdk.c
@@ -38,7 +38,7 @@
38#include <asm/arch/regs-gpio.h> 38#include <asm/arch/regs-gpio.h>
39#include <asm/arch/leds-gpio.h> 39#include <asm/arch/leds-gpio.h>
40 40
41#include <asm/arch/nand.h> 41#include <asm/plat-s3c/nand.h>
42 42
43#include <asm/plat-s3c24xx/common-smdk.h> 43#include <asm/plat-s3c24xx/common-smdk.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <asm/plat-s3c24xx/devs.h>
diff --git a/arch/arm/plat-s3c24xx/cpu.c b/arch/arm/plat-s3c24xx/cpu.c
index 8ce4904d3131..f513ab083b8f 100644
--- a/arch/arm/plat-s3c24xx/cpu.c
+++ b/arch/arm/plat-s3c24xx/cpu.c
@@ -38,7 +38,7 @@
38#include <asm/mach/map.h> 38#include <asm/mach/map.h>
39 39
40#include <asm/arch/regs-gpio.h> 40#include <asm/arch/regs-gpio.h>
41#include <asm/arch/regs-serial.h> 41#include <asm/plat-s3c/regs-serial.h>
42 42
43#include <asm/plat-s3c24xx/cpu.h> 43#include <asm/plat-s3c24xx/cpu.h>
44#include <asm/plat-s3c24xx/devs.h> 44#include <asm/plat-s3c24xx/devs.h>
diff --git a/arch/arm/plat-s3c24xx/devs.c b/arch/arm/plat-s3c24xx/devs.c
index 5875da0ae0eb..e546e933b3f7 100644
--- a/arch/arm/plat-s3c24xx/devs.c
+++ b/arch/arm/plat-s3c24xx/devs.c
@@ -28,12 +28,12 @@
28#include <asm/io.h> 28#include <asm/io.h>
29#include <asm/irq.h> 29#include <asm/irq.h>
30 30
31#include <asm/arch/regs-serial.h> 31#include <asm/plat-s3c/regs-serial.h>
32#include <asm/arch/udc.h> 32#include <asm/plat-s3c24xx/udc.h>
33 33
34#include <asm/plat-s3c24xx/devs.h> 34#include <asm/plat-s3c24xx/devs.h>
35#include <asm/plat-s3c24xx/cpu.h> 35#include <asm/plat-s3c24xx/cpu.h>
36#include <asm/arch/regs-spi.h> 36#include <asm/plat-s3c24xx/regs-spi.h>
37 37
38/* Serial port registrations */ 38/* Serial port registrations */
39 39
diff --git a/arch/arm/plat-s3c24xx/pm.c b/arch/arm/plat-s3c24xx/pm.c
index 5692eccdf4d1..eab1850616d8 100644
--- a/arch/arm/plat-s3c24xx/pm.c
+++ b/arch/arm/plat-s3c24xx/pm.c
@@ -40,7 +40,7 @@
40#include <asm/hardware.h> 40#include <asm/hardware.h>
41#include <asm/io.h> 41#include <asm/io.h>
42 42
43#include <asm/arch/regs-serial.h> 43#include <asm/plat-s3c/regs-serial.h>
44#include <asm/arch/regs-clock.h> 44#include <asm/arch/regs-clock.h>
45#include <asm/arch/regs-gpio.h> 45#include <asm/arch/regs-gpio.h>
46#include <asm/arch/regs-mem.h> 46#include <asm/arch/regs-mem.h>
diff --git a/arch/arm/plat-s3c24xx/s3c244x.c b/arch/arm/plat-s3c24xx/s3c244x.c
index 767f2e9a3a55..3444b13afac5 100644
--- a/arch/arm/plat-s3c24xx/s3c244x.c
+++ b/arch/arm/plat-s3c24xx/s3c244x.c
@@ -30,7 +30,7 @@
30#include <asm/irq.h> 30#include <asm/irq.h>
31 31
32#include <asm/arch/regs-clock.h> 32#include <asm/arch/regs-clock.h>
33#include <asm/arch/regs-serial.h> 33#include <asm/plat-s3c/regs-serial.h>
34#include <asm/arch/regs-gpio.h> 34#include <asm/arch/regs-gpio.h>
35#include <asm/arch/regs-gpioj.h> 35#include <asm/arch/regs-gpioj.h>
36#include <asm/arch/regs-dsc.h> 36#include <asm/arch/regs-dsc.h>
@@ -47,7 +47,6 @@ static struct map_desc s3c244x_iodesc[] __initdata = {
47 IODESC_ENT(CLKPWR), 47 IODESC_ENT(CLKPWR),
48 IODESC_ENT(TIMER), 48 IODESC_ENT(TIMER),
49 IODESC_ENT(WATCHDOG), 49 IODESC_ENT(WATCHDOG),
50 IODESC_ENT(LCD),
51}; 50};
52 51
53/* uart initialisation */ 52/* uart initialisation */
diff --git a/arch/arm/plat-s3c24xx/sleep.S b/arch/arm/plat-s3c24xx/sleep.S
index 7b7ae790b00d..d47113bbc34c 100644
--- a/arch/arm/plat-s3c24xx/sleep.S
+++ b/arch/arm/plat-s3c24xx/sleep.S
@@ -32,7 +32,7 @@
32#include <asm/arch/regs-gpio.h> 32#include <asm/arch/regs-gpio.h>
33#include <asm/arch/regs-clock.h> 33#include <asm/arch/regs-clock.h>
34#include <asm/arch/regs-mem.h> 34#include <asm/arch/regs-mem.h>
35#include <asm/arch/regs-serial.h> 35#include <asm/plat-s3c/regs-serial.h>
36 36
37/* CONFIG_DEBUG_RESUME is dangerous if your bootloader does not 37/* CONFIG_DEBUG_RESUME is dangerous if your bootloader does not
38 * reset the UART configuration, only enable if you really need this! 38 * reset the UART configuration, only enable if you really need this!
diff --git a/arch/arm/plat-s3c24xx/time.c b/arch/arm/plat-s3c24xx/time.c
index b7667375bcec..2ec1daaa0e53 100644
--- a/arch/arm/plat-s3c24xx/time.c
+++ b/arch/arm/plat-s3c24xx/time.c
@@ -33,7 +33,7 @@
33#include <asm/io.h> 33#include <asm/io.h>
34#include <asm/irq.h> 34#include <asm/irq.h>
35#include <asm/arch/map.h> 35#include <asm/arch/map.h>
36#include <asm/arch/regs-timer.h> 36#include <asm/plat-s3c/regs-timer.h>
37#include <asm/arch/regs-irq.h> 37#include <asm/arch/regs-irq.h>
38#include <asm/mach/time.h> 38#include <asm/mach/time.h>
39 39
diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index d4b7b229631d..0ac022f800a1 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -74,14 +74,14 @@ vfp_support_entry:
74 74
75 VFPFMRX r1, FPEXC @ Is the VFP enabled? 75 VFPFMRX r1, FPEXC @ Is the VFP enabled?
76 DBGSTR1 "fpexc %08x", r1 76 DBGSTR1 "fpexc %08x", r1
77 tst r1, #FPEXC_ENABLE 77 tst r1, #FPEXC_EN
78 bne look_for_VFP_exceptions @ VFP is already enabled 78 bne look_for_VFP_exceptions @ VFP is already enabled
79 79
80 DBGSTR1 "enable %x", r10 80 DBGSTR1 "enable %x", r10
81 ldr r3, last_VFP_context_address 81 ldr r3, last_VFP_context_address
82 orr r1, r1, #FPEXC_ENABLE @ user FPEXC has the enable bit set 82 orr r1, r1, #FPEXC_EN @ user FPEXC has the enable bit set
83 ldr r4, [r3, r11, lsl #2] @ last_VFP_context pointer 83 ldr r4, [r3, r11, lsl #2] @ last_VFP_context pointer
84 bic r5, r1, #FPEXC_EXCEPTION @ make sure exceptions are disabled 84 bic r5, r1, #FPEXC_EX @ make sure exceptions are disabled
85 cmp r4, r10 85 cmp r4, r10
86 beq check_for_exception @ we are returning to the same 86 beq check_for_exception @ we are returning to the same
87 @ process, so the registers are 87 @ process, so the registers are
@@ -124,7 +124,7 @@ no_old_VFP_process:
124 VFPFMXR FPSCR, r5 @ restore status 124 VFPFMXR FPSCR, r5 @ restore status
125 125
126check_for_exception: 126check_for_exception:
127 tst r1, #FPEXC_EXCEPTION 127 tst r1, #FPEXC_EX
128 bne process_exception @ might as well handle the pending 128 bne process_exception @ might as well handle the pending
129 @ exception before retrying branch 129 @ exception before retrying branch
130 @ out before setting an FPEXC that 130 @ out before setting an FPEXC that
@@ -136,10 +136,10 @@ check_for_exception:
136 136
137 137
138look_for_VFP_exceptions: 138look_for_VFP_exceptions:
139 tst r1, #FPEXC_EXCEPTION 139 tst r1, #FPEXC_EX
140 bne process_exception 140 bne process_exception
141 VFPFMRX r5, FPSCR 141 VFPFMRX r5, FPSCR
142 tst r5, #FPSCR_IXE @ IXE doesn't set FPEXC_EXCEPTION ! 142 tst r5, #FPSCR_IXE @ IXE doesn't set FPEXC_EX !
143 bne process_exception 143 bne process_exception
144 144
145 @ Fall into hand on to next handler - appropriate coproc instr 145 @ Fall into hand on to next handler - appropriate coproc instr
diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c
index 1106b5f9cf19..04ddab2bd876 100644
--- a/arch/arm/vfp/vfpmodule.c
+++ b/arch/arm/vfp/vfpmodule.c
@@ -53,7 +53,7 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
53 * case the thread migrates to a different CPU. The 53 * case the thread migrates to a different CPU. The
54 * restoring is done lazily. 54 * restoring is done lazily.
55 */ 55 */
56 if ((fpexc & FPEXC_ENABLE) && last_VFP_context[cpu]) { 56 if ((fpexc & FPEXC_EN) && last_VFP_context[cpu]) {
57 vfp_save_state(last_VFP_context[cpu], fpexc); 57 vfp_save_state(last_VFP_context[cpu], fpexc);
58 last_VFP_context[cpu]->hard.cpu = cpu; 58 last_VFP_context[cpu]->hard.cpu = cpu;
59 } 59 }
@@ -70,7 +70,7 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
70 * Always disable VFP so we can lazily save/restore the 70 * Always disable VFP so we can lazily save/restore the
71 * old state. 71 * old state.
72 */ 72 */
73 fmxr(FPEXC, fpexc & ~FPEXC_ENABLE); 73 fmxr(FPEXC, fpexc & ~FPEXC_EN);
74 return NOTIFY_DONE; 74 return NOTIFY_DONE;
75 } 75 }
76 76
@@ -81,13 +81,13 @@ static int vfp_notifier(struct notifier_block *self, unsigned long cmd, void *v)
81 */ 81 */
82 memset(vfp, 0, sizeof(union vfp_state)); 82 memset(vfp, 0, sizeof(union vfp_state));
83 83
84 vfp->hard.fpexc = FPEXC_ENABLE; 84 vfp->hard.fpexc = FPEXC_EN;
85 vfp->hard.fpscr = FPSCR_ROUND_NEAREST; 85 vfp->hard.fpscr = FPSCR_ROUND_NEAREST;
86 86
87 /* 87 /*
88 * Disable VFP to ensure we initialise it first. 88 * Disable VFP to ensure we initialise it first.
89 */ 89 */
90 fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_ENABLE); 90 fmxr(FPEXC, fmrx(FPEXC) & ~FPEXC_EN);
91 } 91 }
92 92
93 /* flush and release case: Per-thread VFP cleanup. */ 93 /* flush and release case: Per-thread VFP cleanup. */
@@ -229,7 +229,7 @@ void VFP9_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
229 /* 229 /*
230 * Enable access to the VFP so we can handle the bounce. 230 * Enable access to the VFP so we can handle the bounce.
231 */ 231 */
232 fmxr(FPEXC, fpexc & ~(FPEXC_EXCEPTION|FPEXC_INV|FPEXC_UFC|FPEXC_IOC)); 232 fmxr(FPEXC, fpexc & ~(FPEXC_EX|FPEXC_INV|FPEXC_UFC|FPEXC_IOC));
233 233
234 orig_fpscr = fpscr = fmrx(FPSCR); 234 orig_fpscr = fpscr = fmrx(FPSCR);
235 235
@@ -248,7 +248,7 @@ void VFP9_bounce(u32 trigger, u32 fpexc, struct pt_regs *regs)
248 /* 248 /*
249 * Modify fpscr to indicate the number of iterations remaining 249 * Modify fpscr to indicate the number of iterations remaining
250 */ 250 */
251 if (fpexc & FPEXC_EXCEPTION) { 251 if (fpexc & FPEXC_EX) {
252 u32 len; 252 u32 len;
253 253
254 len = fpexc + (1 << FPEXC_LENGTH_BIT); 254 len = fpexc + (1 << FPEXC_LENGTH_BIT);
diff --git a/arch/arm26/kernel/armksyms.c b/arch/arm26/kernel/armksyms.c
index f735d7e018e4..fe1e3ceed7cb 100644
--- a/arch/arm26/kernel/armksyms.c
+++ b/arch/arm26/kernel/armksyms.c
@@ -107,8 +107,6 @@ EXPORT_SYMBOL(__bug);
107#endif 107#endif
108EXPORT_SYMBOL(__bad_xchg); 108EXPORT_SYMBOL(__bad_xchg);
109EXPORT_SYMBOL(__readwrite_bug); 109EXPORT_SYMBOL(__readwrite_bug);
110EXPORT_SYMBOL(enable_irq);
111EXPORT_SYMBOL(disable_irq);
112EXPORT_SYMBOL(set_irq_type); 110EXPORT_SYMBOL(set_irq_type);
113EXPORT_SYMBOL(pm_idle); 111EXPORT_SYMBOL(pm_idle);
114EXPORT_SYMBOL(pm_power_off); 112EXPORT_SYMBOL(pm_power_off);
diff --git a/arch/arm26/kernel/irq.c b/arch/arm26/kernel/irq.c
index d53382c83bf9..2ffe695b062e 100644
--- a/arch/arm26/kernel/irq.c
+++ b/arch/arm26/kernel/irq.c
@@ -95,6 +95,11 @@ void disable_irq(unsigned int irq)
95 desc->enabled = 0; 95 desc->enabled = 0;
96 spin_unlock_irqrestore(&irq_controller_lock, flags); 96 spin_unlock_irqrestore(&irq_controller_lock, flags);
97} 97}
98EXPORT_SYMBOL(disable_irq);
99
100void disable_irq_nosync(unsigned int irq) __attribute__((alias("disable_irq")));
101
102EXPORT_SYMBOL(disable_irq_nosync);
98 103
99/** 104/**
100 * enable_irq - enable interrupt handling on an irq 105 * enable_irq - enable interrupt handling on an irq
@@ -131,6 +136,7 @@ void enable_irq(unsigned int irq)
131 } 136 }
132 spin_unlock_irqrestore(&irq_controller_lock, flags); 137 spin_unlock_irqrestore(&irq_controller_lock, flags);
133} 138}
139EXPORT_SYMBOL(enable_irq);
134 140
135int show_interrupts(struct seq_file *p, void *v) 141int show_interrupts(struct seq_file *p, void *v)
136{ 142{
diff --git a/arch/avr32/boards/atngw100/setup.c b/arch/avr32/boards/atngw100/setup.c
index 6c4dc0a00e9f..2edcecdea8bd 100644
--- a/arch/avr32/boards/atngw100/setup.c
+++ b/arch/avr32/boards/atngw100/setup.c
@@ -13,6 +13,7 @@
13#include <linux/linkage.h> 13#include <linux/linkage.h>
14#include <linux/platform_device.h> 14#include <linux/platform_device.h>
15#include <linux/types.h> 15#include <linux/types.h>
16#include <linux/leds.h>
16#include <linux/spi/spi.h> 17#include <linux/spi/spi.h>
17 18
18#include <asm/io.h> 19#include <asm/io.h>
@@ -21,6 +22,7 @@
21#include <asm/arch/at32ap7000.h> 22#include <asm/arch/at32ap7000.h>
22#include <asm/arch/board.h> 23#include <asm/arch/board.h>
23#include <asm/arch/init.h> 24#include <asm/arch/init.h>
25#include <asm/arch/portmux.h>
24 26
25/* Initialized by bootloader-specific startup code. */ 27/* Initialized by bootloader-specific startup code. */
26struct tag *bootloader_tags __initdata; 28struct tag *bootloader_tags __initdata;
@@ -100,8 +102,31 @@ void __init setup_board(void)
100 at32_setup_serial_console(0); 102 at32_setup_serial_console(0);
101} 103}
102 104
105static const struct gpio_led ngw_leds[] = {
106 { .name = "sys", .gpio = GPIO_PIN_PA(16), .active_low = 1,
107 .default_trigger = "heartbeat",
108 },
109 { .name = "a", .gpio = GPIO_PIN_PA(19), .active_low = 1, },
110 { .name = "b", .gpio = GPIO_PIN_PE(19), .active_low = 1, },
111};
112
113static const struct gpio_led_platform_data ngw_led_data = {
114 .num_leds = ARRAY_SIZE(ngw_leds),
115 .leds = (void *) ngw_leds,
116};
117
118static struct platform_device ngw_gpio_leds = {
119 .name = "leds-gpio",
120 .id = -1,
121 .dev = {
122 .platform_data = (void *) &ngw_led_data,
123 }
124};
125
103static int __init atngw100_init(void) 126static int __init atngw100_init(void)
104{ 127{
128 unsigned i;
129
105 /* 130 /*
106 * ATNGW100 uses 16-bit SDRAM interface, so we don't need to 131 * ATNGW100 uses 16-bit SDRAM interface, so we don't need to
107 * reserve any pins for it. 132 * reserve any pins for it.
@@ -116,6 +141,12 @@ static int __init atngw100_init(void)
116 141
117 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info)); 142 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
118 143
144 for (i = 0; i < ARRAY_SIZE(ngw_leds); i++) {
145 at32_select_gpio(ngw_leds[i].gpio,
146 AT32_GPIOF_OUTPUT | AT32_GPIOF_HIGH);
147 }
148 platform_device_register(&ngw_gpio_leds);
149
119 return 0; 150 return 0;
120} 151}
121postcore_initcall(atngw100_init); 152postcore_initcall(atngw100_init);
diff --git a/arch/avr32/configs/atngw100_defconfig b/arch/avr32/configs/atngw100_defconfig
index 49493ad3b5a9..b799a68ffd97 100644
--- a/arch/avr32/configs/atngw100_defconfig
+++ b/arch/avr32/configs/atngw100_defconfig
@@ -712,7 +712,21 @@ CONFIG_SPI_ATMEL=y
712# 712#
713# LED devices 713# LED devices
714# 714#
715# CONFIG_NEW_LEDS is not set 715CONFIG_NEW_LEDS=y
716CONFIG_LEDS_CLASS=y
717
718#
719# LED drivers
720#
721CONFIG_LEDS_GPIO=y
722
723#
724# LED Triggers
725#
726CONFIG_LEDS_TRIGGERS=y
727CONFIG_LEDS_TRIGGER_TIMER=y
728CONFIG_LEDS_TRIGGER_HEARTBEAT=y
729
716 730
717# 731#
718# LED drivers 732# LED drivers
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 7a11b905ef49..abb582bc218f 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -18,6 +18,10 @@ config GENERIC_TIME
18 bool 18 bool
19 default y 19 default y
20 20
21config GENERIC_CMOS_UPDATE
22 bool
23 default y
24
21config CLOCKSOURCE_WATCHDOG 25config CLOCKSOURCE_WATCHDOG
22 bool 26 bool
23 default y 27 default y
@@ -544,6 +548,7 @@ config HIGHMEM4G
544config HIGHMEM64G 548config HIGHMEM64G
545 bool "64GB" 549 bool "64GB"
546 depends on !M386 && !M486 550 depends on !M386 && !M486
551 select X86_PAE
547 help 552 help
548 Select this if you have a 32-bit processor and more than 4 553 Select this if you have a 32-bit processor and more than 4
549 gigabytes of physical RAM. 554 gigabytes of physical RAM.
@@ -573,12 +578,12 @@ choice
573 config VMSPLIT_3G 578 config VMSPLIT_3G
574 bool "3G/1G user/kernel split" 579 bool "3G/1G user/kernel split"
575 config VMSPLIT_3G_OPT 580 config VMSPLIT_3G_OPT
576 depends on !HIGHMEM 581 depends on !X86_PAE
577 bool "3G/1G user/kernel split (for full 1G low memory)" 582 bool "3G/1G user/kernel split (for full 1G low memory)"
578 config VMSPLIT_2G 583 config VMSPLIT_2G
579 bool "2G/2G user/kernel split" 584 bool "2G/2G user/kernel split"
580 config VMSPLIT_2G_OPT 585 config VMSPLIT_2G_OPT
581 depends on !HIGHMEM 586 depends on !X86_PAE
582 bool "2G/2G user/kernel split (for full 2G low memory)" 587 bool "2G/2G user/kernel split (for full 2G low memory)"
583 config VMSPLIT_1G 588 config VMSPLIT_1G
584 bool "1G/3G user/kernel split" 589 bool "1G/3G user/kernel split"
@@ -598,10 +603,15 @@ config HIGHMEM
598 default y 603 default y
599 604
600config X86_PAE 605config X86_PAE
601 bool 606 bool "PAE (Physical Address Extension) Support"
602 depends on HIGHMEM64G 607 default n
603 default y 608 depends on !HIGHMEM4G
604 select RESOURCES_64BIT 609 select RESOURCES_64BIT
610 help
611 PAE is required for NX support, and furthermore enables
612 larger swapspace support for non-overcommit purposes. It
613 has the cost of more pagetable lookup overhead, and also
614 consumes more pagetable space per process.
605 615
606# Common NUMA Features 616# Common NUMA Features
607config NUMA 617config NUMA
@@ -817,6 +827,7 @@ config CRASH_DUMP
817 827
818config PHYSICAL_START 828config PHYSICAL_START
819 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP) 829 hex "Physical address where the kernel is loaded" if (EMBEDDED || CRASH_DUMP)
830 default "0x1000000" if X86_NUMAQ
820 default "0x100000" 831 default "0x100000"
821 help 832 help
822 This gives the physical address where the kernel is loaded. 833 This gives the physical address where the kernel is loaded.
diff --git a/arch/i386/defconfig b/arch/i386/defconfig
index 0ac62cdcd3b7..54ee1764fdae 100644
--- a/arch/i386/defconfig
+++ b/arch/i386/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.22-rc2 3# Linux kernel version: 2.6.22-git14
4# Mon May 21 13:23:44 2007 4# Fri Jul 20 09:53:15 2007
5# 5#
6CONFIG_X86_32=y 6CONFIG_X86_32=y
7CONFIG_GENERIC_TIME=y 7CONFIG_GENERIC_TIME=y
@@ -37,19 +37,18 @@ CONFIG_LOCALVERSION=""
37CONFIG_LOCALVERSION_AUTO=y 37CONFIG_LOCALVERSION_AUTO=y
38CONFIG_SWAP=y 38CONFIG_SWAP=y
39CONFIG_SYSVIPC=y 39CONFIG_SYSVIPC=y
40# CONFIG_IPC_NS is not set
41CONFIG_SYSVIPC_SYSCTL=y 40CONFIG_SYSVIPC_SYSCTL=y
42CONFIG_POSIX_MQUEUE=y 41CONFIG_POSIX_MQUEUE=y
43# CONFIG_BSD_PROCESS_ACCT is not set 42# CONFIG_BSD_PROCESS_ACCT is not set
44# CONFIG_TASKSTATS is not set 43# CONFIG_TASKSTATS is not set
45# CONFIG_UTS_NS is not set 44# CONFIG_USER_NS is not set
46# CONFIG_AUDIT is not set 45# CONFIG_AUDIT is not set
47CONFIG_IKCONFIG=y 46CONFIG_IKCONFIG=y
48CONFIG_IKCONFIG_PROC=y 47CONFIG_IKCONFIG_PROC=y
49CONFIG_LOG_BUF_SHIFT=18 48CONFIG_LOG_BUF_SHIFT=18
50# CONFIG_CPUSETS is not set 49# CONFIG_CPUSETS is not set
51CONFIG_SYSFS_DEPRECATED=y 50CONFIG_SYSFS_DEPRECATED=y
52# CONFIG_RELAY is not set 51CONFIG_RELAY=y
53CONFIG_BLK_DEV_INITRD=y 52CONFIG_BLK_DEV_INITRD=y
54CONFIG_INITRAMFS_SOURCE="" 53CONFIG_INITRAMFS_SOURCE=""
55CONFIG_CC_OPTIMIZE_FOR_SIZE=y 54CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -73,16 +72,13 @@ CONFIG_TIMERFD=y
73CONFIG_EVENTFD=y 72CONFIG_EVENTFD=y
74CONFIG_SHMEM=y 73CONFIG_SHMEM=y
75CONFIG_VM_EVENT_COUNTERS=y 74CONFIG_VM_EVENT_COUNTERS=y
76CONFIG_SLAB=y 75CONFIG_SLUB_DEBUG=y
77# CONFIG_SLUB is not set 76# CONFIG_SLAB is not set
77CONFIG_SLUB=y
78# CONFIG_SLOB is not set 78# CONFIG_SLOB is not set
79CONFIG_RT_MUTEXES=y 79CONFIG_RT_MUTEXES=y
80# CONFIG_TINY_SHMEM is not set 80# CONFIG_TINY_SHMEM is not set
81CONFIG_BASE_SMALL=0 81CONFIG_BASE_SMALL=0
82
83#
84# Loadable module support
85#
86CONFIG_MODULES=y 82CONFIG_MODULES=y
87CONFIG_MODULE_UNLOAD=y 83CONFIG_MODULE_UNLOAD=y
88CONFIG_MODULE_FORCE_UNLOAD=y 84CONFIG_MODULE_FORCE_UNLOAD=y
@@ -90,14 +86,11 @@ CONFIG_MODULE_FORCE_UNLOAD=y
90# CONFIG_MODULE_SRCVERSION_ALL is not set 86# CONFIG_MODULE_SRCVERSION_ALL is not set
91# CONFIG_KMOD is not set 87# CONFIG_KMOD is not set
92CONFIG_STOP_MACHINE=y 88CONFIG_STOP_MACHINE=y
93
94#
95# Block layer
96#
97CONFIG_BLOCK=y 89CONFIG_BLOCK=y
98CONFIG_LBD=y 90CONFIG_LBD=y
99# CONFIG_BLK_DEV_IO_TRACE is not set 91# CONFIG_BLK_DEV_IO_TRACE is not set
100# CONFIG_LSF is not set 92# CONFIG_LSF is not set
93# CONFIG_BLK_DEV_BSG is not set
101 94
102# 95#
103# IO Schedulers 96# IO Schedulers
@@ -201,6 +194,7 @@ CONFIG_X86_CPUID=y
201# CONFIG_EDD is not set 194# CONFIG_EDD is not set
202# CONFIG_DELL_RBU is not set 195# CONFIG_DELL_RBU is not set
203# CONFIG_DCDBAS is not set 196# CONFIG_DCDBAS is not set
197CONFIG_DMIID=y
204# CONFIG_NOHIGHMEM is not set 198# CONFIG_NOHIGHMEM is not set
205CONFIG_HIGHMEM4G=y 199CONFIG_HIGHMEM4G=y
206# CONFIG_HIGHMEM64G is not set 200# CONFIG_HIGHMEM64G is not set
@@ -217,7 +211,9 @@ CONFIG_FLAT_NODE_MEM_MAP=y
217CONFIG_SPLIT_PTLOCK_CPUS=4 211CONFIG_SPLIT_PTLOCK_CPUS=4
218CONFIG_RESOURCES_64BIT=y 212CONFIG_RESOURCES_64BIT=y
219CONFIG_ZONE_DMA_FLAG=1 213CONFIG_ZONE_DMA_FLAG=1
214CONFIG_BOUNCE=y
220CONFIG_NR_QUICK=1 215CONFIG_NR_QUICK=1
216CONFIG_VIRT_TO_BUS=y
221# CONFIG_HIGHPTE is not set 217# CONFIG_HIGHPTE is not set
222# CONFIG_MATH_EMULATION is not set 218# CONFIG_MATH_EMULATION is not set
223CONFIG_MTRR=y 219CONFIG_MTRR=y
@@ -244,7 +240,6 @@ CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
244CONFIG_PM=y 240CONFIG_PM=y
245CONFIG_PM_LEGACY=y 241CONFIG_PM_LEGACY=y
246# CONFIG_PM_DEBUG is not set 242# CONFIG_PM_DEBUG is not set
247# CONFIG_PM_SYSFS_DEPRECATED is not set
248 243
249# 244#
250# ACPI (Advanced Configuration and Power Interface) Support 245# ACPI (Advanced Configuration and Power Interface) Support
@@ -284,7 +279,7 @@ CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
284# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set 279# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
285CONFIG_CPU_FREQ_GOV_USERSPACE=y 280CONFIG_CPU_FREQ_GOV_USERSPACE=y
286CONFIG_CPU_FREQ_GOV_ONDEMAND=y 281CONFIG_CPU_FREQ_GOV_ONDEMAND=y
287# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set 282CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
288 283
289# 284#
290# CPUFreq processor drivers 285# CPUFreq processor drivers
@@ -325,7 +320,7 @@ CONFIG_PCI_MMCONFIG=y
325CONFIG_ARCH_SUPPORTS_MSI=y 320CONFIG_ARCH_SUPPORTS_MSI=y
326CONFIG_PCI_MSI=y 321CONFIG_PCI_MSI=y
327# CONFIG_PCI_DEBUG is not set 322# CONFIG_PCI_DEBUG is not set
328CONFIG_HT_IRQ=y 323# CONFIG_HT_IRQ is not set
329CONFIG_ISA_DMA_API=y 324CONFIG_ISA_DMA_API=y
330# CONFIG_ISA is not set 325# CONFIG_ISA is not set
331# CONFIG_MCA is not set 326# CONFIG_MCA is not set
@@ -381,7 +376,7 @@ CONFIG_IP_PNP_DHCP=y
381CONFIG_INET_TUNNEL=y 376CONFIG_INET_TUNNEL=y
382CONFIG_INET_XFRM_MODE_TRANSPORT=y 377CONFIG_INET_XFRM_MODE_TRANSPORT=y
383CONFIG_INET_XFRM_MODE_TUNNEL=y 378CONFIG_INET_XFRM_MODE_TUNNEL=y
384CONFIG_INET_XFRM_MODE_BEET=y 379# CONFIG_INET_XFRM_MODE_BEET is not set
385CONFIG_INET_DIAG=y 380CONFIG_INET_DIAG=y
386CONFIG_INET_TCP_DIAG=y 381CONFIG_INET_TCP_DIAG=y
387# CONFIG_TCP_CONG_ADVANCED is not set 382# CONFIG_TCP_CONG_ADVANCED is not set
@@ -400,27 +395,15 @@ CONFIG_IPV6=y
400# CONFIG_INET6_TUNNEL is not set 395# CONFIG_INET6_TUNNEL is not set
401CONFIG_INET6_XFRM_MODE_TRANSPORT=y 396CONFIG_INET6_XFRM_MODE_TRANSPORT=y
402CONFIG_INET6_XFRM_MODE_TUNNEL=y 397CONFIG_INET6_XFRM_MODE_TUNNEL=y
403CONFIG_INET6_XFRM_MODE_BEET=y 398# CONFIG_INET6_XFRM_MODE_BEET is not set
404# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set 399# CONFIG_INET6_XFRM_MODE_ROUTEOPTIMIZATION is not set
405CONFIG_IPV6_SIT=y 400CONFIG_IPV6_SIT=y
406# CONFIG_IPV6_TUNNEL is not set 401# CONFIG_IPV6_TUNNEL is not set
407# CONFIG_IPV6_MULTIPLE_TABLES is not set 402# CONFIG_IPV6_MULTIPLE_TABLES is not set
408# CONFIG_NETWORK_SECMARK is not set 403# CONFIG_NETWORK_SECMARK is not set
409# CONFIG_NETFILTER is not set 404# CONFIG_NETFILTER is not set
410
411#
412# DCCP Configuration (EXPERIMENTAL)
413#
414# CONFIG_IP_DCCP is not set 405# CONFIG_IP_DCCP is not set
415
416#
417# SCTP Configuration (EXPERIMENTAL)
418#
419# CONFIG_IP_SCTP is not set 406# CONFIG_IP_SCTP is not set
420
421#
422# TIPC Configuration (EXPERIMENTAL)
423#
424# CONFIG_TIPC is not set 407# CONFIG_TIPC is not set
425# CONFIG_ATM is not set 408# CONFIG_ATM is not set
426# CONFIG_BRIDGE is not set 409# CONFIG_BRIDGE is not set
@@ -457,6 +440,7 @@ CONFIG_IPV6_SIT=y
457# CONFIG_MAC80211 is not set 440# CONFIG_MAC80211 is not set
458# CONFIG_IEEE80211 is not set 441# CONFIG_IEEE80211 is not set
459# CONFIG_RFKILL is not set 442# CONFIG_RFKILL is not set
443# CONFIG_NET_9P is not set
460 444
461# 445#
462# Device Drivers 446# Device Drivers
@@ -471,21 +455,9 @@ CONFIG_FW_LOADER=y
471# CONFIG_DEBUG_DRIVER is not set 455# CONFIG_DEBUG_DRIVER is not set
472# CONFIG_DEBUG_DEVRES is not set 456# CONFIG_DEBUG_DEVRES is not set
473# CONFIG_SYS_HYPERVISOR is not set 457# CONFIG_SYS_HYPERVISOR is not set
474
475#
476# Connector - unified userspace <-> kernelspace linker
477#
478# CONFIG_CONNECTOR is not set 458# CONFIG_CONNECTOR is not set
479# CONFIG_MTD is not set 459# CONFIG_MTD is not set
480
481#
482# Parallel port support
483#
484# CONFIG_PARPORT is not set 460# CONFIG_PARPORT is not set
485
486#
487# Plug and Play support
488#
489CONFIG_PNP=y 461CONFIG_PNP=y
490# CONFIG_PNP_DEBUG is not set 462# CONFIG_PNP_DEBUG is not set
491 463
@@ -493,10 +465,7 @@ CONFIG_PNP=y
493# Protocols 465# Protocols
494# 466#
495CONFIG_PNPACPI=y 467CONFIG_PNPACPI=y
496 468CONFIG_BLK_DEV=y
497#
498# Block devices
499#
500CONFIG_BLK_DEV_FD=y 469CONFIG_BLK_DEV_FD=y
501# CONFIG_BLK_CPQ_DA is not set 470# CONFIG_BLK_CPQ_DA is not set
502# CONFIG_BLK_CPQ_CISS_DA is not set 471# CONFIG_BLK_CPQ_CISS_DA is not set
@@ -514,17 +483,14 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
514CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 483CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
515# CONFIG_CDROM_PKTCDVD is not set 484# CONFIG_CDROM_PKTCDVD is not set
516# CONFIG_ATA_OVER_ETH is not set 485# CONFIG_ATA_OVER_ETH is not set
517 486CONFIG_MISC_DEVICES=y
518#
519# Misc devices
520#
521# CONFIG_IBM_ASM is not set 487# CONFIG_IBM_ASM is not set
522# CONFIG_PHANTOM is not set 488# CONFIG_PHANTOM is not set
489# CONFIG_EEPROM_93CX6 is not set
523# CONFIG_SGI_IOC4 is not set 490# CONFIG_SGI_IOC4 is not set
524# CONFIG_TIFM_CORE is not set 491# CONFIG_TIFM_CORE is not set
525# CONFIG_SONY_LAPTOP is not set 492# CONFIG_SONY_LAPTOP is not set
526# CONFIG_THINKPAD_ACPI is not set 493# CONFIG_THINKPAD_ACPI is not set
527# CONFIG_BLINK is not set
528CONFIG_IDE=y 494CONFIG_IDE=y
529CONFIG_BLK_DEV_IDE=y 495CONFIG_BLK_DEV_IDE=y
530 496
@@ -596,6 +562,7 @@ CONFIG_BLK_DEV_IDEDMA=y
596# 562#
597# CONFIG_RAID_ATTRS is not set 563# CONFIG_RAID_ATTRS is not set
598CONFIG_SCSI=y 564CONFIG_SCSI=y
565CONFIG_SCSI_DMA=y
599# CONFIG_SCSI_TGT is not set 566# CONFIG_SCSI_TGT is not set
600CONFIG_SCSI_NETLINK=y 567CONFIG_SCSI_NETLINK=y
601# CONFIG_SCSI_PROC_FS is not set 568# CONFIG_SCSI_PROC_FS is not set
@@ -606,8 +573,9 @@ CONFIG_SCSI_NETLINK=y
606CONFIG_BLK_DEV_SD=y 573CONFIG_BLK_DEV_SD=y
607# CONFIG_CHR_DEV_ST is not set 574# CONFIG_CHR_DEV_ST is not set
608# CONFIG_CHR_DEV_OSST is not set 575# CONFIG_CHR_DEV_OSST is not set
609# CONFIG_BLK_DEV_SR is not set 576CONFIG_BLK_DEV_SR=y
610# CONFIG_CHR_DEV_SG is not set 577# CONFIG_BLK_DEV_SR_VENDOR is not set
578CONFIG_CHR_DEV_SG=y
611# CONFIG_CHR_DEV_SCH is not set 579# CONFIG_CHR_DEV_SCH is not set
612 580
613# 581#
@@ -667,6 +635,7 @@ CONFIG_AIC79XX_DEBUG_MASK=0
667# CONFIG_SCSI_INIA100 is not set 635# CONFIG_SCSI_INIA100 is not set
668# CONFIG_SCSI_STEX is not set 636# CONFIG_SCSI_STEX is not set
669# CONFIG_SCSI_SYM53C8XX_2 is not set 637# CONFIG_SCSI_SYM53C8XX_2 is not set
638# CONFIG_SCSI_IPR is not set
670# CONFIG_SCSI_QLOGIC_1280 is not set 639# CONFIG_SCSI_QLOGIC_1280 is not set
671# CONFIG_SCSI_QLA_FC is not set 640# CONFIG_SCSI_QLA_FC is not set
672# CONFIG_SCSI_QLA_ISCSI is not set 641# CONFIG_SCSI_QLA_ISCSI is not set
@@ -675,14 +644,73 @@ CONFIG_AIC79XX_DEBUG_MASK=0
675# CONFIG_SCSI_DC390T is not set 644# CONFIG_SCSI_DC390T is not set
676# CONFIG_SCSI_NSP32 is not set 645# CONFIG_SCSI_NSP32 is not set
677# CONFIG_SCSI_DEBUG is not set 646# CONFIG_SCSI_DEBUG is not set
678# CONFIG_SCSI_ESP_CORE is not set
679# CONFIG_SCSI_SRP is not set 647# CONFIG_SCSI_SRP is not set
680# CONFIG_ATA is not set 648CONFIG_ATA=y
681 649# CONFIG_ATA_NONSTANDARD is not set
682# 650CONFIG_ATA_ACPI=y
683# Multi-device support (RAID and LVM) 651CONFIG_SATA_AHCI=y
684# 652CONFIG_SATA_SVW=y
685# CONFIG_MD is not set 653CONFIG_ATA_PIIX=y
654# CONFIG_SATA_MV is not set
655CONFIG_SATA_NV=y
656# CONFIG_PDC_ADMA is not set
657# CONFIG_SATA_QSTOR is not set
658# CONFIG_SATA_PROMISE is not set
659# CONFIG_SATA_SX4 is not set
660CONFIG_SATA_SIL=y
661# CONFIG_SATA_SIL24 is not set
662# CONFIG_SATA_SIS is not set
663# CONFIG_SATA_ULI is not set
664CONFIG_SATA_VIA=y
665# CONFIG_SATA_VITESSE is not set
666# CONFIG_SATA_INIC162X is not set
667# CONFIG_PATA_ALI is not set
668# CONFIG_PATA_AMD is not set
669# CONFIG_PATA_ARTOP is not set
670# CONFIG_PATA_ATIIXP is not set
671# CONFIG_PATA_CMD640_PCI is not set
672# CONFIG_PATA_CMD64X is not set
673# CONFIG_PATA_CS5520 is not set
674# CONFIG_PATA_CS5530 is not set
675# CONFIG_PATA_CS5535 is not set
676# CONFIG_PATA_CYPRESS is not set
677# CONFIG_PATA_EFAR is not set
678# CONFIG_ATA_GENERIC is not set
679# CONFIG_PATA_HPT366 is not set
680# CONFIG_PATA_HPT37X is not set
681# CONFIG_PATA_HPT3X2N is not set
682# CONFIG_PATA_HPT3X3 is not set
683# CONFIG_PATA_IT821X is not set
684# CONFIG_PATA_IT8213 is not set
685# CONFIG_PATA_JMICRON is not set
686# CONFIG_PATA_TRIFLEX is not set
687# CONFIG_PATA_MARVELL is not set
688# CONFIG_PATA_MPIIX is not set
689# CONFIG_PATA_OLDPIIX is not set
690# CONFIG_PATA_NETCELL is not set
691# CONFIG_PATA_NS87410 is not set
692# CONFIG_PATA_OPTI is not set
693# CONFIG_PATA_OPTIDMA is not set
694# CONFIG_PATA_PDC_OLD is not set
695# CONFIG_PATA_RADISYS is not set
696# CONFIG_PATA_RZ1000 is not set
697# CONFIG_PATA_SC1200 is not set
698# CONFIG_PATA_SERVERWORKS is not set
699# CONFIG_PATA_PDC2027X is not set
700# CONFIG_PATA_SIL680 is not set
701# CONFIG_PATA_SIS is not set
702# CONFIG_PATA_VIA is not set
703# CONFIG_PATA_WINBOND is not set
704CONFIG_MD=y
705# CONFIG_BLK_DEV_MD is not set
706CONFIG_BLK_DEV_DM=y
707# CONFIG_DM_DEBUG is not set
708# CONFIG_DM_CRYPT is not set
709# CONFIG_DM_SNAPSHOT is not set
710# CONFIG_DM_MIRROR is not set
711# CONFIG_DM_ZERO is not set
712# CONFIG_DM_MULTIPATH is not set
713# CONFIG_DM_DELAY is not set
686 714
687# 715#
688# Fusion MPT device support 716# Fusion MPT device support
@@ -723,42 +751,27 @@ CONFIG_IEEE1394_OHCI1394=y
723# CONFIG_IEEE1394_ETH1394 is not set 751# CONFIG_IEEE1394_ETH1394 is not set
724# CONFIG_IEEE1394_DV1394 is not set 752# CONFIG_IEEE1394_DV1394 is not set
725CONFIG_IEEE1394_RAWIO=y 753CONFIG_IEEE1394_RAWIO=y
726
727#
728# I2O device support
729#
730# CONFIG_I2O is not set 754# CONFIG_I2O is not set
731# CONFIG_MACINTOSH_DRIVERS is not set 755CONFIG_MACINTOSH_DRIVERS=y
732 756# CONFIG_MAC_EMUMOUSEBTN is not set
733#
734# Network device support
735#
736CONFIG_NETDEVICES=y 757CONFIG_NETDEVICES=y
758CONFIG_NETDEVICES_MULTIQUEUE=y
737# CONFIG_DUMMY is not set 759# CONFIG_DUMMY is not set
738# CONFIG_BONDING is not set 760# CONFIG_BONDING is not set
761# CONFIG_MACVLAN is not set
739# CONFIG_EQUALIZER is not set 762# CONFIG_EQUALIZER is not set
740# CONFIG_TUN is not set 763# CONFIG_TUN is not set
741# CONFIG_NET_SB1000 is not set 764# CONFIG_NET_SB1000 is not set
742
743#
744# ARCnet devices
745#
746# CONFIG_ARCNET is not set 765# CONFIG_ARCNET is not set
747# CONFIG_PHYLIB is not set 766# CONFIG_PHYLIB is not set
748
749#
750# Ethernet (10 or 100Mbit)
751#
752CONFIG_NET_ETHERNET=y 767CONFIG_NET_ETHERNET=y
753CONFIG_MII=y 768CONFIG_MII=y
754# CONFIG_HAPPYMEAL is not set 769# CONFIG_HAPPYMEAL is not set
755# CONFIG_SUNGEM is not set 770# CONFIG_SUNGEM is not set
756# CONFIG_CASSINI is not set 771# CONFIG_CASSINI is not set
757# CONFIG_NET_VENDOR_3COM is not set 772CONFIG_NET_VENDOR_3COM=y
758 773CONFIG_VORTEX=y
759# 774# CONFIG_TYPHOON is not set
760# Tulip family network device support
761#
762CONFIG_NET_TULIP=y 775CONFIG_NET_TULIP=y
763# CONFIG_DE2104X is not set 776# CONFIG_DE2104X is not set
764CONFIG_TULIP=y 777CONFIG_TULIP=y
@@ -809,7 +822,6 @@ CONFIG_R8169=y
809# CONFIG_SIS190 is not set 822# CONFIG_SIS190 is not set
810# CONFIG_SKGE is not set 823# CONFIG_SKGE is not set
811CONFIG_SKY2=y 824CONFIG_SKY2=y
812# CONFIG_SK98LIN is not set
813# CONFIG_VIA_VELOCITY is not set 825# CONFIG_VIA_VELOCITY is not set
814CONFIG_TIGON3=y 826CONFIG_TIGON3=y
815CONFIG_BNX2=y 827CONFIG_BNX2=y
@@ -823,10 +835,6 @@ CONFIG_NETDEV_10000=y
823# CONFIG_MYRI10GE is not set 835# CONFIG_MYRI10GE is not set
824# CONFIG_NETXEN_NIC is not set 836# CONFIG_NETXEN_NIC is not set
825# CONFIG_MLX4_CORE is not set 837# CONFIG_MLX4_CORE is not set
826
827#
828# Token Ring devices
829#
830# CONFIG_TR is not set 838# CONFIG_TR is not set
831 839
832# 840#
@@ -855,15 +863,7 @@ CONFIG_NETCONSOLE=y
855CONFIG_NETPOLL=y 863CONFIG_NETPOLL=y
856# CONFIG_NETPOLL_TRAP is not set 864# CONFIG_NETPOLL_TRAP is not set
857CONFIG_NET_POLL_CONTROLLER=y 865CONFIG_NET_POLL_CONTROLLER=y
858
859#
860# ISDN subsystem
861#
862# CONFIG_ISDN is not set 866# CONFIG_ISDN is not set
863
864#
865# Telephony Support
866#
867# CONFIG_PHONE is not set 867# CONFIG_PHONE is not set
868 868
869# 869#
@@ -871,6 +871,7 @@ CONFIG_NET_POLL_CONTROLLER=y
871# 871#
872CONFIG_INPUT=y 872CONFIG_INPUT=y
873# CONFIG_INPUT_FF_MEMLESS is not set 873# CONFIG_INPUT_FF_MEMLESS is not set
874# CONFIG_INPUT_POLLDEV is not set
874 875
875# 876#
876# Userland interfaces 877# Userland interfaces
@@ -936,6 +937,7 @@ CONFIG_HW_CONSOLE=y
936# 937#
937CONFIG_SERIAL_8250=y 938CONFIG_SERIAL_8250=y
938CONFIG_SERIAL_8250_CONSOLE=y 939CONFIG_SERIAL_8250_CONSOLE=y
940CONFIG_FIX_EARLYCON_MEM=y
939CONFIG_SERIAL_8250_PCI=y 941CONFIG_SERIAL_8250_PCI=y
940CONFIG_SERIAL_8250_PNP=y 942CONFIG_SERIAL_8250_PNP=y
941CONFIG_SERIAL_8250_NR_UARTS=4 943CONFIG_SERIAL_8250_NR_UARTS=4
@@ -951,10 +953,6 @@ CONFIG_SERIAL_CORE_CONSOLE=y
951CONFIG_UNIX98_PTYS=y 953CONFIG_UNIX98_PTYS=y
952CONFIG_LEGACY_PTYS=y 954CONFIG_LEGACY_PTYS=y
953CONFIG_LEGACY_PTY_COUNT=256 955CONFIG_LEGACY_PTY_COUNT=256
954
955#
956# IPMI
957#
958# CONFIG_IPMI_HANDLER is not set 956# CONFIG_IPMI_HANDLER is not set
959# CONFIG_WATCHDOG is not set 957# CONFIG_WATCHDOG is not set
960CONFIG_HW_RANDOM=y 958CONFIG_HW_RANDOM=y
@@ -988,11 +986,7 @@ CONFIG_MAX_RAW_DEVS=256
988CONFIG_HPET=y 986CONFIG_HPET=y
989# CONFIG_HPET_RTC_IRQ is not set 987# CONFIG_HPET_RTC_IRQ is not set
990CONFIG_HPET_MMAP=y 988CONFIG_HPET_MMAP=y
991CONFIG_HANGCHECK_TIMER=y 989# CONFIG_HANGCHECK_TIMER is not set
992
993#
994# TPM devices
995#
996# CONFIG_TCG_TPM is not set 990# CONFIG_TCG_TPM is not set
997# CONFIG_TELCLOCK is not set 991# CONFIG_TELCLOCK is not set
998CONFIG_DEVPORT=y 992CONFIG_DEVPORT=y
@@ -1003,11 +997,8 @@ CONFIG_DEVPORT=y
1003# 997#
1004# CONFIG_SPI is not set 998# CONFIG_SPI is not set
1005# CONFIG_SPI_MASTER is not set 999# CONFIG_SPI_MASTER is not set
1006
1007#
1008# Dallas's 1-wire bus
1009#
1010# CONFIG_W1 is not set 1000# CONFIG_W1 is not set
1001# CONFIG_POWER_SUPPLY is not set
1011# CONFIG_HWMON is not set 1002# CONFIG_HWMON is not set
1012 1003
1013# 1004#
@@ -1041,7 +1032,7 @@ CONFIG_DAB=y
1041CONFIG_VGA_CONSOLE=y 1032CONFIG_VGA_CONSOLE=y
1042CONFIG_VGACON_SOFT_SCROLLBACK=y 1033CONFIG_VGACON_SOFT_SCROLLBACK=y
1043CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=128 1034CONFIG_VGACON_SOFT_SCROLLBACK_SIZE=128
1044# CONFIG_VIDEO_SELECT is not set 1035CONFIG_VIDEO_SELECT=y
1045CONFIG_DUMMY_CONSOLE=y 1036CONFIG_DUMMY_CONSOLE=y
1046 1037
1047# 1038#
@@ -1058,15 +1049,11 @@ CONFIG_SOUND=y
1058# Open Sound System 1049# Open Sound System
1059# 1050#
1060CONFIG_SOUND_PRIME=y 1051CONFIG_SOUND_PRIME=y
1061# CONFIG_OSS_OBSOLETE is not set
1062# CONFIG_SOUND_TRIDENT is not set 1052# CONFIG_SOUND_TRIDENT is not set
1063# CONFIG_SOUND_MSNDCLAS is not set 1053# CONFIG_SOUND_MSNDCLAS is not set
1064# CONFIG_SOUND_MSNDPIN is not set 1054# CONFIG_SOUND_MSNDPIN is not set
1065# CONFIG_SOUND_OSS is not set 1055# CONFIG_SOUND_OSS is not set
1066 1056CONFIG_HID_SUPPORT=y
1067#
1068# HID Devices
1069#
1070CONFIG_HID=y 1057CONFIG_HID=y
1071# CONFIG_HID_DEBUG is not set 1058# CONFIG_HID_DEBUG is not set
1072 1059
@@ -1077,10 +1064,7 @@ CONFIG_USB_HID=y
1077# CONFIG_USB_HIDINPUT_POWERBOOK is not set 1064# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1078# CONFIG_HID_FF is not set 1065# CONFIG_HID_FF is not set
1079# CONFIG_USB_HIDDEV is not set 1066# CONFIG_USB_HIDDEV is not set
1080 1067CONFIG_USB_SUPPORT=y
1081#
1082# USB support
1083#
1084CONFIG_USB_ARCH_HAS_HCD=y 1068CONFIG_USB_ARCH_HAS_HCD=y
1085CONFIG_USB_ARCH_HAS_OHCI=y 1069CONFIG_USB_ARCH_HAS_OHCI=y
1086CONFIG_USB_ARCH_HAS_EHCI=y 1070CONFIG_USB_ARCH_HAS_EHCI=y
@@ -1094,6 +1078,7 @@ CONFIG_USB_DEVICEFS=y
1094# CONFIG_USB_DEVICE_CLASS is not set 1078# CONFIG_USB_DEVICE_CLASS is not set
1095# CONFIG_USB_DYNAMIC_MINORS is not set 1079# CONFIG_USB_DYNAMIC_MINORS is not set
1096# CONFIG_USB_SUSPEND is not set 1080# CONFIG_USB_SUSPEND is not set
1081# CONFIG_USB_PERSIST is not set
1097# CONFIG_USB_OTG is not set 1082# CONFIG_USB_OTG is not set
1098 1083
1099# 1084#
@@ -1103,7 +1088,6 @@ CONFIG_USB_EHCI_HCD=y
1103# CONFIG_USB_EHCI_SPLIT_ISO is not set 1088# CONFIG_USB_EHCI_SPLIT_ISO is not set
1104# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 1089# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1105# CONFIG_USB_EHCI_TT_NEWSCHED is not set 1090# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1106# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set
1107# CONFIG_USB_ISP116X_HCD is not set 1091# CONFIG_USB_ISP116X_HCD is not set
1108CONFIG_USB_OHCI_HCD=y 1092CONFIG_USB_OHCI_HCD=y
1109# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set 1093# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
@@ -1111,6 +1095,7 @@ CONFIG_USB_OHCI_HCD=y
1111CONFIG_USB_OHCI_LITTLE_ENDIAN=y 1095CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1112CONFIG_USB_UHCI_HCD=y 1096CONFIG_USB_UHCI_HCD=y
1113# CONFIG_USB_SL811_HCD is not set 1097# CONFIG_USB_SL811_HCD is not set
1098# CONFIG_USB_R8A66597_HCD is not set
1114 1099
1115# 1100#
1116# USB Device Class drivers 1101# USB Device Class drivers
@@ -1201,15 +1186,7 @@ CONFIG_USB_MON=y
1201# 1186#
1202# LED Triggers 1187# LED Triggers
1203# 1188#
1204
1205#
1206# InfiniBand support
1207#
1208# CONFIG_INFINIBAND is not set 1189# CONFIG_INFINIBAND is not set
1209
1210#
1211# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1212#
1213# CONFIG_EDAC is not set 1190# CONFIG_EDAC is not set
1214 1191
1215# 1192#
@@ -1229,11 +1206,13 @@ CONFIG_USB_MON=y
1229# 1206#
1230# DMA Devices 1207# DMA Devices
1231# 1208#
1209CONFIG_VIRTUALIZATION=y
1210# CONFIG_KVM is not set
1232 1211
1233# 1212#
1234# Virtualization 1213# Userspace I/O
1235# 1214#
1236# CONFIG_KVM is not set 1215# CONFIG_UIO is not set
1237 1216
1238# 1217#
1239# File systems 1218# File systems
@@ -1271,6 +1250,7 @@ CONFIG_DNOTIFY=y
1271# CONFIG_AUTOFS_FS is not set 1250# CONFIG_AUTOFS_FS is not set
1272CONFIG_AUTOFS4_FS=y 1251CONFIG_AUTOFS4_FS=y
1273# CONFIG_FUSE_FS is not set 1252# CONFIG_FUSE_FS is not set
1253CONFIG_GENERIC_ACL=y
1274 1254
1275# 1255#
1276# CD-ROM/DVD Filesystems 1256# CD-ROM/DVD Filesystems
@@ -1298,7 +1278,7 @@ CONFIG_PROC_KCORE=y
1298CONFIG_PROC_SYSCTL=y 1278CONFIG_PROC_SYSCTL=y
1299CONFIG_SYSFS=y 1279CONFIG_SYSFS=y
1300CONFIG_TMPFS=y 1280CONFIG_TMPFS=y
1301# CONFIG_TMPFS_POSIX_ACL is not set 1281CONFIG_TMPFS_POSIX_ACL=y
1302CONFIG_HUGETLBFS=y 1282CONFIG_HUGETLBFS=y
1303CONFIG_HUGETLB_PAGE=y 1283CONFIG_HUGETLB_PAGE=y
1304CONFIG_RAMFS=y 1284CONFIG_RAMFS=y
@@ -1348,7 +1328,6 @@ CONFIG_SUNRPC=y
1348# CONFIG_NCP_FS is not set 1328# CONFIG_NCP_FS is not set
1349# CONFIG_CODA_FS is not set 1329# CONFIG_CODA_FS is not set
1350# CONFIG_AFS_FS is not set 1330# CONFIG_AFS_FS is not set
1351# CONFIG_9P_FS is not set
1352 1331
1353# 1332#
1354# Partition Types 1333# Partition Types
@@ -1404,10 +1383,7 @@ CONFIG_NLS_UTF8=y
1404# Distributed Lock Manager 1383# Distributed Lock Manager
1405# 1384#
1406# CONFIG_DLM is not set 1385# CONFIG_DLM is not set
1407 1386CONFIG_INSTRUMENTATION=y
1408#
1409# Instrumentation Support
1410#
1411CONFIG_PROFILING=y 1387CONFIG_PROFILING=y
1412CONFIG_OPROFILE=y 1388CONFIG_OPROFILE=y
1413CONFIG_KPROBES=y 1389CONFIG_KPROBES=y
@@ -1417,7 +1393,7 @@ CONFIG_KPROBES=y
1417# 1393#
1418CONFIG_TRACE_IRQFLAGS_SUPPORT=y 1394CONFIG_TRACE_IRQFLAGS_SUPPORT=y
1419# CONFIG_PRINTK_TIME is not set 1395# CONFIG_PRINTK_TIME is not set
1420CONFIG_ENABLE_MUST_CHECK=y 1396# CONFIG_ENABLE_MUST_CHECK is not set
1421CONFIG_MAGIC_SYSRQ=y 1397CONFIG_MAGIC_SYSRQ=y
1422CONFIG_UNUSED_SYMBOLS=y 1398CONFIG_UNUSED_SYMBOLS=y
1423# CONFIG_DEBUG_FS is not set 1399# CONFIG_DEBUG_FS is not set
@@ -1425,15 +1401,17 @@ CONFIG_UNUSED_SYMBOLS=y
1425CONFIG_DEBUG_KERNEL=y 1401CONFIG_DEBUG_KERNEL=y
1426# CONFIG_DEBUG_SHIRQ is not set 1402# CONFIG_DEBUG_SHIRQ is not set
1427CONFIG_DETECT_SOFTLOCKUP=y 1403CONFIG_DETECT_SOFTLOCKUP=y
1404# CONFIG_SCHED_DEBUG is not set
1428# CONFIG_SCHEDSTATS is not set 1405# CONFIG_SCHEDSTATS is not set
1429# CONFIG_TIMER_STATS is not set 1406CONFIG_TIMER_STATS=y
1430# CONFIG_DEBUG_SLAB is not set 1407# CONFIG_SLUB_DEBUG_ON is not set
1431# CONFIG_DEBUG_RT_MUTEXES is not set 1408# CONFIG_DEBUG_RT_MUTEXES is not set
1432# CONFIG_RT_MUTEX_TESTER is not set 1409# CONFIG_RT_MUTEX_TESTER is not set
1433# CONFIG_DEBUG_SPINLOCK is not set 1410# CONFIG_DEBUG_SPINLOCK is not set
1434# CONFIG_DEBUG_MUTEXES is not set 1411# CONFIG_DEBUG_MUTEXES is not set
1435# CONFIG_DEBUG_LOCK_ALLOC is not set 1412# CONFIG_DEBUG_LOCK_ALLOC is not set
1436# CONFIG_PROVE_LOCKING is not set 1413# CONFIG_PROVE_LOCKING is not set
1414# CONFIG_LOCK_STAT is not set
1437# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1415# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1438# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1416# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1439# CONFIG_DEBUG_KOBJECT is not set 1417# CONFIG_DEBUG_KOBJECT is not set
@@ -1443,7 +1421,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
1443# CONFIG_DEBUG_VM is not set 1421# CONFIG_DEBUG_VM is not set
1444# CONFIG_DEBUG_LIST is not set 1422# CONFIG_DEBUG_LIST is not set
1445# CONFIG_FRAME_POINTER is not set 1423# CONFIG_FRAME_POINTER is not set
1446# CONFIG_UNWIND_INFO is not set
1447# CONFIG_FORCED_INLINING is not set 1424# CONFIG_FORCED_INLINING is not set
1448# CONFIG_RCU_TORTURE_TEST is not set 1425# CONFIG_RCU_TORTURE_TEST is not set
1449# CONFIG_LKDTM is not set 1426# CONFIG_LKDTM is not set
@@ -1462,10 +1439,6 @@ CONFIG_DOUBLEFAULT=y
1462# 1439#
1463# CONFIG_KEYS is not set 1440# CONFIG_KEYS is not set
1464# CONFIG_SECURITY is not set 1441# CONFIG_SECURITY is not set
1465
1466#
1467# Cryptographic options
1468#
1469# CONFIG_CRYPTO is not set 1442# CONFIG_CRYPTO is not set
1470 1443
1471# 1444#
@@ -1476,6 +1449,7 @@ CONFIG_BITREVERSE=y
1476# CONFIG_CRC16 is not set 1449# CONFIG_CRC16 is not set
1477# CONFIG_CRC_ITU_T is not set 1450# CONFIG_CRC_ITU_T is not set
1478CONFIG_CRC32=y 1451CONFIG_CRC32=y
1452# CONFIG_CRC7 is not set
1479# CONFIG_LIBCRC32C is not set 1453# CONFIG_LIBCRC32C is not set
1480CONFIG_ZLIB_INFLATE=y 1454CONFIG_ZLIB_INFLATE=y
1481CONFIG_PLIST=y 1455CONFIG_PLIST=y
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index 06da59f6f837..dbe5e87e0d66 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -40,6 +40,7 @@ obj-$(CONFIG_VM86) += vm86.o
40obj-$(CONFIG_EARLY_PRINTK) += early_printk.o 40obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
41obj-$(CONFIG_HPET_TIMER) += hpet.o 41obj-$(CONFIG_HPET_TIMER) += hpet.o
42obj-$(CONFIG_K8_NB) += k8.o 42obj-$(CONFIG_K8_NB) += k8.o
43obj-$(CONFIG_MGEODE_LX) += geode.o
43 44
44obj-$(CONFIG_VMI) += vmi.o vmiclock.o 45obj-$(CONFIG_VMI) += vmi.o vmiclock.o
45obj-$(CONFIG_PARAVIRT) += paravirt.o 46obj-$(CONFIG_PARAVIRT) += paravirt.o
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index a574cd2c8b61..cacdd883bf2b 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -618,6 +618,8 @@ static int __init acpi_parse_sbf(struct acpi_table_header *table)
618#ifdef CONFIG_HPET_TIMER 618#ifdef CONFIG_HPET_TIMER
619#include <asm/hpet.h> 619#include <asm/hpet.h>
620 620
621static struct __initdata resource *hpet_res;
622
621static int __init acpi_parse_hpet(struct acpi_table_header *table) 623static int __init acpi_parse_hpet(struct acpi_table_header *table)
622{ 624{
623 struct acpi_table_hpet *hpet_tbl; 625 struct acpi_table_hpet *hpet_tbl;
@@ -638,8 +640,42 @@ static int __init acpi_parse_hpet(struct acpi_table_header *table)
638 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n", 640 printk(KERN_INFO PREFIX "HPET id: %#x base: %#lx\n",
639 hpet_tbl->id, hpet_address); 641 hpet_tbl->id, hpet_address);
640 642
643 /*
644 * Allocate and initialize the HPET firmware resource for adding into
645 * the resource tree during the lateinit timeframe.
646 */
647#define HPET_RESOURCE_NAME_SIZE 9
648 hpet_res = alloc_bootmem(sizeof(*hpet_res) + HPET_RESOURCE_NAME_SIZE);
649
650 if (!hpet_res)
651 return 0;
652
653 memset(hpet_res, 0, sizeof(*hpet_res));
654 hpet_res->name = (void *)&hpet_res[1];
655 hpet_res->flags = IORESOURCE_MEM;
656 snprintf((char *)hpet_res->name, HPET_RESOURCE_NAME_SIZE, "HPET %u",
657 hpet_tbl->sequence);
658
659 hpet_res->start = hpet_address;
660 hpet_res->end = hpet_address + (1 * 1024) - 1;
661
641 return 0; 662 return 0;
642} 663}
664
665/*
666 * hpet_insert_resource inserts the HPET resources used into the resource
667 * tree.
668 */
669static __init int hpet_insert_resource(void)
670{
671 if (!hpet_res)
672 return 1;
673
674 return insert_resource(&iomem_resource, hpet_res);
675}
676
677late_initcall(hpet_insert_resource);
678
643#else 679#else
644#define acpi_parse_hpet NULL 680#define acpi_parse_hpet NULL
645#endif 681#endif
@@ -950,14 +986,6 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
950 }, 986 },
951 { 987 {
952 .callback = force_acpi_ht, 988 .callback = force_acpi_ht,
953 .ident = "DELL GX240",
954 .matches = {
955 DMI_MATCH(DMI_BOARD_VENDOR, "Dell Computer Corporation"),
956 DMI_MATCH(DMI_BOARD_NAME, "OptiPlex GX240"),
957 },
958 },
959 {
960 .callback = force_acpi_ht,
961 .ident = "HP VISUALIZE NT Workstation", 989 .ident = "HP VISUALIZE NT Workstation",
962 .matches = { 990 .matches = {
963 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"), 991 DMI_MATCH(DMI_BOARD_VENDOR, "Hewlett-Packard"),
diff --git a/arch/i386/kernel/alternative.c b/arch/i386/kernel/alternative.c
index d8cda14fff8b..c3750c2c4113 100644
--- a/arch/i386/kernel/alternative.c
+++ b/arch/i386/kernel/alternative.c
@@ -2,12 +2,17 @@
2#include <linux/sched.h> 2#include <linux/sched.h>
3#include <linux/spinlock.h> 3#include <linux/spinlock.h>
4#include <linux/list.h> 4#include <linux/list.h>
5#include <linux/kprobes.h>
6#include <linux/mm.h>
7#include <linux/vmalloc.h>
5#include <asm/alternative.h> 8#include <asm/alternative.h>
6#include <asm/sections.h> 9#include <asm/sections.h>
10#include <asm/pgtable.h>
11#include <asm/mce.h>
12#include <asm/nmi.h>
7 13
8static int noreplace_smp = 0; 14#ifdef CONFIG_HOTPLUG_CPU
9static int smp_alt_once = 0; 15static int smp_alt_once;
10static int debug_alternative = 0;
11 16
12static int __init bootonly(char *str) 17static int __init bootonly(char *str)
13{ 18{
@@ -15,6 +20,11 @@ static int __init bootonly(char *str)
15 return 1; 20 return 1;
16} 21}
17__setup("smp-alt-boot", bootonly); 22__setup("smp-alt-boot", bootonly);
23#else
24#define smp_alt_once 1
25#endif
26
27static int debug_alternative;
18 28
19static int __init debug_alt(char *str) 29static int __init debug_alt(char *str)
20{ 30{
@@ -23,6 +33,8 @@ static int __init debug_alt(char *str)
23} 33}
24__setup("debug-alternative", debug_alt); 34__setup("debug-alternative", debug_alt);
25 35
36static int noreplace_smp;
37
26static int __init setup_noreplace_smp(char *str) 38static int __init setup_noreplace_smp(char *str)
27{ 39{
28 noreplace_smp = 1; 40 noreplace_smp = 1;
@@ -144,7 +156,7 @@ static void nop_out(void *insns, unsigned int len)
144 unsigned int noplen = len; 156 unsigned int noplen = len;
145 if (noplen > ASM_NOP_MAX) 157 if (noplen > ASM_NOP_MAX)
146 noplen = ASM_NOP_MAX; 158 noplen = ASM_NOP_MAX;
147 memcpy(insns, noptable[noplen], noplen); 159 text_poke(insns, noptable[noplen], noplen);
148 insns += noplen; 160 insns += noplen;
149 len -= noplen; 161 len -= noplen;
150 } 162 }
@@ -196,7 +208,7 @@ static void alternatives_smp_lock(u8 **start, u8 **end, u8 *text, u8 *text_end)
196 continue; 208 continue;
197 if (*ptr > text_end) 209 if (*ptr > text_end)
198 continue; 210 continue;
199 **ptr = 0xf0; /* lock prefix */ 211 text_poke(*ptr, ((unsigned char []){0xf0}), 1); /* add lock prefix */
200 }; 212 };
201} 213}
202 214
@@ -354,10 +366,6 @@ void apply_paravirt(struct paravirt_patch_site *start,
354 /* Pad the rest with nops */ 366 /* Pad the rest with nops */
355 nop_out(p->instr + used, p->len - used); 367 nop_out(p->instr + used, p->len - used);
356 } 368 }
357
358 /* Sync to be conservative, in case we patched following
359 * instructions */
360 sync_core();
361} 369}
362extern struct paravirt_patch_site __start_parainstructions[], 370extern struct paravirt_patch_site __start_parainstructions[],
363 __stop_parainstructions[]; 371 __stop_parainstructions[];
@@ -367,6 +375,14 @@ void __init alternative_instructions(void)
367{ 375{
368 unsigned long flags; 376 unsigned long flags;
369 377
378 /* The patching is not fully atomic, so try to avoid local interruptions
379 that might execute the to be patched code.
380 Other CPUs are not running. */
381 stop_nmi();
382#ifdef CONFIG_MCE
383 stop_mce();
384#endif
385
370 local_irq_save(flags); 386 local_irq_save(flags);
371 apply_alternatives(__alt_instructions, __alt_instructions_end); 387 apply_alternatives(__alt_instructions, __alt_instructions_end);
372 388
@@ -376,8 +392,6 @@ void __init alternative_instructions(void)
376#ifdef CONFIG_HOTPLUG_CPU 392#ifdef CONFIG_HOTPLUG_CPU
377 if (num_possible_cpus() < 2) 393 if (num_possible_cpus() < 2)
378 smp_alt_once = 1; 394 smp_alt_once = 1;
379#else
380 smp_alt_once = 1;
381#endif 395#endif
382 396
383#ifdef CONFIG_SMP 397#ifdef CONFIG_SMP
@@ -401,4 +415,37 @@ void __init alternative_instructions(void)
401#endif 415#endif
402 apply_paravirt(__parainstructions, __parainstructions_end); 416 apply_paravirt(__parainstructions, __parainstructions_end);
403 local_irq_restore(flags); 417 local_irq_restore(flags);
418
419 restart_nmi();
420#ifdef CONFIG_MCE
421 restart_mce();
422#endif
423}
424
425/*
426 * Warning:
427 * When you use this code to patch more than one byte of an instruction
428 * you need to make sure that other CPUs cannot execute this code in parallel.
429 * Also no thread must be currently preempted in the middle of these instructions.
430 * And on the local CPU you need to be protected again NMI or MCE handlers
431 * seeing an inconsistent instruction while you patch.
432 */
433void __kprobes text_poke(void *oaddr, unsigned char *opcode, int len)
434{
435 u8 *addr = oaddr;
436 if (!pte_write(*lookup_address((unsigned long)addr))) {
437 struct page *p[2] = { virt_to_page(addr), virt_to_page(addr+PAGE_SIZE) };
438 addr = vmap(p, 2, VM_MAP, PAGE_KERNEL);
439 if (!addr)
440 return;
441 addr += ((unsigned long)oaddr) % PAGE_SIZE;
442 }
443 memcpy(addr, opcode, len);
444 sync_core();
445 /* Not strictly needed, but can speed CPU recovery up. Ignore cross cacheline
446 case. */
447 if (cpu_has_clflush)
448 asm("clflush (%0) " :: "r" (oaddr) : "memory");
449 if (addr != oaddr)
450 vunmap(addr);
404} 451}
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 67824f3bb974..bfc6cb7df7e7 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -263,6 +263,9 @@ static void lapic_timer_setup(enum clock_event_mode mode,
263 v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR); 263 v |= (APIC_LVT_MASKED | LOCAL_TIMER_VECTOR);
264 apic_write_around(APIC_LVTT, v); 264 apic_write_around(APIC_LVTT, v);
265 break; 265 break;
266 case CLOCK_EVT_MODE_RESUME:
267 /* Nothing to do here */
268 break;
266 } 269 }
267 270
268 local_irq_restore(flags); 271 local_irq_restore(flags);
@@ -315,7 +318,7 @@ static void __devinit setup_APIC_timer(void)
315 318
316#define LAPIC_CAL_LOOPS (HZ/10) 319#define LAPIC_CAL_LOOPS (HZ/10)
317 320
318static __initdata volatile int lapic_cal_loops = -1; 321static __initdata int lapic_cal_loops = -1;
319static __initdata long lapic_cal_t1, lapic_cal_t2; 322static __initdata long lapic_cal_t1, lapic_cal_t2;
320static __initdata unsigned long long lapic_cal_tsc1, lapic_cal_tsc2; 323static __initdata unsigned long long lapic_cal_tsc1, lapic_cal_tsc2;
321static __initdata unsigned long lapic_cal_pm1, lapic_cal_pm2; 324static __initdata unsigned long lapic_cal_pm1, lapic_cal_pm2;
@@ -485,7 +488,7 @@ void __init setup_boot_APIC_clock(void)
485 /* Let the interrupts run */ 488 /* Let the interrupts run */
486 local_irq_enable(); 489 local_irq_enable();
487 490
488 while(lapic_cal_loops <= LAPIC_CAL_LOOPS) 491 while (lapic_cal_loops <= LAPIC_CAL_LOOPS)
489 cpu_relax(); 492 cpu_relax();
490 493
491 local_irq_disable(); 494 local_irq_disable();
@@ -521,6 +524,9 @@ void __init setup_boot_APIC_clock(void)
521 */ 524 */
522 if (nmi_watchdog != NMI_IO_APIC) 525 if (nmi_watchdog != NMI_IO_APIC)
523 lapic_clockevent.features &= ~CLOCK_EVT_FEAT_DUMMY; 526 lapic_clockevent.features &= ~CLOCK_EVT_FEAT_DUMMY;
527 else
528 printk(KERN_WARNING "APIC timer registered as dummy,"
529 " due to nmi_watchdog=1!\n");
524 } 530 }
525 531
526 /* Setup the lapic or request the broadcast */ 532 /* Setup the lapic or request the broadcast */
diff --git a/arch/i386/kernel/cpu/Makefile b/arch/i386/kernel/cpu/Makefile
index 0b6a8551e9e2..778396c78d65 100644
--- a/arch/i386/kernel/cpu/Makefile
+++ b/arch/i386/kernel/cpu/Makefile
@@ -9,7 +9,6 @@ obj-y += cyrix.o
9obj-y += centaur.o 9obj-y += centaur.o
10obj-y += transmeta.o 10obj-y += transmeta.o
11obj-y += intel.o intel_cacheinfo.o addon_cpuid_features.o 11obj-y += intel.o intel_cacheinfo.o addon_cpuid_features.o
12obj-y += rise.o
13obj-y += nexgen.o 12obj-y += nexgen.o
14obj-y += umc.o 13obj-y += umc.o
15 14
diff --git a/arch/i386/kernel/cpu/amd.c b/arch/i386/kernel/cpu/amd.c
index 6f47eeeb93ea..c7ba455d5ac7 100644
--- a/arch/i386/kernel/cpu/amd.c
+++ b/arch/i386/kernel/cpu/amd.c
@@ -231,6 +231,9 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
231 231
232 switch (c->x86) { 232 switch (c->x86) {
233 case 15: 233 case 15:
234 /* Use K8 tuning for Fam10h and Fam11h */
235 case 0x10:
236 case 0x11:
234 set_bit(X86_FEATURE_K8, c->x86_capability); 237 set_bit(X86_FEATURE_K8, c->x86_capability);
235 break; 238 break;
236 case 6: 239 case 6:
@@ -272,8 +275,12 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
272 } 275 }
273#endif 276#endif
274 277
275 if (cpuid_eax(0x80000000) >= 0x80000006) 278 if (cpuid_eax(0x80000000) >= 0x80000006) {
276 num_cache_leaves = 3; 279 if ((c->x86 == 0x10) && (cpuid_edx(0x80000006) & 0xf000))
280 num_cache_leaves = 4;
281 else
282 num_cache_leaves = 3;
283 }
277 284
278 if (amd_apic_timer_broken()) 285 if (amd_apic_timer_broken())
279 set_bit(X86_FEATURE_LAPIC_TIMER_BROKEN, c->x86_capability); 286 set_bit(X86_FEATURE_LAPIC_TIMER_BROKEN, c->x86_capability);
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index e5419a9dec88..d506201d397c 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -606,7 +606,6 @@ extern int nsc_init_cpu(void);
606extern int amd_init_cpu(void); 606extern int amd_init_cpu(void);
607extern int centaur_init_cpu(void); 607extern int centaur_init_cpu(void);
608extern int transmeta_init_cpu(void); 608extern int transmeta_init_cpu(void);
609extern int rise_init_cpu(void);
610extern int nexgen_init_cpu(void); 609extern int nexgen_init_cpu(void);
611extern int umc_init_cpu(void); 610extern int umc_init_cpu(void);
612 611
@@ -618,7 +617,6 @@ void __init early_cpu_init(void)
618 amd_init_cpu(); 617 amd_init_cpu();
619 centaur_init_cpu(); 618 centaur_init_cpu();
620 transmeta_init_cpu(); 619 transmeta_init_cpu();
621 rise_init_cpu();
622 nexgen_init_cpu(); 620 nexgen_init_cpu();
623 umc_init_cpu(); 621 umc_init_cpu();
624 early_cpu_detect(); 622 early_cpu_detect();
diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
index 18c8b67ea3a7..6f846bee2103 100644
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
+++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -665,8 +665,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
665 data->max_freq = perf->states[0].core_frequency * 1000; 665 data->max_freq = perf->states[0].core_frequency * 1000;
666 /* table init */ 666 /* table init */
667 for (i=0; i<perf->state_count; i++) { 667 for (i=0; i<perf->state_count; i++) {
668 if (i>0 && perf->states[i].core_frequency == 668 if (i>0 && perf->states[i].core_frequency >=
669 perf->states[i-1].core_frequency) 669 data->freq_table[valid_states-1].frequency / 1000)
670 continue; 670 continue;
671 671
672 data->freq_table[valid_states].index = i; 672 data->freq_table[valid_states].index = i;
diff --git a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
index 194144539a6f..461dabc4e495 100644
--- a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
@@ -79,7 +79,7 @@
79#include <linux/smp.h> 79#include <linux/smp.h>
80#include <linux/cpufreq.h> 80#include <linux/cpufreq.h>
81#include <linux/pci.h> 81#include <linux/pci.h>
82#include <asm/processor.h> 82#include <asm/processor-cyrix.h>
83#include <asm/errno.h> 83#include <asm/errno.h>
84 84
85/* PCI config registers, all at F0 */ 85/* PCI config registers, all at F0 */
diff --git a/arch/i386/kernel/cpu/cyrix.c b/arch/i386/kernel/cpu/cyrix.c
index e88d2fba156b..122d2d75aa9f 100644
--- a/arch/i386/kernel/cpu/cyrix.c
+++ b/arch/i386/kernel/cpu/cyrix.c
@@ -4,7 +4,7 @@
4#include <linux/pci.h> 4#include <linux/pci.h>
5#include <asm/dma.h> 5#include <asm/dma.h>
6#include <asm/io.h> 6#include <asm/io.h>
7#include <asm/processor.h> 7#include <asm/processor-cyrix.h>
8#include <asm/timer.h> 8#include <asm/timer.h>
9#include <asm/pci-direct.h> 9#include <asm/pci-direct.h>
10#include <asm/tsc.h> 10#include <asm/tsc.h>
diff --git a/arch/i386/kernel/cpu/intel_cacheinfo.c b/arch/i386/kernel/cpu/intel_cacheinfo.c
index e5be819492ef..d5a456d27d82 100644
--- a/arch/i386/kernel/cpu/intel_cacheinfo.c
+++ b/arch/i386/kernel/cpu/intel_cacheinfo.c
@@ -4,7 +4,7 @@
4 * Changes: 4 * Changes:
5 * Venkatesh Pallipadi : Adding cache identification through cpuid(4) 5 * Venkatesh Pallipadi : Adding cache identification through cpuid(4)
6 * Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure. 6 * Ashok Raj <ashok.raj@intel.com>: Work with CPU hotplug infrastructure.
7 * Andi Kleen : CPUID4 emulation on AMD. 7 * Andi Kleen / Andreas Herrmann : CPUID4 emulation on AMD.
8 */ 8 */
9 9
10#include <linux/init.h> 10#include <linux/init.h>
@@ -135,7 +135,7 @@ unsigned short num_cache_leaves;
135 135
136/* AMD doesn't have CPUID4. Emulate it here to report the same 136/* AMD doesn't have CPUID4. Emulate it here to report the same
137 information to the user. This makes some assumptions about the machine: 137 information to the user. This makes some assumptions about the machine:
138 No L3, L2 not shared, no SMT etc. that is currently true on AMD CPUs. 138 L2 not shared, no SMT etc. that is currently true on AMD CPUs.
139 139
140 In theory the TLBs could be reported as fake type (they are in "dummy"). 140 In theory the TLBs could be reported as fake type (they are in "dummy").
141 Maybe later */ 141 Maybe later */
@@ -159,13 +159,26 @@ union l2_cache {
159 unsigned val; 159 unsigned val;
160}; 160};
161 161
162union l3_cache {
163 struct {
164 unsigned line_size : 8;
165 unsigned lines_per_tag : 4;
166 unsigned assoc : 4;
167 unsigned res : 2;
168 unsigned size_encoded : 14;
169 };
170 unsigned val;
171};
172
162static const unsigned short assocs[] = { 173static const unsigned short assocs[] = {
163 [1] = 1, [2] = 2, [4] = 4, [6] = 8, 174 [1] = 1, [2] = 2, [4] = 4, [6] = 8,
164 [8] = 16, 175 [8] = 16, [0xa] = 32, [0xb] = 48,
176 [0xc] = 64,
165 [0xf] = 0xffff // ?? 177 [0xf] = 0xffff // ??
166 }; 178};
167static const unsigned char levels[] = { 1, 1, 2 }; 179
168static const unsigned char types[] = { 1, 2, 3 }; 180static const unsigned char levels[] = { 1, 1, 2, 3 };
181static const unsigned char types[] = { 1, 2, 3, 3 };
169 182
170static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, 183static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
171 union _cpuid4_leaf_ebx *ebx, 184 union _cpuid4_leaf_ebx *ebx,
@@ -175,37 +188,58 @@ static void __cpuinit amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax,
175 unsigned line_size, lines_per_tag, assoc, size_in_kb; 188 unsigned line_size, lines_per_tag, assoc, size_in_kb;
176 union l1_cache l1i, l1d; 189 union l1_cache l1i, l1d;
177 union l2_cache l2; 190 union l2_cache l2;
191 union l3_cache l3;
192 union l1_cache *l1 = &l1d;
178 193
179 eax->full = 0; 194 eax->full = 0;
180 ebx->full = 0; 195 ebx->full = 0;
181 ecx->full = 0; 196 ecx->full = 0;
182 197
183 cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val); 198 cpuid(0x80000005, &dummy, &dummy, &l1d.val, &l1i.val);
184 cpuid(0x80000006, &dummy, &dummy, &l2.val, &dummy); 199 cpuid(0x80000006, &dummy, &dummy, &l2.val, &l3.val);
185 200
186 if (leaf > 2 || !l1d.val || !l1i.val || !l2.val) 201 switch (leaf) {
187 return; 202 case 1:
188 203 l1 = &l1i;
189 eax->split.is_self_initializing = 1; 204 case 0:
190 eax->split.type = types[leaf]; 205 if (!l1->val)
191 eax->split.level = levels[leaf]; 206 return;
192 eax->split.num_threads_sharing = 0;
193 eax->split.num_cores_on_die = current_cpu_data.x86_max_cores - 1;
194
195 if (leaf <= 1) {
196 union l1_cache *l1 = leaf == 0 ? &l1d : &l1i;
197 assoc = l1->assoc; 207 assoc = l1->assoc;
198 line_size = l1->line_size; 208 line_size = l1->line_size;
199 lines_per_tag = l1->lines_per_tag; 209 lines_per_tag = l1->lines_per_tag;
200 size_in_kb = l1->size_in_kb; 210 size_in_kb = l1->size_in_kb;
201 } else { 211 break;
212 case 2:
213 if (!l2.val)
214 return;
202 assoc = l2.assoc; 215 assoc = l2.assoc;
203 line_size = l2.line_size; 216 line_size = l2.line_size;
204 lines_per_tag = l2.lines_per_tag; 217 lines_per_tag = l2.lines_per_tag;
205 /* cpu_data has errata corrections for K7 applied */ 218 /* cpu_data has errata corrections for K7 applied */
206 size_in_kb = current_cpu_data.x86_cache_size; 219 size_in_kb = current_cpu_data.x86_cache_size;
220 break;
221 case 3:
222 if (!l3.val)
223 return;
224 assoc = l3.assoc;
225 line_size = l3.line_size;
226 lines_per_tag = l3.lines_per_tag;
227 size_in_kb = l3.size_encoded * 512;
228 break;
229 default:
230 return;
207 } 231 }
208 232
233 eax->split.is_self_initializing = 1;
234 eax->split.type = types[leaf];
235 eax->split.level = levels[leaf];
236 if (leaf == 3)
237 eax->split.num_threads_sharing = current_cpu_data.x86_max_cores - 1;
238 else
239 eax->split.num_threads_sharing = 0;
240 eax->split.num_cores_on_die = current_cpu_data.x86_max_cores - 1;
241
242
209 if (assoc == 0xf) 243 if (assoc == 0xf)
210 eax->split.is_fully_associative = 1; 244 eax->split.is_fully_associative = 1;
211 ebx->split.coherency_line_size = line_size - 1; 245 ebx->split.coherency_line_size = line_size - 1;
@@ -239,8 +273,7 @@ static int __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_le
239 return 0; 273 return 0;
240} 274}
241 275
242/* will only be called once; __init is safe here */ 276static int __cpuinit find_num_cache_leaves(void)
243static int __init find_num_cache_leaves(void)
244{ 277{
245 unsigned int eax, ebx, ecx, edx; 278 unsigned int eax, ebx, ecx, edx;
246 union _cpuid4_leaf_eax cache_eax; 279 union _cpuid4_leaf_eax cache_eax;
@@ -710,7 +743,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev)
710 return retval; 743 return retval;
711} 744}
712 745
713static void __cpuexit cache_remove_dev(struct sys_device * sys_dev) 746static void __cpuinit cache_remove_dev(struct sys_device * sys_dev)
714{ 747{
715 unsigned int cpu = sys_dev->id; 748 unsigned int cpu = sys_dev->id;
716 unsigned long i; 749 unsigned long i;
diff --git a/arch/i386/kernel/cpu/mcheck/mce.c b/arch/i386/kernel/cpu/mcheck/mce.c
index 56cd485b127c..34c781eddee4 100644
--- a/arch/i386/kernel/cpu/mcheck/mce.c
+++ b/arch/i386/kernel/cpu/mcheck/mce.c
@@ -60,6 +60,20 @@ void mcheck_init(struct cpuinfo_x86 *c)
60 } 60 }
61} 61}
62 62
63static unsigned long old_cr4 __initdata;
64
65void __init stop_mce(void)
66{
67 old_cr4 = read_cr4();
68 clear_in_cr4(X86_CR4_MCE);
69}
70
71void __init restart_mce(void)
72{
73 if (old_cr4 & X86_CR4_MCE)
74 set_in_cr4(X86_CR4_MCE);
75}
76
63static int __init mcheck_disable(char *str) 77static int __init mcheck_disable(char *str)
64{ 78{
65 mce_disabled = 1; 79 mce_disabled = 1;
diff --git a/arch/i386/kernel/cpu/mcheck/non-fatal.c b/arch/i386/kernel/cpu/mcheck/non-fatal.c
index 6b5d3518a1c0..bf39409b3838 100644
--- a/arch/i386/kernel/cpu/mcheck/non-fatal.c
+++ b/arch/i386/kernel/cpu/mcheck/non-fatal.c
@@ -57,7 +57,7 @@ static DECLARE_DELAYED_WORK(mce_work, mce_work_fn);
57static void mce_work_fn(struct work_struct *work) 57static void mce_work_fn(struct work_struct *work)
58{ 58{
59 on_each_cpu(mce_checkregs, NULL, 1, 1); 59 on_each_cpu(mce_checkregs, NULL, 1, 1);
60 schedule_delayed_work(&mce_work, MCE_RATE); 60 schedule_delayed_work(&mce_work, round_jiffies_relative(MCE_RATE));
61} 61}
62 62
63static int __init init_nonfatal_mce_checker(void) 63static int __init init_nonfatal_mce_checker(void)
@@ -82,7 +82,7 @@ static int __init init_nonfatal_mce_checker(void)
82 /* 82 /*
83 * Check for non-fatal errors every MCE_RATE s 83 * Check for non-fatal errors every MCE_RATE s
84 */ 84 */
85 schedule_delayed_work(&mce_work, MCE_RATE); 85 schedule_delayed_work(&mce_work, round_jiffies_relative(MCE_RATE));
86 printk(KERN_INFO "Machine check exception polling timer started.\n"); 86 printk(KERN_INFO "Machine check exception polling timer started.\n");
87 return 0; 87 return 0;
88} 88}
diff --git a/arch/i386/kernel/cpu/mtrr/cyrix.c b/arch/i386/kernel/cpu/mtrr/cyrix.c
index 1001f1e0fe6d..2287d4863a8a 100644
--- a/arch/i386/kernel/cpu/mtrr/cyrix.c
+++ b/arch/i386/kernel/cpu/mtrr/cyrix.c
@@ -3,6 +3,7 @@
3#include <asm/mtrr.h> 3#include <asm/mtrr.h>
4#include <asm/msr.h> 4#include <asm/msr.h>
5#include <asm/io.h> 5#include <asm/io.h>
6#include <asm/processor-cyrix.h>
6#include "mtrr.h" 7#include "mtrr.h"
7 8
8int arr3_protected; 9int arr3_protected;
diff --git a/arch/i386/kernel/cpu/mtrr/generic.c b/arch/i386/kernel/cpu/mtrr/generic.c
index f6e46943e6ef..56f64e34829f 100644
--- a/arch/i386/kernel/cpu/mtrr/generic.c
+++ b/arch/i386/kernel/cpu/mtrr/generic.c
@@ -79,7 +79,7 @@ static void print_fixed(unsigned base, unsigned step, const mtrr_type*types)
79} 79}
80 80
81/* Grab all of the MTRR state for this CPU into *state */ 81/* Grab all of the MTRR state for this CPU into *state */
82void get_mtrr_state(void) 82void __init get_mtrr_state(void)
83{ 83{
84 unsigned int i; 84 unsigned int i;
85 struct mtrr_var_range *vrs; 85 struct mtrr_var_range *vrs;
diff --git a/arch/i386/kernel/cpu/mtrr/main.c b/arch/i386/kernel/cpu/mtrr/main.c
index 75dc6d5214bc..c48b6fea5ab4 100644
--- a/arch/i386/kernel/cpu/mtrr/main.c
+++ b/arch/i386/kernel/cpu/mtrr/main.c
@@ -643,7 +643,7 @@ static struct sysdev_driver mtrr_sysdev_driver = {
643 * initialized (i.e. before smp_init()). 643 * initialized (i.e. before smp_init()).
644 * 644 *
645 */ 645 */
646__init void mtrr_bp_init(void) 646void __init mtrr_bp_init(void)
647{ 647{
648 init_ifs(); 648 init_ifs();
649 649
diff --git a/arch/i386/kernel/cpu/mtrr/state.c b/arch/i386/kernel/cpu/mtrr/state.c
index 7b39a2f954d9..c9014ca4a575 100644
--- a/arch/i386/kernel/cpu/mtrr/state.c
+++ b/arch/i386/kernel/cpu/mtrr/state.c
@@ -3,6 +3,7 @@
3#include <asm/io.h> 3#include <asm/io.h>
4#include <asm/mtrr.h> 4#include <asm/mtrr.h>
5#include <asm/msr.h> 5#include <asm/msr.h>
6#include <asm-i386/processor-cyrix.h>
6#include "mtrr.h" 7#include "mtrr.h"
7 8
8 9
diff --git a/arch/i386/kernel/cpu/perfctr-watchdog.c b/arch/i386/kernel/cpu/perfctr-watchdog.c
index 4d26d514c56f..4be488e73bee 100644
--- a/arch/i386/kernel/cpu/perfctr-watchdog.c
+++ b/arch/i386/kernel/cpu/perfctr-watchdog.c
@@ -325,7 +325,7 @@ static struct wd_ops k7_wd_ops = {
325 .stop = single_msr_stop_watchdog, 325 .stop = single_msr_stop_watchdog,
326 .perfctr = MSR_K7_PERFCTR0, 326 .perfctr = MSR_K7_PERFCTR0,
327 .evntsel = MSR_K7_EVNTSEL0, 327 .evntsel = MSR_K7_EVNTSEL0,
328 .checkbit = 1ULL<<63, 328 .checkbit = 1ULL<<47,
329}; 329};
330 330
331/* Intel Model 6 (PPro+,P2,P3,P-M,Core1) */ 331/* Intel Model 6 (PPro+,P2,P3,P-M,Core1) */
@@ -346,7 +346,9 @@ static int setup_p6_watchdog(unsigned nmi_hz)
346 perfctr_msr = MSR_P6_PERFCTR0; 346 perfctr_msr = MSR_P6_PERFCTR0;
347 evntsel_msr = MSR_P6_EVNTSEL0; 347 evntsel_msr = MSR_P6_EVNTSEL0;
348 348
349 wrmsrl(perfctr_msr, 0UL); 349 /* KVM doesn't implement this MSR */
350 if (wrmsr_safe(perfctr_msr, 0, 0) < 0)
351 return 0;
350 352
351 evntsel = P6_EVNTSEL_INT 353 evntsel = P6_EVNTSEL_INT
352 | P6_EVNTSEL_OS 354 | P6_EVNTSEL_OS
@@ -599,8 +601,8 @@ static struct wd_ops intel_arch_wd_ops = {
599 .setup = setup_intel_arch_watchdog, 601 .setup = setup_intel_arch_watchdog,
600 .rearm = p6_rearm, 602 .rearm = p6_rearm,
601 .stop = single_msr_stop_watchdog, 603 .stop = single_msr_stop_watchdog,
602 .perfctr = MSR_ARCH_PERFMON_PERFCTR0, 604 .perfctr = MSR_ARCH_PERFMON_PERFCTR1,
603 .evntsel = MSR_ARCH_PERFMON_EVENTSEL0, 605 .evntsel = MSR_ARCH_PERFMON_EVENTSEL1,
604}; 606};
605 607
606static void probe_nmi_watchdog(void) 608static void probe_nmi_watchdog(void)
diff --git a/arch/i386/kernel/cpu/rise.c b/arch/i386/kernel/cpu/rise.c
deleted file mode 100644
index 50076f22e90f..000000000000
--- a/arch/i386/kernel/cpu/rise.c
+++ /dev/null
@@ -1,52 +0,0 @@
1#include <linux/kernel.h>
2#include <linux/init.h>
3#include <linux/bitops.h>
4#include <asm/processor.h>
5
6#include "cpu.h"
7
8static void __cpuinit init_rise(struct cpuinfo_x86 *c)
9{
10 printk("CPU: Rise iDragon");
11 if (c->x86_model > 2)
12 printk(" II");
13 printk("\n");
14
15 /* Unhide possibly hidden capability flags
16 The mp6 iDragon family don't have MSRs.
17 We switch on extra features with this cpuid weirdness: */
18 __asm__ (
19 "movl $0x6363452a, %%eax\n\t"
20 "movl $0x3231206c, %%ecx\n\t"
21 "movl $0x2a32313a, %%edx\n\t"
22 "cpuid\n\t"
23 "movl $0x63634523, %%eax\n\t"
24 "movl $0x32315f6c, %%ecx\n\t"
25 "movl $0x2333313a, %%edx\n\t"
26 "cpuid\n\t" : : : "eax", "ebx", "ecx", "edx"
27 );
28 set_bit(X86_FEATURE_CX8, c->x86_capability);
29}
30
31static struct cpu_dev rise_cpu_dev __cpuinitdata = {
32 .c_vendor = "Rise",
33 .c_ident = { "RiseRiseRise" },
34 .c_models = {
35 { .vendor = X86_VENDOR_RISE, .family = 5, .model_names =
36 {
37 [0] = "iDragon",
38 [2] = "iDragon",
39 [8] = "iDragon II",
40 [9] = "iDragon II"
41 }
42 },
43 },
44 .c_init = init_rise,
45};
46
47int __init rise_init_cpu(void)
48{
49 cpu_devs[X86_VENDOR_RISE] = &rise_cpu_dev;
50 return 0;
51}
52
diff --git a/arch/i386/kernel/e820.c b/arch/i386/kernel/e820.c
index fc822a46897a..e60cddbc4cfb 100644
--- a/arch/i386/kernel/e820.c
+++ b/arch/i386/kernel/e820.c
@@ -10,6 +10,7 @@
10#include <linux/efi.h> 10#include <linux/efi.h>
11#include <linux/pfn.h> 11#include <linux/pfn.h>
12#include <linux/uaccess.h> 12#include <linux/uaccess.h>
13#include <linux/suspend.h>
13 14
14#include <asm/pgtable.h> 15#include <asm/pgtable.h>
15#include <asm/page.h> 16#include <asm/page.h>
@@ -320,6 +321,37 @@ static int __init request_standard_resources(void)
320 321
321subsys_initcall(request_standard_resources); 322subsys_initcall(request_standard_resources);
322 323
324#if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND)
325/**
326 * e820_mark_nosave_regions - Find the ranges of physical addresses that do not
327 * correspond to e820 RAM areas and mark the corresponding pages as nosave for
328 * hibernation.
329 *
330 * This function requires the e820 map to be sorted and without any
331 * overlapping entries and assumes the first e820 area to be RAM.
332 */
333void __init e820_mark_nosave_regions(void)
334{
335 int i;
336 unsigned long pfn;
337
338 pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size);
339 for (i = 1; i < e820.nr_map; i++) {
340 struct e820entry *ei = &e820.map[i];
341
342 if (pfn < PFN_UP(ei->addr))
343 register_nosave_region(pfn, PFN_UP(ei->addr));
344
345 pfn = PFN_DOWN(ei->addr + ei->size);
346 if (ei->type != E820_RAM)
347 register_nosave_region(PFN_UP(ei->addr), pfn);
348
349 if (pfn >= max_low_pfn)
350 break;
351 }
352}
353#endif
354
323void __init add_memory_region(unsigned long long start, 355void __init add_memory_region(unsigned long long start,
324 unsigned long long size, int type) 356 unsigned long long size, int type)
325{ 357{
diff --git a/arch/i386/kernel/geode.c b/arch/i386/kernel/geode.c
new file mode 100644
index 000000000000..41e8aec4c61d
--- /dev/null
+++ b/arch/i386/kernel/geode.c
@@ -0,0 +1,155 @@
1/*
2 * AMD Geode southbridge support code
3 * Copyright (C) 2006, Advanced Micro Devices, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
8 */
9
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/ioport.h>
13#include <linux/io.h>
14#include <asm/msr.h>
15#include <asm/geode.h>
16
17static struct {
18 char *name;
19 u32 msr;
20 int size;
21 u32 base;
22} lbars[] = {
23 { "geode-pms", MSR_LBAR_PMS, LBAR_PMS_SIZE, 0 },
24 { "geode-acpi", MSR_LBAR_ACPI, LBAR_ACPI_SIZE, 0 },
25 { "geode-gpio", MSR_LBAR_GPIO, LBAR_GPIO_SIZE, 0 },
26 { "geode-mfgpt", MSR_LBAR_MFGPT, LBAR_MFGPT_SIZE, 0 }
27};
28
29static void __init init_lbars(void)
30{
31 u32 lo, hi;
32 int i;
33
34 for (i = 0; i < ARRAY_SIZE(lbars); i++) {
35 rdmsr(lbars[i].msr, lo, hi);
36 if (hi & 0x01)
37 lbars[i].base = lo & 0x0000ffff;
38
39 if (lbars[i].base == 0)
40 printk(KERN_ERR "geode: Couldn't initialize '%s'\n",
41 lbars[i].name);
42 }
43}
44
45int geode_get_dev_base(unsigned int dev)
46{
47 BUG_ON(dev >= ARRAY_SIZE(lbars));
48 return lbars[dev].base;
49}
50EXPORT_SYMBOL_GPL(geode_get_dev_base);
51
52/* === GPIO API === */
53
54void geode_gpio_set(unsigned int gpio, unsigned int reg)
55{
56 u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
57
58 if (!base)
59 return;
60
61 if (gpio < 16)
62 outl(1 << gpio, base + reg);
63 else
64 outl(1 << (gpio - 16), base + 0x80 + reg);
65}
66EXPORT_SYMBOL_GPL(geode_gpio_set);
67
68void geode_gpio_clear(unsigned int gpio, unsigned int reg)
69{
70 u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
71
72 if (!base)
73 return;
74
75 if (gpio < 16)
76 outl(1 << (gpio + 16), base + reg);
77 else
78 outl(1 << gpio, base + 0x80 + reg);
79}
80EXPORT_SYMBOL_GPL(geode_gpio_clear);
81
82int geode_gpio_isset(unsigned int gpio, unsigned int reg)
83{
84 u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
85
86 if (!base)
87 return 0;
88
89 if (gpio < 16)
90 return (inl(base + reg) & (1 << gpio)) ? 1 : 0;
91 else
92 return (inl(base + 0x80 + reg) & (1 << (gpio - 16))) ? 1 : 0;
93}
94EXPORT_SYMBOL_GPL(geode_gpio_isset);
95
96void geode_gpio_set_irq(unsigned int group, unsigned int irq)
97{
98 u32 lo, hi;
99
100 if (group > 7 || irq > 15)
101 return;
102
103 rdmsr(MSR_PIC_ZSEL_HIGH, lo, hi);
104
105 lo &= ~(0xF << (group * 4));
106 lo |= (irq & 0xF) << (group * 4);
107
108 wrmsr(MSR_PIC_ZSEL_HIGH, lo, hi);
109}
110EXPORT_SYMBOL_GPL(geode_gpio_set_irq);
111
112void geode_gpio_setup_event(unsigned int gpio, int pair, int pme)
113{
114 u32 base = geode_get_dev_base(GEODE_DEV_GPIO);
115 u32 offset, shift, val;
116
117 if (gpio >= 24)
118 offset = GPIO_MAP_W;
119 else if (gpio >= 16)
120 offset = GPIO_MAP_Z;
121 else if (gpio >= 8)
122 offset = GPIO_MAP_Y;
123 else
124 offset = GPIO_MAP_X;
125
126 shift = (gpio % 8) * 4;
127
128 val = inl(base + offset);
129
130 /* Clear whatever was there before */
131 val &= ~(0xF << shift);
132
133 /* And set the new value */
134
135 val |= ((pair & 7) << shift);
136
137 /* Set the PME bit if this is a PME event */
138
139 if (pme)
140 val |= (1 << (shift + 3));
141
142 outl(val, base + offset);
143}
144EXPORT_SYMBOL_GPL(geode_gpio_setup_event);
145
146static int __init geode_southbridge_init(void)
147{
148 if (!is_geode())
149 return -ENODEV;
150
151 init_lbars();
152 return 0;
153}
154
155postcore_initcall(geode_southbridge_init);
diff --git a/arch/i386/kernel/hpet.c b/arch/i386/kernel/hpet.c
index 17d73459fc5f..533d4932bc79 100644
--- a/arch/i386/kernel/hpet.c
+++ b/arch/i386/kernel/hpet.c
@@ -5,6 +5,7 @@
5#include <linux/init.h> 5#include <linux/init.h>
6#include <linux/sysdev.h> 6#include <linux/sysdev.h>
7#include <linux/pm.h> 7#include <linux/pm.h>
8#include <linux/delay.h>
8 9
9#include <asm/hpet.h> 10#include <asm/hpet.h>
10#include <asm/io.h> 11#include <asm/io.h>
@@ -187,6 +188,10 @@ static void hpet_set_mode(enum clock_event_mode mode,
187 cfg &= ~HPET_TN_ENABLE; 188 cfg &= ~HPET_TN_ENABLE;
188 hpet_writel(cfg, HPET_T0_CFG); 189 hpet_writel(cfg, HPET_T0_CFG);
189 break; 190 break;
191
192 case CLOCK_EVT_MODE_RESUME:
193 hpet_enable_int();
194 break;
190 } 195 }
191} 196}
192 197
@@ -217,6 +222,7 @@ static struct clocksource clocksource_hpet = {
217 .mask = HPET_MASK, 222 .mask = HPET_MASK,
218 .shift = HPET_SHIFT, 223 .shift = HPET_SHIFT,
219 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 224 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
225 .resume = hpet_start_counter,
220}; 226};
221 227
222/* 228/*
@@ -226,7 +232,8 @@ int __init hpet_enable(void)
226{ 232{
227 unsigned long id; 233 unsigned long id;
228 uint64_t hpet_freq; 234 uint64_t hpet_freq;
229 u64 tmp; 235 u64 tmp, start, now;
236 cycle_t t1;
230 237
231 if (!is_hpet_capable()) 238 if (!is_hpet_capable())
232 return 0; 239 return 0;
@@ -273,6 +280,27 @@ int __init hpet_enable(void)
273 /* Start the counter */ 280 /* Start the counter */
274 hpet_start_counter(); 281 hpet_start_counter();
275 282
283 /* Verify whether hpet counter works */
284 t1 = read_hpet();
285 rdtscll(start);
286
287 /*
288 * We don't know the TSC frequency yet, but waiting for
289 * 200000 TSC cycles is safe:
290 * 4 GHz == 50us
291 * 1 GHz == 200us
292 */
293 do {
294 rep_nop();
295 rdtscll(now);
296 } while ((now - start) < 200000UL);
297
298 if (t1 == read_hpet()) {
299 printk(KERN_WARNING
300 "HPET counter not counting. HPET disabled\n");
301 goto out_nohpet;
302 }
303
276 /* Initialize and register HPET clocksource 304 /* Initialize and register HPET clocksource
277 * 305 *
278 * hpet period is in femto seconds per cycle 306 * hpet period is in femto seconds per cycle
@@ -291,7 +319,6 @@ int __init hpet_enable(void)
291 319
292 clocksource_register(&clocksource_hpet); 320 clocksource_register(&clocksource_hpet);
293 321
294
295 if (id & HPET_ID_LEGSUP) { 322 if (id & HPET_ID_LEGSUP) {
296 hpet_enable_int(); 323 hpet_enable_int();
297 hpet_reserve_platform_timers(id); 324 hpet_reserve_platform_timers(id);
@@ -299,7 +326,7 @@ int __init hpet_enable(void)
299 * Start hpet with the boot cpu mask and make it 326 * Start hpet with the boot cpu mask and make it
300 * global after the IO_APIC has been initialized. 327 * global after the IO_APIC has been initialized.
301 */ 328 */
302 hpet_clockevent.cpumask =cpumask_of_cpu(0); 329 hpet_clockevent.cpumask = cpumask_of_cpu(smp_processor_id());
303 clockevents_register_device(&hpet_clockevent); 330 clockevents_register_device(&hpet_clockevent);
304 global_clock_event = &hpet_clockevent; 331 global_clock_event = &hpet_clockevent;
305 return 1; 332 return 1;
@@ -524,68 +551,3 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
524 return IRQ_HANDLED; 551 return IRQ_HANDLED;
525} 552}
526#endif 553#endif
527
528
529/*
530 * Suspend/resume part
531 */
532
533#ifdef CONFIG_PM
534
535static int hpet_suspend(struct sys_device *sys_device, pm_message_t state)
536{
537 unsigned long cfg = hpet_readl(HPET_CFG);
538
539 cfg &= ~(HPET_CFG_ENABLE|HPET_CFG_LEGACY);
540 hpet_writel(cfg, HPET_CFG);
541
542 return 0;
543}
544
545static int hpet_resume(struct sys_device *sys_device)
546{
547 unsigned int id;
548
549 hpet_start_counter();
550
551 id = hpet_readl(HPET_ID);
552
553 if (id & HPET_ID_LEGSUP)
554 hpet_enable_int();
555
556 return 0;
557}
558
559static struct sysdev_class hpet_class = {
560 set_kset_name("hpet"),
561 .suspend = hpet_suspend,
562 .resume = hpet_resume,
563};
564
565static struct sys_device hpet_device = {
566 .id = 0,
567 .cls = &hpet_class,
568};
569
570
571static __init int hpet_register_sysfs(void)
572{
573 int err;
574
575 if (!is_hpet_capable())
576 return 0;
577
578 err = sysdev_class_register(&hpet_class);
579
580 if (!err) {
581 err = sysdev_register(&hpet_device);
582 if (err)
583 sysdev_class_unregister(&hpet_class);
584 }
585
586 return err;
587}
588
589device_initcall(hpet_register_sysfs);
590
591#endif
diff --git a/arch/i386/kernel/i8253.c b/arch/i386/kernel/i8253.c
index f8a3c4054c70..6d839f2f1b1a 100644
--- a/arch/i386/kernel/i8253.c
+++ b/arch/i386/kernel/i8253.c
@@ -3,18 +3,17 @@
3 * 3 *
4 */ 4 */
5#include <linux/clockchips.h> 5#include <linux/clockchips.h>
6#include <linux/spinlock.h> 6#include <linux/init.h>
7#include <linux/interrupt.h>
7#include <linux/jiffies.h> 8#include <linux/jiffies.h>
8#include <linux/sysdev.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <linux/init.h> 10#include <linux/spinlock.h>
11 11
12#include <asm/smp.h> 12#include <asm/smp.h>
13#include <asm/delay.h> 13#include <asm/delay.h>
14#include <asm/i8253.h> 14#include <asm/i8253.h>
15#include <asm/io.h> 15#include <asm/io.h>
16 16#include <asm/timer.h>
17#include "io_ports.h"
18 17
19DEFINE_SPINLOCK(i8253_lock); 18DEFINE_SPINLOCK(i8253_lock);
20EXPORT_SYMBOL(i8253_lock); 19EXPORT_SYMBOL(i8253_lock);
@@ -41,26 +40,27 @@ static void init_pit_timer(enum clock_event_mode mode,
41 case CLOCK_EVT_MODE_PERIODIC: 40 case CLOCK_EVT_MODE_PERIODIC:
42 /* binary, mode 2, LSB/MSB, ch 0 */ 41 /* binary, mode 2, LSB/MSB, ch 0 */
43 outb_p(0x34, PIT_MODE); 42 outb_p(0x34, PIT_MODE);
44 udelay(10);
45 outb_p(LATCH & 0xff , PIT_CH0); /* LSB */ 43 outb_p(LATCH & 0xff , PIT_CH0); /* LSB */
46 udelay(10);
47 outb(LATCH >> 8 , PIT_CH0); /* MSB */ 44 outb(LATCH >> 8 , PIT_CH0); /* MSB */
48 break; 45 break;
49 46
50 /*
51 * Avoid unnecessary state transitions, as it confuses
52 * Geode / Cyrix based boxen.
53 */
54 case CLOCK_EVT_MODE_SHUTDOWN: 47 case CLOCK_EVT_MODE_SHUTDOWN:
55 if (evt->mode == CLOCK_EVT_MODE_UNUSED)
56 break;
57 case CLOCK_EVT_MODE_UNUSED: 48 case CLOCK_EVT_MODE_UNUSED:
58 if (evt->mode == CLOCK_EVT_MODE_SHUTDOWN) 49 if (evt->mode == CLOCK_EVT_MODE_PERIODIC ||
59 break; 50 evt->mode == CLOCK_EVT_MODE_ONESHOT) {
51 outb_p(0x30, PIT_MODE);
52 outb_p(0, PIT_CH0);
53 outb_p(0, PIT_CH0);
54 }
55 break;
56
60 case CLOCK_EVT_MODE_ONESHOT: 57 case CLOCK_EVT_MODE_ONESHOT:
61 /* One shot setup */ 58 /* One shot setup */
62 outb_p(0x38, PIT_MODE); 59 outb_p(0x38, PIT_MODE);
63 udelay(10); 60 break;
61
62 case CLOCK_EVT_MODE_RESUME:
63 /* Nothing to do here */
64 break; 64 break;
65 } 65 }
66 spin_unlock_irqrestore(&i8253_lock, flags); 66 spin_unlock_irqrestore(&i8253_lock, flags);
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 21db8f56c9a1..893df8280756 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -353,14 +353,6 @@ static void set_ioapic_affinity_irq(unsigned int irq, cpumask_t cpumask)
353# include <linux/slab.h> /* kmalloc() */ 353# include <linux/slab.h> /* kmalloc() */
354# include <linux/timer.h> /* time_after() */ 354# include <linux/timer.h> /* time_after() */
355 355
356#ifdef CONFIG_BALANCED_IRQ_DEBUG
357# define TDprintk(x...) do { printk("<%ld:%s:%d>: ", jiffies, __FILE__, __LINE__); printk(x); } while (0)
358# define Dprintk(x...) do { TDprintk(x); } while (0)
359# else
360# define TDprintk(x...)
361# define Dprintk(x...)
362# endif
363
364#define IRQBALANCE_CHECK_ARCH -999 356#define IRQBALANCE_CHECK_ARCH -999
365#define MAX_BALANCED_IRQ_INTERVAL (5*HZ) 357#define MAX_BALANCED_IRQ_INTERVAL (5*HZ)
366#define MIN_BALANCED_IRQ_INTERVAL (HZ/2) 358#define MIN_BALANCED_IRQ_INTERVAL (HZ/2)
@@ -443,7 +435,7 @@ static inline void balance_irq(int cpu, int irq)
443static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold) 435static inline void rotate_irqs_among_cpus(unsigned long useful_load_threshold)
444{ 436{
445 int i, j; 437 int i, j;
446 Dprintk("Rotating IRQs among CPUs.\n"); 438
447 for_each_online_cpu(i) { 439 for_each_online_cpu(i) {
448 for (j = 0; j < NR_IRQS; j++) { 440 for (j = 0; j < NR_IRQS; j++) {
449 if (!irq_desc[j].action) 441 if (!irq_desc[j].action)
@@ -560,19 +552,11 @@ tryanothercpu:
560 max_loaded = tmp_loaded; /* processor */ 552 max_loaded = tmp_loaded; /* processor */
561 imbalance = (max_cpu_irq - min_cpu_irq) / 2; 553 imbalance = (max_cpu_irq - min_cpu_irq) / 2;
562 554
563 Dprintk("max_loaded cpu = %d\n", max_loaded);
564 Dprintk("min_loaded cpu = %d\n", min_loaded);
565 Dprintk("max_cpu_irq load = %ld\n", max_cpu_irq);
566 Dprintk("min_cpu_irq load = %ld\n", min_cpu_irq);
567 Dprintk("load imbalance = %lu\n", imbalance);
568
569 /* if imbalance is less than approx 10% of max load, then 555 /* if imbalance is less than approx 10% of max load, then
570 * observe diminishing returns action. - quit 556 * observe diminishing returns action. - quit
571 */ 557 */
572 if (imbalance < (max_cpu_irq >> 3)) { 558 if (imbalance < (max_cpu_irq >> 3))
573 Dprintk("Imbalance too trivial\n");
574 goto not_worth_the_effort; 559 goto not_worth_the_effort;
575 }
576 560
577tryanotherirq: 561tryanotherirq:
578 /* if we select an IRQ to move that can't go where we want, then 562 /* if we select an IRQ to move that can't go where we want, then
@@ -629,9 +613,6 @@ tryanotherirq:
629 cpus_and(tmp, target_cpu_mask, allowed_mask); 613 cpus_and(tmp, target_cpu_mask, allowed_mask);
630 614
631 if (!cpus_empty(tmp)) { 615 if (!cpus_empty(tmp)) {
632
633 Dprintk("irq = %d moved to cpu = %d\n",
634 selected_irq, min_loaded);
635 /* mark for change destination */ 616 /* mark for change destination */
636 set_pending_irq(selected_irq, cpumask_of_cpu(min_loaded)); 617 set_pending_irq(selected_irq, cpumask_of_cpu(min_loaded));
637 618
@@ -651,7 +632,6 @@ not_worth_the_effort:
651 */ 632 */
652 balanced_irq_interval = min((long)MAX_BALANCED_IRQ_INTERVAL, 633 balanced_irq_interval = min((long)MAX_BALANCED_IRQ_INTERVAL,
653 balanced_irq_interval + BALANCED_IRQ_MORE_DELTA); 634 balanced_irq_interval + BALANCED_IRQ_MORE_DELTA);
654 Dprintk("IRQ worth rotating not found\n");
655 return; 635 return;
656} 636}
657 637
@@ -1902,7 +1882,7 @@ __setup("no_timer_check", notimercheck);
1902 * - if this function detects that timer IRQs are defunct, then we fall 1882 * - if this function detects that timer IRQs are defunct, then we fall
1903 * back to ISA timer IRQs 1883 * back to ISA timer IRQs
1904 */ 1884 */
1905int __init timer_irq_works(void) 1885static int __init timer_irq_works(void)
1906{ 1886{
1907 unsigned long t1 = jiffies; 1887 unsigned long t1 = jiffies;
1908 1888
diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c
index ba44d40b066d..dd2b97fc00b2 100644
--- a/arch/i386/kernel/irq.c
+++ b/arch/i386/kernel/irq.c
@@ -149,15 +149,11 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
149 149
150#ifdef CONFIG_4KSTACKS 150#ifdef CONFIG_4KSTACKS
151 151
152/*
153 * These should really be __section__(".bss.page_aligned") as well, but
154 * gcc's 3.0 and earlier don't handle that correctly.
155 */
156static char softirq_stack[NR_CPUS * THREAD_SIZE] 152static char softirq_stack[NR_CPUS * THREAD_SIZE]
157 __attribute__((__aligned__(THREAD_SIZE))); 153 __attribute__((__section__(".bss.page_aligned")));
158 154
159static char hardirq_stack[NR_CPUS * THREAD_SIZE] 155static char hardirq_stack[NR_CPUS * THREAD_SIZE]
160 __attribute__((__aligned__(THREAD_SIZE))); 156 __attribute__((__section__(".bss.page_aligned")));
161 157
162/* 158/*
163 * allocate per-cpu stacks for hardirq and for softirq processing 159 * allocate per-cpu stacks for hardirq and for softirq processing
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index dde828a333c3..448a50b1324c 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -35,6 +35,7 @@
35#include <asm/cacheflush.h> 35#include <asm/cacheflush.h>
36#include <asm/desc.h> 36#include <asm/desc.h>
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38#include <asm/alternative.h>
38 39
39void jprobe_return_end(void); 40void jprobe_return_end(void);
40 41
@@ -169,16 +170,12 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p)
169 170
170void __kprobes arch_arm_kprobe(struct kprobe *p) 171void __kprobes arch_arm_kprobe(struct kprobe *p)
171{ 172{
172 *p->addr = BREAKPOINT_INSTRUCTION; 173 text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1);
173 flush_icache_range((unsigned long) p->addr,
174 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
175} 174}
176 175
177void __kprobes arch_disarm_kprobe(struct kprobe *p) 176void __kprobes arch_disarm_kprobe(struct kprobe *p)
178{ 177{
179 *p->addr = p->opcode; 178 text_poke(p->addr, &p->opcode, 1);
180 flush_icache_range((unsigned long) p->addr,
181 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
182} 179}
183 180
184void __kprobes arch_remove_kprobe(struct kprobe *p) 181void __kprobes arch_remove_kprobe(struct kprobe *p)
diff --git a/arch/i386/kernel/nmi.c b/arch/i386/kernel/nmi.c
index 03b7f5584d71..99beac7f96ce 100644
--- a/arch/i386/kernel/nmi.c
+++ b/arch/i386/kernel/nmi.c
@@ -353,7 +353,7 @@ __kprobes int nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
353 * Take the local apic timer and PIT/HPET into account. We don't 353 * Take the local apic timer and PIT/HPET into account. We don't
354 * know which one is active, when we have highres/dyntick on 354 * know which one is active, when we have highres/dyntick on
355 */ 355 */
356 sum = per_cpu(irq_stat, cpu).apic_timer_irqs + kstat_irqs(0); 356 sum = per_cpu(irq_stat, cpu).apic_timer_irqs + kstat_cpu(cpu).irqs[0];
357 357
358 /* if the none of the timers isn't firing, this cpu isn't doing much */ 358 /* if the none of the timers isn't firing, this cpu isn't doing much */
359 if (!touched && last_irq_sums[cpu] == sum) { 359 if (!touched && last_irq_sums[cpu] == sum) {
diff --git a/arch/i386/kernel/paravirt.c b/arch/i386/kernel/paravirt.c
index 53f07a8275e3..ea962c0667d5 100644
--- a/arch/i386/kernel/paravirt.c
+++ b/arch/i386/kernel/paravirt.c
@@ -124,20 +124,28 @@ unsigned paravirt_patch_ignore(unsigned len)
124 return len; 124 return len;
125} 125}
126 126
127struct branch {
128 unsigned char opcode;
129 u32 delta;
130} __attribute__((packed));
131
127unsigned paravirt_patch_call(void *target, u16 tgt_clobbers, 132unsigned paravirt_patch_call(void *target, u16 tgt_clobbers,
128 void *site, u16 site_clobbers, 133 void *site, u16 site_clobbers,
129 unsigned len) 134 unsigned len)
130{ 135{
131 unsigned char *call = site; 136 unsigned char *call = site;
132 unsigned long delta = (unsigned long)target - (unsigned long)(call+5); 137 unsigned long delta = (unsigned long)target - (unsigned long)(call+5);
138 struct branch b;
133 139
134 if (tgt_clobbers & ~site_clobbers) 140 if (tgt_clobbers & ~site_clobbers)
135 return len; /* target would clobber too much for this site */ 141 return len; /* target would clobber too much for this site */
136 if (len < 5) 142 if (len < 5)
137 return len; /* call too long for patch site */ 143 return len; /* call too long for patch site */
138 144
139 *call++ = 0xe8; /* call */ 145 b.opcode = 0xe8; /* call */
140 *(unsigned long *)call = delta; 146 b.delta = delta;
147 BUILD_BUG_ON(sizeof(b) != 5);
148 text_poke(call, (unsigned char *)&b, 5);
141 149
142 return 5; 150 return 5;
143} 151}
@@ -146,12 +154,14 @@ unsigned paravirt_patch_jmp(void *target, void *site, unsigned len)
146{ 154{
147 unsigned char *jmp = site; 155 unsigned char *jmp = site;
148 unsigned long delta = (unsigned long)target - (unsigned long)(jmp+5); 156 unsigned long delta = (unsigned long)target - (unsigned long)(jmp+5);
157 struct branch b;
149 158
150 if (len < 5) 159 if (len < 5)
151 return len; /* call too long for patch site */ 160 return len; /* call too long for patch site */
152 161
153 *jmp++ = 0xe9; /* jmp */ 162 b.opcode = 0xe9; /* jmp */
154 *(unsigned long *)jmp = delta; 163 b.delta = delta;
164 text_poke(jmp, (unsigned char *)&b, 5);
155 165
156 return 5; 166 return 5;
157} 167}
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 6c49acb96982..84664710b784 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -300,6 +300,7 @@ early_param("idle", idle_setup);
300void show_regs(struct pt_regs * regs) 300void show_regs(struct pt_regs * regs)
301{ 301{
302 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L; 302 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L;
303 unsigned long d0, d1, d2, d3, d6, d7;
303 304
304 printk("\n"); 305 printk("\n");
305 printk("Pid: %d, comm: %20s\n", current->pid, current->comm); 306 printk("Pid: %d, comm: %20s\n", current->pid, current->comm);
@@ -324,6 +325,17 @@ void show_regs(struct pt_regs * regs)
324 cr3 = read_cr3(); 325 cr3 = read_cr3();
325 cr4 = read_cr4_safe(); 326 cr4 = read_cr4_safe();
326 printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4); 327 printk("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n", cr0, cr2, cr3, cr4);
328
329 get_debugreg(d0, 0);
330 get_debugreg(d1, 1);
331 get_debugreg(d2, 2);
332 get_debugreg(d3, 3);
333 printk("DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n",
334 d0, d1, d2, d3);
335 get_debugreg(d6, 6);
336 get_debugreg(d7, 7);
337 printk("DR6: %08lx DR7: %08lx\n", d6, d7);
338
327 show_trace(NULL, regs, &regs->esp); 339 show_trace(NULL, regs, &regs->esp);
328} 340}
329 341
diff --git a/arch/i386/kernel/reboot.c b/arch/i386/kernel/reboot.c
index 5513f8d5b5be..0d796248866c 100644
--- a/arch/i386/kernel/reboot.c
+++ b/arch/i386/kernel/reboot.c
@@ -113,6 +113,15 @@ static struct dmi_system_id __initdata reboot_dmi_table[] = {
113 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 300/"), 113 DMI_MATCH(DMI_PRODUCT_NAME, "PowerEdge 300/"),
114 }, 114 },
115 }, 115 },
116 { /* Handle problems with rebooting on Dell Optiplex 745's SFF*/
117 .callback = set_bios_reboot,
118 .ident = "Dell OptiPlex 745",
119 .matches = {
120 DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
121 DMI_MATCH(DMI_PRODUCT_NAME, "OptiPlex 745"),
122 DMI_MATCH(DMI_BOARD_NAME, "0WF810"),
123 },
124 },
116 { /* Handle problems with rebooting on Dell 2400's */ 125 { /* Handle problems with rebooting on Dell 2400's */
117 .callback = set_bios_reboot, 126 .callback = set_bios_reboot,
118 .ident = "Dell PowerEdge 2400", 127 .ident = "Dell PowerEdge 2400",
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index 74871d066c2b..d474cd639bcb 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -273,18 +273,18 @@ unsigned long __init find_max_low_pfn(void)
273 printk(KERN_WARNING "Warning only %ldMB will be used.\n", 273 printk(KERN_WARNING "Warning only %ldMB will be used.\n",
274 MAXMEM>>20); 274 MAXMEM>>20);
275 if (max_pfn > MAX_NONPAE_PFN) 275 if (max_pfn > MAX_NONPAE_PFN)
276 printk(KERN_WARNING "Use a PAE enabled kernel.\n"); 276 printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
277 else 277 else
278 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n"); 278 printk(KERN_WARNING "Use a HIGHMEM enabled kernel.\n");
279 max_pfn = MAXMEM_PFN; 279 max_pfn = MAXMEM_PFN;
280#else /* !CONFIG_HIGHMEM */ 280#else /* !CONFIG_HIGHMEM */
281#ifndef CONFIG_X86_PAE 281#ifndef CONFIG_HIGHMEM64G
282 if (max_pfn > MAX_NONPAE_PFN) { 282 if (max_pfn > MAX_NONPAE_PFN) {
283 max_pfn = MAX_NONPAE_PFN; 283 max_pfn = MAX_NONPAE_PFN;
284 printk(KERN_WARNING "Warning only 4GB will be used.\n"); 284 printk(KERN_WARNING "Warning only 4GB will be used.\n");
285 printk(KERN_WARNING "Use a PAE enabled kernel.\n"); 285 printk(KERN_WARNING "Use a HIGHMEM64G enabled kernel.\n");
286 } 286 }
287#endif /* !CONFIG_X86_PAE */ 287#endif /* !CONFIG_HIGHMEM64G */
288#endif /* !CONFIG_HIGHMEM */ 288#endif /* !CONFIG_HIGHMEM */
289 } else { 289 } else {
290 if (highmem_pages == -1) 290 if (highmem_pages == -1)
@@ -466,7 +466,7 @@ void __init setup_bootmem_allocator(void)
466 * 466 *
467 * This should all compile down to nothing when NUMA is off. 467 * This should all compile down to nothing when NUMA is off.
468 */ 468 */
469void __init remapped_pgdat_init(void) 469static void __init remapped_pgdat_init(void)
470{ 470{
471 int nid; 471 int nid;
472 472
@@ -640,6 +640,7 @@ void __init setup_arch(char **cmdline_p)
640#endif 640#endif
641 641
642 e820_register_memory(); 642 e820_register_memory();
643 e820_mark_nosave_regions();
643 644
644#ifdef CONFIG_VT 645#ifdef CONFIG_VT
645#if defined(CONFIG_VGA_CONSOLE) 646#if defined(CONFIG_VGA_CONSOLE)
diff --git a/arch/i386/kernel/signal.c b/arch/i386/kernel/signal.c
index d574e38f0f77..f5dd85656c18 100644
--- a/arch/i386/kernel/signal.c
+++ b/arch/i386/kernel/signal.c
@@ -199,6 +199,13 @@ asmlinkage int sys_sigreturn(unsigned long __unused)
199 return eax; 199 return eax;
200 200
201badframe: 201badframe:
202 if (show_unhandled_signals && printk_ratelimit())
203 printk("%s%s[%d] bad frame in sigreturn frame:%p eip:%lx"
204 " esp:%lx oeax:%lx\n",
205 current->pid > 1 ? KERN_INFO : KERN_EMERG,
206 current->comm, current->pid, frame, regs->eip,
207 regs->esp, regs->orig_eax);
208
202 force_sig(SIGSEGV, current); 209 force_sig(SIGSEGV, current);
203 return 0; 210 return 0;
204} 211}
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 5910d3fac561..e4f61d1c6248 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -308,7 +308,7 @@ cpumask_t cpu_coregroup_map(int cpu)
308/* representing cpus for which sibling maps can be computed */ 308/* representing cpus for which sibling maps can be computed */
309static cpumask_t cpu_sibling_setup_map; 309static cpumask_t cpu_sibling_setup_map;
310 310
311void set_cpu_sibling_map(int cpu) 311void __cpuinit set_cpu_sibling_map(int cpu)
312{ 312{
313 int i; 313 int i;
314 struct cpuinfo_x86 *c = cpu_data; 314 struct cpuinfo_x86 *c = cpu_data;
diff --git a/arch/i386/kernel/sysenter.c b/arch/i386/kernel/sysenter.c
index ff4ee6f3326b..6deb159d08e0 100644
--- a/arch/i386/kernel/sysenter.c
+++ b/arch/i386/kernel/sysenter.c
@@ -336,7 +336,9 @@ struct vm_area_struct *get_gate_vma(struct task_struct *tsk)
336 336
337int in_gate_area(struct task_struct *task, unsigned long addr) 337int in_gate_area(struct task_struct *task, unsigned long addr)
338{ 338{
339 return 0; 339 const struct vm_area_struct *vma = get_gate_vma(task);
340
341 return vma && addr >= vma->vm_start && addr < vma->vm_end;
340} 342}
341 343
342int in_gate_area_no_task(unsigned long addr) 344int in_gate_area_no_task(unsigned long addr)
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index a665df61f08c..19a6c678d02e 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -207,55 +207,9 @@ unsigned long read_persistent_clock(void)
207 return retval; 207 return retval;
208} 208}
209 209
210static void sync_cmos_clock(unsigned long dummy); 210int update_persistent_clock(struct timespec now)
211
212static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0);
213int no_sync_cmos_clock;
214
215static void sync_cmos_clock(unsigned long dummy)
216{
217 struct timeval now, next;
218 int fail = 1;
219
220 /*
221 * If we have an externally synchronized Linux clock, then update
222 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
223 * called as close as possible to 500 ms before the new second starts.
224 * This code is run on a timer. If the clock is set, that timer
225 * may not expire at the correct time. Thus, we adjust...
226 */
227 if (!ntp_synced())
228 /*
229 * Not synced, exit, do not restart a timer (if one is
230 * running, let it run out).
231 */
232 return;
233
234 do_gettimeofday(&now);
235 if (now.tv_usec >= USEC_AFTER - ((unsigned) TICK_SIZE) / 2 &&
236 now.tv_usec <= USEC_BEFORE + ((unsigned) TICK_SIZE) / 2)
237 fail = set_rtc_mmss(now.tv_sec);
238
239 next.tv_usec = USEC_AFTER - now.tv_usec;
240 if (next.tv_usec <= 0)
241 next.tv_usec += USEC_PER_SEC;
242
243 if (!fail)
244 next.tv_sec = 659;
245 else
246 next.tv_sec = 0;
247
248 if (next.tv_usec >= USEC_PER_SEC) {
249 next.tv_sec++;
250 next.tv_usec -= USEC_PER_SEC;
251 }
252 mod_timer(&sync_cmos_timer, jiffies + timeval_to_jiffies(&next));
253}
254
255void notify_arch_cmos_timer(void)
256{ 211{
257 if (!no_sync_cmos_clock) 212 return set_rtc_mmss(now.tv_sec);
258 mod_timer(&sync_cmos_timer, jiffies + 1);
259} 213}
260 214
261extern void (*late_time_init)(void); 215extern void (*late_time_init)(void);
diff --git a/arch/i386/kernel/traps.c b/arch/i386/kernel/traps.c
index 3e7753c78b9b..cfffe3dd9e83 100644
--- a/arch/i386/kernel/traps.c
+++ b/arch/i386/kernel/traps.c
@@ -152,7 +152,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
152 if (!stack) { 152 if (!stack) {
153 unsigned long dummy; 153 unsigned long dummy;
154 stack = &dummy; 154 stack = &dummy;
155 if (task && task != current) 155 if (task != current)
156 stack = (unsigned long *)task->thread.esp; 156 stack = (unsigned long *)task->thread.esp;
157 } 157 }
158 158
@@ -211,6 +211,7 @@ static void print_trace_address(void *data, unsigned long addr)
211{ 211{
212 printk("%s [<%08lx>] ", (char *)data, addr); 212 printk("%s [<%08lx>] ", (char *)data, addr);
213 print_symbol("%s\n", addr); 213 print_symbol("%s\n", addr);
214 touch_nmi_watchdog();
214} 215}
215 216
216static struct stacktrace_ops print_trace_ops = { 217static struct stacktrace_ops print_trace_ops = {
@@ -617,6 +618,13 @@ fastcall void __kprobes do_general_protection(struct pt_regs * regs,
617 618
618 current->thread.error_code = error_code; 619 current->thread.error_code = error_code;
619 current->thread.trap_no = 13; 620 current->thread.trap_no = 13;
621 if (show_unhandled_signals && unhandled_signal(current, SIGSEGV) &&
622 printk_ratelimit())
623 printk(KERN_INFO
624 "%s[%d] general protection eip:%lx esp:%lx error:%lx\n",
625 current->comm, current->pid,
626 regs->eip, regs->esp, error_code);
627
620 force_sig(SIGSEGV, current); 628 force_sig(SIGSEGV, current);
621 return; 629 return;
622 630
@@ -767,6 +775,8 @@ static __kprobes void default_do_nmi(struct pt_regs * regs)
767 reassert_nmi(); 775 reassert_nmi();
768} 776}
769 777
778static int ignore_nmis;
779
770fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code) 780fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code)
771{ 781{
772 int cpu; 782 int cpu;
@@ -777,11 +787,24 @@ fastcall __kprobes void do_nmi(struct pt_regs * regs, long error_code)
777 787
778 ++nmi_count(cpu); 788 ++nmi_count(cpu);
779 789
780 default_do_nmi(regs); 790 if (!ignore_nmis)
791 default_do_nmi(regs);
781 792
782 nmi_exit(); 793 nmi_exit();
783} 794}
784 795
796void stop_nmi(void)
797{
798 acpi_nmi_disable();
799 ignore_nmis++;
800}
801
802void restart_nmi(void)
803{
804 ignore_nmis--;
805 acpi_nmi_enable();
806}
807
785#ifdef CONFIG_KPROBES 808#ifdef CONFIG_KPROBES
786fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code) 809fastcall void __kprobes do_int3(struct pt_regs *regs, long error_code)
787{ 810{
diff --git a/arch/i386/kernel/vmiclock.c b/arch/i386/kernel/vmiclock.c
index f9b845f4e692..b1b5ab08b26e 100644
--- a/arch/i386/kernel/vmiclock.c
+++ b/arch/i386/kernel/vmiclock.c
@@ -32,6 +32,7 @@
32#include <asm/apicdef.h> 32#include <asm/apicdef.h>
33#include <asm/apic.h> 33#include <asm/apic.h>
34#include <asm/timer.h> 34#include <asm/timer.h>
35#include <asm/i8253.h>
35 36
36#include <irq_vectors.h> 37#include <irq_vectors.h>
37#include "io_ports.h" 38#include "io_ports.h"
@@ -142,6 +143,7 @@ static void vmi_timer_set_mode(enum clock_event_mode mode,
142 143
143 switch (mode) { 144 switch (mode) {
144 case CLOCK_EVT_MODE_ONESHOT: 145 case CLOCK_EVT_MODE_ONESHOT:
146 case CLOCK_EVT_MODE_RESUME:
145 break; 147 break;
146 case CLOCK_EVT_MODE_PERIODIC: 148 case CLOCK_EVT_MODE_PERIODIC:
147 cycles_per_hz = vmi_timer_ops.get_cycle_frequency(); 149 cycles_per_hz = vmi_timer_ops.get_cycle_frequency();
diff --git a/arch/i386/lib/Makefile b/arch/i386/lib/Makefile
index 22d8ac5815f0..4d105fdfe817 100644
--- a/arch/i386/lib/Makefile
+++ b/arch/i386/lib/Makefile
@@ -4,7 +4,7 @@
4 4
5 5
6lib-y = checksum.o delay.o usercopy.o getuser.o putuser.o memcpy.o strstr.o \ 6lib-y = checksum.o delay.o usercopy.o getuser.o putuser.o memcpy.o strstr.o \
7 bitops.o semaphore.o 7 bitops.o semaphore.o string.o
8 8
9lib-$(CONFIG_X86_USE_3DNOW) += mmx.o 9lib-$(CONFIG_X86_USE_3DNOW) += mmx.o
10 10
diff --git a/arch/i386/lib/string.c b/arch/i386/lib/string.c
new file mode 100644
index 000000000000..2c773fefa3dd
--- /dev/null
+++ b/arch/i386/lib/string.c
@@ -0,0 +1,257 @@
1/*
2 * Most of the string-functions are rather heavily hand-optimized,
3 * see especially strsep,strstr,str[c]spn. They should work, but are not
4 * very easy to understand. Everything is done entirely within the register
5 * set, making the functions fast and clean. String instructions have been
6 * used through-out, making for "slightly" unclear code :-)
7 *
8 * AK: On P4 and K7 using non string instruction implementations might be faster
9 * for large memory blocks. But most of them are unlikely to be used on large
10 * strings.
11 */
12
13#include <linux/string.h>
14#include <linux/module.h>
15
16#ifdef __HAVE_ARCH_STRCPY
17char *strcpy(char * dest,const char *src)
18{
19 int d0, d1, d2;
20 asm volatile( "1:\tlodsb\n\t"
21 "stosb\n\t"
22 "testb %%al,%%al\n\t"
23 "jne 1b"
24 : "=&S" (d0), "=&D" (d1), "=&a" (d2)
25 :"0" (src),"1" (dest) : "memory");
26 return dest;
27}
28EXPORT_SYMBOL(strcpy);
29#endif
30
31#ifdef __HAVE_ARCH_STRNCPY
32char *strncpy(char * dest,const char *src,size_t count)
33{
34 int d0, d1, d2, d3;
35 asm volatile( "1:\tdecl %2\n\t"
36 "js 2f\n\t"
37 "lodsb\n\t"
38 "stosb\n\t"
39 "testb %%al,%%al\n\t"
40 "jne 1b\n\t"
41 "rep\n\t"
42 "stosb\n"
43 "2:"
44 : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
45 :"0" (src),"1" (dest),"2" (count) : "memory");
46 return dest;
47}
48EXPORT_SYMBOL(strncpy);
49#endif
50
51#ifdef __HAVE_ARCH_STRCAT
52char *strcat(char * dest,const char * src)
53{
54 int d0, d1, d2, d3;
55 asm volatile( "repne\n\t"
56 "scasb\n\t"
57 "decl %1\n"
58 "1:\tlodsb\n\t"
59 "stosb\n\t"
60 "testb %%al,%%al\n\t"
61 "jne 1b"
62 : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
63 : "0" (src), "1" (dest), "2" (0), "3" (0xffffffffu): "memory");
64 return dest;
65}
66EXPORT_SYMBOL(strcat);
67#endif
68
69#ifdef __HAVE_ARCH_STRNCAT
70char *strncat(char * dest,const char * src,size_t count)
71{
72 int d0, d1, d2, d3;
73 asm volatile( "repne\n\t"
74 "scasb\n\t"
75 "decl %1\n\t"
76 "movl %8,%3\n"
77 "1:\tdecl %3\n\t"
78 "js 2f\n\t"
79 "lodsb\n\t"
80 "stosb\n\t"
81 "testb %%al,%%al\n\t"
82 "jne 1b\n"
83 "2:\txorl %2,%2\n\t"
84 "stosb"
85 : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
86 : "0" (src),"1" (dest),"2" (0),"3" (0xffffffffu), "g" (count)
87 : "memory");
88 return dest;
89}
90EXPORT_SYMBOL(strncat);
91#endif
92
93#ifdef __HAVE_ARCH_STRCMP
94int strcmp(const char * cs,const char * ct)
95{
96 int d0, d1;
97 int res;
98 asm volatile( "1:\tlodsb\n\t"
99 "scasb\n\t"
100 "jne 2f\n\t"
101 "testb %%al,%%al\n\t"
102 "jne 1b\n\t"
103 "xorl %%eax,%%eax\n\t"
104 "jmp 3f\n"
105 "2:\tsbbl %%eax,%%eax\n\t"
106 "orb $1,%%al\n"
107 "3:"
108 :"=a" (res), "=&S" (d0), "=&D" (d1)
109 :"1" (cs),"2" (ct)
110 :"memory");
111 return res;
112}
113EXPORT_SYMBOL(strcmp);
114#endif
115
116#ifdef __HAVE_ARCH_STRNCMP
117int strncmp(const char * cs,const char * ct,size_t count)
118{
119 int res;
120 int d0, d1, d2;
121 asm volatile( "1:\tdecl %3\n\t"
122 "js 2f\n\t"
123 "lodsb\n\t"
124 "scasb\n\t"
125 "jne 3f\n\t"
126 "testb %%al,%%al\n\t"
127 "jne 1b\n"
128 "2:\txorl %%eax,%%eax\n\t"
129 "jmp 4f\n"
130 "3:\tsbbl %%eax,%%eax\n\t"
131 "orb $1,%%al\n"
132 "4:"
133 :"=a" (res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
134 :"1" (cs),"2" (ct),"3" (count)
135 :"memory");
136 return res;
137}
138EXPORT_SYMBOL(strncmp);
139#endif
140
141#ifdef __HAVE_ARCH_STRCHR
142char *strchr(const char * s, int c)
143{
144 int d0;
145 char * res;
146 asm volatile( "movb %%al,%%ah\n"
147 "1:\tlodsb\n\t"
148 "cmpb %%ah,%%al\n\t"
149 "je 2f\n\t"
150 "testb %%al,%%al\n\t"
151 "jne 1b\n\t"
152 "movl $1,%1\n"
153 "2:\tmovl %1,%0\n\t"
154 "decl %0"
155 :"=a" (res), "=&S" (d0)
156 :"1" (s),"0" (c)
157 :"memory");
158 return res;
159}
160EXPORT_SYMBOL(strchr);
161#endif
162
163#ifdef __HAVE_ARCH_STRRCHR
164char *strrchr(const char * s, int c)
165{
166 int d0, d1;
167 char * res;
168 asm volatile( "movb %%al,%%ah\n"
169 "1:\tlodsb\n\t"
170 "cmpb %%ah,%%al\n\t"
171 "jne 2f\n\t"
172 "leal -1(%%esi),%0\n"
173 "2:\ttestb %%al,%%al\n\t"
174 "jne 1b"
175 :"=g" (res), "=&S" (d0), "=&a" (d1)
176 :"0" (0),"1" (s),"2" (c)
177 :"memory");
178 return res;
179}
180EXPORT_SYMBOL(strrchr);
181#endif
182
183#ifdef __HAVE_ARCH_STRLEN
184size_t strlen(const char * s)
185{
186 int d0;
187 int res;
188 asm volatile( "repne\n\t"
189 "scasb\n\t"
190 "notl %0\n\t"
191 "decl %0"
192 :"=c" (res), "=&D" (d0)
193 :"1" (s),"a" (0), "0" (0xffffffffu)
194 :"memory");
195 return res;
196}
197EXPORT_SYMBOL(strlen);
198#endif
199
200#ifdef __HAVE_ARCH_MEMCHR
201void *memchr(const void *cs,int c,size_t count)
202{
203 int d0;
204 void *res;
205 if (!count)
206 return NULL;
207 asm volatile( "repne\n\t"
208 "scasb\n\t"
209 "je 1f\n\t"
210 "movl $1,%0\n"
211 "1:\tdecl %0"
212 :"=D" (res), "=&c" (d0)
213 :"a" (c),"0" (cs),"1" (count)
214 :"memory");
215 return res;
216}
217EXPORT_SYMBOL(memchr);
218#endif
219
220#ifdef __HAVE_ARCH_MEMSCAN
221void *memscan(void * addr, int c, size_t size)
222{
223 if (!size)
224 return addr;
225 asm volatile("repnz; scasb\n\t"
226 "jnz 1f\n\t"
227 "dec %%edi\n"
228 "1:"
229 : "=D" (addr), "=c" (size)
230 : "0" (addr), "1" (size), "a" (c)
231 : "memory");
232 return addr;
233}
234EXPORT_SYMBOL(memscan);
235#endif
236
237#ifdef __HAVE_ARCH_STRNLEN
238size_t strnlen(const char *s, size_t count)
239{
240 int d0;
241 int res;
242 asm volatile( "movl %2,%0\n\t"
243 "jmp 2f\n"
244 "1:\tcmpb $0,(%0)\n\t"
245 "je 3f\n\t"
246 "incl %0\n"
247 "2:\tdecl %1\n\t"
248 "cmpl $-1,%1\n\t"
249 "jne 1b\n"
250 "3:\tsubl %2,%0"
251 :"=a" (res), "=&d" (d0)
252 :"c" (s),"1" (count)
253 :"memory");
254 return res;
255}
256EXPORT_SYMBOL(strnlen);
257#endif
diff --git a/arch/i386/mm/fault.c b/arch/i386/mm/fault.c
index e92a10124935..01ffdd4964f0 100644
--- a/arch/i386/mm/fault.c
+++ b/arch/i386/mm/fault.c
@@ -283,6 +283,8 @@ static inline int vmalloc_fault(unsigned long address)
283 return 0; 283 return 0;
284} 284}
285 285
286int show_unhandled_signals = 1;
287
286/* 288/*
287 * This routine handles page faults. It determines the address, 289 * This routine handles page faults. It determines the address,
288 * and the problem, and then passes it off to one of the appropriate 290 * and the problem, and then passes it off to one of the appropriate
@@ -469,6 +471,14 @@ bad_area_nosemaphore:
469 if (is_prefetch(regs, address, error_code)) 471 if (is_prefetch(regs, address, error_code))
470 return; 472 return;
471 473
474 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
475 printk_ratelimit()) {
476 printk("%s%s[%d]: segfault at %08lx eip %08lx "
477 "esp %08lx error %lx\n",
478 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
479 tsk->comm, tsk->pid, address, regs->eip,
480 regs->esp, error_code);
481 }
472 tsk->thread.cr2 = address; 482 tsk->thread.cr2 = address;
473 /* Kernel addresses are always protection faults */ 483 /* Kernel addresses are always protection faults */
474 tsk->thread.error_code = error_code | (address >= TASK_SIZE); 484 tsk->thread.error_code = error_code | (address >= TASK_SIZE);
diff --git a/arch/i386/mm/init.c b/arch/i386/mm/init.c
index 6e72f22e6bbd..c3b9905af2d5 100644
--- a/arch/i386/mm/init.c
+++ b/arch/i386/mm/init.c
@@ -471,6 +471,10 @@ void zap_low_mappings (void)
471 flush_tlb_all(); 471 flush_tlb_all();
472} 472}
473 473
474int nx_enabled = 0;
475
476#ifdef CONFIG_X86_PAE
477
474static int disable_nx __initdata = 0; 478static int disable_nx __initdata = 0;
475u64 __supported_pte_mask __read_mostly = ~_PAGE_NX; 479u64 __supported_pte_mask __read_mostly = ~_PAGE_NX;
476EXPORT_SYMBOL_GPL(__supported_pte_mask); 480EXPORT_SYMBOL_GPL(__supported_pte_mask);
@@ -500,9 +504,6 @@ static int __init noexec_setup(char *str)
500} 504}
501early_param("noexec", noexec_setup); 505early_param("noexec", noexec_setup);
502 506
503int nx_enabled = 0;
504#ifdef CONFIG_X86_PAE
505
506static void __init set_nx(void) 507static void __init set_nx(void)
507{ 508{
508 unsigned int v[4], l, h; 509 unsigned int v[4], l, h;
@@ -799,17 +800,9 @@ void mark_rodata_ro(void)
799 unsigned long start = PFN_ALIGN(_text); 800 unsigned long start = PFN_ALIGN(_text);
800 unsigned long size = PFN_ALIGN(_etext) - start; 801 unsigned long size = PFN_ALIGN(_etext) - start;
801 802
802#ifndef CONFIG_KPROBES 803 change_page_attr(virt_to_page(start),
803#ifdef CONFIG_HOTPLUG_CPU 804 size >> PAGE_SHIFT, PAGE_KERNEL_RX);
804 /* It must still be possible to apply SMP alternatives. */ 805 printk("Write protecting the kernel text: %luk\n", size >> 10);
805 if (num_possible_cpus() <= 1)
806#endif
807 {
808 change_page_attr(virt_to_page(start),
809 size >> PAGE_SHIFT, PAGE_KERNEL_RX);
810 printk("Write protecting the kernel text: %luk\n", size >> 10);
811 }
812#endif
813 start += size; 806 start += size;
814 size = (unsigned long)__end_rodata - start; 807 size = (unsigned long)__end_rodata - start;
815 change_page_attr(virt_to_page(start), 808 change_page_attr(virt_to_page(start),
diff --git a/arch/i386/mm/ioremap.c b/arch/i386/mm/ioremap.c
index fff08ae7b5ed..0b278315d737 100644
--- a/arch/i386/mm/ioremap.c
+++ b/arch/i386/mm/ioremap.c
@@ -196,7 +196,7 @@ void iounmap(volatile void __iomem *addr)
196 /* Reset the direct mapping. Can block */ 196 /* Reset the direct mapping. Can block */
197 if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) { 197 if ((p->flags >> 20) && p->phys_addr < virt_to_phys(high_memory) - 1) {
198 change_page_attr(virt_to_page(__va(p->phys_addr)), 198 change_page_attr(virt_to_page(__va(p->phys_addr)),
199 p->size >> PAGE_SHIFT, 199 get_vm_area_size(p) >> PAGE_SHIFT,
200 PAGE_KERNEL); 200 PAGE_KERNEL);
201 global_flush_tlb(); 201 global_flush_tlb();
202 } 202 }
diff --git a/arch/i386/mm/pageattr.c b/arch/i386/mm/pageattr.c
index 37992ffb1633..8927222b3ab2 100644
--- a/arch/i386/mm/pageattr.c
+++ b/arch/i386/mm/pageattr.c
@@ -82,7 +82,7 @@ static void flush_kernel_map(void *arg)
82 struct page *p; 82 struct page *p;
83 83
84 /* High level code is not ready for clflush yet */ 84 /* High level code is not ready for clflush yet */
85 if (0 && cpu_has_clflush) { 85 if (cpu_has_clflush) {
86 list_for_each_entry (p, lh, lru) 86 list_for_each_entry (p, lh, lru)
87 cache_flush_page(p); 87 cache_flush_page(p);
88 } else if (boot_cpu_data.x86_model >= 4) 88 } else if (boot_cpu_data.x86_model >= 4)
@@ -136,6 +136,12 @@ static inline void revert_page(struct page *kpte_page, unsigned long address)
136 ref_prot)); 136 ref_prot));
137} 137}
138 138
139static inline void save_page(struct page *kpte_page)
140{
141 if (!test_and_set_bit(PG_arch_1, &kpte_page->flags))
142 list_add(&kpte_page->lru, &df_list);
143}
144
139static int 145static int
140__change_page_attr(struct page *page, pgprot_t prot) 146__change_page_attr(struct page *page, pgprot_t prot)
141{ 147{
@@ -150,6 +156,9 @@ __change_page_attr(struct page *page, pgprot_t prot)
150 if (!kpte) 156 if (!kpte)
151 return -EINVAL; 157 return -EINVAL;
152 kpte_page = virt_to_page(kpte); 158 kpte_page = virt_to_page(kpte);
159 BUG_ON(PageLRU(kpte_page));
160 BUG_ON(PageCompound(kpte_page));
161
153 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) { 162 if (pgprot_val(prot) != pgprot_val(PAGE_KERNEL)) {
154 if (!pte_huge(*kpte)) { 163 if (!pte_huge(*kpte)) {
155 set_pte_atomic(kpte, mk_pte(page, prot)); 164 set_pte_atomic(kpte, mk_pte(page, prot));
@@ -179,11 +188,11 @@ __change_page_attr(struct page *page, pgprot_t prot)
179 * time (not via split_large_page) and in turn we must not 188 * time (not via split_large_page) and in turn we must not
180 * replace it with a largepage. 189 * replace it with a largepage.
181 */ 190 */
191
192 save_page(kpte_page);
182 if (!PageReserved(kpte_page)) { 193 if (!PageReserved(kpte_page)) {
183 if (cpu_has_pse && (page_private(kpte_page) == 0)) { 194 if (cpu_has_pse && (page_private(kpte_page) == 0)) {
184 ClearPagePrivate(kpte_page);
185 paravirt_release_pt(page_to_pfn(kpte_page)); 195 paravirt_release_pt(page_to_pfn(kpte_page));
186 list_add(&kpte_page->lru, &df_list);
187 revert_page(kpte_page, address); 196 revert_page(kpte_page, address);
188 } 197 }
189 } 198 }
@@ -236,6 +245,11 @@ void global_flush_tlb(void)
236 spin_unlock_irq(&cpa_lock); 245 spin_unlock_irq(&cpa_lock);
237 flush_map(&l); 246 flush_map(&l);
238 list_for_each_entry_safe(pg, next, &l, lru) { 247 list_for_each_entry_safe(pg, next, &l, lru) {
248 list_del(&pg->lru);
249 clear_bit(PG_arch_1, &pg->flags);
250 if (PageReserved(pg) || !cpu_has_pse || page_private(pg) != 0)
251 continue;
252 ClearPagePrivate(pg);
239 __free_page(pg); 253 __free_page(pg);
240 } 254 }
241} 255}
diff --git a/arch/i386/mm/pgtable.c b/arch/i386/mm/pgtable.c
index 8d7c0864cc04..01437c46baae 100644
--- a/arch/i386/mm/pgtable.c
+++ b/arch/i386/mm/pgtable.c
@@ -235,7 +235,7 @@ static inline void pgd_list_del(pgd_t *pgd)
235 235
236#if (PTRS_PER_PMD == 1) 236#if (PTRS_PER_PMD == 1)
237/* Non-PAE pgd constructor */ 237/* Non-PAE pgd constructor */
238void pgd_ctor(void *pgd) 238static void pgd_ctor(void *pgd)
239{ 239{
240 unsigned long flags; 240 unsigned long flags;
241 241
@@ -257,7 +257,7 @@ void pgd_ctor(void *pgd)
257} 257}
258#else /* PTRS_PER_PMD > 1 */ 258#else /* PTRS_PER_PMD > 1 */
259/* PAE pgd constructor */ 259/* PAE pgd constructor */
260void pgd_ctor(void *pgd) 260static void pgd_ctor(void *pgd)
261{ 261{
262 /* PAE, kernel PMD may be shared */ 262 /* PAE, kernel PMD may be shared */
263 263
@@ -276,7 +276,7 @@ void pgd_ctor(void *pgd)
276} 276}
277#endif /* PTRS_PER_PMD */ 277#endif /* PTRS_PER_PMD */
278 278
279void pgd_dtor(void *pgd) 279static void pgd_dtor(void *pgd)
280{ 280{
281 unsigned long flags; /* can be called from interrupt context */ 281 unsigned long flags; /* can be called from interrupt context */
282 282
diff --git a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c
index b33aea845f58..bc8a44bddaa7 100644
--- a/arch/i386/pci/acpi.c
+++ b/arch/i386/pci/acpi.c
@@ -8,20 +8,42 @@
8struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum) 8struct pci_bus * __devinit pci_acpi_scan_root(struct acpi_device *device, int domain, int busnum)
9{ 9{
10 struct pci_bus *bus; 10 struct pci_bus *bus;
11 struct pci_sysdata *sd;
12 int pxm;
13
14 /* Allocate per-root-bus (not per bus) arch-specific data.
15 * TODO: leak; this memory is never freed.
16 * It's arguable whether it's worth the trouble to care.
17 */
18 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
19 if (!sd) {
20 printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
21 return NULL;
22 }
11 23
12 if (domain != 0) { 24 if (domain != 0) {
13 printk(KERN_WARNING "PCI: Multiple domains not supported\n"); 25 printk(KERN_WARNING "PCI: Multiple domains not supported\n");
26 kfree(sd);
14 return NULL; 27 return NULL;
15 } 28 }
16 29
17 bus = pcibios_scan_root(busnum); 30 sd->node = -1;
31
32 pxm = acpi_get_pxm(device->handle);
33#ifdef CONFIG_ACPI_NUMA
34 if (pxm >= 0)
35 sd->node = pxm_to_node(pxm);
36#endif
37
38 bus = pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
39 if (!bus)
40 kfree(sd);
41
18#ifdef CONFIG_ACPI_NUMA 42#ifdef CONFIG_ACPI_NUMA
19 if (bus != NULL) { 43 if (bus != NULL) {
20 int pxm = acpi_get_pxm(device->handle);
21 if (pxm >= 0) { 44 if (pxm >= 0) {
22 bus->sysdata = (void *)(unsigned long)pxm_to_node(pxm); 45 printk("bus %d -> pxm %d -> node %d\n",
23 printk("bus %d -> pxm %d -> node %ld\n", 46 busnum, pxm, sd->node);
24 busnum, pxm, (long)(bus->sysdata));
25 } 47 }
26 } 48 }
27#endif 49#endif
diff --git a/arch/i386/pci/common.c b/arch/i386/pci/common.c
index 3f78d4d8ecf3..85503deeda46 100644
--- a/arch/i386/pci/common.c
+++ b/arch/i386/pci/common.c
@@ -293,6 +293,7 @@ static struct dmi_system_id __devinitdata pciprobe_dmi_table[] = {
293struct pci_bus * __devinit pcibios_scan_root(int busnum) 293struct pci_bus * __devinit pcibios_scan_root(int busnum)
294{ 294{
295 struct pci_bus *bus = NULL; 295 struct pci_bus *bus = NULL;
296 struct pci_sysdata *sd;
296 297
297 dmi_check_system(pciprobe_dmi_table); 298 dmi_check_system(pciprobe_dmi_table);
298 299
@@ -303,9 +304,19 @@ struct pci_bus * __devinit pcibios_scan_root(int busnum)
303 } 304 }
304 } 305 }
305 306
307 /* Allocate per-root-bus (not per bus) arch-specific data.
308 * TODO: leak; this memory is never freed.
309 * It's arguable whether it's worth the trouble to care.
310 */
311 sd = kzalloc(sizeof(*sd), GFP_KERNEL);
312 if (!sd) {
313 printk(KERN_ERR "PCI: OOM, not probing PCI bus %02x\n", busnum);
314 return NULL;
315 }
316
306 printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum); 317 printk(KERN_DEBUG "PCI: Probing PCI hardware (bus %02x)\n", busnum);
307 318
308 return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, NULL); 319 return pci_scan_bus_parented(NULL, busnum, &pci_root_ops, sd);
309} 320}
310 321
311extern u8 pci_cache_line_size; 322extern u8 pci_cache_line_size;
diff --git a/arch/i386/pci/mmconfig-shared.c b/arch/i386/pci/mmconfig-shared.c
index c7cabeed4d7b..4df637e34f81 100644
--- a/arch/i386/pci/mmconfig-shared.c
+++ b/arch/i386/pci/mmconfig-shared.c
@@ -24,6 +24,9 @@
24 24
25DECLARE_BITMAP(pci_mmcfg_fallback_slots, 32*PCI_MMCFG_MAX_CHECK_BUS); 25DECLARE_BITMAP(pci_mmcfg_fallback_slots, 32*PCI_MMCFG_MAX_CHECK_BUS);
26 26
27/* Indicate if the mmcfg resources have been placed into the resource table. */
28static int __initdata pci_mmcfg_resources_inserted;
29
27/* K8 systems have some devices (typically in the builtin northbridge) 30/* K8 systems have some devices (typically in the builtin northbridge)
28 that are only accessible using type1 31 that are only accessible using type1
29 Normally this can be expressed in the MCFG by not listing them 32 Normally this can be expressed in the MCFG by not listing them
@@ -170,7 +173,7 @@ static int __init pci_mmcfg_check_hostbridge(void)
170 return name != NULL; 173 return name != NULL;
171} 174}
172 175
173static void __init pci_mmcfg_insert_resources(void) 176static void __init pci_mmcfg_insert_resources(unsigned long resource_flags)
174{ 177{
175#define PCI_MMCFG_RESOURCE_NAME_LEN 19 178#define PCI_MMCFG_RESOURCE_NAME_LEN 19
176 int i; 179 int i;
@@ -194,10 +197,13 @@ static void __init pci_mmcfg_insert_resources(void)
194 cfg->pci_segment); 197 cfg->pci_segment);
195 res->start = cfg->address; 198 res->start = cfg->address;
196 res->end = res->start + (num_buses << 20) - 1; 199 res->end = res->start + (num_buses << 20) - 1;
197 res->flags = IORESOURCE_MEM | IORESOURCE_BUSY; 200 res->flags = IORESOURCE_MEM | resource_flags;
198 insert_resource(&iomem_resource, res); 201 insert_resource(&iomem_resource, res);
199 names += PCI_MMCFG_RESOURCE_NAME_LEN; 202 names += PCI_MMCFG_RESOURCE_NAME_LEN;
200 } 203 }
204
205 /* Mark that the resources have been inserted. */
206 pci_mmcfg_resources_inserted = 1;
201} 207}
202 208
203static void __init pci_mmcfg_reject_broken(int type) 209static void __init pci_mmcfg_reject_broken(int type)
@@ -267,7 +273,43 @@ void __init pci_mmcfg_init(int type)
267 if (type == 1) 273 if (type == 1)
268 unreachable_devices(); 274 unreachable_devices();
269 if (known_bridge) 275 if (known_bridge)
270 pci_mmcfg_insert_resources(); 276 pci_mmcfg_insert_resources(IORESOURCE_BUSY);
271 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF; 277 pci_probe = (pci_probe & ~PCI_PROBE_MASK) | PCI_PROBE_MMCONF;
278 } else {
279 /*
280 * Signal not to attempt to insert mmcfg resources because
281 * the architecture mmcfg setup could not initialize.
282 */
283 pci_mmcfg_resources_inserted = 1;
272 } 284 }
273} 285}
286
287static int __init pci_mmcfg_late_insert_resources(void)
288{
289 /*
290 * If resources are already inserted or we are not using MMCONFIG,
291 * don't insert the resources.
292 */
293 if ((pci_mmcfg_resources_inserted == 1) ||
294 (pci_probe & PCI_PROBE_MMCONF) == 0 ||
295 (pci_mmcfg_config_num == 0) ||
296 (pci_mmcfg_config == NULL) ||
297 (pci_mmcfg_config[0].address == 0))
298 return 1;
299
300 /*
301 * Attempt to insert the mmcfg resources but not with the busy flag
302 * marked so it won't cause request errors when __request_region is
303 * called.
304 */
305 pci_mmcfg_insert_resources(0);
306
307 return 0;
308}
309
310/*
311 * Perform MMCONFIG resource insertion after PCI initialization to allow for
312 * misprogrammed MCFG tables that state larger sizes but actually conflict
313 * with other system resources.
314 */
315late_initcall(pci_mmcfg_late_insert_resources);
diff --git a/arch/i386/xen/time.c b/arch/i386/xen/time.c
index 51fdabf1fd4d..dfd6db69ead5 100644
--- a/arch/i386/xen/time.c
+++ b/arch/i386/xen/time.c
@@ -412,6 +412,7 @@ static void xen_timerop_set_mode(enum clock_event_mode mode,
412 break; 412 break;
413 413
414 case CLOCK_EVT_MODE_ONESHOT: 414 case CLOCK_EVT_MODE_ONESHOT:
415 case CLOCK_EVT_MODE_RESUME:
415 break; 416 break;
416 417
417 case CLOCK_EVT_MODE_UNUSED: 418 case CLOCK_EVT_MODE_UNUSED:
@@ -474,6 +475,8 @@ static void xen_vcpuop_set_mode(enum clock_event_mode mode,
474 HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL)) 475 HYPERVISOR_vcpu_op(VCPUOP_stop_periodic_timer, cpu, NULL))
475 BUG(); 476 BUG();
476 break; 477 break;
478 case CLOCK_EVT_MODE_RESUME:
479 break;
477 } 480 }
478} 481}
479 482
diff --git a/arch/i386/xen/xen-head.S b/arch/i386/xen/xen-head.S
index 2998d55a0017..bc71f3bc4014 100644
--- a/arch/i386/xen/xen-head.S
+++ b/arch/i386/xen/xen-head.S
@@ -7,6 +7,7 @@
7#include <asm/boot.h> 7#include <asm/boot.h>
8#include <xen/interface/elfnote.h> 8#include <xen/interface/elfnote.h>
9 9
10 .section .init.text
10ENTRY(startup_xen) 11ENTRY(startup_xen)
11 movl %esi,xen_start_info 12 movl %esi,xen_start_info
12 cld 13 cld
@@ -19,6 +20,7 @@ ENTRY(hypercall_page)
19 .skip 0x1000 20 .skip 0x1000
20.popsection 21.popsection
21 22
23 .section .text
22 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux") 24 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS, .asciz "linux")
23 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6") 25 ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION, .asciz "2.6")
24 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0") 26 ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION, .asciz "xen-3.0")
diff --git a/arch/ia64/ia32/binfmt_elf32.c b/arch/ia64/ia32/binfmt_elf32.c
index e1189ba1ca5e..1cfab326fb7e 100644
--- a/arch/ia64/ia32/binfmt_elf32.c
+++ b/arch/ia64/ia32/binfmt_elf32.c
@@ -226,7 +226,7 @@ elf32_set_personality (void)
226} 226}
227 227
228static unsigned long 228static unsigned long
229elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type, unsigned long unused) 229elf32_map (struct file *filep, unsigned long addr, struct elf_phdr *eppnt, int prot, int type)
230{ 230{
231 unsigned long pgoff = (eppnt->p_vaddr) & ~IA32_PAGE_MASK; 231 unsigned long pgoff = (eppnt->p_vaddr) & ~IA32_PAGE_MASK;
232 232
diff --git a/arch/m68k/kernel/ints.c b/arch/m68k/kernel/ints.c
index 60d4d75f5798..2b412454cb41 100644
--- a/arch/m68k/kernel/ints.c
+++ b/arch/m68k/kernel/ints.c
@@ -326,6 +326,10 @@ void disable_irq(unsigned int irq)
326 326
327EXPORT_SYMBOL(disable_irq); 327EXPORT_SYMBOL(disable_irq);
328 328
329void disable_irq_nosync(unsigned int irq) __attribute__((alias("disable_irq")));
330
331EXPORT_SYMBOL(disable_irq_nosync);
332
329int m68k_irq_startup(unsigned int irq) 333int m68k_irq_startup(unsigned int irq)
330{ 334{
331 if (irq <= IRQ_AUTO_7) 335 if (irq <= IRQ_AUTO_7)
diff --git a/arch/powerpc/boot/ps3-head.S b/arch/powerpc/boot/ps3-head.S
index 1a6d64a68df5..a55c2735f759 100644
--- a/arch/powerpc/boot/ps3-head.S
+++ b/arch/powerpc/boot/ps3-head.S
@@ -20,6 +20,8 @@
20 20
21#include "ppc_asm.h" 21#include "ppc_asm.h"
22 22
23 .machine "ppc64"
24
23 .text 25 .text
24 26
25/* 27/*
diff --git a/arch/powerpc/boot/ps3-hvcall.S b/arch/powerpc/boot/ps3-hvcall.S
index c8b7df3210d1..585965f7e6a8 100644
--- a/arch/powerpc/boot/ps3-hvcall.S
+++ b/arch/powerpc/boot/ps3-hvcall.S
@@ -20,6 +20,8 @@
20 20
21#include "ppc_asm.h" 21#include "ppc_asm.h"
22 22
23 .machine "ppc64"
24
23/* 25/*
24 * The PS3 hypervisor uses a 64 bit "C" language calling convention. 26 * The PS3 hypervisor uses a 64 bit "C" language calling convention.
25 * The routines here marshal arguments between the 32 bit wrapper 27 * The routines here marshal arguments between the 32 bit wrapper
diff --git a/arch/powerpc/configs/prpmc2800_defconfig b/arch/powerpc/configs/prpmc2800_defconfig
index fb504a714625..858f865f2d59 100644
--- a/arch/powerpc/configs/prpmc2800_defconfig
+++ b/arch/powerpc/configs/prpmc2800_defconfig
@@ -48,7 +48,7 @@ CONFIG_PPC_STD_MMU_32=y
48# CONFIG_PPC_MM_SLICES is not set 48# CONFIG_PPC_MM_SLICES is not set
49# CONFIG_SMP is not set 49# CONFIG_SMP is not set
50CONFIG_NOT_COHERENT_CACHE=y 50CONFIG_NOT_COHERENT_CACHE=y
51CONFIG_CONFIG_CHECK_CACHE_COHERENCY=y 51CONFIG_CHECK_CACHE_COHERENCY=y
52CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config" 52CONFIG_DEFCONFIG_LIST="/lib/modules/$UNAME_RELEASE/.config"
53 53
54# 54#
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c
index 94b4a028232a..fe7d1255e11e 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -166,7 +166,7 @@ int pcibios_add_platform_entries(struct pci_dev *pdev)
166 166
167} 167}
168 168
169char __init *pcibios_setup(char *str) 169char __devinit *pcibios_setup(char *str)
170{ 170{
171 return str; 171 return str;
172} 172}
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index bdcd23d8d8b9..a38197b12d3e 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -1218,7 +1218,7 @@ void of_attach_node(struct device_node *np)
1218 * a reference to the node. The memory associated with the node 1218 * a reference to the node. The memory associated with the node
1219 * is not freed until its refcount goes to zero. 1219 * is not freed until its refcount goes to zero.
1220 */ 1220 */
1221void of_detach_node(const struct device_node *np) 1221void of_detach_node(struct device_node *np)
1222{ 1222{
1223 struct device_node *parent; 1223 struct device_node *parent;
1224 1224
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index d577b71db375..087c92f2a3eb 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -284,7 +284,7 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, int
284 int wait) 284 int wait)
285{ 285{
286 cpumask_t map = CPU_MASK_NONE; 286 cpumask_t map = CPU_MASK_NONE;
287 int ret = -EBUSY; 287 int ret = 0;
288 288
289 if (!cpu_online(cpu)) 289 if (!cpu_online(cpu))
290 return -EINVAL; 290 return -EINVAL;
@@ -292,6 +292,11 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info, int
292 cpu_set(cpu, map); 292 cpu_set(cpu, map);
293 if (cpu != get_cpu()) 293 if (cpu != get_cpu())
294 ret = smp_call_function_map(func,info,nonatomic,wait,map); 294 ret = smp_call_function_map(func,info,nonatomic,wait,map);
295 else {
296 local_irq_disable();
297 func(info);
298 local_irq_enable();
299 }
295 put_cpu(); 300 put_cpu();
296 return ret; 301 return ret;
297} 302}
diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
index 3767211b3d0f..ab3546c5ac3a 100644
--- a/arch/powerpc/mm/fault.c
+++ b/arch/powerpc/mm/fault.c
@@ -283,7 +283,13 @@ good_area:
283 /* protection fault */ 283 /* protection fault */
284 if (error_code & DSISR_PROTFAULT) 284 if (error_code & DSISR_PROTFAULT)
285 goto bad_area; 285 goto bad_area;
286 if (!(vma->vm_flags & VM_EXEC)) 286 /*
287 * Allow execution from readable areas if the MMU does not
288 * provide separate controls over reading and executing.
289 */
290 if (!(vma->vm_flags & VM_EXEC) &&
291 (cpu_has_feature(CPU_FTR_NOEXECUTE) ||
292 !(vma->vm_flags & (VM_READ | VM_WRITE))))
287 goto bad_area; 293 goto bad_area;
288#else 294#else
289 pte_t *ptep; 295 pte_t *ptep;
diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 2ce9491b48d4..bc7b0cedae5e 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -609,7 +609,7 @@ static void demote_segment_4k(struct mm_struct *mm, unsigned long addr)
609 mm->context.sllp = SLB_VSID_USER | mmu_psize_defs[MMU_PAGE_4K].sllp; 609 mm->context.sllp = SLB_VSID_USER | mmu_psize_defs[MMU_PAGE_4K].sllp;
610#endif /* CONFIG_PPC_MM_SLICES */ 610#endif /* CONFIG_PPC_MM_SLICES */
611 611
612#ifdef CONFIG_SPE_BASE 612#ifdef CONFIG_SPU_BASE
613 spu_flush_all_slbs(mm); 613 spu_flush_all_slbs(mm);
614#endif 614#endif
615} 615}
@@ -744,7 +744,7 @@ int hash_page(unsigned long ea, unsigned long access, unsigned long trap)
744 "to 4kB pages because of " 744 "to 4kB pages because of "
745 "non-cacheable mapping\n"); 745 "non-cacheable mapping\n");
746 psize = mmu_vmalloc_psize = MMU_PAGE_4K; 746 psize = mmu_vmalloc_psize = MMU_PAGE_4K;
747#ifdef CONFIG_SPE_BASE 747#ifdef CONFIG_SPU_BASE
748 spu_flush_all_slbs(mm); 748 spu_flush_all_slbs(mm);
749#endif 749#endif
750 } 750 }
diff --git a/arch/powerpc/mm/tlb_32.c b/arch/powerpc/mm/tlb_32.c
index 06c7e77e097a..eb4b512d65fa 100644
--- a/arch/powerpc/mm/tlb_32.c
+++ b/arch/powerpc/mm/tlb_32.c
@@ -26,6 +26,8 @@
26#include <linux/mm.h> 26#include <linux/mm.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/highmem.h> 28#include <linux/highmem.h>
29#include <linux/pagemap.h>
30
29#include <asm/tlbflush.h> 31#include <asm/tlbflush.h>
30#include <asm/tlb.h> 32#include <asm/tlb.h>
31 33
diff --git a/arch/powerpc/platforms/Kconfig.cputype b/arch/powerpc/platforms/Kconfig.cputype
index b8b5fde94668..e4b2aee53a73 100644
--- a/arch/powerpc/platforms/Kconfig.cputype
+++ b/arch/powerpc/platforms/Kconfig.cputype
@@ -215,7 +215,7 @@ config NOT_COHERENT_CACHE
215 depends on 4xx || 8xx || E200 215 depends on 4xx || 8xx || E200
216 default y 216 default y
217 217
218config CONFIG_CHECK_CACHE_COHERENCY 218config CHECK_CACHE_COHERENCY
219 bool 219 bool
220 220
221endmenu 221endmenu
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 7de4e919687b..4100ddc52f02 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -2177,8 +2177,8 @@ struct tree_descr spufs_dir_contents[] = {
2177 { "mbox_stat", &spufs_mbox_stat_fops, 0444, }, 2177 { "mbox_stat", &spufs_mbox_stat_fops, 0444, },
2178 { "ibox_stat", &spufs_ibox_stat_fops, 0444, }, 2178 { "ibox_stat", &spufs_ibox_stat_fops, 0444, },
2179 { "wbox_stat", &spufs_wbox_stat_fops, 0444, }, 2179 { "wbox_stat", &spufs_wbox_stat_fops, 0444, },
2180 { "signal1", &spufs_signal1_fops, 0666, }, 2180 { "signal1", &spufs_signal1_nosched_fops, 0222, },
2181 { "signal2", &spufs_signal2_fops, 0666, }, 2181 { "signal2", &spufs_signal2_nosched_fops, 0222, },
2182 { "signal1_type", &spufs_signal1_type, 0666, }, 2182 { "signal1_type", &spufs_signal1_type, 0666, },
2183 { "signal2_type", &spufs_signal2_type, 0666, }, 2183 { "signal2_type", &spufs_signal2_type, 0666, },
2184 { "cntl", &spufs_cntl_fops, 0666, }, 2184 { "cntl", &spufs_cntl_fops, 0666, },
diff --git a/arch/powerpc/platforms/embedded6xx/Kconfig b/arch/powerpc/platforms/embedded6xx/Kconfig
index bec772674e40..2d12f77e46bc 100644
--- a/arch/powerpc/platforms/embedded6xx/Kconfig
+++ b/arch/powerpc/platforms/embedded6xx/Kconfig
@@ -59,7 +59,7 @@ config MPC10X_BRIDGE
59config MV64X60 59config MV64X60
60 bool 60 bool
61 select PPC_INDIRECT_PCI 61 select PPC_INDIRECT_PCI
62 select CONFIG_CHECK_CACHE_COHERENCY 62 select CHECK_CACHE_COHERENCY
63 63
64config MPC10X_OPENPIC 64config MPC10X_OPENPIC
65 bool 65 bool
diff --git a/arch/powerpc/platforms/ps3/Kconfig b/arch/powerpc/platforms/ps3/Kconfig
index a05079b07696..d4fc74f7bb15 100644
--- a/arch/powerpc/platforms/ps3/Kconfig
+++ b/arch/powerpc/platforms/ps3/Kconfig
@@ -102,4 +102,40 @@ config PS3_STORAGE
102 depends on PPC_PS3 102 depends on PPC_PS3
103 tristate 103 tristate
104 104
105config PS3_DISK
106 tristate "PS3 Disk Storage Driver"
107 depends on PPC_PS3 && BLOCK
108 select PS3_STORAGE
109 help
110 Include support for the PS3 Disk Storage.
111
112 This support is required to access the PS3 hard disk.
113 In general, all users will say Y or M.
114
115config PS3_ROM
116 tristate "PS3 BD/DVD/CD-ROM Storage Driver"
117 depends on PPC_PS3 && SCSI
118 select PS3_STORAGE
119 help
120 Include support for the PS3 ROM Storage.
121
122 This support is required to access the PS3 BD/DVD/CD-ROM drive.
123 In general, all users will say Y or M.
124 Also make sure to say Y or M to "SCSI CDROM support" later.
125
126config PS3_FLASH
127 tristate "PS3 FLASH ROM Storage Driver"
128 depends on PPC_PS3
129 select PS3_STORAGE
130 help
131 Include support for the PS3 FLASH ROM Storage.
132
133 This support is required to access the PS3 FLASH ROM, which
134 contains the boot loader and some boot options.
135 In general, all users will say Y or M.
136
137 As this driver needs a fixed buffer of 256 KiB of memory, it can
138 be disabled on the kernel command line using "ps3flash=off", to
139 not allocate this fixed buffer.
140
105endmenu 141endmenu
diff --git a/arch/powerpc/platforms/pseries/firmware.c b/arch/powerpc/platforms/pseries/firmware.c
index 29bf83bfb1f0..8b18a1c40092 100644
--- a/arch/powerpc/platforms/pseries/firmware.c
+++ b/arch/powerpc/platforms/pseries/firmware.c
@@ -66,24 +66,13 @@ firmware_features_table[FIRMWARE_MAX_FEATURES] = {
66 * device-tree/ibm,hypertas-functions. Ultimately this functionality may 66 * device-tree/ibm,hypertas-functions. Ultimately this functionality may
67 * be moved into prom.c prom_init(). 67 * be moved into prom.c prom_init().
68 */ 68 */
69void __init fw_feature_init(void) 69void __init fw_feature_init(const char *hypertas, unsigned long len)
70{ 70{
71 struct device_node *dn; 71 const char *s;
72 const char *hypertas, *s; 72 int i;
73 int len, i;
74 73
75 DBG(" -> fw_feature_init()\n"); 74 DBG(" -> fw_feature_init()\n");
76 75
77 dn = of_find_node_by_path("/rtas");
78 if (dn == NULL) {
79 printk(KERN_ERR "WARNING! Cannot find RTAS in device-tree!\n");
80 goto out;
81 }
82
83 hypertas = of_get_property(dn, "ibm,hypertas-functions", &len);
84 if (hypertas == NULL)
85 goto out;
86
87 for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) { 76 for (s = hypertas; s < hypertas + len; s += strlen(s) + 1) {
88 for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) { 77 for (i = 0; i < FIRMWARE_MAX_FEATURES; i++) {
89 /* check value against table of strings */ 78 /* check value against table of strings */
@@ -98,7 +87,5 @@ void __init fw_feature_init(void)
98 } 87 }
99 } 88 }
100 89
101out:
102 of_node_put(dn);
103 DBG(" <- fw_feature_init()\n"); 90 DBG(" <- fw_feature_init()\n");
104} 91}
diff --git a/arch/powerpc/platforms/pseries/pseries.h b/arch/powerpc/platforms/pseries/pseries.h
index 61e19f78b923..61136d019554 100644
--- a/arch/powerpc/platforms/pseries/pseries.h
+++ b/arch/powerpc/platforms/pseries/pseries.h
@@ -10,7 +10,7 @@
10#ifndef _PSERIES_PSERIES_H 10#ifndef _PSERIES_PSERIES_H
11#define _PSERIES_PSERIES_H 11#define _PSERIES_PSERIES_H
12 12
13extern void __init fw_feature_init(void); 13extern void __init fw_feature_init(const char *hypertas, unsigned long len);
14 14
15struct pt_regs; 15struct pt_regs;
16 16
diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 59e69f085cb4..f0b7146a110f 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -320,8 +320,6 @@ static void __init pSeries_init_early(void)
320{ 320{
321 DBG(" -> pSeries_init_early()\n"); 321 DBG(" -> pSeries_init_early()\n");
322 322
323 fw_feature_init();
324
325 if (firmware_has_feature(FW_FEATURE_LPAR)) 323 if (firmware_has_feature(FW_FEATURE_LPAR))
326 find_udbg_vterm(); 324 find_udbg_vterm();
327 325
@@ -343,14 +341,21 @@ static int __init pSeries_probe_hypertas(unsigned long node,
343 const char *uname, int depth, 341 const char *uname, int depth,
344 void *data) 342 void *data)
345{ 343{
344 const char *hypertas;
345 unsigned long len;
346
346 if (depth != 1 || 347 if (depth != 1 ||
347 (strcmp(uname, "rtas") != 0 && strcmp(uname, "rtas@0") != 0)) 348 (strcmp(uname, "rtas") != 0 && strcmp(uname, "rtas@0") != 0))
348 return 0; 349 return 0;
350
351 hypertas = of_get_flat_dt_prop(node, "ibm,hypertas-functions", &len);
352 if (!hypertas)
353 return 1;
349 354
350 if (of_get_flat_dt_prop(node, "ibm,hypertas-functions", NULL) != NULL) 355 powerpc_firmware_features |= FW_FEATURE_LPAR;
351 powerpc_firmware_features |= FW_FEATURE_LPAR; 356 fw_feature_init(hypertas, len);
352 357
353 return 1; 358 return 1;
354} 359}
355 360
356static int __init pSeries_probe(void) 361static int __init pSeries_probe(void)
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 75aad38179f0..74c64c0d3b71 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -877,6 +877,8 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
877 877
878 if (hw == mpic->spurious_vec) 878 if (hw == mpic->spurious_vec)
879 return -EINVAL; 879 return -EINVAL;
880 if (mpic->protected && test_bit(hw, mpic->protected))
881 return -EINVAL;
880 882
881#ifdef CONFIG_SMP 883#ifdef CONFIG_SMP
882 else if (hw >= mpic->ipi_vecs[0]) { 884 else if (hw >= mpic->ipi_vecs[0]) {
@@ -1034,6 +1036,25 @@ struct mpic * __init mpic_alloc(struct device_node *node,
1034 if (node && of_get_property(node, "big-endian", NULL) != NULL) 1036 if (node && of_get_property(node, "big-endian", NULL) != NULL)
1035 mpic->flags |= MPIC_BIG_ENDIAN; 1037 mpic->flags |= MPIC_BIG_ENDIAN;
1036 1038
1039 /* Look for protected sources */
1040 if (node) {
1041 unsigned int psize, bits, mapsize;
1042 const u32 *psrc =
1043 of_get_property(node, "protected-sources", &psize);
1044 if (psrc) {
1045 psize /= 4;
1046 bits = intvec_top + 1;
1047 mapsize = BITS_TO_LONGS(bits) * sizeof(unsigned long);
1048 mpic->protected = alloc_bootmem(mapsize);
1049 BUG_ON(mpic->protected == NULL);
1050 memset(mpic->protected, 0, mapsize);
1051 for (i = 0; i < psize; i++) {
1052 if (psrc[i] > intvec_top)
1053 continue;
1054 __set_bit(psrc[i], mpic->protected);
1055 }
1056 }
1057 }
1037 1058
1038#ifdef CONFIG_MPIC_WEIRD 1059#ifdef CONFIG_MPIC_WEIRD
1039 mpic->hw_set = mpic_infos[MPIC_GET_REGSET(flags)]; 1060 mpic->hw_set = mpic_infos[MPIC_GET_REGSET(flags)];
@@ -1213,6 +1234,9 @@ void __init mpic_init(struct mpic *mpic)
1213 u32 vecpri = MPIC_VECPRI_MASK | i | 1234 u32 vecpri = MPIC_VECPRI_MASK | i |
1214 (8 << MPIC_VECPRI_PRIORITY_SHIFT); 1235 (8 << MPIC_VECPRI_PRIORITY_SHIFT);
1215 1236
1237 /* check if protected */
1238 if (mpic->protected && test_bit(i, mpic->protected))
1239 continue;
1216 /* init hw */ 1240 /* init hw */
1217 mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri); 1241 mpic_irq_write(i, MPIC_INFO(IRQ_VECTOR_PRI), vecpri);
1218 mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION), 1242 mpic_irq_write(i, MPIC_INFO(IRQ_DESTINATION),
@@ -1407,6 +1431,14 @@ unsigned int mpic_get_one_irq(struct mpic *mpic)
1407 mpic_eoi(mpic); 1431 mpic_eoi(mpic);
1408 return NO_IRQ; 1432 return NO_IRQ;
1409 } 1433 }
1434 if (unlikely(mpic->protected && test_bit(src, mpic->protected))) {
1435 if (printk_ratelimit())
1436 printk(KERN_WARNING "%s: Got protected source %d !\n",
1437 mpic->name, (int)src);
1438 mpic_eoi(mpic);
1439 return NO_IRQ;
1440 }
1441
1410 return irq_linear_revmap(mpic->irqhost, src); 1442 return irq_linear_revmap(mpic->irqhost, src);
1411} 1443}
1412 1444
diff --git a/arch/powerpc/xmon/nonstdio.c b/arch/powerpc/xmon/nonstdio.c
index 78765833f4c0..bfac84fbe780 100644
--- a/arch/powerpc/xmon/nonstdio.c
+++ b/arch/powerpc/xmon/nonstdio.c
@@ -132,3 +132,8 @@ void xmon_printf(const char *format, ...)
132 va_end(args); 132 va_end(args);
133 xmon_write(xmon_outbuf, n); 133 xmon_write(xmon_outbuf, n);
134} 134}
135
136void xmon_puts(const char *str)
137{
138 xmon_write(str, strlen(str));
139}
diff --git a/arch/powerpc/xmon/nonstdio.h b/arch/powerpc/xmon/nonstdio.h
index 47cebbd2b1b1..23dd95f4599c 100644
--- a/arch/powerpc/xmon/nonstdio.h
+++ b/arch/powerpc/xmon/nonstdio.h
@@ -5,10 +5,11 @@
5 5
6extern int xmon_putchar(int c); 6extern int xmon_putchar(int c);
7extern int xmon_getchar(void); 7extern int xmon_getchar(void);
8extern void xmon_puts(const char *);
8extern char *xmon_gets(char *, int); 9extern char *xmon_gets(char *, int);
9extern void xmon_printf(const char *, ...); 10extern void xmon_printf(const char *, ...);
10extern void xmon_map_scc(void); 11extern void xmon_map_scc(void);
11extern int xmon_expect(const char *str, unsigned long timeout); 12extern int xmon_expect(const char *str, unsigned long timeout);
12extern int xmon_write(void *ptr, int nb); 13extern int xmon_write(const void *ptr, int nb);
13extern int xmon_readchar(void); 14extern int xmon_readchar(void);
14extern int xmon_read_poll(void); 15extern int xmon_read_poll(void);
diff --git a/arch/powerpc/xmon/start.c b/arch/powerpc/xmon/start.c
index 712552c4f242..8864de2af382 100644
--- a/arch/powerpc/xmon/start.c
+++ b/arch/powerpc/xmon/start.c
@@ -14,7 +14,7 @@ void xmon_map_scc(void)
14{ 14{
15} 15}
16 16
17int xmon_write(void *ptr, int nb) 17int xmon_write(const void *ptr, int nb)
18{ 18{
19 return udbg_write(ptr, nb); 19 return udbg_write(ptr, nb);
20} 20}
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 669e6566ad70..121b04d165d1 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -833,7 +833,7 @@ cmds(struct pt_regs *excp)
833 mdelay(2000); 833 mdelay(2000);
834 return cmd; 834 return cmd;
835 case '?': 835 case '?':
836 printf(help_string); 836 xmon_puts(help_string);
837 break; 837 break;
838 case 'b': 838 case 'b':
839 bpt_cmds(); 839 bpt_cmds();
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c
index 032f4b7f4225..d212b1c418a9 100644
--- a/arch/ppc/syslib/mv64x60.c
+++ b/arch/ppc/syslib/mv64x60.c
@@ -14,6 +14,7 @@
14#include <linux/pci.h> 14#include <linux/pci.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/mutex.h>
17#include <linux/string.h> 18#include <linux/string.h>
18#include <linux/spinlock.h> 19#include <linux/spinlock.h>
19#include <linux/mv643xx.h> 20#include <linux/mv643xx.h>
@@ -2359,7 +2360,7 @@ mv64460_chip_specific_init(struct mv64x60_handle *bh,
2359/* Export the hotswap register via sysfs for enum event monitoring */ 2360/* Export the hotswap register via sysfs for enum event monitoring */
2360#define VAL_LEN_MAX 11 /* 32-bit hex or dec stringified number + '\n' */ 2361#define VAL_LEN_MAX 11 /* 32-bit hex or dec stringified number + '\n' */
2361 2362
2362DECLARE_MUTEX(mv64xxx_hs_lock); 2363static DEFINE_MUTEX(mv64xxx_hs_lock);
2363 2364
2364static ssize_t 2365static ssize_t
2365mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count) 2366mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
@@ -2372,14 +2373,14 @@ mv64xxx_hs_reg_read(struct kobject *kobj, char *buf, loff_t off, size_t count)
2372 if (count < VAL_LEN_MAX) 2373 if (count < VAL_LEN_MAX)
2373 return -EINVAL; 2374 return -EINVAL;
2374 2375
2375 if (down_interruptible(&mv64xxx_hs_lock)) 2376 if (mutex_lock_interruptible(&mv64xxx_hs_lock))
2376 return -ERESTARTSYS; 2377 return -ERESTARTSYS;
2377 save_exclude = mv64x60_pci_exclude_bridge; 2378 save_exclude = mv64x60_pci_exclude_bridge;
2378 mv64x60_pci_exclude_bridge = 0; 2379 mv64x60_pci_exclude_bridge = 0;
2379 early_read_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0), 2380 early_read_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
2380 MV64360_PCICFG_CPCI_HOTSWAP, &v); 2381 MV64360_PCICFG_CPCI_HOTSWAP, &v);
2381 mv64x60_pci_exclude_bridge = save_exclude; 2382 mv64x60_pci_exclude_bridge = save_exclude;
2382 up(&mv64xxx_hs_lock); 2383 mutex_unlock(&mv64xxx_hs_lock);
2383 2384
2384 return sprintf(buf, "0x%08x\n", v); 2385 return sprintf(buf, "0x%08x\n", v);
2385} 2386}
@@ -2396,14 +2397,14 @@ mv64xxx_hs_reg_write(struct kobject *kobj, char *buf, loff_t off, size_t count)
2396 return -EINVAL; 2397 return -EINVAL;
2397 2398
2398 if (sscanf(buf, "%i", &v) == 1) { 2399 if (sscanf(buf, "%i", &v) == 1) {
2399 if (down_interruptible(&mv64xxx_hs_lock)) 2400 if (mutex_lock_interruptible(&mv64xxx_hs_lock))
2400 return -ERESTARTSYS; 2401 return -ERESTARTSYS;
2401 save_exclude = mv64x60_pci_exclude_bridge; 2402 save_exclude = mv64x60_pci_exclude_bridge;
2402 mv64x60_pci_exclude_bridge = 0; 2403 mv64x60_pci_exclude_bridge = 0;
2403 early_write_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0), 2404 early_write_config_dword(&sysfs_hose_a, 0, PCI_DEVFN(0, 0),
2404 MV64360_PCICFG_CPCI_HOTSWAP, v); 2405 MV64360_PCICFG_CPCI_HOTSWAP, v);
2405 mv64x60_pci_exclude_bridge = save_exclude; 2406 mv64x60_pci_exclude_bridge = save_exclude;
2406 up(&mv64xxx_hs_lock); 2407 mutex_unlock(&mv64xxx_hs_lock);
2407 } 2408 }
2408 else 2409 else
2409 count = -EINVAL; 2410 count = -EINVAL;
@@ -2433,10 +2434,10 @@ mv64xxx_hs_reg_valid_show(struct device *dev, struct device_attribute *attr,
2433 pdev = container_of(dev, struct platform_device, dev); 2434 pdev = container_of(dev, struct platform_device, dev);
2434 pdp = (struct mv64xxx_pdata *)pdev->dev.platform_data; 2435 pdp = (struct mv64xxx_pdata *)pdev->dev.platform_data;
2435 2436
2436 if (down_interruptible(&mv64xxx_hs_lock)) 2437 if (mutex_lock_interruptible(&mv64xxx_hs_lock))
2437 return -ERESTARTSYS; 2438 return -ERESTARTSYS;
2438 v = pdp->hs_reg_valid; 2439 v = pdp->hs_reg_valid;
2439 up(&mv64xxx_hs_lock); 2440 mutex_unlock(&mv64xxx_hs_lock);
2440 2441
2441 return sprintf(buf, "%i\n", v); 2442 return sprintf(buf, "%i\n", v);
2442} 2443}
diff --git a/arch/sh/kernel/timers/timer-tmu.c b/arch/sh/kernel/timers/timer-tmu.c
index 097ebd49f1bf..7aca37d79766 100644
--- a/arch/sh/kernel/timers/timer-tmu.c
+++ b/arch/sh/kernel/timers/timer-tmu.c
@@ -80,6 +80,7 @@ static void tmu_set_mode(enum clock_event_mode mode,
80 break; 80 break;
81 case CLOCK_EVT_MODE_UNUSED: 81 case CLOCK_EVT_MODE_UNUSED:
82 case CLOCK_EVT_MODE_SHUTDOWN: 82 case CLOCK_EVT_MODE_SHUTDOWN:
83 case CLOCK_EVT_MODE_RESUME:
83 break; 84 break;
84 } 85 }
85} 86}
diff --git a/arch/sparc/kernel/entry.S b/arch/sparc/kernel/entry.S
index 831f540251f8..eac38388f5fd 100644
--- a/arch/sparc/kernel/entry.S
+++ b/arch/sparc/kernel/entry.S
@@ -1749,8 +1749,8 @@ fpload:
1749__ndelay: 1749__ndelay:
1750 save %sp, -STACKFRAME_SZ, %sp 1750 save %sp, -STACKFRAME_SZ, %sp
1751 mov %i0, %o0 1751 mov %i0, %o0
1752 call .umul 1752 call .umul ! round multiplier up so large ns ok
1753 mov 0x1ad, %o1 ! 2**32 / (1 000 000 000 / HZ) 1753 mov 0x1ae, %o1 ! 2**32 / (1 000 000 000 / HZ)
1754 call .umul 1754 call .umul
1755 mov %i1, %o1 ! udelay_val 1755 mov %i1, %o1 ! udelay_val
1756 ba delay_continue 1756 ba delay_continue
@@ -1760,11 +1760,17 @@ __ndelay:
1760__udelay: 1760__udelay:
1761 save %sp, -STACKFRAME_SZ, %sp 1761 save %sp, -STACKFRAME_SZ, %sp
1762 mov %i0, %o0 1762 mov %i0, %o0
1763 sethi %hi(0x10c6), %o1 1763 sethi %hi(0x10c7), %o1 ! round multiplier up so large us ok
1764 call .umul 1764 call .umul
1765 or %o1, %lo(0x10c6), %o1 ! 2**32 / 1 000 000 1765 or %o1, %lo(0x10c7), %o1 ! 2**32 / 1 000 000
1766 call .umul 1766 call .umul
1767 mov %i1, %o1 ! udelay_val 1767 mov %i1, %o1 ! udelay_val
1768 sethi %hi(0x028f4b62), %l0 ! Add in rounding constant * 2**32,
1769 or %g0, %lo(0x028f4b62), %l0
1770 addcc %o0, %l0, %o0 ! 2**32 * 0.009 999
1771 bcs,a 3f
1772 add %o1, 0x01, %o1
17733:
1768 call .umul 1774 call .umul
1769 mov HZ, %o0 ! >>32 earlier for wider range 1775 mov HZ, %o0 ! >>32 earlier for wider range
1770 1776
diff --git a/arch/sparc/kernel/irq.c b/arch/sparc/kernel/irq.c
index f257a67bcf93..75b2240ad0f9 100644
--- a/arch/sparc/kernel/irq.c
+++ b/arch/sparc/kernel/irq.c
@@ -47,6 +47,8 @@
47#include <asm/cacheflush.h> 47#include <asm/cacheflush.h>
48#include <asm/irq_regs.h> 48#include <asm/irq_regs.h>
49 49
50#include "irq.h"
51
50#ifdef CONFIG_SMP 52#ifdef CONFIG_SMP
51#define SMP_NOP2 "nop; nop;\n\t" 53#define SMP_NOP2 "nop; nop;\n\t"
52#define SMP_NOP3 "nop; nop; nop;\n\t" 54#define SMP_NOP3 "nop; nop; nop;\n\t"
@@ -268,7 +270,7 @@ void free_irq(unsigned int irq, void *dev_id)
268 kfree(action); 270 kfree(action);
269 271
270 if (!sparc_irq[cpu_irq].action) 272 if (!sparc_irq[cpu_irq].action)
271 disable_irq(irq); 273 __disable_irq(irq);
272 274
273out_unlock: 275out_unlock:
274 spin_unlock_irqrestore(&irq_action_lock, flags); 276 spin_unlock_irqrestore(&irq_action_lock, flags);
@@ -464,7 +466,7 @@ int request_fast_irq(unsigned int irq,
464 466
465 sparc_irq[cpu_irq].action = action; 467 sparc_irq[cpu_irq].action = action;
466 468
467 enable_irq(irq); 469 __enable_irq(irq);
468 470
469 ret = 0; 471 ret = 0;
470out_unlock: 472out_unlock:
@@ -544,7 +546,7 @@ int request_irq(unsigned int irq,
544 546
545 *actionp = action; 547 *actionp = action;
546 548
547 enable_irq(irq); 549 __enable_irq(irq);
548 550
549 ret = 0; 551 ret = 0;
550out_unlock: 552out_unlock:
@@ -555,6 +557,25 @@ out:
555 557
556EXPORT_SYMBOL(request_irq); 558EXPORT_SYMBOL(request_irq);
557 559
560void disable_irq_nosync(unsigned int irq)
561{
562 return __disable_irq(irq);
563}
564EXPORT_SYMBOL(disable_irq_nosync);
565
566void disable_irq(unsigned int irq)
567{
568 return __disable_irq(irq);
569}
570EXPORT_SYMBOL(disable_irq);
571
572void enable_irq(unsigned int irq)
573{
574 return __enable_irq(irq);
575}
576
577EXPORT_SYMBOL(enable_irq);
578
558/* We really don't need these at all on the Sparc. We only have 579/* We really don't need these at all on the Sparc. We only have
559 * stubs here because they are exported to modules. 580 * stubs here because they are exported to modules.
560 */ 581 */
diff --git a/arch/sparc/kernel/irq.h b/arch/sparc/kernel/irq.h
new file mode 100644
index 000000000000..32ef3ebd0a88
--- /dev/null
+++ b/arch/sparc/kernel/irq.h
@@ -0,0 +1,68 @@
1#include <asm/btfixup.h>
2
3/* Dave Redman (djhr@tadpole.co.uk)
4 * changed these to function pointers.. it saves cycles and will allow
5 * the irq dependencies to be split into different files at a later date
6 * sun4c_irq.c, sun4m_irq.c etc so we could reduce the kernel size.
7 * Jakub Jelinek (jj@sunsite.mff.cuni.cz)
8 * Changed these to btfixup entities... It saves cycles :)
9 */
10
11BTFIXUPDEF_CALL(void, disable_irq, unsigned int)
12BTFIXUPDEF_CALL(void, enable_irq, unsigned int)
13BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int)
14BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int)
15BTFIXUPDEF_CALL(void, clear_clock_irq, void)
16BTFIXUPDEF_CALL(void, clear_profile_irq, int)
17BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int)
18
19static inline void __disable_irq(unsigned int irq)
20{
21 BTFIXUP_CALL(disable_irq)(irq);
22}
23
24static inline void __enable_irq(unsigned int irq)
25{
26 BTFIXUP_CALL(enable_irq)(irq);
27}
28
29static inline void disable_pil_irq(unsigned int irq)
30{
31 BTFIXUP_CALL(disable_pil_irq)(irq);
32}
33
34static inline void enable_pil_irq(unsigned int irq)
35{
36 BTFIXUP_CALL(enable_pil_irq)(irq);
37}
38
39static inline void clear_clock_irq(void)
40{
41 BTFIXUP_CALL(clear_clock_irq)();
42}
43
44static inline void clear_profile_irq(int irq)
45{
46 BTFIXUP_CALL(clear_profile_irq)(irq);
47}
48
49static inline void load_profile_irq(int cpu, int limit)
50{
51 BTFIXUP_CALL(load_profile_irq)(cpu, limit);
52}
53
54extern void (*sparc_init_timers)(irq_handler_t lvl10_irq);
55
56extern void claim_ticker14(irq_handler_t irq_handler,
57 int irq,
58 unsigned int timeout);
59
60#ifdef CONFIG_SMP
61BTFIXUPDEF_CALL(void, set_cpu_int, int, int)
62BTFIXUPDEF_CALL(void, clear_cpu_int, int, int)
63BTFIXUPDEF_CALL(void, set_irq_udt, int)
64
65#define set_cpu_int(cpu,level) BTFIXUP_CALL(set_cpu_int)(cpu,level)
66#define clear_cpu_int(cpu,level) BTFIXUP_CALL(clear_cpu_int)(cpu,level)
67#define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)
68#endif
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c
index 791771196905..f2eae457fc9a 100644
--- a/arch/sparc/kernel/pcic.c
+++ b/arch/sparc/kernel/pcic.c
@@ -36,6 +36,7 @@
36#include <asm/uaccess.h> 36#include <asm/uaccess.h>
37#include <asm/irq_regs.h> 37#include <asm/irq_regs.h>
38 38
39#include "irq.h"
39 40
40/* 41/*
41 * I studied different documents and many live PROMs both from 2.30 42 * I studied different documents and many live PROMs both from 2.30
diff --git a/arch/sparc/kernel/smp.c b/arch/sparc/kernel/smp.c
index 4fea3ac7bff0..6724ab90f82b 100644
--- a/arch/sparc/kernel/smp.c
+++ b/arch/sparc/kernel/smp.c
@@ -33,6 +33,8 @@
33#include <asm/tlbflush.h> 33#include <asm/tlbflush.h>
34#include <asm/cpudata.h> 34#include <asm/cpudata.h>
35 35
36#include "irq.h"
37
36int smp_num_cpus = 1; 38int smp_num_cpus = 1;
37volatile unsigned long cpu_callin_map[NR_CPUS] __initdata = {0,}; 39volatile unsigned long cpu_callin_map[NR_CPUS] __initdata = {0,};
38unsigned char boot_cpu_id = 0; 40unsigned char boot_cpu_id = 0;
diff --git a/arch/sparc/kernel/sparc_ksyms.c b/arch/sparc/kernel/sparc_ksyms.c
index d8e008a04e2b..55bac516dfe2 100644
--- a/arch/sparc/kernel/sparc_ksyms.c
+++ b/arch/sparc/kernel/sparc_ksyms.c
@@ -154,8 +154,6 @@ EXPORT_SYMBOL(BTFIXUP_CALL(___xchg32));
154#else 154#else
155EXPORT_SYMBOL(BTFIXUP_CALL(__hard_smp_processor_id)); 155EXPORT_SYMBOL(BTFIXUP_CALL(__hard_smp_processor_id));
156#endif 156#endif
157EXPORT_SYMBOL(BTFIXUP_CALL(enable_irq));
158EXPORT_SYMBOL(BTFIXUP_CALL(disable_irq));
159EXPORT_SYMBOL(BTFIXUP_CALL(mmu_unlockarea)); 157EXPORT_SYMBOL(BTFIXUP_CALL(mmu_unlockarea));
160EXPORT_SYMBOL(BTFIXUP_CALL(mmu_lockarea)); 158EXPORT_SYMBOL(BTFIXUP_CALL(mmu_lockarea));
161EXPORT_SYMBOL(BTFIXUP_CALL(mmu_get_scsi_sgl)); 159EXPORT_SYMBOL(BTFIXUP_CALL(mmu_get_scsi_sgl));
diff --git a/arch/sparc/kernel/sun4c_irq.c b/arch/sparc/kernel/sun4c_irq.c
index 009e891a4329..c6ac9fc52563 100644
--- a/arch/sparc/kernel/sun4c_irq.c
+++ b/arch/sparc/kernel/sun4c_irq.c
@@ -18,6 +18,7 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/slab.h> 19#include <linux/slab.h>
20#include <linux/init.h> 20#include <linux/init.h>
21#include "irq.h"
21 22
22#include <asm/ptrace.h> 23#include <asm/ptrace.h>
23#include <asm/processor.h> 24#include <asm/processor.h>
@@ -40,6 +41,20 @@ static struct resource sun4c_timer_eb = { "sun4c_timer" };
40static struct resource sun4c_intr_eb = { "sun4c_intr" }; 41static struct resource sun4c_intr_eb = { "sun4c_intr" };
41#endif 42#endif
42 43
44/*
45 * Bit field defines for the interrupt registers on various
46 * Sparc machines.
47 */
48
49/* The sun4c interrupt register. */
50#define SUN4C_INT_ENABLE 0x01 /* Allow interrupts. */
51#define SUN4C_INT_E14 0x80 /* Enable level 14 IRQ. */
52#define SUN4C_INT_E10 0x20 /* Enable level 10 IRQ. */
53#define SUN4C_INT_E8 0x10 /* Enable level 8 IRQ. */
54#define SUN4C_INT_E6 0x08 /* Enable level 6 IRQ. */
55#define SUN4C_INT_E4 0x04 /* Enable level 4 IRQ. */
56#define SUN4C_INT_E1 0x02 /* Enable level 1 IRQ. */
57
43/* Pointer to the interrupt enable byte 58/* Pointer to the interrupt enable byte
44 * 59 *
45 * Dave Redman (djhr@tadpole.co.uk) 60 * Dave Redman (djhr@tadpole.co.uk)
diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c
index 396797e20c39..e0efab2a6bef 100644
--- a/arch/sparc/kernel/sun4d_irq.c
+++ b/arch/sparc/kernel/sun4d_irq.c
@@ -39,6 +39,8 @@
39#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
40#include <asm/irq_regs.h> 40#include <asm/irq_regs.h>
41 41
42#include "irq.h"
43
42/* If you trust current SCSI layer to handle different SCSI IRQs, enable this. I don't trust it... -jj */ 44/* If you trust current SCSI layer to handle different SCSI IRQs, enable this. I don't trust it... -jj */
43/* #define DISTRIBUTE_IRQS */ 45/* #define DISTRIBUTE_IRQS */
44 46
@@ -188,7 +190,7 @@ void sun4d_free_irq(unsigned int irq, void *dev_id)
188 kfree(action); 190 kfree(action);
189 191
190 if (!(*actionp)) 192 if (!(*actionp))
191 disable_irq(irq); 193 __disable_irq(irq);
192 194
193out_unlock: 195out_unlock:
194 spin_unlock_irqrestore(&irq_action_lock, flags); 196 spin_unlock_irqrestore(&irq_action_lock, flags);
@@ -346,7 +348,7 @@ int sun4d_request_irq(unsigned int irq,
346 else 348 else
347 *actionp = action; 349 *actionp = action;
348 350
349 enable_irq(irq); 351 __enable_irq(irq);
350 352
351 ret = 0; 353 ret = 0;
352out_unlock: 354out_unlock:
diff --git a/arch/sparc/kernel/sun4d_smp.c b/arch/sparc/kernel/sun4d_smp.c
index 098c94f1a322..89a6de95070c 100644
--- a/arch/sparc/kernel/sun4d_smp.c
+++ b/arch/sparc/kernel/sun4d_smp.c
@@ -36,6 +36,7 @@
36#include <asm/cacheflush.h> 36#include <asm/cacheflush.h>
37#include <asm/cpudata.h> 37#include <asm/cpudata.h>
38 38
39#include "irq.h"
39#define IRQ_CROSS_CALL 15 40#define IRQ_CROSS_CALL 15
40 41
41extern ctxd_t *srmmu_ctx_table_phys; 42extern ctxd_t *srmmu_ctx_table_phys;
diff --git a/arch/sparc/kernel/sun4m_irq.c b/arch/sparc/kernel/sun4m_irq.c
index 91a803ea88be..b92d6d2d5b04 100644
--- a/arch/sparc/kernel/sun4m_irq.c
+++ b/arch/sparc/kernel/sun4m_irq.c
@@ -38,11 +38,85 @@
38#include <asm/sbus.h> 38#include <asm/sbus.h>
39#include <asm/cacheflush.h> 39#include <asm/cacheflush.h>
40 40
41#include "irq.h"
42
43/* On the sun4m, just like the timers, we have both per-cpu and master
44 * interrupt registers.
45 */
46
47/* These registers are used for sending/receiving irqs from/to
48 * different cpu's.
49 */
50struct sun4m_intreg_percpu {
51 unsigned int tbt; /* Interrupts still pending for this cpu. */
52
53 /* These next two registers are WRITE-ONLY and are only
54 * "on bit" sensitive, "off bits" written have NO affect.
55 */
56 unsigned int clear; /* Clear this cpus irqs here. */
57 unsigned int set; /* Set this cpus irqs here. */
58 unsigned char space[PAGE_SIZE - 12];
59};
60
61/*
62 * djhr
63 * Actually the clear and set fields in this struct are misleading..
64 * according to the SLAVIO manual (and the same applies for the SEC)
65 * the clear field clears bits in the mask which will ENABLE that IRQ
66 * the set field sets bits in the mask to DISABLE the IRQ.
67 *
68 * Also the undirected_xx address in the SLAVIO is defined as
69 * RESERVED and write only..
70 *
71 * DAVEM_NOTE: The SLAVIO only specifies behavior on uniprocessor
72 * sun4m machines, for MP the layout makes more sense.
73 */
74struct sun4m_intregs {
75 struct sun4m_intreg_percpu cpu_intregs[SUN4M_NCPUS];
76 unsigned int tbt; /* IRQ's that are still pending. */
77 unsigned int irqs; /* Master IRQ bits. */
78
79 /* Again, like the above, two these registers are WRITE-ONLY. */
80 unsigned int clear; /* Clear master IRQ's by setting bits here. */
81 unsigned int set; /* Set master IRQ's by setting bits here. */
82
83 /* This register is both READ and WRITE. */
84 unsigned int undirected_target; /* Which cpu gets undirected irqs. */
85};
86
41static unsigned long dummy; 87static unsigned long dummy;
42 88
43struct sun4m_intregs *sun4m_interrupts; 89struct sun4m_intregs *sun4m_interrupts;
44unsigned long *irq_rcvreg = &dummy; 90unsigned long *irq_rcvreg = &dummy;
45 91
92/* Dave Redman (djhr@tadpole.co.uk)
93 * The sun4m interrupt registers.
94 */
95#define SUN4M_INT_ENABLE 0x80000000
96#define SUN4M_INT_E14 0x00000080
97#define SUN4M_INT_E10 0x00080000
98
99#define SUN4M_HARD_INT(x) (0x000000001 << (x))
100#define SUN4M_SOFT_INT(x) (0x000010000 << (x))
101
102#define SUN4M_INT_MASKALL 0x80000000 /* mask all interrupts */
103#define SUN4M_INT_MODULE_ERR 0x40000000 /* module error */
104#define SUN4M_INT_M2S_WRITE 0x20000000 /* write buffer error */
105#define SUN4M_INT_ECC 0x10000000 /* ecc memory error */
106#define SUN4M_INT_FLOPPY 0x00400000 /* floppy disk */
107#define SUN4M_INT_MODULE 0x00200000 /* module interrupt */
108#define SUN4M_INT_VIDEO 0x00100000 /* onboard video */
109#define SUN4M_INT_REALTIME 0x00080000 /* system timer */
110#define SUN4M_INT_SCSI 0x00040000 /* onboard scsi */
111#define SUN4M_INT_AUDIO 0x00020000 /* audio/isdn */
112#define SUN4M_INT_ETHERNET 0x00010000 /* onboard ethernet */
113#define SUN4M_INT_SERIAL 0x00008000 /* serial ports */
114#define SUN4M_INT_KBDMS 0x00004000 /* keyboard/mouse */
115#define SUN4M_INT_SBUSBITS 0x00003F80 /* sbus int bits */
116
117#define SUN4M_INT_SBUS(x) (1 << (x+7))
118#define SUN4M_INT_VME(x) (1 << (x))
119
46/* These tables only apply for interrupts greater than 15.. 120/* These tables only apply for interrupts greater than 15..
47 * 121 *
48 * any intr value below 0x10 is considered to be a soft-int 122 * any intr value below 0x10 is considered to be a soft-int
diff --git a/arch/sparc/kernel/sun4m_smp.c b/arch/sparc/kernel/sun4m_smp.c
index 63ed19bfd028..730eb5796f8e 100644
--- a/arch/sparc/kernel/sun4m_smp.c
+++ b/arch/sparc/kernel/sun4m_smp.c
@@ -31,6 +31,8 @@
31#include <asm/oplib.h> 31#include <asm/oplib.h>
32#include <asm/cpudata.h> 32#include <asm/cpudata.h>
33 33
34#include "irq.h"
35
34#define IRQ_RESCHEDULE 13 36#define IRQ_RESCHEDULE 13
35#define IRQ_STOP_CPU 14 37#define IRQ_STOP_CPU 14
36#define IRQ_CROSS_CALL 15 38#define IRQ_CROSS_CALL 15
diff --git a/arch/sparc/kernel/tick14.c b/arch/sparc/kernel/tick14.c
index f1a7bd19e04f..707bfda86570 100644
--- a/arch/sparc/kernel/tick14.c
+++ b/arch/sparc/kernel/tick14.c
@@ -25,6 +25,8 @@
25#include <asm/irq.h> 25#include <asm/irq.h>
26#include <asm/io.h> 26#include <asm/io.h>
27 27
28#include "irq.h"
29
28extern unsigned long lvl14_save[5]; 30extern unsigned long lvl14_save[5];
29static unsigned long *linux_lvl14 = NULL; 31static unsigned long *linux_lvl14 = NULL;
30static unsigned long obp_lvl14[4]; 32static unsigned long obp_lvl14[4];
@@ -62,7 +64,7 @@ void claim_ticker14(irq_handler_t handler,
62 64
63 /* first we copy the obp handler instructions 65 /* first we copy the obp handler instructions
64 */ 66 */
65 disable_irq(irq_nr); 67 __disable_irq(irq_nr);
66 if (!handler) 68 if (!handler)
67 return; 69 return;
68 70
@@ -79,6 +81,6 @@ void claim_ticker14(irq_handler_t handler,
79 NULL)) { 81 NULL)) {
80 install_linux_ticker(); 82 install_linux_ticker();
81 load_profile_irq(cpu, timeout); 83 load_profile_irq(cpu, timeout);
82 enable_irq(irq_nr); 84 __enable_irq(irq_nr);
83 } 85 }
84} 86}
diff --git a/arch/sparc/kernel/time.c b/arch/sparc/kernel/time.c
index f2fdbb3664d3..6a2513321620 100644
--- a/arch/sparc/kernel/time.c
+++ b/arch/sparc/kernel/time.c
@@ -44,6 +44,8 @@
44#include <asm/of_device.h> 44#include <asm/of_device.h>
45#include <asm/irq_regs.h> 45#include <asm/irq_regs.h>
46 46
47#include "irq.h"
48
47DEFINE_SPINLOCK(rtc_lock); 49DEFINE_SPINLOCK(rtc_lock);
48enum sparc_clock_type sp_clock_typ; 50enum sparc_clock_type sp_clock_typ;
49DEFINE_SPINLOCK(mostek_lock); 51DEFINE_SPINLOCK(mostek_lock);
diff --git a/arch/sparc/mm/init.c b/arch/sparc/mm/init.c
index a532922e2e35..a1bef07755a9 100644
--- a/arch/sparc/mm/init.c
+++ b/arch/sparc/mm/init.c
@@ -308,6 +308,9 @@ extern void sun4c_paging_init(void);
308extern void srmmu_paging_init(void); 308extern void srmmu_paging_init(void);
309extern void device_scan(void); 309extern void device_scan(void);
310 310
311pgprot_t PAGE_SHARED __read_mostly;
312EXPORT_SYMBOL(PAGE_SHARED);
313
311void __init paging_init(void) 314void __init paging_init(void)
312{ 315{
313 switch(sparc_cpu_model) { 316 switch(sparc_cpu_model) {
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index ca26232da7ab..17b485f2825c 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -2154,7 +2154,7 @@ void __init ld_mmu_srmmu(void)
2154 BTFIXUPSET_SIMM13(ptrs_per_pgd, SRMMU_PTRS_PER_PGD); 2154 BTFIXUPSET_SIMM13(ptrs_per_pgd, SRMMU_PTRS_PER_PGD);
2155 2155
2156 BTFIXUPSET_INT(page_none, pgprot_val(SRMMU_PAGE_NONE)); 2156 BTFIXUPSET_INT(page_none, pgprot_val(SRMMU_PAGE_NONE));
2157 BTFIXUPSET_INT(page_shared, pgprot_val(SRMMU_PAGE_SHARED)); 2157 PAGE_SHARED = pgprot_val(SRMMU_PAGE_SHARED);
2158 BTFIXUPSET_INT(page_copy, pgprot_val(SRMMU_PAGE_COPY)); 2158 BTFIXUPSET_INT(page_copy, pgprot_val(SRMMU_PAGE_COPY));
2159 BTFIXUPSET_INT(page_readonly, pgprot_val(SRMMU_PAGE_RDONLY)); 2159 BTFIXUPSET_INT(page_readonly, pgprot_val(SRMMU_PAGE_RDONLY));
2160 BTFIXUPSET_INT(page_kernel, pgprot_val(SRMMU_PAGE_KERNEL)); 2160 BTFIXUPSET_INT(page_kernel, pgprot_val(SRMMU_PAGE_KERNEL));
diff --git a/arch/sparc/mm/sun4c.c b/arch/sparc/mm/sun4c.c
index bdd835fba02e..a57a366e339a 100644
--- a/arch/sparc/mm/sun4c.c
+++ b/arch/sparc/mm/sun4c.c
@@ -2155,7 +2155,7 @@ void __init ld_mmu_sun4c(void)
2155 BTFIXUPSET_SIMM13(user_ptrs_per_pgd, KERNBASE / SUN4C_PGDIR_SIZE); 2155 BTFIXUPSET_SIMM13(user_ptrs_per_pgd, KERNBASE / SUN4C_PGDIR_SIZE);
2156 2156
2157 BTFIXUPSET_INT(page_none, pgprot_val(SUN4C_PAGE_NONE)); 2157 BTFIXUPSET_INT(page_none, pgprot_val(SUN4C_PAGE_NONE));
2158 BTFIXUPSET_INT(page_shared, pgprot_val(SUN4C_PAGE_SHARED)); 2158 PAGE_SHARED = pgprot_val(SUN4C_PAGE_SHARED);
2159 BTFIXUPSET_INT(page_copy, pgprot_val(SUN4C_PAGE_COPY)); 2159 BTFIXUPSET_INT(page_copy, pgprot_val(SUN4C_PAGE_COPY));
2160 BTFIXUPSET_INT(page_readonly, pgprot_val(SUN4C_PAGE_READONLY)); 2160 BTFIXUPSET_INT(page_readonly, pgprot_val(SUN4C_PAGE_READONLY));
2161 BTFIXUPSET_INT(page_kernel, pgprot_val(SUN4C_PAGE_KERNEL)); 2161 BTFIXUPSET_INT(page_kernel, pgprot_val(SUN4C_PAGE_KERNEL));
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index f1cc55677ff2..33dabf588bdd 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -23,6 +23,10 @@ config GENERIC_TIME
23 bool 23 bool
24 default y 24 default y
25 25
26config GENERIC_CMOS_UPDATE
27 bool
28 default y
29
26config GENERIC_CLOCKEVENTS 30config GENERIC_CLOCKEVENTS
27 bool 31 bool
28 default y 32 default y
diff --git a/arch/sparc64/kernel/sparc64_ksyms.c b/arch/sparc64/kernel/sparc64_ksyms.c
index 7d36531aa5b9..d270c2f0be0f 100644
--- a/arch/sparc64/kernel/sparc64_ksyms.c
+++ b/arch/sparc64/kernel/sparc64_ksyms.c
@@ -280,6 +280,7 @@ EXPORT_SYMBOL(sys_getgid);
280EXPORT_SYMBOL(svr4_getcontext); 280EXPORT_SYMBOL(svr4_getcontext);
281EXPORT_SYMBOL(svr4_setcontext); 281EXPORT_SYMBOL(svr4_setcontext);
282EXPORT_SYMBOL(compat_sys_ioctl); 282EXPORT_SYMBOL(compat_sys_ioctl);
283EXPORT_SYMBOL(sys_ioctl);
283EXPORT_SYMBOL(sparc32_open); 284EXPORT_SYMBOL(sparc32_open);
284#endif 285#endif
285 286
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c
index e340eb401fb9..49063ca2efcd 100644
--- a/arch/sparc64/kernel/time.c
+++ b/arch/sparc64/kernel/time.c
@@ -403,58 +403,9 @@ static struct sparc64_tick_ops hbtick_operations __read_mostly = {
403 403
404static unsigned long timer_ticks_per_nsec_quotient __read_mostly; 404static unsigned long timer_ticks_per_nsec_quotient __read_mostly;
405 405
406#define TICK_SIZE (tick_nsec / 1000) 406int update_persistent_clock(struct timespec now)
407
408#define USEC_AFTER 500000
409#define USEC_BEFORE 500000
410
411static void sync_cmos_clock(unsigned long dummy);
412
413static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0);
414
415static void sync_cmos_clock(unsigned long dummy)
416{
417 struct timeval now, next;
418 int fail = 1;
419
420 /*
421 * If we have an externally synchronized Linux clock, then update
422 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
423 * called as close as possible to 500 ms before the new second starts.
424 * This code is run on a timer. If the clock is set, that timer
425 * may not expire at the correct time. Thus, we adjust...
426 */
427 if (!ntp_synced())
428 /*
429 * Not synced, exit, do not restart a timer (if one is
430 * running, let it run out).
431 */
432 return;
433
434 do_gettimeofday(&now);
435 if (now.tv_usec >= USEC_AFTER - ((unsigned) TICK_SIZE) / 2 &&
436 now.tv_usec <= USEC_BEFORE + ((unsigned) TICK_SIZE) / 2)
437 fail = set_rtc_mmss(now.tv_sec);
438
439 next.tv_usec = USEC_AFTER - now.tv_usec;
440 if (next.tv_usec <= 0)
441 next.tv_usec += USEC_PER_SEC;
442
443 if (!fail)
444 next.tv_sec = 659;
445 else
446 next.tv_sec = 0;
447
448 if (next.tv_usec >= USEC_PER_SEC) {
449 next.tv_sec++;
450 next.tv_usec -= USEC_PER_SEC;
451 }
452 mod_timer(&sync_cmos_timer, jiffies + timeval_to_jiffies(&next));
453}
454
455void notify_arch_cmos_timer(void)
456{ 407{
457 mod_timer(&sync_cmos_timer, jiffies + 1); 408 return set_rtc_mmss(now.tv_sec);
458} 409}
459 410
460/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */ 411/* Kick start a stopped clock (procedure from the Sun NVRAM/hostid FAQ). */
@@ -931,6 +882,7 @@ static void sparc64_timer_setup(enum clock_event_mode mode,
931{ 882{
932 switch (mode) { 883 switch (mode) {
933 case CLOCK_EVT_MODE_ONESHOT: 884 case CLOCK_EVT_MODE_ONESHOT:
885 case CLOCK_EVT_MODE_RESUME:
934 break; 886 break;
935 887
936 case CLOCK_EVT_MODE_SHUTDOWN: 888 case CLOCK_EVT_MODE_SHUTDOWN:
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 14bf8ce3ea23..45f82ae6d389 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -32,6 +32,10 @@ config GENERIC_TIME_VSYSCALL
32 bool 32 bool
33 default y 33 default y
34 34
35config GENERIC_CMOS_UPDATE
36 bool
37 default y
38
35config ZONE_DMA32 39config ZONE_DMA32
36 bool 40 bool
37 default y 41 default y
@@ -56,6 +60,14 @@ config ZONE_DMA
56 bool 60 bool
57 default y 61 default y
58 62
63config QUICKLIST
64 bool
65 default y
66
67config NR_QUICK
68 int
69 default 2
70
59config ISA 71config ISA
60 bool 72 bool
61 73
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 29617ae3926d..128561d3e876 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -76,7 +76,8 @@ head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kern
76libs-y += arch/x86_64/lib/ 76libs-y += arch/x86_64/lib/
77core-y += arch/x86_64/kernel/ \ 77core-y += arch/x86_64/kernel/ \
78 arch/x86_64/mm/ \ 78 arch/x86_64/mm/ \
79 arch/x86_64/crypto/ 79 arch/x86_64/crypto/ \
80 arch/x86_64/vdso/
80core-$(CONFIG_IA32_EMULATION) += arch/x86_64/ia32/ 81core-$(CONFIG_IA32_EMULATION) += arch/x86_64/ia32/
81drivers-$(CONFIG_PCI) += arch/x86_64/pci/ 82drivers-$(CONFIG_PCI) += arch/x86_64/pci/
82drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/ 83drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/
diff --git a/arch/x86_64/boot/compressed/Makefile b/arch/x86_64/boot/compressed/Makefile
index c9f2da7496c1..877c0bdbbc67 100644
--- a/arch/x86_64/boot/compressed/Makefile
+++ b/arch/x86_64/boot/compressed/Makefile
@@ -3,8 +3,6 @@
3# 3#
4# create a compressed vmlinux image from the original vmlinux 4# create a compressed vmlinux image from the original vmlinux
5# 5#
6# Note all the files here are compiled/linked as 32bit executables.
7#
8 6
9targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o 7targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
10 8
diff --git a/arch/x86_64/defconfig b/arch/x86_64/defconfig
index 40178e5c3104..b7c4cd04bfc3 100644
--- a/arch/x86_64/defconfig
+++ b/arch/x86_64/defconfig
@@ -1,19 +1,22 @@
1# 1#
2# Automatically generated make config: don't edit 2# Automatically generated make config: don't edit
3# Linux kernel version: 2.6.22-rc2 3# Linux kernel version: 2.6.22-git14
4# Mon May 21 13:23:40 2007 4# Fri Jul 20 09:53:15 2007
5# 5#
6CONFIG_X86_64=y 6CONFIG_X86_64=y
7CONFIG_64BIT=y 7CONFIG_64BIT=y
8CONFIG_X86=y 8CONFIG_X86=y
9CONFIG_GENERIC_TIME=y 9CONFIG_GENERIC_TIME=y
10CONFIG_GENERIC_TIME_VSYSCALL=y 10CONFIG_GENERIC_TIME_VSYSCALL=y
11CONFIG_GENERIC_CMOS_UPDATE=y
11CONFIG_ZONE_DMA32=y 12CONFIG_ZONE_DMA32=y
12CONFIG_LOCKDEP_SUPPORT=y 13CONFIG_LOCKDEP_SUPPORT=y
13CONFIG_STACKTRACE_SUPPORT=y 14CONFIG_STACKTRACE_SUPPORT=y
14CONFIG_SEMAPHORE_SLEEPERS=y 15CONFIG_SEMAPHORE_SLEEPERS=y
15CONFIG_MMU=y 16CONFIG_MMU=y
16CONFIG_ZONE_DMA=y 17CONFIG_ZONE_DMA=y
18CONFIG_QUICKLIST=y
19CONFIG_NR_QUICK=2
17CONFIG_RWSEM_GENERIC_SPINLOCK=y 20CONFIG_RWSEM_GENERIC_SPINLOCK=y
18CONFIG_GENERIC_HWEIGHT=y 21CONFIG_GENERIC_HWEIGHT=y
19CONFIG_GENERIC_CALIBRATE_DELAY=y 22CONFIG_GENERIC_CALIBRATE_DELAY=y
@@ -44,19 +47,18 @@ CONFIG_LOCALVERSION=""
44CONFIG_LOCALVERSION_AUTO=y 47CONFIG_LOCALVERSION_AUTO=y
45CONFIG_SWAP=y 48CONFIG_SWAP=y
46CONFIG_SYSVIPC=y 49CONFIG_SYSVIPC=y
47# CONFIG_IPC_NS is not set
48CONFIG_SYSVIPC_SYSCTL=y 50CONFIG_SYSVIPC_SYSCTL=y
49CONFIG_POSIX_MQUEUE=y 51CONFIG_POSIX_MQUEUE=y
50# CONFIG_BSD_PROCESS_ACCT is not set 52# CONFIG_BSD_PROCESS_ACCT is not set
51# CONFIG_TASKSTATS is not set 53# CONFIG_TASKSTATS is not set
52# CONFIG_UTS_NS is not set 54# CONFIG_USER_NS is not set
53# CONFIG_AUDIT is not set 55# CONFIG_AUDIT is not set
54CONFIG_IKCONFIG=y 56CONFIG_IKCONFIG=y
55CONFIG_IKCONFIG_PROC=y 57CONFIG_IKCONFIG_PROC=y
56CONFIG_LOG_BUF_SHIFT=18 58CONFIG_LOG_BUF_SHIFT=18
57# CONFIG_CPUSETS is not set 59# CONFIG_CPUSETS is not set
58CONFIG_SYSFS_DEPRECATED=y 60CONFIG_SYSFS_DEPRECATED=y
59# CONFIG_RELAY is not set 61CONFIG_RELAY=y
60CONFIG_BLK_DEV_INITRD=y 62CONFIG_BLK_DEV_INITRD=y
61CONFIG_INITRAMFS_SOURCE="" 63CONFIG_INITRAMFS_SOURCE=""
62CONFIG_CC_OPTIMIZE_FOR_SIZE=y 64CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -86,10 +88,6 @@ CONFIG_SLAB=y
86CONFIG_RT_MUTEXES=y 88CONFIG_RT_MUTEXES=y
87# CONFIG_TINY_SHMEM is not set 89# CONFIG_TINY_SHMEM is not set
88CONFIG_BASE_SMALL=0 90CONFIG_BASE_SMALL=0
89
90#
91# Loadable module support
92#
93CONFIG_MODULES=y 91CONFIG_MODULES=y
94CONFIG_MODULE_UNLOAD=y 92CONFIG_MODULE_UNLOAD=y
95CONFIG_MODULE_FORCE_UNLOAD=y 93CONFIG_MODULE_FORCE_UNLOAD=y
@@ -97,12 +95,9 @@ CONFIG_MODULE_FORCE_UNLOAD=y
97# CONFIG_MODULE_SRCVERSION_ALL is not set 95# CONFIG_MODULE_SRCVERSION_ALL is not set
98# CONFIG_KMOD is not set 96# CONFIG_KMOD is not set
99CONFIG_STOP_MACHINE=y 97CONFIG_STOP_MACHINE=y
100
101#
102# Block layer
103#
104CONFIG_BLOCK=y 98CONFIG_BLOCK=y
105# CONFIG_BLK_DEV_IO_TRACE is not set 99# CONFIG_BLK_DEV_IO_TRACE is not set
100# CONFIG_BLK_DEV_BSG is not set
106 101
107# 102#
108# IO Schedulers 103# IO Schedulers
@@ -165,9 +160,12 @@ CONFIG_SPLIT_PTLOCK_CPUS=4
165CONFIG_MIGRATION=y 160CONFIG_MIGRATION=y
166CONFIG_RESOURCES_64BIT=y 161CONFIG_RESOURCES_64BIT=y
167CONFIG_ZONE_DMA_FLAG=1 162CONFIG_ZONE_DMA_FLAG=1
163CONFIG_BOUNCE=y
164CONFIG_VIRT_TO_BUS=y
168CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y 165CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y
169CONFIG_OUT_OF_LINE_PFN_TO_PAGE=y 166CONFIG_OUT_OF_LINE_PFN_TO_PAGE=y
170CONFIG_NR_CPUS=32 167CONFIG_NR_CPUS=32
168CONFIG_PHYSICAL_ALIGN=0x200000
171CONFIG_HOTPLUG_CPU=y 169CONFIG_HOTPLUG_CPU=y
172CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y 170CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG=y
173CONFIG_HPET_TIMER=y 171CONFIG_HPET_TIMER=y
@@ -180,7 +178,7 @@ CONFIG_X86_MCE_INTEL=y
180CONFIG_X86_MCE_AMD=y 178CONFIG_X86_MCE_AMD=y
181# CONFIG_KEXEC is not set 179# CONFIG_KEXEC is not set
182# CONFIG_CRASH_DUMP is not set 180# CONFIG_CRASH_DUMP is not set
183CONFIG_RELOCATABLE=y 181# CONFIG_RELOCATABLE is not set
184CONFIG_PHYSICAL_START=0x200000 182CONFIG_PHYSICAL_START=0x200000
185CONFIG_SECCOMP=y 183CONFIG_SECCOMP=y
186# CONFIG_CC_STACKPROTECTOR is not set 184# CONFIG_CC_STACKPROTECTOR is not set
@@ -201,7 +199,6 @@ CONFIG_GENERIC_PENDING_IRQ=y
201CONFIG_PM=y 199CONFIG_PM=y
202# CONFIG_PM_LEGACY is not set 200# CONFIG_PM_LEGACY is not set
203# CONFIG_PM_DEBUG is not set 201# CONFIG_PM_DEBUG is not set
204# CONFIG_PM_SYSFS_DEPRECATED is not set
205CONFIG_SOFTWARE_SUSPEND=y 202CONFIG_SOFTWARE_SUSPEND=y
206CONFIG_PM_STD_PARTITION="" 203CONFIG_PM_STD_PARTITION=""
207CONFIG_SUSPEND_SMP=y 204CONFIG_SUSPEND_SMP=y
@@ -248,7 +245,7 @@ CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
248# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set 245# CONFIG_CPU_FREQ_GOV_POWERSAVE is not set
249CONFIG_CPU_FREQ_GOV_USERSPACE=y 246CONFIG_CPU_FREQ_GOV_USERSPACE=y
250CONFIG_CPU_FREQ_GOV_ONDEMAND=y 247CONFIG_CPU_FREQ_GOV_ONDEMAND=y
251# CONFIG_CPU_FREQ_GOV_CONSERVATIVE is not set 248CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
252 249
253# 250#
254# CPUFreq processor drivers 251# CPUFreq processor drivers
@@ -351,20 +348,8 @@ CONFIG_IPV6_SIT=y
351# CONFIG_IPV6_MULTIPLE_TABLES is not set 348# CONFIG_IPV6_MULTIPLE_TABLES is not set
352# CONFIG_NETWORK_SECMARK is not set 349# CONFIG_NETWORK_SECMARK is not set
353# CONFIG_NETFILTER is not set 350# CONFIG_NETFILTER is not set
354
355#
356# DCCP Configuration (EXPERIMENTAL)
357#
358# CONFIG_IP_DCCP is not set 351# CONFIG_IP_DCCP is not set
359
360#
361# SCTP Configuration (EXPERIMENTAL)
362#
363# CONFIG_IP_SCTP is not set 352# CONFIG_IP_SCTP is not set
364
365#
366# TIPC Configuration (EXPERIMENTAL)
367#
368# CONFIG_TIPC is not set 353# CONFIG_TIPC is not set
369# CONFIG_ATM is not set 354# CONFIG_ATM is not set
370# CONFIG_BRIDGE is not set 355# CONFIG_BRIDGE is not set
@@ -401,6 +386,7 @@ CONFIG_IPV6_SIT=y
401# CONFIG_MAC80211 is not set 386# CONFIG_MAC80211 is not set
402# CONFIG_IEEE80211 is not set 387# CONFIG_IEEE80211 is not set
403# CONFIG_RFKILL is not set 388# CONFIG_RFKILL is not set
389# CONFIG_NET_9P is not set
404 390
405# 391#
406# Device Drivers 392# Device Drivers
@@ -415,21 +401,9 @@ CONFIG_FW_LOADER=y
415# CONFIG_DEBUG_DRIVER is not set 401# CONFIG_DEBUG_DRIVER is not set
416# CONFIG_DEBUG_DEVRES is not set 402# CONFIG_DEBUG_DEVRES is not set
417# CONFIG_SYS_HYPERVISOR is not set 403# CONFIG_SYS_HYPERVISOR is not set
418
419#
420# Connector - unified userspace <-> kernelspace linker
421#
422# CONFIG_CONNECTOR is not set 404# CONFIG_CONNECTOR is not set
423# CONFIG_MTD is not set 405# CONFIG_MTD is not set
424
425#
426# Parallel port support
427#
428# CONFIG_PARPORT is not set 406# CONFIG_PARPORT is not set
429
430#
431# Plug and Play support
432#
433CONFIG_PNP=y 407CONFIG_PNP=y
434# CONFIG_PNP_DEBUG is not set 408# CONFIG_PNP_DEBUG is not set
435 409
@@ -437,10 +411,7 @@ CONFIG_PNP=y
437# Protocols 411# Protocols
438# 412#
439CONFIG_PNPACPI=y 413CONFIG_PNPACPI=y
440 414CONFIG_BLK_DEV=y
441#
442# Block devices
443#
444CONFIG_BLK_DEV_FD=y 415CONFIG_BLK_DEV_FD=y
445# CONFIG_BLK_CPQ_DA is not set 416# CONFIG_BLK_CPQ_DA is not set
446# CONFIG_BLK_CPQ_CISS_DA is not set 417# CONFIG_BLK_CPQ_CISS_DA is not set
@@ -458,17 +429,14 @@ CONFIG_BLK_DEV_RAM_SIZE=4096
458CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024 429CONFIG_BLK_DEV_RAM_BLOCKSIZE=1024
459# CONFIG_CDROM_PKTCDVD is not set 430# CONFIG_CDROM_PKTCDVD is not set
460# CONFIG_ATA_OVER_ETH is not set 431# CONFIG_ATA_OVER_ETH is not set
461 432CONFIG_MISC_DEVICES=y
462#
463# Misc devices
464#
465# CONFIG_IBM_ASM is not set 433# CONFIG_IBM_ASM is not set
466# CONFIG_PHANTOM is not set 434# CONFIG_PHANTOM is not set
435# CONFIG_EEPROM_93CX6 is not set
467# CONFIG_SGI_IOC4 is not set 436# CONFIG_SGI_IOC4 is not set
468# CONFIG_TIFM_CORE is not set 437# CONFIG_TIFM_CORE is not set
469# CONFIG_SONY_LAPTOP is not set 438# CONFIG_SONY_LAPTOP is not set
470# CONFIG_THINKPAD_ACPI is not set 439# CONFIG_THINKPAD_ACPI is not set
471# CONFIG_BLINK is not set
472CONFIG_IDE=y 440CONFIG_IDE=y
473CONFIG_BLK_DEV_IDE=y 441CONFIG_BLK_DEV_IDE=y
474 442
@@ -539,6 +507,7 @@ CONFIG_BLK_DEV_IDEDMA=y
539# 507#
540# CONFIG_RAID_ATTRS is not set 508# CONFIG_RAID_ATTRS is not set
541CONFIG_SCSI=y 509CONFIG_SCSI=y
510CONFIG_SCSI_DMA=y
542# CONFIG_SCSI_TGT is not set 511# CONFIG_SCSI_TGT is not set
543CONFIG_SCSI_NETLINK=y 512CONFIG_SCSI_NETLINK=y
544# CONFIG_SCSI_PROC_FS is not set 513# CONFIG_SCSI_PROC_FS is not set
@@ -590,11 +559,9 @@ CONFIG_AIC79XX_DEBUG_MASK=0
590# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set 559# CONFIG_AIC79XX_REG_PRETTY_PRINT is not set
591# CONFIG_SCSI_AIC94XX is not set 560# CONFIG_SCSI_AIC94XX is not set
592# CONFIG_SCSI_ARCMSR is not set 561# CONFIG_SCSI_ARCMSR is not set
593CONFIG_MEGARAID_NEWGEN=y 562# CONFIG_MEGARAID_NEWGEN is not set
594CONFIG_MEGARAID_MM=y
595CONFIG_MEGARAID_MAILBOX=y
596# CONFIG_MEGARAID_LEGACY is not set 563# CONFIG_MEGARAID_LEGACY is not set
597CONFIG_MEGARAID_SAS=y 564# CONFIG_MEGARAID_SAS is not set
598# CONFIG_SCSI_HPTIOP is not set 565# CONFIG_SCSI_HPTIOP is not set
599# CONFIG_SCSI_BUSLOGIC is not set 566# CONFIG_SCSI_BUSLOGIC is not set
600# CONFIG_SCSI_DMX3191D is not set 567# CONFIG_SCSI_DMX3191D is not set
@@ -614,7 +581,6 @@ CONFIG_MEGARAID_SAS=y
614# CONFIG_SCSI_DC395x is not set 581# CONFIG_SCSI_DC395x is not set
615# CONFIG_SCSI_DC390T is not set 582# CONFIG_SCSI_DC390T is not set
616# CONFIG_SCSI_DEBUG is not set 583# CONFIG_SCSI_DEBUG is not set
617# CONFIG_SCSI_ESP_CORE is not set
618# CONFIG_SCSI_SRP is not set 584# CONFIG_SCSI_SRP is not set
619CONFIG_ATA=y 585CONFIG_ATA=y
620# CONFIG_ATA_NONSTANDARD is not set 586# CONFIG_ATA_NONSTANDARD is not set
@@ -671,10 +637,6 @@ CONFIG_SATA_VIA=y
671# CONFIG_PATA_SIS is not set 637# CONFIG_PATA_SIS is not set
672# CONFIG_PATA_VIA is not set 638# CONFIG_PATA_VIA is not set
673# CONFIG_PATA_WINBOND is not set 639# CONFIG_PATA_WINBOND is not set
674
675#
676# Multi-device support (RAID and LVM)
677#
678CONFIG_MD=y 640CONFIG_MD=y
679# CONFIG_BLK_DEV_MD is not set 641# CONFIG_BLK_DEV_MD is not set
680CONFIG_BLK_DEV_DM=y 642CONFIG_BLK_DEV_DM=y
@@ -692,7 +654,7 @@ CONFIG_BLK_DEV_DM=y
692CONFIG_FUSION=y 654CONFIG_FUSION=y
693CONFIG_FUSION_SPI=y 655CONFIG_FUSION_SPI=y
694# CONFIG_FUSION_FC is not set 656# CONFIG_FUSION_FC is not set
695CONFIG_FUSION_SAS=y 657# CONFIG_FUSION_SAS is not set
696CONFIG_FUSION_MAX_SGE=128 658CONFIG_FUSION_MAX_SGE=128
697# CONFIG_FUSION_CTL is not set 659# CONFIG_FUSION_CTL is not set
698 660
@@ -710,7 +672,10 @@ CONFIG_IEEE1394=y
710# 672#
711# Controllers 673# Controllers
712# 674#
713# CONFIG_IEEE1394_PCILYNX is not set 675
676#
677# Texas Instruments PCILynx requires I2C
678#
714CONFIG_IEEE1394_OHCI1394=y 679CONFIG_IEEE1394_OHCI1394=y
715 680
716# 681#
@@ -722,32 +687,19 @@ CONFIG_IEEE1394_OHCI1394=y
722# CONFIG_IEEE1394_ETH1394 is not set 687# CONFIG_IEEE1394_ETH1394 is not set
723# CONFIG_IEEE1394_DV1394 is not set 688# CONFIG_IEEE1394_DV1394 is not set
724CONFIG_IEEE1394_RAWIO=y 689CONFIG_IEEE1394_RAWIO=y
725
726#
727# I2O device support
728#
729# CONFIG_I2O is not set 690# CONFIG_I2O is not set
730# CONFIG_MACINTOSH_DRIVERS is not set 691CONFIG_MACINTOSH_DRIVERS=y
731 692# CONFIG_MAC_EMUMOUSEBTN is not set
732#
733# Network device support
734#
735CONFIG_NETDEVICES=y 693CONFIG_NETDEVICES=y
694CONFIG_NETDEVICES_MULTIQUEUE=y
736# CONFIG_DUMMY is not set 695# CONFIG_DUMMY is not set
737# CONFIG_BONDING is not set 696# CONFIG_BONDING is not set
697# CONFIG_MACVLAN is not set
738# CONFIG_EQUALIZER is not set 698# CONFIG_EQUALIZER is not set
739CONFIG_TUN=y 699CONFIG_TUN=y
740# CONFIG_NET_SB1000 is not set 700# CONFIG_NET_SB1000 is not set
741
742#
743# ARCnet devices
744#
745# CONFIG_ARCNET is not set 701# CONFIG_ARCNET is not set
746# CONFIG_PHYLIB is not set 702# CONFIG_PHYLIB is not set
747
748#
749# Ethernet (10 or 100Mbit)
750#
751CONFIG_NET_ETHERNET=y 703CONFIG_NET_ETHERNET=y
752CONFIG_MII=y 704CONFIG_MII=y
753# CONFIG_HAPPYMEAL is not set 705# CONFIG_HAPPYMEAL is not set
@@ -756,10 +708,6 @@ CONFIG_MII=y
756CONFIG_NET_VENDOR_3COM=y 708CONFIG_NET_VENDOR_3COM=y
757CONFIG_VORTEX=y 709CONFIG_VORTEX=y
758# CONFIG_TYPHOON is not set 710# CONFIG_TYPHOON is not set
759
760#
761# Tulip family network device support
762#
763CONFIG_NET_TULIP=y 711CONFIG_NET_TULIP=y
764# CONFIG_DE2104X is not set 712# CONFIG_DE2104X is not set
765CONFIG_TULIP=y 713CONFIG_TULIP=y
@@ -773,7 +721,8 @@ CONFIG_TULIP=y
773# CONFIG_HP100 is not set 721# CONFIG_HP100 is not set
774CONFIG_NET_PCI=y 722CONFIG_NET_PCI=y
775# CONFIG_PCNET32 is not set 723# CONFIG_PCNET32 is not set
776# CONFIG_AMD8111_ETH is not set 724CONFIG_AMD8111_ETH=y
725# CONFIG_AMD8111E_NAPI is not set
777# CONFIG_ADAPTEC_STARFIRE is not set 726# CONFIG_ADAPTEC_STARFIRE is not set
778CONFIG_B44=y 727CONFIG_B44=y
779CONFIG_FORCEDETH=y 728CONFIG_FORCEDETH=y
@@ -808,7 +757,6 @@ CONFIG_E1000=y
808# CONFIG_SIS190 is not set 757# CONFIG_SIS190 is not set
809# CONFIG_SKGE is not set 758# CONFIG_SKGE is not set
810# CONFIG_SKY2 is not set 759# CONFIG_SKY2 is not set
811# CONFIG_SK98LIN is not set
812# CONFIG_VIA_VELOCITY is not set 760# CONFIG_VIA_VELOCITY is not set
813CONFIG_TIGON3=y 761CONFIG_TIGON3=y
814CONFIG_BNX2=y 762CONFIG_BNX2=y
@@ -823,10 +771,6 @@ CONFIG_S2IO=m
823# CONFIG_MYRI10GE is not set 771# CONFIG_MYRI10GE is not set
824# CONFIG_NETXEN_NIC is not set 772# CONFIG_NETXEN_NIC is not set
825# CONFIG_MLX4_CORE is not set 773# CONFIG_MLX4_CORE is not set
826
827#
828# Token Ring devices
829#
830# CONFIG_TR is not set 774# CONFIG_TR is not set
831 775
832# 776#
@@ -855,15 +799,7 @@ CONFIG_NETCONSOLE=y
855CONFIG_NETPOLL=y 799CONFIG_NETPOLL=y
856# CONFIG_NETPOLL_TRAP is not set 800# CONFIG_NETPOLL_TRAP is not set
857CONFIG_NET_POLL_CONTROLLER=y 801CONFIG_NET_POLL_CONTROLLER=y
858
859#
860# ISDN subsystem
861#
862# CONFIG_ISDN is not set 802# CONFIG_ISDN is not set
863
864#
865# Telephony Support
866#
867# CONFIG_PHONE is not set 803# CONFIG_PHONE is not set
868 804
869# 805#
@@ -871,6 +807,7 @@ CONFIG_NET_POLL_CONTROLLER=y
871# 807#
872CONFIG_INPUT=y 808CONFIG_INPUT=y
873# CONFIG_INPUT_FF_MEMLESS is not set 809# CONFIG_INPUT_FF_MEMLESS is not set
810# CONFIG_INPUT_POLLDEV is not set
874 811
875# 812#
876# Userland interfaces 813# Userland interfaces
@@ -936,6 +873,7 @@ CONFIG_HW_CONSOLE=y
936# 873#
937CONFIG_SERIAL_8250=y 874CONFIG_SERIAL_8250=y
938CONFIG_SERIAL_8250_CONSOLE=y 875CONFIG_SERIAL_8250_CONSOLE=y
876CONFIG_FIX_EARLYCON_MEM=y
939CONFIG_SERIAL_8250_PCI=y 877CONFIG_SERIAL_8250_PCI=y
940CONFIG_SERIAL_8250_PNP=y 878CONFIG_SERIAL_8250_PNP=y
941CONFIG_SERIAL_8250_NR_UARTS=4 879CONFIG_SERIAL_8250_NR_UARTS=4
@@ -951,16 +889,11 @@ CONFIG_SERIAL_CORE_CONSOLE=y
951CONFIG_UNIX98_PTYS=y 889CONFIG_UNIX98_PTYS=y
952CONFIG_LEGACY_PTYS=y 890CONFIG_LEGACY_PTYS=y
953CONFIG_LEGACY_PTY_COUNT=256 891CONFIG_LEGACY_PTY_COUNT=256
954
955#
956# IPMI
957#
958# CONFIG_IPMI_HANDLER is not set 892# CONFIG_IPMI_HANDLER is not set
959# CONFIG_WATCHDOG is not set 893# CONFIG_WATCHDOG is not set
960CONFIG_HW_RANDOM=y 894CONFIG_HW_RANDOM=y
961CONFIG_HW_RANDOM_INTEL=y 895CONFIG_HW_RANDOM_INTEL=y
962CONFIG_HW_RANDOM_AMD=y 896CONFIG_HW_RANDOM_AMD=y
963# CONFIG_HW_RANDOM_GEODE is not set
964# CONFIG_NVRAM is not set 897# CONFIG_NVRAM is not set
965CONFIG_RTC=y 898CONFIG_RTC=y
966# CONFIG_R3964 is not set 899# CONFIG_R3964 is not set
@@ -979,127 +912,19 @@ CONFIG_HPET=y
979# CONFIG_HPET_RTC_IRQ is not set 912# CONFIG_HPET_RTC_IRQ is not set
980CONFIG_HPET_MMAP=y 913CONFIG_HPET_MMAP=y
981# CONFIG_HANGCHECK_TIMER is not set 914# CONFIG_HANGCHECK_TIMER is not set
982
983#
984# TPM devices
985#
986# CONFIG_TCG_TPM is not set 915# CONFIG_TCG_TPM is not set
987# CONFIG_TELCLOCK is not set 916# CONFIG_TELCLOCK is not set
988CONFIG_DEVPORT=y 917CONFIG_DEVPORT=y
989CONFIG_I2C=m 918# CONFIG_I2C is not set
990CONFIG_I2C_BOARDINFO=y
991CONFIG_I2C_CHARDEV=m
992
993#
994# I2C Algorithms
995#
996# CONFIG_I2C_ALGOBIT is not set
997# CONFIG_I2C_ALGOPCF is not set
998# CONFIG_I2C_ALGOPCA is not set
999
1000#
1001# I2C Hardware Bus support
1002#
1003# CONFIG_I2C_ALI1535 is not set
1004# CONFIG_I2C_ALI1563 is not set
1005# CONFIG_I2C_ALI15X3 is not set
1006# CONFIG_I2C_AMD756 is not set
1007# CONFIG_I2C_AMD8111 is not set
1008# CONFIG_I2C_I801 is not set
1009# CONFIG_I2C_I810 is not set
1010# CONFIG_I2C_PIIX4 is not set
1011# CONFIG_I2C_NFORCE2 is not set
1012# CONFIG_I2C_OCORES is not set
1013# CONFIG_I2C_PARPORT_LIGHT is not set
1014# CONFIG_I2C_PROSAVAGE is not set
1015# CONFIG_I2C_SAVAGE4 is not set
1016# CONFIG_I2C_SIMTEC is not set
1017# CONFIG_I2C_SIS5595 is not set
1018# CONFIG_I2C_SIS630 is not set
1019# CONFIG_I2C_SIS96X is not set
1020# CONFIG_I2C_STUB is not set
1021# CONFIG_I2C_TINY_USB is not set
1022# CONFIG_I2C_VIA is not set
1023# CONFIG_I2C_VIAPRO is not set
1024# CONFIG_I2C_VOODOO3 is not set
1025
1026#
1027# Miscellaneous I2C Chip support
1028#
1029# CONFIG_SENSORS_DS1337 is not set
1030# CONFIG_SENSORS_DS1374 is not set
1031# CONFIG_SENSORS_EEPROM is not set
1032# CONFIG_SENSORS_PCF8574 is not set
1033# CONFIG_SENSORS_PCA9539 is not set
1034# CONFIG_SENSORS_PCF8591 is not set
1035# CONFIG_SENSORS_MAX6875 is not set
1036# CONFIG_I2C_DEBUG_CORE is not set
1037# CONFIG_I2C_DEBUG_ALGO is not set
1038# CONFIG_I2C_DEBUG_BUS is not set
1039# CONFIG_I2C_DEBUG_CHIP is not set
1040 919
1041# 920#
1042# SPI support 921# SPI support
1043# 922#
1044# CONFIG_SPI is not set 923# CONFIG_SPI is not set
1045# CONFIG_SPI_MASTER is not set 924# CONFIG_SPI_MASTER is not set
1046
1047#
1048# Dallas's 1-wire bus
1049#
1050# CONFIG_W1 is not set 925# CONFIG_W1 is not set
1051CONFIG_HWMON=y 926# CONFIG_POWER_SUPPLY is not set
1052# CONFIG_HWMON_VID is not set 927# CONFIG_HWMON is not set
1053# CONFIG_SENSORS_ABITUGURU is not set
1054# CONFIG_SENSORS_AD7418 is not set
1055# CONFIG_SENSORS_ADM1021 is not set
1056# CONFIG_SENSORS_ADM1025 is not set
1057# CONFIG_SENSORS_ADM1026 is not set
1058# CONFIG_SENSORS_ADM1029 is not set
1059# CONFIG_SENSORS_ADM1031 is not set
1060# CONFIG_SENSORS_ADM9240 is not set
1061# CONFIG_SENSORS_K8TEMP is not set
1062# CONFIG_SENSORS_ASB100 is not set
1063# CONFIG_SENSORS_ATXP1 is not set
1064# CONFIG_SENSORS_DS1621 is not set
1065# CONFIG_SENSORS_F71805F is not set
1066# CONFIG_SENSORS_FSCHER is not set
1067# CONFIG_SENSORS_FSCPOS is not set
1068# CONFIG_SENSORS_GL518SM is not set
1069# CONFIG_SENSORS_GL520SM is not set
1070CONFIG_SENSORS_CORETEMP=y
1071# CONFIG_SENSORS_IT87 is not set
1072# CONFIG_SENSORS_LM63 is not set
1073# CONFIG_SENSORS_LM75 is not set
1074# CONFIG_SENSORS_LM77 is not set
1075# CONFIG_SENSORS_LM78 is not set
1076# CONFIG_SENSORS_LM80 is not set
1077# CONFIG_SENSORS_LM83 is not set
1078# CONFIG_SENSORS_LM85 is not set
1079# CONFIG_SENSORS_LM87 is not set
1080# CONFIG_SENSORS_LM90 is not set
1081# CONFIG_SENSORS_LM92 is not set
1082# CONFIG_SENSORS_MAX1619 is not set
1083# CONFIG_SENSORS_MAX6650 is not set
1084# CONFIG_SENSORS_PC87360 is not set
1085# CONFIG_SENSORS_PC87427 is not set
1086# CONFIG_SENSORS_SIS5595 is not set
1087# CONFIG_SENSORS_SMSC47M1 is not set
1088# CONFIG_SENSORS_SMSC47M192 is not set
1089CONFIG_SENSORS_SMSC47B397=m
1090# CONFIG_SENSORS_VIA686A is not set
1091# CONFIG_SENSORS_VT1211 is not set
1092# CONFIG_SENSORS_VT8231 is not set
1093# CONFIG_SENSORS_W83781D is not set
1094# CONFIG_SENSORS_W83791D is not set
1095# CONFIG_SENSORS_W83792D is not set
1096# CONFIG_SENSORS_W83793 is not set
1097# CONFIG_SENSORS_W83L785TS is not set
1098# CONFIG_SENSORS_W83627HF is not set
1099# CONFIG_SENSORS_W83627EHF is not set
1100# CONFIG_SENSORS_HDAPS is not set
1101# CONFIG_SENSORS_APPLESMC is not set
1102# CONFIG_HWMON_DEBUG_CHIP is not set
1103 928
1104# 929#
1105# Multifunction device drivers 930# Multifunction device drivers
@@ -1149,15 +974,11 @@ CONFIG_SOUND=y
1149# Open Sound System 974# Open Sound System
1150# 975#
1151CONFIG_SOUND_PRIME=y 976CONFIG_SOUND_PRIME=y
1152# CONFIG_OSS_OBSOLETE is not set
1153# CONFIG_SOUND_TRIDENT is not set 977# CONFIG_SOUND_TRIDENT is not set
1154# CONFIG_SOUND_MSNDCLAS is not set 978# CONFIG_SOUND_MSNDCLAS is not set
1155# CONFIG_SOUND_MSNDPIN is not set 979# CONFIG_SOUND_MSNDPIN is not set
1156# CONFIG_SOUND_OSS is not set 980# CONFIG_SOUND_OSS is not set
1157 981CONFIG_HID_SUPPORT=y
1158#
1159# HID Devices
1160#
1161CONFIG_HID=y 982CONFIG_HID=y
1162# CONFIG_HID_DEBUG is not set 983# CONFIG_HID_DEBUG is not set
1163 984
@@ -1168,10 +989,7 @@ CONFIG_USB_HID=y
1168# CONFIG_USB_HIDINPUT_POWERBOOK is not set 989# CONFIG_USB_HIDINPUT_POWERBOOK is not set
1169# CONFIG_HID_FF is not set 990# CONFIG_HID_FF is not set
1170# CONFIG_USB_HIDDEV is not set 991# CONFIG_USB_HIDDEV is not set
1171 992CONFIG_USB_SUPPORT=y
1172#
1173# USB support
1174#
1175CONFIG_USB_ARCH_HAS_HCD=y 993CONFIG_USB_ARCH_HAS_HCD=y
1176CONFIG_USB_ARCH_HAS_OHCI=y 994CONFIG_USB_ARCH_HAS_OHCI=y
1177CONFIG_USB_ARCH_HAS_EHCI=y 995CONFIG_USB_ARCH_HAS_EHCI=y
@@ -1185,6 +1003,7 @@ CONFIG_USB_DEVICEFS=y
1185# CONFIG_USB_DEVICE_CLASS is not set 1003# CONFIG_USB_DEVICE_CLASS is not set
1186# CONFIG_USB_DYNAMIC_MINORS is not set 1004# CONFIG_USB_DYNAMIC_MINORS is not set
1187# CONFIG_USB_SUSPEND is not set 1005# CONFIG_USB_SUSPEND is not set
1006# CONFIG_USB_PERSIST is not set
1188# CONFIG_USB_OTG is not set 1007# CONFIG_USB_OTG is not set
1189 1008
1190# 1009#
@@ -1194,7 +1013,6 @@ CONFIG_USB_EHCI_HCD=y
1194# CONFIG_USB_EHCI_SPLIT_ISO is not set 1013# CONFIG_USB_EHCI_SPLIT_ISO is not set
1195# CONFIG_USB_EHCI_ROOT_HUB_TT is not set 1014# CONFIG_USB_EHCI_ROOT_HUB_TT is not set
1196# CONFIG_USB_EHCI_TT_NEWSCHED is not set 1015# CONFIG_USB_EHCI_TT_NEWSCHED is not set
1197# CONFIG_USB_EHCI_BIG_ENDIAN_MMIO is not set
1198# CONFIG_USB_ISP116X_HCD is not set 1016# CONFIG_USB_ISP116X_HCD is not set
1199CONFIG_USB_OHCI_HCD=y 1017CONFIG_USB_OHCI_HCD=y
1200# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set 1018# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set
@@ -1202,6 +1020,7 @@ CONFIG_USB_OHCI_HCD=y
1202CONFIG_USB_OHCI_LITTLE_ENDIAN=y 1020CONFIG_USB_OHCI_LITTLE_ENDIAN=y
1203CONFIG_USB_UHCI_HCD=y 1021CONFIG_USB_UHCI_HCD=y
1204# CONFIG_USB_SL811_HCD is not set 1022# CONFIG_USB_SL811_HCD is not set
1023# CONFIG_USB_R8A66597_HCD is not set
1205 1024
1206# 1025#
1207# USB Device Class drivers 1026# USB Device Class drivers
@@ -1292,15 +1111,7 @@ CONFIG_USB_MON=y
1292# 1111#
1293# LED Triggers 1112# LED Triggers
1294# 1113#
1295
1296#
1297# InfiniBand support
1298#
1299# CONFIG_INFINIBAND is not set 1114# CONFIG_INFINIBAND is not set
1300
1301#
1302# EDAC - error detection and reporting (RAS) (EXPERIMENTAL)
1303#
1304# CONFIG_EDAC is not set 1115# CONFIG_EDAC is not set
1305 1116
1306# 1117#
@@ -1320,11 +1131,13 @@ CONFIG_USB_MON=y
1320# 1131#
1321# DMA Devices 1132# DMA Devices
1322# 1133#
1134CONFIG_VIRTUALIZATION=y
1135# CONFIG_KVM is not set
1323 1136
1324# 1137#
1325# Virtualization 1138# Userspace I/O
1326# 1139#
1327# CONFIG_KVM is not set 1140# CONFIG_UIO is not set
1328 1141
1329# 1142#
1330# Firmware Drivers 1143# Firmware Drivers
@@ -1332,6 +1145,7 @@ CONFIG_USB_MON=y
1332# CONFIG_EDD is not set 1145# CONFIG_EDD is not set
1333# CONFIG_DELL_RBU is not set 1146# CONFIG_DELL_RBU is not set
1334# CONFIG_DCDBAS is not set 1147# CONFIG_DCDBAS is not set
1148CONFIG_DMIID=y
1335 1149
1336# 1150#
1337# File systems 1151# File systems
@@ -1447,7 +1261,6 @@ CONFIG_SUNRPC=y
1447# CONFIG_NCP_FS is not set 1261# CONFIG_NCP_FS is not set
1448# CONFIG_CODA_FS is not set 1262# CONFIG_CODA_FS is not set
1449# CONFIG_AFS_FS is not set 1263# CONFIG_AFS_FS is not set
1450# CONFIG_9P_FS is not set
1451 1264
1452# 1265#
1453# Partition Types 1266# Partition Types
@@ -1524,8 +1337,9 @@ CONFIG_DEBUG_FS=y
1524CONFIG_DEBUG_KERNEL=y 1337CONFIG_DEBUG_KERNEL=y
1525# CONFIG_DEBUG_SHIRQ is not set 1338# CONFIG_DEBUG_SHIRQ is not set
1526CONFIG_DETECT_SOFTLOCKUP=y 1339CONFIG_DETECT_SOFTLOCKUP=y
1340# CONFIG_SCHED_DEBUG is not set
1527# CONFIG_SCHEDSTATS is not set 1341# CONFIG_SCHEDSTATS is not set
1528# CONFIG_TIMER_STATS is not set 1342CONFIG_TIMER_STATS=y
1529# CONFIG_DEBUG_SLAB is not set 1343# CONFIG_DEBUG_SLAB is not set
1530# CONFIG_DEBUG_RT_MUTEXES is not set 1344# CONFIG_DEBUG_RT_MUTEXES is not set
1531# CONFIG_RT_MUTEX_TESTER is not set 1345# CONFIG_RT_MUTEX_TESTER is not set
@@ -1533,6 +1347,7 @@ CONFIG_DETECT_SOFTLOCKUP=y
1533# CONFIG_DEBUG_MUTEXES is not set 1347# CONFIG_DEBUG_MUTEXES is not set
1534# CONFIG_DEBUG_LOCK_ALLOC is not set 1348# CONFIG_DEBUG_LOCK_ALLOC is not set
1535# CONFIG_PROVE_LOCKING is not set 1349# CONFIG_PROVE_LOCKING is not set
1350# CONFIG_LOCK_STAT is not set
1536# CONFIG_DEBUG_SPINLOCK_SLEEP is not set 1351# CONFIG_DEBUG_SPINLOCK_SLEEP is not set
1537# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set 1352# CONFIG_DEBUG_LOCKING_API_SELFTESTS is not set
1538# CONFIG_DEBUG_KOBJECT is not set 1353# CONFIG_DEBUG_KOBJECT is not set
@@ -1541,8 +1356,6 @@ CONFIG_DEBUG_BUGVERBOSE=y
1541# CONFIG_DEBUG_VM is not set 1356# CONFIG_DEBUG_VM is not set
1542# CONFIG_DEBUG_LIST is not set 1357# CONFIG_DEBUG_LIST is not set
1543# CONFIG_FRAME_POINTER is not set 1358# CONFIG_FRAME_POINTER is not set
1544CONFIG_UNWIND_INFO=y
1545CONFIG_STACK_UNWIND=y
1546# CONFIG_FORCED_INLINING is not set 1359# CONFIG_FORCED_INLINING is not set
1547# CONFIG_RCU_TORTURE_TEST is not set 1360# CONFIG_RCU_TORTURE_TEST is not set
1548# CONFIG_LKDTM is not set 1361# CONFIG_LKDTM is not set
@@ -1557,10 +1370,6 @@ CONFIG_DEBUG_STACKOVERFLOW=y
1557# 1370#
1558# CONFIG_KEYS is not set 1371# CONFIG_KEYS is not set
1559# CONFIG_SECURITY is not set 1372# CONFIG_SECURITY is not set
1560
1561#
1562# Cryptographic options
1563#
1564# CONFIG_CRYPTO is not set 1373# CONFIG_CRYPTO is not set
1565 1374
1566# 1375#
@@ -1571,6 +1380,7 @@ CONFIG_BITREVERSE=y
1571# CONFIG_CRC16 is not set 1380# CONFIG_CRC16 is not set
1572# CONFIG_CRC_ITU_T is not set 1381# CONFIG_CRC_ITU_T is not set
1573CONFIG_CRC32=y 1382CONFIG_CRC32=y
1383# CONFIG_CRC7 is not set
1574# CONFIG_LIBCRC32C is not set 1384# CONFIG_LIBCRC32C is not set
1575CONFIG_ZLIB_INFLATE=y 1385CONFIG_ZLIB_INFLATE=y
1576CONFIG_PLIST=y 1386CONFIG_PLIST=y
diff --git a/arch/x86_64/ia32/ia32_binfmt.c b/arch/x86_64/ia32/ia32_binfmt.c
index ed56a8806eab..b70f3e7cf06c 100644
--- a/arch/x86_64/ia32/ia32_binfmt.c
+++ b/arch/x86_64/ia32/ia32_binfmt.c
@@ -38,6 +38,7 @@
38 38
39int sysctl_vsyscall32 = 1; 39int sysctl_vsyscall32 = 1;
40 40
41#undef ARCH_DLINFO
41#define ARCH_DLINFO do { \ 42#define ARCH_DLINFO do { \
42 if (sysctl_vsyscall32) { \ 43 if (sysctl_vsyscall32) { \
43 NEW_AUX_ENT(AT_SYSINFO, (u32)(u64)VSYSCALL32_VSYSCALL); \ 44 NEW_AUX_ENT(AT_SYSINFO, (u32)(u64)VSYSCALL32_VSYSCALL); \
diff --git a/arch/x86_64/ia32/ia32entry.S b/arch/x86_64/ia32/ia32entry.S
index 3f66e970d86f..938278697e20 100644
--- a/arch/x86_64/ia32/ia32entry.S
+++ b/arch/x86_64/ia32/ia32entry.S
@@ -104,7 +104,7 @@ ENTRY(ia32_sysenter_target)
104 pushq %rax 104 pushq %rax
105 CFI_ADJUST_CFA_OFFSET 8 105 CFI_ADJUST_CFA_OFFSET 8
106 cld 106 cld
107 SAVE_ARGS 0,0,0 107 SAVE_ARGS 0,0,1
108 /* no need to do an access_ok check here because rbp has been 108 /* no need to do an access_ok check here because rbp has been
109 32bit zero extended */ 109 32bit zero extended */
1101: movl (%rbp),%r9d 1101: movl (%rbp),%r9d
@@ -294,7 +294,7 @@ ia32_badarg:
294 */ 294 */
295 295
296ENTRY(ia32_syscall) 296ENTRY(ia32_syscall)
297 CFI_STARTPROC simple 297 CFI_STARTPROC32 simple
298 CFI_SIGNAL_FRAME 298 CFI_SIGNAL_FRAME
299 CFI_DEF_CFA rsp,SS+8-RIP 299 CFI_DEF_CFA rsp,SS+8-RIP
300 /*CFI_REL_OFFSET ss,SS-RIP*/ 300 /*CFI_REL_OFFSET ss,SS-RIP*/
@@ -330,6 +330,7 @@ ia32_sysret:
330 330
331ia32_tracesys: 331ia32_tracesys:
332 SAVE_REST 332 SAVE_REST
333 CLEAR_RREGS
333 movq $-ENOSYS,RAX(%rsp) /* really needed? */ 334 movq $-ENOSYS,RAX(%rsp) /* really needed? */
334 movq %rsp,%rdi /* &pt_regs -> arg1 */ 335 movq %rsp,%rdi /* &pt_regs -> arg1 */
335 call syscall_trace_enter 336 call syscall_trace_enter
diff --git a/arch/x86_64/kernel/aperture.c b/arch/x86_64/kernel/aperture.c
index a3d450d6c15b..8f681cae7bf7 100644
--- a/arch/x86_64/kernel/aperture.c
+++ b/arch/x86_64/kernel/aperture.c
@@ -20,7 +20,7 @@
20#include <linux/ioport.h> 20#include <linux/ioport.h>
21#include <asm/e820.h> 21#include <asm/e820.h>
22#include <asm/io.h> 22#include <asm/io.h>
23#include <asm/proto.h> 23#include <asm/iommu.h>
24#include <asm/pci-direct.h> 24#include <asm/pci-direct.h>
25#include <asm/dma.h> 25#include <asm/dma.h>
26#include <asm/k8.h> 26#include <asm/k8.h>
@@ -214,7 +214,7 @@ void __init iommu_hole_init(void)
214 if (iommu_aperture_disabled || !fix_aperture || !early_pci_allowed()) 214 if (iommu_aperture_disabled || !fix_aperture || !early_pci_allowed())
215 return; 215 return;
216 216
217 printk("Checking aperture...\n"); 217 printk(KERN_INFO "Checking aperture...\n");
218 218
219 fix = 0; 219 fix = 0;
220 for (num = 24; num < 32; num++) { 220 for (num = 24; num < 32; num++) {
diff --git a/arch/x86_64/kernel/apic.c b/arch/x86_64/kernel/apic.c
index 1b0e07bb8728..900ff38d68de 100644
--- a/arch/x86_64/kernel/apic.c
+++ b/arch/x86_64/kernel/apic.c
@@ -92,8 +92,9 @@ unsigned int safe_apic_wait_icr_idle(void)
92void enable_NMI_through_LVT0 (void * dummy) 92void enable_NMI_through_LVT0 (void * dummy)
93{ 93{
94 unsigned int v; 94 unsigned int v;
95 95
96 v = APIC_DM_NMI; /* unmask and set to NMI */ 96 /* unmask and set to NMI */
97 v = APIC_DM_NMI;
97 apic_write(APIC_LVT0, v); 98 apic_write(APIC_LVT0, v);
98} 99}
99 100
@@ -120,7 +121,7 @@ void ack_bad_irq(unsigned int irq)
120 * holds up an irq slot - in excessive cases (when multiple 121 * holds up an irq slot - in excessive cases (when multiple
121 * unexpected vectors occur) that might lock up the APIC 122 * unexpected vectors occur) that might lock up the APIC
122 * completely. 123 * completely.
123 * But don't ack when the APIC is disabled. -AK 124 * But don't ack when the APIC is disabled. -AK
124 */ 125 */
125 if (!disable_apic) 126 if (!disable_apic)
126 ack_APIC_irq(); 127 ack_APIC_irq();
@@ -616,7 +617,7 @@ early_param("apic", apic_set_verbosity);
616 * Detect and enable local APICs on non-SMP boards. 617 * Detect and enable local APICs on non-SMP boards.
617 * Original code written by Keir Fraser. 618 * Original code written by Keir Fraser.
618 * On AMD64 we trust the BIOS - if it says no APIC it is likely 619 * On AMD64 we trust the BIOS - if it says no APIC it is likely
619 * not correctly set up (usually the APIC timer won't work etc.) 620 * not correctly set up (usually the APIC timer won't work etc.)
620 */ 621 */
621 622
622static int __init detect_init_APIC (void) 623static int __init detect_init_APIC (void)
@@ -789,13 +790,13 @@ static void setup_APIC_timer(unsigned int clocks)
789 local_irq_save(flags); 790 local_irq_save(flags);
790 791
791 /* wait for irq slice */ 792 /* wait for irq slice */
792 if (hpet_address && hpet_use_timer) { 793 if (hpet_address && hpet_use_timer) {
793 int trigger = hpet_readl(HPET_T0_CMP); 794 int trigger = hpet_readl(HPET_T0_CMP);
794 while (hpet_readl(HPET_COUNTER) >= trigger) 795 while (hpet_readl(HPET_COUNTER) >= trigger)
795 /* do nothing */ ; 796 /* do nothing */ ;
796 while (hpet_readl(HPET_COUNTER) < trigger) 797 while (hpet_readl(HPET_COUNTER) < trigger)
797 /* do nothing */ ; 798 /* do nothing */ ;
798 } else { 799 } else {
799 int c1, c2; 800 int c1, c2;
800 outb_p(0x00, 0x43); 801 outb_p(0x00, 0x43);
801 c2 = inb_p(0x40); 802 c2 = inb_p(0x40);
@@ -881,10 +882,10 @@ static unsigned int calibration_result;
881 882
882void __init setup_boot_APIC_clock (void) 883void __init setup_boot_APIC_clock (void)
883{ 884{
884 if (disable_apic_timer) { 885 if (disable_apic_timer) {
885 printk(KERN_INFO "Disabling APIC timer\n"); 886 printk(KERN_INFO "Disabling APIC timer\n");
886 return; 887 return;
887 } 888 }
888 889
889 printk(KERN_INFO "Using local APIC timer interrupts.\n"); 890 printk(KERN_INFO "Using local APIC timer interrupts.\n");
890 using_apic_timer = 1; 891 using_apic_timer = 1;
@@ -990,8 +991,8 @@ int setup_profiling_timer(unsigned int multiplier)
990 return -EINVAL; 991 return -EINVAL;
991} 992}
992 993
993void setup_APIC_extened_lvt(unsigned char lvt_off, unsigned char vector, 994void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector,
994 unsigned char msg_type, unsigned char mask) 995 unsigned char msg_type, unsigned char mask)
995{ 996{
996 unsigned long reg = (lvt_off << 4) + K8_APIC_EXT_LVT_BASE; 997 unsigned long reg = (lvt_off << 4) + K8_APIC_EXT_LVT_BASE;
997 unsigned int v = (mask << 16) | (msg_type << 8) | vector; 998 unsigned int v = (mask << 16) | (msg_type << 8) | vector;
@@ -1128,20 +1129,6 @@ asmlinkage void smp_spurious_interrupt(void)
1128 if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f))) 1129 if (v & (1 << (SPURIOUS_APIC_VECTOR & 0x1f)))
1129 ack_APIC_irq(); 1130 ack_APIC_irq();
1130 1131
1131#if 0
1132 static unsigned long last_warning;
1133 static unsigned long skipped;
1134
1135 /* see sw-dev-man vol 3, chapter 7.4.13.5 */
1136 if (time_before(last_warning+30*HZ,jiffies)) {
1137 printk(KERN_INFO "spurious APIC interrupt on CPU#%d, %ld skipped.\n",
1138 smp_processor_id(), skipped);
1139 last_warning = jiffies;
1140 skipped = 0;
1141 } else {
1142 skipped++;
1143 }
1144#endif
1145 irq_exit(); 1132 irq_exit();
1146} 1133}
1147 1134
@@ -1173,11 +1160,11 @@ asmlinkage void smp_error_interrupt(void)
1173 7: Illegal register address 1160 7: Illegal register address
1174 */ 1161 */
1175 printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n", 1162 printk (KERN_DEBUG "APIC error on CPU%d: %02x(%02x)\n",
1176 smp_processor_id(), v , v1); 1163 smp_processor_id(), v , v1);
1177 irq_exit(); 1164 irq_exit();
1178} 1165}
1179 1166
1180int disable_apic; 1167int disable_apic;
1181 1168
1182/* 1169/*
1183 * This initializes the IO-APIC and APIC hardware if this is 1170 * This initializes the IO-APIC and APIC hardware if this is
@@ -1185,11 +1172,11 @@ int disable_apic;
1185 */ 1172 */
1186int __init APIC_init_uniprocessor (void) 1173int __init APIC_init_uniprocessor (void)
1187{ 1174{
1188 if (disable_apic) { 1175 if (disable_apic) {
1189 printk(KERN_INFO "Apic disabled\n"); 1176 printk(KERN_INFO "Apic disabled\n");
1190 return -1; 1177 return -1;
1191 } 1178 }
1192 if (!cpu_has_apic) { 1179 if (!cpu_has_apic) {
1193 disable_apic = 1; 1180 disable_apic = 1;
1194 printk(KERN_INFO "Apic disabled by BIOS\n"); 1181 printk(KERN_INFO "Apic disabled by BIOS\n");
1195 return -1; 1182 return -1;
@@ -1211,8 +1198,8 @@ int __init APIC_init_uniprocessor (void)
1211 return 0; 1198 return 0;
1212} 1199}
1213 1200
1214static __init int setup_disableapic(char *str) 1201static __init int setup_disableapic(char *str)
1215{ 1202{
1216 disable_apic = 1; 1203 disable_apic = 1;
1217 clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability); 1204 clear_bit(X86_FEATURE_APIC, boot_cpu_data.x86_capability);
1218 return 0; 1205 return 0;
@@ -1220,10 +1207,10 @@ static __init int setup_disableapic(char *str)
1220early_param("disableapic", setup_disableapic); 1207early_param("disableapic", setup_disableapic);
1221 1208
1222/* same as disableapic, for compatibility */ 1209/* same as disableapic, for compatibility */
1223static __init int setup_nolapic(char *str) 1210static __init int setup_nolapic(char *str)
1224{ 1211{
1225 return setup_disableapic(str); 1212 return setup_disableapic(str);
1226} 1213}
1227early_param("nolapic", setup_nolapic); 1214early_param("nolapic", setup_nolapic);
1228 1215
1229static int __init parse_lapic_timer_c2_ok(char *arg) 1216static int __init parse_lapic_timer_c2_ok(char *arg)
@@ -1233,13 +1220,13 @@ static int __init parse_lapic_timer_c2_ok(char *arg)
1233} 1220}
1234early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok); 1221early_param("lapic_timer_c2_ok", parse_lapic_timer_c2_ok);
1235 1222
1236static __init int setup_noapictimer(char *str) 1223static __init int setup_noapictimer(char *str)
1237{ 1224{
1238 if (str[0] != ' ' && str[0] != 0) 1225 if (str[0] != ' ' && str[0] != 0)
1239 return 0; 1226 return 0;
1240 disable_apic_timer = 1; 1227 disable_apic_timer = 1;
1241 return 1; 1228 return 1;
1242} 1229}
1243 1230
1244static __init int setup_apicmaintimer(char *str) 1231static __init int setup_apicmaintimer(char *str)
1245{ 1232{
@@ -1264,5 +1251,5 @@ static __init int setup_apicpmtimer(char *s)
1264} 1251}
1265__setup("apicpmtimer", setup_apicpmtimer); 1252__setup("apicpmtimer", setup_apicpmtimer);
1266 1253
1267__setup("noapictimer", setup_noapictimer); 1254__setup("noapictimer", setup_noapictimer);
1268 1255
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index 13c6c37610e0..0f4d5e209e9b 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -194,37 +194,6 @@ unsigned long __init e820_end_of_ram(void)
194} 194}
195 195
196/* 196/*
197 * Find the hole size in the range.
198 */
199unsigned long __init e820_hole_size(unsigned long start, unsigned long end)
200{
201 unsigned long ram = 0;
202 int i;
203
204 for (i = 0; i < e820.nr_map; i++) {
205 struct e820entry *ei = &e820.map[i];
206 unsigned long last, addr;
207
208 if (ei->type != E820_RAM ||
209 ei->addr+ei->size <= start ||
210 ei->addr >= end)
211 continue;
212
213 addr = round_up(ei->addr, PAGE_SIZE);
214 if (addr < start)
215 addr = start;
216
217 last = round_down(ei->addr + ei->size, PAGE_SIZE);
218 if (last >= end)
219 last = end;
220
221 if (last > addr)
222 ram += last - addr;
223 }
224 return ((end - start) - ram);
225}
226
227/*
228 * Mark e820 reserved areas as busy for the resource manager. 197 * Mark e820 reserved areas as busy for the resource manager.
229 */ 198 */
230void __init e820_reserve_resources(void) 199void __init e820_reserve_resources(void)
@@ -289,47 +258,61 @@ void __init e820_mark_nosave_regions(void)
289 } 258 }
290} 259}
291 260
292/* Walk the e820 map and register active regions within a node */ 261/*
293void __init 262 * Finds an active region in the address range from start_pfn to end_pfn and
294e820_register_active_regions(int nid, unsigned long start_pfn, 263 * returns its range in ei_startpfn and ei_endpfn for the e820 entry.
295 unsigned long end_pfn) 264 */
265static int __init e820_find_active_region(const struct e820entry *ei,
266 unsigned long start_pfn,
267 unsigned long end_pfn,
268 unsigned long *ei_startpfn,
269 unsigned long *ei_endpfn)
296{ 270{
297 int i; 271 *ei_startpfn = round_up(ei->addr, PAGE_SIZE) >> PAGE_SHIFT;
298 unsigned long ei_startpfn, ei_endpfn; 272 *ei_endpfn = round_down(ei->addr + ei->size, PAGE_SIZE) >> PAGE_SHIFT;
299 for (i = 0; i < e820.nr_map; i++) {
300 struct e820entry *ei = &e820.map[i];
301 ei_startpfn = round_up(ei->addr, PAGE_SIZE) >> PAGE_SHIFT;
302 ei_endpfn = round_down(ei->addr + ei->size, PAGE_SIZE)
303 >> PAGE_SHIFT;
304 273
305 /* Skip map entries smaller than a page */ 274 /* Skip map entries smaller than a page */
306 if (ei_startpfn >= ei_endpfn) 275 if (*ei_startpfn >= *ei_endpfn)
307 continue; 276 return 0;
308 277
309 /* Check if end_pfn_map should be updated */ 278 /* Check if end_pfn_map should be updated */
310 if (ei->type != E820_RAM && ei_endpfn > end_pfn_map) 279 if (ei->type != E820_RAM && *ei_endpfn > end_pfn_map)
311 end_pfn_map = ei_endpfn; 280 end_pfn_map = *ei_endpfn;
312 281
313 /* Skip if map is outside the node */ 282 /* Skip if map is outside the node */
314 if (ei->type != E820_RAM || 283 if (ei->type != E820_RAM || *ei_endpfn <= start_pfn ||
315 ei_endpfn <= start_pfn || 284 *ei_startpfn >= end_pfn)
316 ei_startpfn >= end_pfn) 285 return 0;
317 continue;
318 286
319 /* Check for overlaps */ 287 /* Check for overlaps */
320 if (ei_startpfn < start_pfn) 288 if (*ei_startpfn < start_pfn)
321 ei_startpfn = start_pfn; 289 *ei_startpfn = start_pfn;
322 if (ei_endpfn > end_pfn) 290 if (*ei_endpfn > end_pfn)
323 ei_endpfn = end_pfn; 291 *ei_endpfn = end_pfn;
324 292
325 /* Obey end_user_pfn to save on memmap */ 293 /* Obey end_user_pfn to save on memmap */
326 if (ei_startpfn >= end_user_pfn) 294 if (*ei_startpfn >= end_user_pfn)
327 continue; 295 return 0;
328 if (ei_endpfn > end_user_pfn) 296 if (*ei_endpfn > end_user_pfn)
329 ei_endpfn = end_user_pfn; 297 *ei_endpfn = end_user_pfn;
330 298
331 add_active_range(nid, ei_startpfn, ei_endpfn); 299 return 1;
332 } 300}
301
302/* Walk the e820 map and register active regions within a node */
303void __init
304e820_register_active_regions(int nid, unsigned long start_pfn,
305 unsigned long end_pfn)
306{
307 unsigned long ei_startpfn;
308 unsigned long ei_endpfn;
309 int i;
310
311 for (i = 0; i < e820.nr_map; i++)
312 if (e820_find_active_region(&e820.map[i],
313 start_pfn, end_pfn,
314 &ei_startpfn, &ei_endpfn))
315 add_active_range(nid, ei_startpfn, ei_endpfn);
333} 316}
334 317
335/* 318/*
@@ -350,12 +333,35 @@ void __init add_memory_region(unsigned long start, unsigned long size, int type)
350 e820.nr_map++; 333 e820.nr_map++;
351} 334}
352 335
336/*
337 * Find the hole size (in bytes) in the memory range.
338 * @start: starting address of the memory range to scan
339 * @end: ending address of the memory range to scan
340 */
341unsigned long __init e820_hole_size(unsigned long start, unsigned long end)
342{
343 unsigned long start_pfn = start >> PAGE_SHIFT;
344 unsigned long end_pfn = end >> PAGE_SHIFT;
345 unsigned long ei_startpfn;
346 unsigned long ei_endpfn;
347 unsigned long ram = 0;
348 int i;
349
350 for (i = 0; i < e820.nr_map; i++) {
351 if (e820_find_active_region(&e820.map[i],
352 start_pfn, end_pfn,
353 &ei_startpfn, &ei_endpfn))
354 ram += ei_endpfn - ei_startpfn;
355 }
356 return end - start - (ram << PAGE_SHIFT);
357}
358
353void __init e820_print_map(char *who) 359void __init e820_print_map(char *who)
354{ 360{
355 int i; 361 int i;
356 362
357 for (i = 0; i < e820.nr_map; i++) { 363 for (i = 0; i < e820.nr_map; i++) {
358 printk(" %s: %016Lx - %016Lx ", who, 364 printk(KERN_INFO " %s: %016Lx - %016Lx ", who,
359 (unsigned long long) e820.map[i].addr, 365 (unsigned long long) e820.map[i].addr,
360 (unsigned long long) (e820.map[i].addr + e820.map[i].size)); 366 (unsigned long long) (e820.map[i].addr + e820.map[i].size));
361 switch (e820.map[i].type) { 367 switch (e820.map[i].type) {
diff --git a/arch/x86_64/kernel/early-quirks.c b/arch/x86_64/kernel/early-quirks.c
index 990d9c218a5d..13aa4fd728f3 100644
--- a/arch/x86_64/kernel/early-quirks.c
+++ b/arch/x86_64/kernel/early-quirks.c
@@ -14,6 +14,7 @@
14#include <linux/pci_ids.h> 14#include <linux/pci_ids.h>
15#include <asm/pci-direct.h> 15#include <asm/pci-direct.h>
16#include <asm/proto.h> 16#include <asm/proto.h>
17#include <asm/iommu.h>
17#include <asm/dma.h> 18#include <asm/dma.h>
18 19
19static void __init via_bugs(void) 20static void __init via_bugs(void)
diff --git a/arch/x86_64/kernel/entry.S b/arch/x86_64/kernel/entry.S
index a67f87bf4015..830cfc6ee8cb 100644
--- a/arch/x86_64/kernel/entry.S
+++ b/arch/x86_64/kernel/entry.S
@@ -282,7 +282,7 @@ sysret_careful:
282sysret_signal: 282sysret_signal:
283 TRACE_IRQS_ON 283 TRACE_IRQS_ON
284 sti 284 sti
285 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx 285 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
286 jz 1f 286 jz 1f
287 287
288 /* Really a signal */ 288 /* Really a signal */
@@ -375,7 +375,7 @@ int_very_careful:
375 jmp int_restore_rest 375 jmp int_restore_rest
376 376
377int_signal: 377int_signal:
378 testl $(_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_SINGLESTEP),%edx 378 testl $(_TIF_NOTIFY_RESUME|_TIF_SIGPENDING|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
379 jz 1f 379 jz 1f
380 movq %rsp,%rdi # &ptregs -> arg1 380 movq %rsp,%rdi # &ptregs -> arg1
381 xorl %esi,%esi # oldset -> arg2 381 xorl %esi,%esi # oldset -> arg2
@@ -599,7 +599,7 @@ retint_careful:
599 jmp retint_check 599 jmp retint_check
600 600
601retint_signal: 601retint_signal:
602 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP),%edx 602 testl $(_TIF_SIGPENDING|_TIF_NOTIFY_RESUME|_TIF_SINGLESTEP|_TIF_MCE_NOTIFY),%edx
603 jz retint_swapgs 603 jz retint_swapgs
604 TRACE_IRQS_ON 604 TRACE_IRQS_ON
605 sti 605 sti
diff --git a/arch/x86_64/kernel/head.S b/arch/x86_64/kernel/head.S
index 941c84baecc8..e89abcdbdde8 100644
--- a/arch/x86_64/kernel/head.S
+++ b/arch/x86_64/kernel/head.S
@@ -25,7 +25,7 @@
25 */ 25 */
26 26
27 .text 27 .text
28 .section .bootstrap.text 28 .section .text.head
29 .code64 29 .code64
30 .globl startup_64 30 .globl startup_64
31startup_64: 31startup_64:
@@ -243,10 +243,16 @@ ENTRY(secondary_startup_64)
243 lretq 243 lretq
244 244
245 /* SMP bootup changes these two */ 245 /* SMP bootup changes these two */
246#ifndef CONFIG_HOTPLUG_CPU
247 .pushsection .init.data
248#endif
246 .align 8 249 .align 8
247 .globl initial_code 250 .globl initial_code
248initial_code: 251initial_code:
249 .quad x86_64_start_kernel 252 .quad x86_64_start_kernel
253#ifndef CONFIG_HOTPLUG_CPU
254 .popsection
255#endif
250 .globl init_rsp 256 .globl init_rsp
251init_rsp: 257init_rsp:
252 .quad init_thread_union+THREAD_SIZE-8 258 .quad init_thread_union+THREAD_SIZE-8
diff --git a/arch/x86_64/kernel/hpet.c b/arch/x86_64/kernel/hpet.c
index b8286968662d..e2d1b912e154 100644
--- a/arch/x86_64/kernel/hpet.c
+++ b/arch/x86_64/kernel/hpet.c
@@ -133,7 +133,7 @@ struct clocksource clocksource_hpet = {
133 .vread = vread_hpet, 133 .vread = vread_hpet,
134}; 134};
135 135
136int hpet_arch_init(void) 136int __init hpet_arch_init(void)
137{ 137{
138 unsigned int id; 138 unsigned int id;
139 u64 tmp; 139 u64 tmp;
@@ -190,7 +190,7 @@ int hpet_reenable(void)
190 */ 190 */
191 191
192#define TICK_COUNT 100000000 192#define TICK_COUNT 100000000
193#define TICK_MIN 5000 193#define SMI_THRESHOLD 50000
194#define MAX_TRIES 5 194#define MAX_TRIES 5
195 195
196/* 196/*
@@ -205,7 +205,7 @@ static void __init read_hpet_tsc(int *hpet, int *tsc)
205 tsc1 = get_cycles_sync(); 205 tsc1 = get_cycles_sync();
206 hpet1 = hpet_readl(HPET_COUNTER); 206 hpet1 = hpet_readl(HPET_COUNTER);
207 tsc2 = get_cycles_sync(); 207 tsc2 = get_cycles_sync();
208 if (tsc2 - tsc1 > TICK_MIN) 208 if ((tsc2 - tsc1) < SMI_THRESHOLD)
209 break; 209 break;
210 } 210 }
211 *hpet = hpet1; 211 *hpet = hpet1;
@@ -439,7 +439,7 @@ int hpet_rtc_dropped_irq(void)
439 return 1; 439 return 1;
440} 440}
441 441
442irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs) 442irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
443{ 443{
444 struct rtc_time curr_time; 444 struct rtc_time curr_time;
445 unsigned long rtc_int_flag = 0; 445 unsigned long rtc_int_flag = 0;
diff --git a/arch/x86_64/kernel/i8259.c b/arch/x86_64/kernel/i8259.c
index 4b326655b208..948cae646099 100644
--- a/arch/x86_64/kernel/i8259.c
+++ b/arch/x86_64/kernel/i8259.c
@@ -444,24 +444,6 @@ void __init init_ISA_irqs (void)
444 } 444 }
445} 445}
446 446
447void apic_timer_interrupt(void);
448void spurious_interrupt(void);
449void error_interrupt(void);
450void reschedule_interrupt(void);
451void call_function_interrupt(void);
452void irq_move_cleanup_interrupt(void);
453void invalidate_interrupt0(void);
454void invalidate_interrupt1(void);
455void invalidate_interrupt2(void);
456void invalidate_interrupt3(void);
457void invalidate_interrupt4(void);
458void invalidate_interrupt5(void);
459void invalidate_interrupt6(void);
460void invalidate_interrupt7(void);
461void thermal_interrupt(void);
462void threshold_interrupt(void);
463void i8254_timer_resume(void);
464
465static void setup_timer_hardware(void) 447static void setup_timer_hardware(void)
466{ 448{
467 outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */ 449 outb_p(0x34,0x43); /* binary, mode 2, LSB/MSB, ch 0 */
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 1c6c6f724573..050141c0602b 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -152,6 +152,32 @@ static inline void io_apic_modify(unsigned int apic, unsigned int value)
152 writel(value, &io_apic->data); 152 writel(value, &io_apic->data);
153} 153}
154 154
155static int io_apic_level_ack_pending(unsigned int irq)
156{
157 struct irq_pin_list *entry;
158 unsigned long flags;
159 int pending = 0;
160
161 spin_lock_irqsave(&ioapic_lock, flags);
162 entry = irq_2_pin + irq;
163 for (;;) {
164 unsigned int reg;
165 int pin;
166
167 pin = entry->pin;
168 if (pin == -1)
169 break;
170 reg = io_apic_read(entry->apic, 0x10 + pin*2);
171 /* Is the remote IRR bit set? */
172 pending |= (reg >> 14) & 1;
173 if (!entry->next)
174 break;
175 entry = irq_2_pin + entry->next;
176 }
177 spin_unlock_irqrestore(&ioapic_lock, flags);
178 return pending;
179}
180
155/* 181/*
156 * Synchronize the IO-APIC and the CPU by doing 182 * Synchronize the IO-APIC and the CPU by doing
157 * a dummy read from the IO-APIC 183 * a dummy read from the IO-APIC
@@ -1418,9 +1444,37 @@ static void ack_apic_level(unsigned int irq)
1418 ack_APIC_irq(); 1444 ack_APIC_irq();
1419 1445
1420 /* Now we can move and renable the irq */ 1446 /* Now we can move and renable the irq */
1421 move_masked_irq(irq); 1447 if (unlikely(do_unmask_irq)) {
1422 if (unlikely(do_unmask_irq)) 1448 /* Only migrate the irq if the ack has been received.
1449 *
1450 * On rare occasions the broadcast level triggered ack gets
1451 * delayed going to ioapics, and if we reprogram the
1452 * vector while Remote IRR is still set the irq will never
1453 * fire again.
1454 *
1455 * To prevent this scenario we read the Remote IRR bit
1456 * of the ioapic. This has two effects.
1457 * - On any sane system the read of the ioapic will
1458 * flush writes (and acks) going to the ioapic from
1459 * this cpu.
1460 * - We get to see if the ACK has actually been delivered.
1461 *
1462 * Based on failed experiments of reprogramming the
1463 * ioapic entry from outside of irq context starting
1464 * with masking the ioapic entry and then polling until
1465 * Remote IRR was clear before reprogramming the
1466 * ioapic I don't trust the Remote IRR bit to be
1467 * completey accurate.
1468 *
1469 * However there appears to be no other way to plug
1470 * this race, so if the Remote IRR bit is not
1471 * accurate and is causing problems then it is a hardware bug
1472 * and you can go talk to the chipset vendor about it.
1473 */
1474 if (!io_apic_level_ack_pending(irq))
1475 move_masked_irq(irq);
1423 unmask_IO_APIC_irq(irq); 1476 unmask_IO_APIC_irq(irq);
1477 }
1424} 1478}
1425 1479
1426static struct irq_chip ioapic_chip __read_mostly = { 1480static struct irq_chip ioapic_chip __read_mostly = {
diff --git a/arch/x86_64/kernel/kprobes.c b/arch/x86_64/kernel/kprobes.c
index d4a0d0ac9935..a30e004682e2 100644
--- a/arch/x86_64/kernel/kprobes.c
+++ b/arch/x86_64/kernel/kprobes.c
@@ -39,9 +39,9 @@
39#include <linux/module.h> 39#include <linux/module.h>
40#include <linux/kdebug.h> 40#include <linux/kdebug.h>
41 41
42#include <asm/cacheflush.h>
43#include <asm/pgtable.h> 42#include <asm/pgtable.h>
44#include <asm/uaccess.h> 43#include <asm/uaccess.h>
44#include <asm/alternative.h>
45 45
46void jprobe_return_end(void); 46void jprobe_return_end(void);
47static void __kprobes arch_copy_kprobe(struct kprobe *p); 47static void __kprobes arch_copy_kprobe(struct kprobe *p);
@@ -209,16 +209,12 @@ static void __kprobes arch_copy_kprobe(struct kprobe *p)
209 209
210void __kprobes arch_arm_kprobe(struct kprobe *p) 210void __kprobes arch_arm_kprobe(struct kprobe *p)
211{ 211{
212 *p->addr = BREAKPOINT_INSTRUCTION; 212 text_poke(p->addr, ((unsigned char []){BREAKPOINT_INSTRUCTION}), 1);
213 flush_icache_range((unsigned long) p->addr,
214 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
215} 213}
216 214
217void __kprobes arch_disarm_kprobe(struct kprobe *p) 215void __kprobes arch_disarm_kprobe(struct kprobe *p)
218{ 216{
219 *p->addr = p->opcode; 217 text_poke(p->addr, &p->opcode, 1);
220 flush_icache_range((unsigned long) p->addr,
221 (unsigned long) p->addr + sizeof(kprobe_opcode_t));
222} 218}
223 219
224void __kprobes arch_remove_kprobe(struct kprobe *p) 220void __kprobes arch_remove_kprobe(struct kprobe *p)
diff --git a/arch/x86_64/kernel/mce.c b/arch/x86_64/kernel/mce.c
index f3fb8174559e..a66d607f5b92 100644
--- a/arch/x86_64/kernel/mce.c
+++ b/arch/x86_64/kernel/mce.c
@@ -18,6 +18,8 @@
18#include <linux/capability.h> 18#include <linux/capability.h>
19#include <linux/cpu.h> 19#include <linux/cpu.h>
20#include <linux/percpu.h> 20#include <linux/percpu.h>
21#include <linux/poll.h>
22#include <linux/thread_info.h>
21#include <linux/ctype.h> 23#include <linux/ctype.h>
22#include <linux/kmod.h> 24#include <linux/kmod.h>
23#include <linux/kdebug.h> 25#include <linux/kdebug.h>
@@ -26,6 +28,7 @@
26#include <asm/mce.h> 28#include <asm/mce.h>
27#include <asm/uaccess.h> 29#include <asm/uaccess.h>
28#include <asm/smp.h> 30#include <asm/smp.h>
31#include <asm/idle.h>
29 32
30#define MISC_MCELOG_MINOR 227 33#define MISC_MCELOG_MINOR 227
31#define NR_BANKS 6 34#define NR_BANKS 6
@@ -34,13 +37,17 @@ atomic_t mce_entry;
34 37
35static int mce_dont_init; 38static int mce_dont_init;
36 39
37/* 0: always panic, 1: panic if deadlock possible, 2: try to avoid panic, 40/*
38 3: never panic or exit (for testing only) */ 41 * Tolerant levels:
42 * 0: always panic on uncorrected errors, log corrected errors
43 * 1: panic or SIGBUS on uncorrected errors, log corrected errors
44 * 2: SIGBUS or log uncorrected errors (if possible), log corrected errors
45 * 3: never panic or SIGBUS, log all errors (for testing only)
46 */
39static int tolerant = 1; 47static int tolerant = 1;
40static int banks; 48static int banks;
41static unsigned long bank[NR_BANKS] = { [0 ... NR_BANKS-1] = ~0UL }; 49static unsigned long bank[NR_BANKS] = { [0 ... NR_BANKS-1] = ~0UL };
42static unsigned long console_logged; 50static unsigned long notify_user;
43static int notify_user;
44static int rip_msr; 51static int rip_msr;
45static int mce_bootlog = 1; 52static int mce_bootlog = 1;
46static atomic_t mce_events; 53static atomic_t mce_events;
@@ -48,6 +55,8 @@ static atomic_t mce_events;
48static char trigger[128]; 55static char trigger[128];
49static char *trigger_argv[2] = { trigger, NULL }; 56static char *trigger_argv[2] = { trigger, NULL };
50 57
58static DECLARE_WAIT_QUEUE_HEAD(mce_wait);
59
51/* 60/*
52 * Lockless MCE logging infrastructure. 61 * Lockless MCE logging infrastructure.
53 * This avoids deadlocks on printk locks without having to break locks. Also 62 * This avoids deadlocks on printk locks without having to break locks. Also
@@ -94,8 +103,7 @@ void mce_log(struct mce *mce)
94 mcelog.entry[entry].finished = 1; 103 mcelog.entry[entry].finished = 1;
95 wmb(); 104 wmb();
96 105
97 if (!test_and_set_bit(0, &console_logged)) 106 set_bit(0, &notify_user);
98 notify_user = 1;
99} 107}
100 108
101static void print_mce(struct mce *m) 109static void print_mce(struct mce *m)
@@ -128,6 +136,7 @@ static void print_mce(struct mce *m)
128static void mce_panic(char *msg, struct mce *backup, unsigned long start) 136static void mce_panic(char *msg, struct mce *backup, unsigned long start)
129{ 137{
130 int i; 138 int i;
139
131 oops_begin(); 140 oops_begin();
132 for (i = 0; i < MCE_LOG_LEN; i++) { 141 for (i = 0; i < MCE_LOG_LEN; i++) {
133 unsigned long tsc = mcelog.entry[i].tsc; 142 unsigned long tsc = mcelog.entry[i].tsc;
@@ -139,10 +148,7 @@ static void mce_panic(char *msg, struct mce *backup, unsigned long start)
139 } 148 }
140 if (backup) 149 if (backup)
141 print_mce(backup); 150 print_mce(backup);
142 if (tolerant >= 3) 151 panic(msg);
143 printk("Fake panic: %s\n", msg);
144 else
145 panic(msg);
146} 152}
147 153
148static int mce_available(struct cpuinfo_x86 *c) 154static int mce_available(struct cpuinfo_x86 *c)
@@ -167,17 +173,6 @@ static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
167 } 173 }
168} 174}
169 175
170static void do_mce_trigger(void)
171{
172 static atomic_t mce_logged;
173 int events = atomic_read(&mce_events);
174 if (events != atomic_read(&mce_logged) && trigger[0]) {
175 /* Small race window, but should be harmless. */
176 atomic_set(&mce_logged, events);
177 call_usermodehelper(trigger, trigger_argv, NULL, UMH_NO_WAIT);
178 }
179}
180
181/* 176/*
182 * The actual machine check handler 177 * The actual machine check handler
183 */ 178 */
@@ -185,11 +180,19 @@ static void do_mce_trigger(void)
185void do_machine_check(struct pt_regs * regs, long error_code) 180void do_machine_check(struct pt_regs * regs, long error_code)
186{ 181{
187 struct mce m, panicm; 182 struct mce m, panicm;
188 int nowayout = (tolerant < 1);
189 int kill_it = 0;
190 u64 mcestart = 0; 183 u64 mcestart = 0;
191 int i; 184 int i;
192 int panicm_found = 0; 185 int panicm_found = 0;
186 /*
187 * If no_way_out gets set, there is no safe way to recover from this
188 * MCE. If tolerant is cranked up, we'll try anyway.
189 */
190 int no_way_out = 0;
191 /*
192 * If kill_it gets set, there might be a way to recover from this
193 * error.
194 */
195 int kill_it = 0;
193 196
194 atomic_inc(&mce_entry); 197 atomic_inc(&mce_entry);
195 198
@@ -201,8 +204,9 @@ void do_machine_check(struct pt_regs * regs, long error_code)
201 memset(&m, 0, sizeof(struct mce)); 204 memset(&m, 0, sizeof(struct mce));
202 m.cpu = smp_processor_id(); 205 m.cpu = smp_processor_id();
203 rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus); 206 rdmsrl(MSR_IA32_MCG_STATUS, m.mcgstatus);
207 /* if the restart IP is not valid, we're done for */
204 if (!(m.mcgstatus & MCG_STATUS_RIPV)) 208 if (!(m.mcgstatus & MCG_STATUS_RIPV))
205 kill_it = 1; 209 no_way_out = 1;
206 210
207 rdtscll(mcestart); 211 rdtscll(mcestart);
208 barrier(); 212 barrier();
@@ -221,10 +225,18 @@ void do_machine_check(struct pt_regs * regs, long error_code)
221 continue; 225 continue;
222 226
223 if (m.status & MCI_STATUS_EN) { 227 if (m.status & MCI_STATUS_EN) {
224 /* In theory _OVER could be a nowayout too, but 228 /* if PCC was set, there's no way out */
225 assume any overflowed errors were no fatal. */ 229 no_way_out |= !!(m.status & MCI_STATUS_PCC);
226 nowayout |= !!(m.status & MCI_STATUS_PCC); 230 /*
227 kill_it |= !!(m.status & MCI_STATUS_UC); 231 * If this error was uncorrectable and there was
232 * an overflow, we're in trouble. If no overflow,
233 * we might get away with just killing a task.
234 */
235 if (m.status & MCI_STATUS_UC) {
236 if (tolerant < 1 || m.status & MCI_STATUS_OVER)
237 no_way_out = 1;
238 kill_it = 1;
239 }
228 } 240 }
229 241
230 if (m.status & MCI_STATUS_MISCV) 242 if (m.status & MCI_STATUS_MISCV)
@@ -235,7 +247,6 @@ void do_machine_check(struct pt_regs * regs, long error_code)
235 mce_get_rip(&m, regs); 247 mce_get_rip(&m, regs);
236 if (error_code >= 0) 248 if (error_code >= 0)
237 rdtscll(m.tsc); 249 rdtscll(m.tsc);
238 wrmsrl(MSR_IA32_MC0_STATUS + i*4, 0);
239 if (error_code != -2) 250 if (error_code != -2)
240 mce_log(&m); 251 mce_log(&m);
241 252
@@ -251,45 +262,59 @@ void do_machine_check(struct pt_regs * regs, long error_code)
251 } 262 }
252 263
253 /* Never do anything final in the polling timer */ 264 /* Never do anything final in the polling timer */
254 if (!regs) { 265 if (!regs)
255 /* Normal interrupt context here. Call trigger for any new
256 events. */
257 do_mce_trigger();
258 goto out; 266 goto out;
259 }
260 267
261 /* If we didn't find an uncorrectable error, pick 268 /* If we didn't find an uncorrectable error, pick
262 the last one (shouldn't happen, just being safe). */ 269 the last one (shouldn't happen, just being safe). */
263 if (!panicm_found) 270 if (!panicm_found)
264 panicm = m; 271 panicm = m;
265 if (nowayout) 272
273 /*
274 * If we have decided that we just CAN'T continue, and the user
275 * has not set tolerant to an insane level, give up and die.
276 */
277 if (no_way_out && tolerant < 3)
266 mce_panic("Machine check", &panicm, mcestart); 278 mce_panic("Machine check", &panicm, mcestart);
267 if (kill_it) { 279
280 /*
281 * If the error seems to be unrecoverable, something should be
282 * done. Try to kill as little as possible. If we can kill just
283 * one task, do that. If the user has set the tolerance very
284 * high, don't try to do anything at all.
285 */
286 if (kill_it && tolerant < 3) {
268 int user_space = 0; 287 int user_space = 0;
269 288
270 if (m.mcgstatus & MCG_STATUS_RIPV) 289 /*
290 * If the EIPV bit is set, it means the saved IP is the
291 * instruction which caused the MCE.
292 */
293 if (m.mcgstatus & MCG_STATUS_EIPV)
271 user_space = panicm.rip && (panicm.cs & 3); 294 user_space = panicm.rip && (panicm.cs & 3);
272 295
273 /* When the machine was in user space and the CPU didn't get 296 /*
274 confused it's normally not necessary to panic, unless you 297 * If we know that the error was in user space, send a
275 are paranoid (tolerant == 0) 298 * SIGBUS. Otherwise, panic if tolerance is low.
276 299 *
277 RED-PEN could be more tolerant for MCEs in idle, 300 * do_exit() takes an awful lot of locks and has a slight
278 but most likely they occur at boot anyways, where 301 * risk of deadlocking.
279 it is best to just halt the machine. */ 302 */
280 if ((!user_space && (panic_on_oops || tolerant < 2)) || 303 if (user_space) {
281 (unsigned)current->pid <= 1)
282 mce_panic("Uncorrected machine check", &panicm, mcestart);
283
284 /* do_exit takes an awful lot of locks and has as
285 slight risk of deadlocking. If you don't want that
286 don't set tolerant >= 2 */
287 if (tolerant < 3)
288 do_exit(SIGBUS); 304 do_exit(SIGBUS);
305 } else if (panic_on_oops || tolerant < 2) {
306 mce_panic("Uncorrected machine check",
307 &panicm, mcestart);
308 }
289 } 309 }
290 310
311 /* notify userspace ASAP */
312 set_thread_flag(TIF_MCE_NOTIFY);
313
291 out: 314 out:
292 /* Last thing done in the machine check exception to clear state. */ 315 /* the last thing we do is clear state */
316 for (i = 0; i < banks; i++)
317 wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0);
293 wrmsrl(MSR_IA32_MCG_STATUS, 0); 318 wrmsrl(MSR_IA32_MCG_STATUS, 0);
294 out2: 319 out2:
295 atomic_dec(&mce_entry); 320 atomic_dec(&mce_entry);
@@ -344,37 +369,69 @@ static void mcheck_timer(struct work_struct *work)
344 on_each_cpu(mcheck_check_cpu, NULL, 1, 1); 369 on_each_cpu(mcheck_check_cpu, NULL, 1, 1);
345 370
346 /* 371 /*
347 * It's ok to read stale data here for notify_user and 372 * Alert userspace if needed. If we logged an MCE, reduce the
348 * console_logged as we'll simply get the updated versions 373 * polling interval, otherwise increase the polling interval.
349 * on the next mcheck_timer execution and atomic operations
350 * on console_logged act as synchronization for notify_user
351 * writes.
352 */ 374 */
353 if (notify_user && console_logged) { 375 if (mce_notify_user()) {
376 next_interval = max(next_interval/2, HZ/100);
377 } else {
378 next_interval = min(next_interval*2,
379 (int)round_jiffies_relative(check_interval*HZ));
380 }
381
382 schedule_delayed_work(&mcheck_work, next_interval);
383}
384
385/*
386 * This is only called from process context. This is where we do
387 * anything we need to alert userspace about new MCEs. This is called
388 * directly from the poller and also from entry.S and idle, thanks to
389 * TIF_MCE_NOTIFY.
390 */
391int mce_notify_user(void)
392{
393 clear_thread_flag(TIF_MCE_NOTIFY);
394 if (test_and_clear_bit(0, &notify_user)) {
354 static unsigned long last_print; 395 static unsigned long last_print;
355 unsigned long now = jiffies; 396 unsigned long now = jiffies;
356 397
357 /* if we logged an MCE, reduce the polling interval */ 398 wake_up_interruptible(&mce_wait);
358 next_interval = max(next_interval/2, HZ/100); 399 if (trigger[0])
359 notify_user = 0; 400 call_usermodehelper(trigger, trigger_argv, NULL,
360 clear_bit(0, &console_logged); 401 UMH_NO_WAIT);
402
361 if (time_after_eq(now, last_print + (check_interval*HZ))) { 403 if (time_after_eq(now, last_print + (check_interval*HZ))) {
362 last_print = now; 404 last_print = now;
363 printk(KERN_INFO "Machine check events logged\n"); 405 printk(KERN_INFO "Machine check events logged\n");
364 } 406 }
365 } else { 407
366 next_interval = min(next_interval*2, check_interval*HZ); 408 return 1;
367 } 409 }
410 return 0;
411}
368 412
369 schedule_delayed_work(&mcheck_work, next_interval); 413/* see if the idle task needs to notify userspace */
414static int
415mce_idle_callback(struct notifier_block *nfb, unsigned long action, void *junk)
416{
417 /* IDLE_END should be safe - interrupts are back on */
418 if (action == IDLE_END && test_thread_flag(TIF_MCE_NOTIFY))
419 mce_notify_user();
420
421 return NOTIFY_OK;
370} 422}
371 423
424static struct notifier_block mce_idle_notifier = {
425 .notifier_call = mce_idle_callback,
426};
372 427
373static __init int periodic_mcheck_init(void) 428static __init int periodic_mcheck_init(void)
374{ 429{
375 next_interval = check_interval * HZ; 430 next_interval = check_interval * HZ;
376 if (next_interval) 431 if (next_interval)
377 schedule_delayed_work(&mcheck_work, next_interval); 432 schedule_delayed_work(&mcheck_work,
433 round_jiffies_relative(next_interval));
434 idle_notifier_register(&mce_idle_notifier);
378 return 0; 435 return 0;
379} 436}
380__initcall(periodic_mcheck_init); 437__initcall(periodic_mcheck_init);
@@ -465,6 +522,40 @@ void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
465 * Character device to read and clear the MCE log. 522 * Character device to read and clear the MCE log.
466 */ 523 */
467 524
525static DEFINE_SPINLOCK(mce_state_lock);
526static int open_count; /* #times opened */
527static int open_exclu; /* already open exclusive? */
528
529static int mce_open(struct inode *inode, struct file *file)
530{
531 spin_lock(&mce_state_lock);
532
533 if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
534 spin_unlock(&mce_state_lock);
535 return -EBUSY;
536 }
537
538 if (file->f_flags & O_EXCL)
539 open_exclu = 1;
540 open_count++;
541
542 spin_unlock(&mce_state_lock);
543
544 return nonseekable_open(inode, file);
545}
546
547static int mce_release(struct inode *inode, struct file *file)
548{
549 spin_lock(&mce_state_lock);
550
551 open_count--;
552 open_exclu = 0;
553
554 spin_unlock(&mce_state_lock);
555
556 return 0;
557}
558
468static void collect_tscs(void *data) 559static void collect_tscs(void *data)
469{ 560{
470 unsigned long *cpu_tsc = (unsigned long *)data; 561 unsigned long *cpu_tsc = (unsigned long *)data;
@@ -532,6 +623,14 @@ static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, loff
532 return err ? -EFAULT : buf - ubuf; 623 return err ? -EFAULT : buf - ubuf;
533} 624}
534 625
626static unsigned int mce_poll(struct file *file, poll_table *wait)
627{
628 poll_wait(file, &mce_wait, wait);
629 if (rcu_dereference(mcelog.next))
630 return POLLIN | POLLRDNORM;
631 return 0;
632}
633
535static int mce_ioctl(struct inode *i, struct file *f,unsigned int cmd, unsigned long arg) 634static int mce_ioctl(struct inode *i, struct file *f,unsigned int cmd, unsigned long arg)
536{ 635{
537 int __user *p = (int __user *)arg; 636 int __user *p = (int __user *)arg;
@@ -555,7 +654,10 @@ static int mce_ioctl(struct inode *i, struct file *f,unsigned int cmd, unsigned
555} 654}
556 655
557static const struct file_operations mce_chrdev_ops = { 656static const struct file_operations mce_chrdev_ops = {
657 .open = mce_open,
658 .release = mce_release,
558 .read = mce_read, 659 .read = mce_read,
660 .poll = mce_poll,
559 .ioctl = mce_ioctl, 661 .ioctl = mce_ioctl,
560}; 662};
561 663
@@ -565,6 +667,20 @@ static struct miscdevice mce_log_device = {
565 &mce_chrdev_ops, 667 &mce_chrdev_ops,
566}; 668};
567 669
670static unsigned long old_cr4 __initdata;
671
672void __init stop_mce(void)
673{
674 old_cr4 = read_cr4();
675 clear_in_cr4(X86_CR4_MCE);
676}
677
678void __init restart_mce(void)
679{
680 if (old_cr4 & X86_CR4_MCE)
681 set_in_cr4(X86_CR4_MCE);
682}
683
568/* 684/*
569 * Old style boot options parsing. Only for compatibility. 685 * Old style boot options parsing. Only for compatibility.
570 */ 686 */
@@ -620,7 +736,8 @@ static void mce_restart(void)
620 on_each_cpu(mce_init, NULL, 1, 1); 736 on_each_cpu(mce_init, NULL, 1, 1);
621 next_interval = check_interval * HZ; 737 next_interval = check_interval * HZ;
622 if (next_interval) 738 if (next_interval)
623 schedule_delayed_work(&mcheck_work, next_interval); 739 schedule_delayed_work(&mcheck_work,
740 round_jiffies_relative(next_interval));
624} 741}
625 742
626static struct sysdev_class mce_sysclass = { 743static struct sysdev_class mce_sysclass = {
diff --git a/arch/x86_64/kernel/mce_amd.c b/arch/x86_64/kernel/mce_amd.c
index 03356e64f9c8..2f8a7f18b0fe 100644
--- a/arch/x86_64/kernel/mce_amd.c
+++ b/arch/x86_64/kernel/mce_amd.c
@@ -157,9 +157,9 @@ void __cpuinit mce_amd_feature_init(struct cpuinfo_x86 *c)
157 high |= K8_APIC_EXT_LVT_ENTRY_THRESHOLD << 20; 157 high |= K8_APIC_EXT_LVT_ENTRY_THRESHOLD << 20;
158 wrmsr(address, low, high); 158 wrmsr(address, low, high);
159 159
160 setup_APIC_extened_lvt(K8_APIC_EXT_LVT_ENTRY_THRESHOLD, 160 setup_APIC_extended_lvt(K8_APIC_EXT_LVT_ENTRY_THRESHOLD,
161 THRESHOLD_APIC_VECTOR, 161 THRESHOLD_APIC_VECTOR,
162 K8_APIC_EXT_INT_MSG_FIX, 0); 162 K8_APIC_EXT_INT_MSG_FIX, 0);
163 163
164 threshold_defaults.address = address; 164 threshold_defaults.address = address;
165 threshold_restart_bank(&threshold_defaults, 0, 0); 165 threshold_restart_bank(&threshold_defaults, 0, 0);
diff --git a/arch/x86_64/kernel/mpparse.c b/arch/x86_64/kernel/mpparse.c
index 61ae57eb9e4c..8bf0ca03ac8e 100644
--- a/arch/x86_64/kernel/mpparse.c
+++ b/arch/x86_64/kernel/mpparse.c
@@ -32,7 +32,6 @@
32 32
33/* Have we found an MP table */ 33/* Have we found an MP table */
34int smp_found_config; 34int smp_found_config;
35unsigned int __initdata maxcpus = NR_CPUS;
36 35
37/* 36/*
38 * Various Linux-internal data structures created from the 37 * Various Linux-internal data structures created from the
@@ -649,6 +648,20 @@ static int mp_find_ioapic(int gsi)
649 return -1; 648 return -1;
650} 649}
651 650
651static u8 uniq_ioapic_id(u8 id)
652{
653 int i;
654 DECLARE_BITMAP(used, 256);
655 bitmap_zero(used, 256);
656 for (i = 0; i < nr_ioapics; i++) {
657 struct mpc_config_ioapic *ia = &mp_ioapics[i];
658 __set_bit(ia->mpc_apicid, used);
659 }
660 if (!test_bit(id, used))
661 return id;
662 return find_first_zero_bit(used, 256);
663}
664
652void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base) 665void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
653{ 666{
654 int idx = 0; 667 int idx = 0;
@@ -656,14 +669,14 @@ void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
656 if (bad_ioapic(address)) 669 if (bad_ioapic(address))
657 return; 670 return;
658 671
659 idx = nr_ioapics++; 672 idx = nr_ioapics;
660 673
661 mp_ioapics[idx].mpc_type = MP_IOAPIC; 674 mp_ioapics[idx].mpc_type = MP_IOAPIC;
662 mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE; 675 mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
663 mp_ioapics[idx].mpc_apicaddr = address; 676 mp_ioapics[idx].mpc_apicaddr = address;
664 677
665 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address); 678 set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
666 mp_ioapics[idx].mpc_apicid = id; 679 mp_ioapics[idx].mpc_apicid = uniq_ioapic_id(id);
667 mp_ioapics[idx].mpc_apicver = 0; 680 mp_ioapics[idx].mpc_apicver = 0;
668 681
669 /* 682 /*
@@ -680,6 +693,8 @@ void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
680 mp_ioapics[idx].mpc_apicaddr, 693 mp_ioapics[idx].mpc_apicaddr,
681 mp_ioapic_routing[idx].gsi_start, 694 mp_ioapic_routing[idx].gsi_start,
682 mp_ioapic_routing[idx].gsi_end); 695 mp_ioapic_routing[idx].gsi_end);
696
697 nr_ioapics++;
683} 698}
684 699
685void __init 700void __init
diff --git a/arch/x86_64/kernel/nmi.c b/arch/x86_64/kernel/nmi.c
index edbbc59b7523..cb8ee9d02f86 100644
--- a/arch/x86_64/kernel/nmi.c
+++ b/arch/x86_64/kernel/nmi.c
@@ -384,11 +384,14 @@ int __kprobes nmi_watchdog_tick(struct pt_regs * regs, unsigned reason)
384 return rc; 384 return rc;
385} 385}
386 386
387static unsigned ignore_nmis;
388
387asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code) 389asmlinkage __kprobes void do_nmi(struct pt_regs * regs, long error_code)
388{ 390{
389 nmi_enter(); 391 nmi_enter();
390 add_pda(__nmi_count,1); 392 add_pda(__nmi_count,1);
391 default_do_nmi(regs); 393 if (!ignore_nmis)
394 default_do_nmi(regs);
392 nmi_exit(); 395 nmi_exit();
393} 396}
394 397
@@ -401,6 +404,18 @@ int do_nmi_callback(struct pt_regs * regs, int cpu)
401 return 0; 404 return 0;
402} 405}
403 406
407void stop_nmi(void)
408{
409 acpi_nmi_disable();
410 ignore_nmis++;
411}
412
413void restart_nmi(void)
414{
415 ignore_nmis--;
416 acpi_nmi_enable();
417}
418
404#ifdef CONFIG_SYSCTL 419#ifdef CONFIG_SYSCTL
405 420
406static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu) 421static int unknown_nmi_panic_callback(struct pt_regs *regs, int cpu)
diff --git a/arch/x86_64/kernel/pci-calgary.c b/arch/x86_64/kernel/pci-calgary.c
index 5bd20b542c1e..ba16c968ca3f 100644
--- a/arch/x86_64/kernel/pci-calgary.c
+++ b/arch/x86_64/kernel/pci-calgary.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Derived from arch/powerpc/kernel/iommu.c 2 * Derived from arch/powerpc/kernel/iommu.c
3 * 3 *
4 * Copyright (C) IBM Corporation, 2006 4 * Copyright IBM Corporation, 2006-2007
5 * Copyright (C) 2006 Jon Mason <jdmason@kudzu.us> 5 * Copyright (C) 2006 Jon Mason <jdmason@kudzu.us>
6 * 6 *
7 * Author: Jon Mason <jdmason@kudzu.us> 7 * Author: Jon Mason <jdmason@kudzu.us>
@@ -35,7 +35,7 @@
35#include <linux/pci_ids.h> 35#include <linux/pci_ids.h>
36#include <linux/pci.h> 36#include <linux/pci.h>
37#include <linux/delay.h> 37#include <linux/delay.h>
38#include <asm/proto.h> 38#include <asm/iommu.h>
39#include <asm/calgary.h> 39#include <asm/calgary.h>
40#include <asm/tce.h> 40#include <asm/tce.h>
41#include <asm/pci-direct.h> 41#include <asm/pci-direct.h>
@@ -50,13 +50,7 @@ int use_calgary __read_mostly = 0;
50#endif /* CONFIG_CALGARY_DEFAULT_ENABLED */ 50#endif /* CONFIG_CALGARY_DEFAULT_ENABLED */
51 51
52#define PCI_DEVICE_ID_IBM_CALGARY 0x02a1 52#define PCI_DEVICE_ID_IBM_CALGARY 0x02a1
53#define PCI_VENDOR_DEVICE_ID_CALGARY \ 53#define PCI_DEVICE_ID_IBM_CALIOC2 0x0308
54 (PCI_VENDOR_ID_IBM | PCI_DEVICE_ID_IBM_CALGARY << 16)
55
56/* we need these for register space address calculation */
57#define START_ADDRESS 0xfe000000
58#define CHASSIS_BASE 0
59#define ONE_BASED_CHASSIS_NUM 1
60 54
61/* register offsets inside the host bridge space */ 55/* register offsets inside the host bridge space */
62#define CALGARY_CONFIG_REG 0x0108 56#define CALGARY_CONFIG_REG 0x0108
@@ -80,6 +74,12 @@ int use_calgary __read_mostly = 0;
80#define PHB_MEM_2_SIZE_LOW 0x02E0 74#define PHB_MEM_2_SIZE_LOW 0x02E0
81#define PHB_DOSHOLE_OFFSET 0x08E0 75#define PHB_DOSHOLE_OFFSET 0x08E0
82 76
77/* CalIOC2 specific */
78#define PHB_SAVIOR_L2 0x0DB0
79#define PHB_PAGE_MIG_CTRL 0x0DA8
80#define PHB_PAGE_MIG_DEBUG 0x0DA0
81#define PHB_ROOT_COMPLEX_STATUS 0x0CB0
82
83/* PHB_CONFIG_RW */ 83/* PHB_CONFIG_RW */
84#define PHB_TCE_ENABLE 0x20000000 84#define PHB_TCE_ENABLE 0x20000000
85#define PHB_SLOT_DISABLE 0x1C000000 85#define PHB_SLOT_DISABLE 0x1C000000
@@ -92,7 +92,11 @@ int use_calgary __read_mostly = 0;
92/* CSR (Channel/DMA Status Register) */ 92/* CSR (Channel/DMA Status Register) */
93#define CSR_AGENT_MASK 0xffe0ffff 93#define CSR_AGENT_MASK 0xffe0ffff
94/* CCR (Calgary Configuration Register) */ 94/* CCR (Calgary Configuration Register) */
95#define CCR_2SEC_TIMEOUT 0x000000000000000EUL 95#define CCR_2SEC_TIMEOUT 0x000000000000000EUL
96/* PMCR/PMDR (Page Migration Control/Debug Registers */
97#define PMR_SOFTSTOP 0x80000000
98#define PMR_SOFTSTOPFAULT 0x40000000
99#define PMR_HARDSTOP 0x20000000
96 100
97#define MAX_NUM_OF_PHBS 8 /* how many PHBs in total? */ 101#define MAX_NUM_OF_PHBS 8 /* how many PHBs in total? */
98#define MAX_NUM_CHASSIS 8 /* max number of chassis */ 102#define MAX_NUM_CHASSIS 8 /* max number of chassis */
@@ -155,9 +159,26 @@ struct calgary_bus_info {
155 void __iomem *bbar; 159 void __iomem *bbar;
156}; 160};
157 161
158static struct calgary_bus_info bus_info[MAX_PHB_BUS_NUM] = { { NULL, 0, 0 }, }; 162static void calgary_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev);
163static void calgary_tce_cache_blast(struct iommu_table *tbl);
164static void calgary_dump_error_regs(struct iommu_table *tbl);
165static void calioc2_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev);
166static void calioc2_tce_cache_blast(struct iommu_table *tbl);
167static void calioc2_dump_error_regs(struct iommu_table *tbl);
168
169static struct cal_chipset_ops calgary_chip_ops = {
170 .handle_quirks = calgary_handle_quirks,
171 .tce_cache_blast = calgary_tce_cache_blast,
172 .dump_error_regs = calgary_dump_error_regs
173};
159 174
160static void tce_cache_blast(struct iommu_table *tbl); 175static struct cal_chipset_ops calioc2_chip_ops = {
176 .handle_quirks = calioc2_handle_quirks,
177 .tce_cache_blast = calioc2_tce_cache_blast,
178 .dump_error_regs = calioc2_dump_error_regs
179};
180
181static struct calgary_bus_info bus_info[MAX_PHB_BUS_NUM] = { { NULL, 0, 0 }, };
161 182
162/* enable this to stress test the chip's TCE cache */ 183/* enable this to stress test the chip's TCE cache */
163#ifdef CONFIG_IOMMU_DEBUG 184#ifdef CONFIG_IOMMU_DEBUG
@@ -187,6 +208,7 @@ static inline unsigned long verify_bit_range(unsigned long* bitmap,
187{ 208{
188 return ~0UL; 209 return ~0UL;
189} 210}
211
190#endif /* CONFIG_IOMMU_DEBUG */ 212#endif /* CONFIG_IOMMU_DEBUG */
191 213
192static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen) 214static inline unsigned int num_dma_pages(unsigned long dma, unsigned int dmalen)
@@ -206,11 +228,12 @@ static inline int translate_phb(struct pci_dev* dev)
206} 228}
207 229
208static void iommu_range_reserve(struct iommu_table *tbl, 230static void iommu_range_reserve(struct iommu_table *tbl,
209 unsigned long start_addr, unsigned int npages) 231 unsigned long start_addr, unsigned int npages)
210{ 232{
211 unsigned long index; 233 unsigned long index;
212 unsigned long end; 234 unsigned long end;
213 unsigned long badbit; 235 unsigned long badbit;
236 unsigned long flags;
214 237
215 index = start_addr >> PAGE_SHIFT; 238 index = start_addr >> PAGE_SHIFT;
216 239
@@ -222,6 +245,8 @@ static void iommu_range_reserve(struct iommu_table *tbl,
222 if (end > tbl->it_size) /* don't go off the table */ 245 if (end > tbl->it_size) /* don't go off the table */
223 end = tbl->it_size; 246 end = tbl->it_size;
224 247
248 spin_lock_irqsave(&tbl->it_lock, flags);
249
225 badbit = verify_bit_range(tbl->it_map, 0, index, end); 250 badbit = verify_bit_range(tbl->it_map, 0, index, end);
226 if (badbit != ~0UL) { 251 if (badbit != ~0UL) {
227 if (printk_ratelimit()) 252 if (printk_ratelimit())
@@ -231,23 +256,29 @@ static void iommu_range_reserve(struct iommu_table *tbl,
231 } 256 }
232 257
233 set_bit_string(tbl->it_map, index, npages); 258 set_bit_string(tbl->it_map, index, npages);
259
260 spin_unlock_irqrestore(&tbl->it_lock, flags);
234} 261}
235 262
236static unsigned long iommu_range_alloc(struct iommu_table *tbl, 263static unsigned long iommu_range_alloc(struct iommu_table *tbl,
237 unsigned int npages) 264 unsigned int npages)
238{ 265{
266 unsigned long flags;
239 unsigned long offset; 267 unsigned long offset;
240 268
241 BUG_ON(npages == 0); 269 BUG_ON(npages == 0);
242 270
271 spin_lock_irqsave(&tbl->it_lock, flags);
272
243 offset = find_next_zero_string(tbl->it_map, tbl->it_hint, 273 offset = find_next_zero_string(tbl->it_map, tbl->it_hint,
244 tbl->it_size, npages); 274 tbl->it_size, npages);
245 if (offset == ~0UL) { 275 if (offset == ~0UL) {
246 tce_cache_blast(tbl); 276 tbl->chip_ops->tce_cache_blast(tbl);
247 offset = find_next_zero_string(tbl->it_map, 0, 277 offset = find_next_zero_string(tbl->it_map, 0,
248 tbl->it_size, npages); 278 tbl->it_size, npages);
249 if (offset == ~0UL) { 279 if (offset == ~0UL) {
250 printk(KERN_WARNING "Calgary: IOMMU full.\n"); 280 printk(KERN_WARNING "Calgary: IOMMU full.\n");
281 spin_unlock_irqrestore(&tbl->it_lock, flags);
251 if (panic_on_overflow) 282 if (panic_on_overflow)
252 panic("Calgary: fix the allocator.\n"); 283 panic("Calgary: fix the allocator.\n");
253 else 284 else
@@ -259,17 +290,17 @@ static unsigned long iommu_range_alloc(struct iommu_table *tbl,
259 tbl->it_hint = offset + npages; 290 tbl->it_hint = offset + npages;
260 BUG_ON(tbl->it_hint > tbl->it_size); 291 BUG_ON(tbl->it_hint > tbl->it_size);
261 292
293 spin_unlock_irqrestore(&tbl->it_lock, flags);
294
262 return offset; 295 return offset;
263} 296}
264 297
265static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *vaddr, 298static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *vaddr,
266 unsigned int npages, int direction) 299 unsigned int npages, int direction)
267{ 300{
268 unsigned long entry, flags; 301 unsigned long entry;
269 dma_addr_t ret = bad_dma_address; 302 dma_addr_t ret = bad_dma_address;
270 303
271 spin_lock_irqsave(&tbl->it_lock, flags);
272
273 entry = iommu_range_alloc(tbl, npages); 304 entry = iommu_range_alloc(tbl, npages);
274 305
275 if (unlikely(entry == bad_dma_address)) 306 if (unlikely(entry == bad_dma_address))
@@ -282,23 +313,21 @@ static dma_addr_t iommu_alloc(struct iommu_table *tbl, void *vaddr,
282 tce_build(tbl, entry, npages, (unsigned long)vaddr & PAGE_MASK, 313 tce_build(tbl, entry, npages, (unsigned long)vaddr & PAGE_MASK,
283 direction); 314 direction);
284 315
285 spin_unlock_irqrestore(&tbl->it_lock, flags);
286
287 return ret; 316 return ret;
288 317
289error: 318error:
290 spin_unlock_irqrestore(&tbl->it_lock, flags);
291 printk(KERN_WARNING "Calgary: failed to allocate %u pages in " 319 printk(KERN_WARNING "Calgary: failed to allocate %u pages in "
292 "iommu %p\n", npages, tbl); 320 "iommu %p\n", npages, tbl);
293 return bad_dma_address; 321 return bad_dma_address;
294} 322}
295 323
296static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr, 324static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
297 unsigned int npages) 325 unsigned int npages)
298{ 326{
299 unsigned long entry; 327 unsigned long entry;
300 unsigned long badbit; 328 unsigned long badbit;
301 unsigned long badend; 329 unsigned long badend;
330 unsigned long flags;
302 331
303 /* were we called with bad_dma_address? */ 332 /* were we called with bad_dma_address? */
304 badend = bad_dma_address + (EMERGENCY_PAGES * PAGE_SIZE); 333 badend = bad_dma_address + (EMERGENCY_PAGES * PAGE_SIZE);
@@ -315,6 +344,8 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
315 344
316 tce_free(tbl, entry, npages); 345 tce_free(tbl, entry, npages);
317 346
347 spin_lock_irqsave(&tbl->it_lock, flags);
348
318 badbit = verify_bit_range(tbl->it_map, 1, entry, entry + npages); 349 badbit = verify_bit_range(tbl->it_map, 1, entry, entry + npages);
319 if (badbit != ~0UL) { 350 if (badbit != ~0UL) {
320 if (printk_ratelimit()) 351 if (printk_ratelimit())
@@ -324,23 +355,40 @@ static void __iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr,
324 } 355 }
325 356
326 __clear_bit_string(tbl->it_map, entry, npages); 357 __clear_bit_string(tbl->it_map, entry, npages);
358
359 spin_unlock_irqrestore(&tbl->it_lock, flags);
327} 360}
328 361
329static void iommu_free(struct iommu_table *tbl, dma_addr_t dma_addr, 362static inline struct iommu_table *find_iommu_table(struct device *dev)
330 unsigned int npages)
331{ 363{
332 unsigned long flags; 364 struct pci_dev *pdev;
365 struct pci_bus *pbus;
366 struct iommu_table *tbl;
333 367
334 spin_lock_irqsave(&tbl->it_lock, flags); 368 pdev = to_pci_dev(dev);
335 369
336 __iommu_free(tbl, dma_addr, npages); 370 /* is the device behind a bridge? */
371 if (unlikely(pdev->bus->parent))
372 pbus = pdev->bus->parent;
373 else
374 pbus = pdev->bus;
337 375
338 spin_unlock_irqrestore(&tbl->it_lock, flags); 376 tbl = pci_iommu(pbus);
377
378 BUG_ON(pdev->bus->parent &&
379 (tbl->it_busno != pdev->bus->parent->number));
380
381 return tbl;
339} 382}
340 383
341static void __calgary_unmap_sg(struct iommu_table *tbl, 384static void calgary_unmap_sg(struct device *dev,
342 struct scatterlist *sglist, int nelems, int direction) 385 struct scatterlist *sglist, int nelems, int direction)
343{ 386{
387 struct iommu_table *tbl = find_iommu_table(dev);
388
389 if (!translate_phb(to_pci_dev(dev)))
390 return;
391
344 while (nelems--) { 392 while (nelems--) {
345 unsigned int npages; 393 unsigned int npages;
346 dma_addr_t dma = sglist->dma_address; 394 dma_addr_t dma = sglist->dma_address;
@@ -350,33 +398,17 @@ static void __calgary_unmap_sg(struct iommu_table *tbl,
350 break; 398 break;
351 399
352 npages = num_dma_pages(dma, dmalen); 400 npages = num_dma_pages(dma, dmalen);
353 __iommu_free(tbl, dma, npages); 401 iommu_free(tbl, dma, npages);
354 sglist++; 402 sglist++;
355 } 403 }
356} 404}
357 405
358void calgary_unmap_sg(struct device *dev, struct scatterlist *sglist,
359 int nelems, int direction)
360{
361 unsigned long flags;
362 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata;
363
364 if (!translate_phb(to_pci_dev(dev)))
365 return;
366
367 spin_lock_irqsave(&tbl->it_lock, flags);
368
369 __calgary_unmap_sg(tbl, sglist, nelems, direction);
370
371 spin_unlock_irqrestore(&tbl->it_lock, flags);
372}
373
374static int calgary_nontranslate_map_sg(struct device* dev, 406static int calgary_nontranslate_map_sg(struct device* dev,
375 struct scatterlist *sg, int nelems, int direction) 407 struct scatterlist *sg, int nelems, int direction)
376{ 408{
377 int i; 409 int i;
378 410
379 for (i = 0; i < nelems; i++ ) { 411 for (i = 0; i < nelems; i++ ) {
380 struct scatterlist *s = &sg[i]; 412 struct scatterlist *s = &sg[i];
381 BUG_ON(!s->page); 413 BUG_ON(!s->page);
382 s->dma_address = virt_to_bus(page_address(s->page) +s->offset); 414 s->dma_address = virt_to_bus(page_address(s->page) +s->offset);
@@ -385,11 +417,10 @@ static int calgary_nontranslate_map_sg(struct device* dev,
385 return nelems; 417 return nelems;
386} 418}
387 419
388int calgary_map_sg(struct device *dev, struct scatterlist *sg, 420static int calgary_map_sg(struct device *dev, struct scatterlist *sg,
389 int nelems, int direction) 421 int nelems, int direction)
390{ 422{
391 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata; 423 struct iommu_table *tbl = find_iommu_table(dev);
392 unsigned long flags;
393 unsigned long vaddr; 424 unsigned long vaddr;
394 unsigned int npages; 425 unsigned int npages;
395 unsigned long entry; 426 unsigned long entry;
@@ -398,8 +429,6 @@ int calgary_map_sg(struct device *dev, struct scatterlist *sg,
398 if (!translate_phb(to_pci_dev(dev))) 429 if (!translate_phb(to_pci_dev(dev)))
399 return calgary_nontranslate_map_sg(dev, sg, nelems, direction); 430 return calgary_nontranslate_map_sg(dev, sg, nelems, direction);
400 431
401 spin_lock_irqsave(&tbl->it_lock, flags);
402
403 for (i = 0; i < nelems; i++ ) { 432 for (i = 0; i < nelems; i++ ) {
404 struct scatterlist *s = &sg[i]; 433 struct scatterlist *s = &sg[i];
405 BUG_ON(!s->page); 434 BUG_ON(!s->page);
@@ -423,26 +452,23 @@ int calgary_map_sg(struct device *dev, struct scatterlist *sg,
423 s->dma_length = s->length; 452 s->dma_length = s->length;
424 } 453 }
425 454
426 spin_unlock_irqrestore(&tbl->it_lock, flags);
427
428 return nelems; 455 return nelems;
429error: 456error:
430 __calgary_unmap_sg(tbl, sg, nelems, direction); 457 calgary_unmap_sg(dev, sg, nelems, direction);
431 for (i = 0; i < nelems; i++) { 458 for (i = 0; i < nelems; i++) {
432 sg[i].dma_address = bad_dma_address; 459 sg[i].dma_address = bad_dma_address;
433 sg[i].dma_length = 0; 460 sg[i].dma_length = 0;
434 } 461 }
435 spin_unlock_irqrestore(&tbl->it_lock, flags);
436 return 0; 462 return 0;
437} 463}
438 464
439dma_addr_t calgary_map_single(struct device *dev, void *vaddr, 465static dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
440 size_t size, int direction) 466 size_t size, int direction)
441{ 467{
442 dma_addr_t dma_handle = bad_dma_address; 468 dma_addr_t dma_handle = bad_dma_address;
443 unsigned long uaddr; 469 unsigned long uaddr;
444 unsigned int npages; 470 unsigned int npages;
445 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata; 471 struct iommu_table *tbl = find_iommu_table(dev);
446 472
447 uaddr = (unsigned long)vaddr; 473 uaddr = (unsigned long)vaddr;
448 npages = num_dma_pages(uaddr, size); 474 npages = num_dma_pages(uaddr, size);
@@ -455,10 +481,10 @@ dma_addr_t calgary_map_single(struct device *dev, void *vaddr,
455 return dma_handle; 481 return dma_handle;
456} 482}
457 483
458void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle, 484static void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
459 size_t size, int direction) 485 size_t size, int direction)
460{ 486{
461 struct iommu_table *tbl = to_pci_dev(dev)->bus->self->sysdata; 487 struct iommu_table *tbl = find_iommu_table(dev);
462 unsigned int npages; 488 unsigned int npages;
463 489
464 if (!translate_phb(to_pci_dev(dev))) 490 if (!translate_phb(to_pci_dev(dev)))
@@ -468,15 +494,13 @@ void calgary_unmap_single(struct device *dev, dma_addr_t dma_handle,
468 iommu_free(tbl, dma_handle, npages); 494 iommu_free(tbl, dma_handle, npages);
469} 495}
470 496
471void* calgary_alloc_coherent(struct device *dev, size_t size, 497static void* calgary_alloc_coherent(struct device *dev, size_t size,
472 dma_addr_t *dma_handle, gfp_t flag) 498 dma_addr_t *dma_handle, gfp_t flag)
473{ 499{
474 void *ret = NULL; 500 void *ret = NULL;
475 dma_addr_t mapping; 501 dma_addr_t mapping;
476 unsigned int npages, order; 502 unsigned int npages, order;
477 struct iommu_table *tbl; 503 struct iommu_table *tbl = find_iommu_table(dev);
478
479 tbl = to_pci_dev(dev)->bus->self->sysdata;
480 504
481 size = PAGE_ALIGN(size); /* size rounded up to full pages */ 505 size = PAGE_ALIGN(size); /* size rounded up to full pages */
482 npages = size >> PAGE_SHIFT; 506 npages = size >> PAGE_SHIFT;
@@ -552,7 +576,22 @@ static inline void __iomem* calgary_reg(void __iomem *bar, unsigned long offset)
552 return (void __iomem*)target; 576 return (void __iomem*)target;
553} 577}
554 578
555static void tce_cache_blast(struct iommu_table *tbl) 579static inline int is_calioc2(unsigned short device)
580{
581 return (device == PCI_DEVICE_ID_IBM_CALIOC2);
582}
583
584static inline int is_calgary(unsigned short device)
585{
586 return (device == PCI_DEVICE_ID_IBM_CALGARY);
587}
588
589static inline int is_cal_pci_dev(unsigned short device)
590{
591 return (is_calgary(device) || is_calioc2(device));
592}
593
594static void calgary_tce_cache_blast(struct iommu_table *tbl)
556{ 595{
557 u64 val; 596 u64 val;
558 u32 aer; 597 u32 aer;
@@ -589,6 +628,85 @@ static void tce_cache_blast(struct iommu_table *tbl)
589 (void)readl(target); /* flush */ 628 (void)readl(target); /* flush */
590} 629}
591 630
631static void calioc2_tce_cache_blast(struct iommu_table *tbl)
632{
633 void __iomem *bbar = tbl->bbar;
634 void __iomem *target;
635 u64 val64;
636 u32 val;
637 int i = 0;
638 int count = 1;
639 unsigned char bus = tbl->it_busno;
640
641begin:
642 printk(KERN_DEBUG "Calgary: CalIOC2 bus 0x%x entering tce cache blast "
643 "sequence - count %d\n", bus, count);
644
645 /* 1. using the Page Migration Control reg set SoftStop */
646 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
647 val = be32_to_cpu(readl(target));
648 printk(KERN_DEBUG "1a. read 0x%x [LE] from %p\n", val, target);
649 val |= PMR_SOFTSTOP;
650 printk(KERN_DEBUG "1b. writing 0x%x [LE] to %p\n", val, target);
651 writel(cpu_to_be32(val), target);
652
653 /* 2. poll split queues until all DMA activity is done */
654 printk(KERN_DEBUG "2a. starting to poll split queues\n");
655 target = calgary_reg(bbar, split_queue_offset(bus));
656 do {
657 val64 = readq(target);
658 i++;
659 } while ((val64 & 0xff) != 0xff && i < 100);
660 if (i == 100)
661 printk(KERN_WARNING "CalIOC2: PCI bus not quiesced, "
662 "continuing anyway\n");
663
664 /* 3. poll Page Migration DEBUG for SoftStopFault */
665 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_DEBUG);
666 val = be32_to_cpu(readl(target));
667 printk(KERN_DEBUG "3. read 0x%x [LE] from %p\n", val, target);
668
669 /* 4. if SoftStopFault - goto (1) */
670 if (val & PMR_SOFTSTOPFAULT) {
671 if (++count < 100)
672 goto begin;
673 else {
674 printk(KERN_WARNING "CalIOC2: too many SoftStopFaults, "
675 "aborting TCE cache flush sequence!\n");
676 return; /* pray for the best */
677 }
678 }
679
680 /* 5. Slam into HardStop by reading PHB_PAGE_MIG_CTRL */
681 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
682 printk(KERN_DEBUG "5a. slamming into HardStop by reading %p\n", target);
683 val = be32_to_cpu(readl(target));
684 printk(KERN_DEBUG "5b. read 0x%x [LE] from %p\n", val, target);
685 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_DEBUG);
686 val = be32_to_cpu(readl(target));
687 printk(KERN_DEBUG "5c. read 0x%x [LE] from %p (debug)\n", val, target);
688
689 /* 6. invalidate TCE cache */
690 printk(KERN_DEBUG "6. invalidating TCE cache\n");
691 target = calgary_reg(bbar, tar_offset(bus));
692 writeq(tbl->tar_val, target);
693
694 /* 7. Re-read PMCR */
695 printk(KERN_DEBUG "7a. Re-reading PMCR\n");
696 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
697 val = be32_to_cpu(readl(target));
698 printk(KERN_DEBUG "7b. read 0x%x [LE] from %p\n", val, target);
699
700 /* 8. Remove HardStop */
701 printk(KERN_DEBUG "8a. removing HardStop from PMCR\n");
702 target = calgary_reg(bbar, phb_offset(bus) | PHB_PAGE_MIG_CTRL);
703 val = 0;
704 printk(KERN_DEBUG "8b. writing 0x%x [LE] to %p\n", val, target);
705 writel(cpu_to_be32(val), target);
706 val = be32_to_cpu(readl(target));
707 printk(KERN_DEBUG "8c. read 0x%x [LE] from %p\n", val, target);
708}
709
592static void __init calgary_reserve_mem_region(struct pci_dev *dev, u64 start, 710static void __init calgary_reserve_mem_region(struct pci_dev *dev, u64 start,
593 u64 limit) 711 u64 limit)
594{ 712{
@@ -598,7 +716,7 @@ static void __init calgary_reserve_mem_region(struct pci_dev *dev, u64 start,
598 limit++; 716 limit++;
599 717
600 numpages = ((limit - start) >> PAGE_SHIFT); 718 numpages = ((limit - start) >> PAGE_SHIFT);
601 iommu_range_reserve(dev->sysdata, start, numpages); 719 iommu_range_reserve(pci_iommu(dev->bus), start, numpages);
602} 720}
603 721
604static void __init calgary_reserve_peripheral_mem_1(struct pci_dev *dev) 722static void __init calgary_reserve_peripheral_mem_1(struct pci_dev *dev)
@@ -606,7 +724,7 @@ static void __init calgary_reserve_peripheral_mem_1(struct pci_dev *dev)
606 void __iomem *target; 724 void __iomem *target;
607 u64 low, high, sizelow; 725 u64 low, high, sizelow;
608 u64 start, limit; 726 u64 start, limit;
609 struct iommu_table *tbl = dev->sysdata; 727 struct iommu_table *tbl = pci_iommu(dev->bus);
610 unsigned char busnum = dev->bus->number; 728 unsigned char busnum = dev->bus->number;
611 void __iomem *bbar = tbl->bbar; 729 void __iomem *bbar = tbl->bbar;
612 730
@@ -630,7 +748,7 @@ static void __init calgary_reserve_peripheral_mem_2(struct pci_dev *dev)
630 u32 val32; 748 u32 val32;
631 u64 low, high, sizelow, sizehigh; 749 u64 low, high, sizelow, sizehigh;
632 u64 start, limit; 750 u64 start, limit;
633 struct iommu_table *tbl = dev->sysdata; 751 struct iommu_table *tbl = pci_iommu(dev->bus);
634 unsigned char busnum = dev->bus->number; 752 unsigned char busnum = dev->bus->number;
635 void __iomem *bbar = tbl->bbar; 753 void __iomem *bbar = tbl->bbar;
636 754
@@ -666,14 +784,20 @@ static void __init calgary_reserve_regions(struct pci_dev *dev)
666{ 784{
667 unsigned int npages; 785 unsigned int npages;
668 u64 start; 786 u64 start;
669 struct iommu_table *tbl = dev->sysdata; 787 struct iommu_table *tbl = pci_iommu(dev->bus);
670 788
671 /* reserve EMERGENCY_PAGES from bad_dma_address and up */ 789 /* reserve EMERGENCY_PAGES from bad_dma_address and up */
672 iommu_range_reserve(tbl, bad_dma_address, EMERGENCY_PAGES); 790 iommu_range_reserve(tbl, bad_dma_address, EMERGENCY_PAGES);
673 791
674 /* avoid the BIOS/VGA first 640KB-1MB region */ 792 /* avoid the BIOS/VGA first 640KB-1MB region */
675 start = (640 * 1024); 793 /* for CalIOC2 - avoid the entire first MB */
676 npages = ((1024 - 640) * 1024) >> PAGE_SHIFT; 794 if (is_calgary(dev->device)) {
795 start = (640 * 1024);
796 npages = ((1024 - 640) * 1024) >> PAGE_SHIFT;
797 } else { /* calioc2 */
798 start = 0;
799 npages = (1 * 1024 * 1024) >> PAGE_SHIFT;
800 }
677 iommu_range_reserve(tbl, start, npages); 801 iommu_range_reserve(tbl, start, npages);
678 802
679 /* reserve the two PCI peripheral memory regions in IO space */ 803 /* reserve the two PCI peripheral memory regions in IO space */
@@ -694,10 +818,17 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
694 if (ret) 818 if (ret)
695 return ret; 819 return ret;
696 820
697 tbl = dev->sysdata; 821 tbl = pci_iommu(dev->bus);
698 tbl->it_base = (unsigned long)bus_info[dev->bus->number].tce_space; 822 tbl->it_base = (unsigned long)bus_info[dev->bus->number].tce_space;
699 tce_free(tbl, 0, tbl->it_size); 823 tce_free(tbl, 0, tbl->it_size);
700 824
825 if (is_calgary(dev->device))
826 tbl->chip_ops = &calgary_chip_ops;
827 else if (is_calioc2(dev->device))
828 tbl->chip_ops = &calioc2_chip_ops;
829 else
830 BUG();
831
701 calgary_reserve_regions(dev); 832 calgary_reserve_regions(dev);
702 833
703 /* set TARs for each PHB */ 834 /* set TARs for each PHB */
@@ -706,15 +837,15 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
706 837
707 /* zero out all TAR bits under sw control */ 838 /* zero out all TAR bits under sw control */
708 val64 &= ~TAR_SW_BITS; 839 val64 &= ~TAR_SW_BITS;
709
710 tbl = dev->sysdata;
711 table_phys = (u64)__pa(tbl->it_base); 840 table_phys = (u64)__pa(tbl->it_base);
841
712 val64 |= table_phys; 842 val64 |= table_phys;
713 843
714 BUG_ON(specified_table_size > TCE_TABLE_SIZE_8M); 844 BUG_ON(specified_table_size > TCE_TABLE_SIZE_8M);
715 val64 |= (u64) specified_table_size; 845 val64 |= (u64) specified_table_size;
716 846
717 tbl->tar_val = cpu_to_be64(val64); 847 tbl->tar_val = cpu_to_be64(val64);
848
718 writeq(tbl->tar_val, target); 849 writeq(tbl->tar_val, target);
719 readq(target); /* flush */ 850 readq(target); /* flush */
720 851
@@ -724,7 +855,7 @@ static int __init calgary_setup_tar(struct pci_dev *dev, void __iomem *bbar)
724static void __init calgary_free_bus(struct pci_dev *dev) 855static void __init calgary_free_bus(struct pci_dev *dev)
725{ 856{
726 u64 val64; 857 u64 val64;
727 struct iommu_table *tbl = dev->sysdata; 858 struct iommu_table *tbl = pci_iommu(dev->bus);
728 void __iomem *target; 859 void __iomem *target;
729 unsigned int bitmapsz; 860 unsigned int bitmapsz;
730 861
@@ -739,16 +870,81 @@ static void __init calgary_free_bus(struct pci_dev *dev)
739 tbl->it_map = NULL; 870 tbl->it_map = NULL;
740 871
741 kfree(tbl); 872 kfree(tbl);
742 dev->sysdata = NULL; 873
874 set_pci_iommu(dev->bus, NULL);
743 875
744 /* Can't free bootmem allocated memory after system is up :-( */ 876 /* Can't free bootmem allocated memory after system is up :-( */
745 bus_info[dev->bus->number].tce_space = NULL; 877 bus_info[dev->bus->number].tce_space = NULL;
746} 878}
747 879
880static void calgary_dump_error_regs(struct iommu_table *tbl)
881{
882 void __iomem *bbar = tbl->bbar;
883 void __iomem *target;
884 u32 csr, plssr;
885
886 target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_CSR_OFFSET);
887 csr = be32_to_cpu(readl(target));
888
889 target = calgary_reg(bbar, phb_offset(tbl->it_busno) | PHB_PLSSR_OFFSET);
890 plssr = be32_to_cpu(readl(target));
891
892 /* If no error, the agent ID in the CSR is not valid */
893 printk(KERN_EMERG "Calgary: DMA error on Calgary PHB 0x%x, "
894 "0x%08x@CSR 0x%08x@PLSSR\n", tbl->it_busno, csr, plssr);
895}
896
897static void calioc2_dump_error_regs(struct iommu_table *tbl)
898{
899 void __iomem *bbar = tbl->bbar;
900 u32 csr, csmr, plssr, mck, rcstat;
901 void __iomem *target;
902 unsigned long phboff = phb_offset(tbl->it_busno);
903 unsigned long erroff;
904 u32 errregs[7];
905 int i;
906
907 /* dump CSR */
908 target = calgary_reg(bbar, phboff | PHB_CSR_OFFSET);
909 csr = be32_to_cpu(readl(target));
910 /* dump PLSSR */
911 target = calgary_reg(bbar, phboff | PHB_PLSSR_OFFSET);
912 plssr = be32_to_cpu(readl(target));
913 /* dump CSMR */
914 target = calgary_reg(bbar, phboff | 0x290);
915 csmr = be32_to_cpu(readl(target));
916 /* dump mck */
917 target = calgary_reg(bbar, phboff | 0x800);
918 mck = be32_to_cpu(readl(target));
919
920 printk(KERN_EMERG "Calgary: DMA error on CalIOC2 PHB 0x%x\n",
921 tbl->it_busno);
922
923 printk(KERN_EMERG "Calgary: 0x%08x@CSR 0x%08x@PLSSR 0x%08x@CSMR 0x%08x@MCK\n",
924 csr, plssr, csmr, mck);
925
926 /* dump rest of error regs */
927 printk(KERN_EMERG "Calgary: ");
928 for (i = 0; i < ARRAY_SIZE(errregs); i++) {
929 /* err regs are at 0x810 - 0x870 */
930 erroff = (0x810 + (i * 0x10));
931 target = calgary_reg(bbar, phboff | erroff);
932 errregs[i] = be32_to_cpu(readl(target));
933 printk("0x%08x@0x%lx ", errregs[i], erroff);
934 }
935 printk("\n");
936
937 /* root complex status */
938 target = calgary_reg(bbar, phboff | PHB_ROOT_COMPLEX_STATUS);
939 rcstat = be32_to_cpu(readl(target));
940 printk(KERN_EMERG "Calgary: 0x%08x@0x%x\n", rcstat,
941 PHB_ROOT_COMPLEX_STATUS);
942}
943
748static void calgary_watchdog(unsigned long data) 944static void calgary_watchdog(unsigned long data)
749{ 945{
750 struct pci_dev *dev = (struct pci_dev *)data; 946 struct pci_dev *dev = (struct pci_dev *)data;
751 struct iommu_table *tbl = dev->sysdata; 947 struct iommu_table *tbl = pci_iommu(dev->bus);
752 void __iomem *bbar = tbl->bbar; 948 void __iomem *bbar = tbl->bbar;
753 u32 val32; 949 u32 val32;
754 void __iomem *target; 950 void __iomem *target;
@@ -758,13 +954,14 @@ static void calgary_watchdog(unsigned long data)
758 954
759 /* If no error, the agent ID in the CSR is not valid */ 955 /* If no error, the agent ID in the CSR is not valid */
760 if (val32 & CSR_AGENT_MASK) { 956 if (val32 & CSR_AGENT_MASK) {
761 printk(KERN_EMERG "calgary_watchdog: DMA error on PHB %#x, " 957 tbl->chip_ops->dump_error_regs(tbl);
762 "CSR = %#x\n", dev->bus->number, val32); 958
959 /* reset error */
763 writel(0, target); 960 writel(0, target);
764 961
765 /* Disable bus that caused the error */ 962 /* Disable bus that caused the error */
766 target = calgary_reg(bbar, phb_offset(tbl->it_busno) | 963 target = calgary_reg(bbar, phb_offset(tbl->it_busno) |
767 PHB_CONFIG_RW_OFFSET); 964 PHB_CONFIG_RW_OFFSET);
768 val32 = be32_to_cpu(readl(target)); 965 val32 = be32_to_cpu(readl(target));
769 val32 |= PHB_SLOT_DISABLE; 966 val32 |= PHB_SLOT_DISABLE;
770 writel(cpu_to_be32(val32), target); 967 writel(cpu_to_be32(val32), target);
@@ -775,8 +972,8 @@ static void calgary_watchdog(unsigned long data)
775 } 972 }
776} 973}
777 974
778static void __init calgary_increase_split_completion_timeout(void __iomem *bbar, 975static void __init calgary_set_split_completion_timeout(void __iomem *bbar,
779 unsigned char busnum) 976 unsigned char busnum, unsigned long timeout)
780{ 977{
781 u64 val64; 978 u64 val64;
782 void __iomem *target; 979 void __iomem *target;
@@ -802,11 +999,40 @@ static void __init calgary_increase_split_completion_timeout(void __iomem *bbar,
802 /* zero out this PHB's timer bits */ 999 /* zero out this PHB's timer bits */
803 mask = ~(0xFUL << phb_shift); 1000 mask = ~(0xFUL << phb_shift);
804 val64 &= mask; 1001 val64 &= mask;
805 val64 |= (CCR_2SEC_TIMEOUT << phb_shift); 1002 val64 |= (timeout << phb_shift);
806 writeq(cpu_to_be64(val64), target); 1003 writeq(cpu_to_be64(val64), target);
807 readq(target); /* flush */ 1004 readq(target); /* flush */
808} 1005}
809 1006
1007static void calioc2_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev)
1008{
1009 unsigned char busnum = dev->bus->number;
1010 void __iomem *bbar = tbl->bbar;
1011 void __iomem *target;
1012 u32 val;
1013
1014 /*
1015 * CalIOC2 designers recommend setting bit 8 in 0xnDB0 to 1
1016 */
1017 target = calgary_reg(bbar, phb_offset(busnum) | PHB_SAVIOR_L2);
1018 val = cpu_to_be32(readl(target));
1019 val |= 0x00800000;
1020 writel(cpu_to_be32(val), target);
1021}
1022
1023static void calgary_handle_quirks(struct iommu_table *tbl, struct pci_dev *dev)
1024{
1025 unsigned char busnum = dev->bus->number;
1026
1027 /*
1028 * Give split completion a longer timeout on bus 1 for aic94xx
1029 * http://bugzilla.kernel.org/show_bug.cgi?id=7180
1030 */
1031 if (is_calgary(dev->device) && (busnum == 1))
1032 calgary_set_split_completion_timeout(tbl->bbar, busnum,
1033 CCR_2SEC_TIMEOUT);
1034}
1035
810static void __init calgary_enable_translation(struct pci_dev *dev) 1036static void __init calgary_enable_translation(struct pci_dev *dev)
811{ 1037{
812 u32 val32; 1038 u32 val32;
@@ -816,7 +1042,7 @@ static void __init calgary_enable_translation(struct pci_dev *dev)
816 struct iommu_table *tbl; 1042 struct iommu_table *tbl;
817 1043
818 busnum = dev->bus->number; 1044 busnum = dev->bus->number;
819 tbl = dev->sysdata; 1045 tbl = pci_iommu(dev->bus);
820 bbar = tbl->bbar; 1046 bbar = tbl->bbar;
821 1047
822 /* enable TCE in PHB Config Register */ 1048 /* enable TCE in PHB Config Register */
@@ -824,20 +1050,15 @@ static void __init calgary_enable_translation(struct pci_dev *dev)
824 val32 = be32_to_cpu(readl(target)); 1050 val32 = be32_to_cpu(readl(target));
825 val32 |= PHB_TCE_ENABLE | PHB_DAC_DISABLE | PHB_MCSR_ENABLE; 1051 val32 |= PHB_TCE_ENABLE | PHB_DAC_DISABLE | PHB_MCSR_ENABLE;
826 1052
827 printk(KERN_INFO "Calgary: enabling translation on PHB %#x\n", busnum); 1053 printk(KERN_INFO "Calgary: enabling translation on %s PHB %#x\n",
1054 (dev->device == PCI_DEVICE_ID_IBM_CALGARY) ?
1055 "Calgary" : "CalIOC2", busnum);
828 printk(KERN_INFO "Calgary: errant DMAs will now be prevented on this " 1056 printk(KERN_INFO "Calgary: errant DMAs will now be prevented on this "
829 "bus.\n"); 1057 "bus.\n");
830 1058
831 writel(cpu_to_be32(val32), target); 1059 writel(cpu_to_be32(val32), target);
832 readl(target); /* flush */ 1060 readl(target); /* flush */
833 1061
834 /*
835 * Give split completion a longer timeout on bus 1 for aic94xx
836 * http://bugzilla.kernel.org/show_bug.cgi?id=7180
837 */
838 if (busnum == 1)
839 calgary_increase_split_completion_timeout(bbar, busnum);
840
841 init_timer(&tbl->watchdog_timer); 1062 init_timer(&tbl->watchdog_timer);
842 tbl->watchdog_timer.function = &calgary_watchdog; 1063 tbl->watchdog_timer.function = &calgary_watchdog;
843 tbl->watchdog_timer.data = (unsigned long)dev; 1064 tbl->watchdog_timer.data = (unsigned long)dev;
@@ -853,7 +1074,7 @@ static void __init calgary_disable_translation(struct pci_dev *dev)
853 struct iommu_table *tbl; 1074 struct iommu_table *tbl;
854 1075
855 busnum = dev->bus->number; 1076 busnum = dev->bus->number;
856 tbl = dev->sysdata; 1077 tbl = pci_iommu(dev->bus);
857 bbar = tbl->bbar; 1078 bbar = tbl->bbar;
858 1079
859 /* disable TCE in PHB Config Register */ 1080 /* disable TCE in PHB Config Register */
@@ -871,13 +1092,19 @@ static void __init calgary_disable_translation(struct pci_dev *dev)
871static void __init calgary_init_one_nontraslated(struct pci_dev *dev) 1092static void __init calgary_init_one_nontraslated(struct pci_dev *dev)
872{ 1093{
873 pci_dev_get(dev); 1094 pci_dev_get(dev);
874 dev->sysdata = NULL; 1095 set_pci_iommu(dev->bus, NULL);
875 dev->bus->self = dev; 1096
1097 /* is the device behind a bridge? */
1098 if (dev->bus->parent)
1099 dev->bus->parent->self = dev;
1100 else
1101 dev->bus->self = dev;
876} 1102}
877 1103
878static int __init calgary_init_one(struct pci_dev *dev) 1104static int __init calgary_init_one(struct pci_dev *dev)
879{ 1105{
880 void __iomem *bbar; 1106 void __iomem *bbar;
1107 struct iommu_table *tbl;
881 int ret; 1108 int ret;
882 1109
883 BUG_ON(dev->bus->number >= MAX_PHB_BUS_NUM); 1110 BUG_ON(dev->bus->number >= MAX_PHB_BUS_NUM);
@@ -888,7 +1115,18 @@ static int __init calgary_init_one(struct pci_dev *dev)
888 goto done; 1115 goto done;
889 1116
890 pci_dev_get(dev); 1117 pci_dev_get(dev);
891 dev->bus->self = dev; 1118
1119 if (dev->bus->parent) {
1120 if (dev->bus->parent->self)
1121 printk(KERN_WARNING "Calgary: IEEEE, dev %p has "
1122 "bus->parent->self!\n", dev);
1123 dev->bus->parent->self = dev;
1124 } else
1125 dev->bus->self = dev;
1126
1127 tbl = pci_iommu(dev->bus);
1128 tbl->chip_ops->handle_quirks(tbl, dev);
1129
892 calgary_enable_translation(dev); 1130 calgary_enable_translation(dev);
893 1131
894 return 0; 1132 return 0;
@@ -924,11 +1162,18 @@ static int __init calgary_locate_bbars(void)
924 target = calgary_reg(bbar, offset); 1162 target = calgary_reg(bbar, offset);
925 1163
926 val = be32_to_cpu(readl(target)); 1164 val = be32_to_cpu(readl(target));
1165
927 start_bus = (u8)((val & 0x00FF0000) >> 16); 1166 start_bus = (u8)((val & 0x00FF0000) >> 16);
928 end_bus = (u8)((val & 0x0000FF00) >> 8); 1167 end_bus = (u8)((val & 0x0000FF00) >> 8);
929 for (bus = start_bus; bus <= end_bus; bus++) { 1168
930 bus_info[bus].bbar = bbar; 1169 if (end_bus) {
931 bus_info[bus].phbid = phb; 1170 for (bus = start_bus; bus <= end_bus; bus++) {
1171 bus_info[bus].bbar = bbar;
1172 bus_info[bus].phbid = phb;
1173 }
1174 } else {
1175 bus_info[start_bus].bbar = bbar;
1176 bus_info[start_bus].phbid = phb;
932 } 1177 }
933 } 1178 }
934 } 1179 }
@@ -948,22 +1193,24 @@ static int __init calgary_init(void)
948{ 1193{
949 int ret; 1194 int ret;
950 struct pci_dev *dev = NULL; 1195 struct pci_dev *dev = NULL;
1196 void *tce_space;
951 1197
952 ret = calgary_locate_bbars(); 1198 ret = calgary_locate_bbars();
953 if (ret) 1199 if (ret)
954 return ret; 1200 return ret;
955 1201
956 do { 1202 do {
957 dev = pci_get_device(PCI_VENDOR_ID_IBM, 1203 dev = pci_get_device(PCI_VENDOR_ID_IBM, PCI_ANY_ID, dev);
958 PCI_DEVICE_ID_IBM_CALGARY,
959 dev);
960 if (!dev) 1204 if (!dev)
961 break; 1205 break;
1206 if (!is_cal_pci_dev(dev->device))
1207 continue;
962 if (!translate_phb(dev)) { 1208 if (!translate_phb(dev)) {
963 calgary_init_one_nontraslated(dev); 1209 calgary_init_one_nontraslated(dev);
964 continue; 1210 continue;
965 } 1211 }
966 if (!bus_info[dev->bus->number].tce_space && !translate_empty_slots) 1212 tce_space = bus_info[dev->bus->number].tce_space;
1213 if (!tce_space && !translate_empty_slots)
967 continue; 1214 continue;
968 1215
969 ret = calgary_init_one(dev); 1216 ret = calgary_init_one(dev);
@@ -976,10 +1223,11 @@ static int __init calgary_init(void)
976error: 1223error:
977 do { 1224 do {
978 dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM, 1225 dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
979 PCI_DEVICE_ID_IBM_CALGARY, 1226 PCI_ANY_ID, dev);
980 dev);
981 if (!dev) 1227 if (!dev)
982 break; 1228 break;
1229 if (!is_cal_pci_dev(dev->device))
1230 continue;
983 if (!translate_phb(dev)) { 1231 if (!translate_phb(dev)) {
984 pci_dev_put(dev); 1232 pci_dev_put(dev);
985 continue; 1233 continue;
@@ -1057,9 +1305,29 @@ static int __init build_detail_arrays(void)
1057 return 0; 1305 return 0;
1058} 1306}
1059 1307
1060void __init detect_calgary(void) 1308static int __init calgary_bus_has_devices(int bus, unsigned short pci_dev)
1061{ 1309{
1310 int dev;
1062 u32 val; 1311 u32 val;
1312
1313 if (pci_dev == PCI_DEVICE_ID_IBM_CALIOC2) {
1314 /*
1315 * FIXME: properly scan for devices accross the
1316 * PCI-to-PCI bridge on every CalIOC2 port.
1317 */
1318 return 1;
1319 }
1320
1321 for (dev = 1; dev < 8; dev++) {
1322 val = read_pci_config(bus, dev, 0, 0);
1323 if (val != 0xffffffff)
1324 break;
1325 }
1326 return (val != 0xffffffff);
1327}
1328
1329void __init detect_calgary(void)
1330{
1063 int bus; 1331 int bus;
1064 void *tbl; 1332 void *tbl;
1065 int calgary_found = 0; 1333 int calgary_found = 0;
@@ -1116,29 +1384,26 @@ void __init detect_calgary(void)
1116 specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE); 1384 specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE);
1117 1385
1118 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) { 1386 for (bus = 0; bus < MAX_PHB_BUS_NUM; bus++) {
1119 int dev;
1120 struct calgary_bus_info *info = &bus_info[bus]; 1387 struct calgary_bus_info *info = &bus_info[bus];
1388 unsigned short pci_device;
1389 u32 val;
1390
1391 val = read_pci_config(bus, 0, 0, 0);
1392 pci_device = (val & 0xFFFF0000) >> 16;
1121 1393
1122 if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY) 1394 if (!is_cal_pci_dev(pci_device))
1123 continue; 1395 continue;
1124 1396
1125 if (info->translation_disabled) 1397 if (info->translation_disabled)
1126 continue; 1398 continue;
1127 1399
1128 /* 1400 if (calgary_bus_has_devices(bus, pci_device) ||
1129 * Scan the slots of the PCI bus to see if there is a device present. 1401 translate_empty_slots) {
1130 * The parent bus will be the zero-ith device, so start at 1. 1402 tbl = alloc_tce_table();
1131 */ 1403 if (!tbl)
1132 for (dev = 1; dev < 8; dev++) { 1404 goto cleanup;
1133 val = read_pci_config(bus, dev, 0, 0); 1405 info->tce_space = tbl;
1134 if (val != 0xffffffff || translate_empty_slots) { 1406 calgary_found = 1;
1135 tbl = alloc_tce_table();
1136 if (!tbl)
1137 goto cleanup;
1138 info->tce_space = tbl;
1139 calgary_found = 1;
1140 break;
1141 }
1142 } 1407 }
1143 } 1408 }
1144 1409
@@ -1249,3 +1514,66 @@ static int __init calgary_parse_options(char *p)
1249 return 1; 1514 return 1;
1250} 1515}
1251__setup("calgary=", calgary_parse_options); 1516__setup("calgary=", calgary_parse_options);
1517
1518static void __init calgary_fixup_one_tce_space(struct pci_dev *dev)
1519{
1520 struct iommu_table *tbl;
1521 unsigned int npages;
1522 int i;
1523
1524 tbl = pci_iommu(dev->bus);
1525
1526 for (i = 0; i < 4; i++) {
1527 struct resource *r = &dev->resource[PCI_BRIDGE_RESOURCES + i];
1528
1529 /* Don't give out TCEs that map MEM resources */
1530 if (!(r->flags & IORESOURCE_MEM))
1531 continue;
1532
1533 /* 0-based? we reserve the whole 1st MB anyway */
1534 if (!r->start)
1535 continue;
1536
1537 /* cover the whole region */
1538 npages = (r->end - r->start) >> PAGE_SHIFT;
1539 npages++;
1540
1541 iommu_range_reserve(tbl, r->start, npages);
1542 }
1543}
1544
1545static int __init calgary_fixup_tce_spaces(void)
1546{
1547 struct pci_dev *dev = NULL;
1548 void *tce_space;
1549
1550 if (no_iommu || swiotlb || !calgary_detected)
1551 return -ENODEV;
1552
1553 printk(KERN_DEBUG "Calgary: fixing up tce spaces\n");
1554
1555 do {
1556 dev = pci_get_device(PCI_VENDOR_ID_IBM, PCI_ANY_ID, dev);
1557 if (!dev)
1558 break;
1559 if (!is_cal_pci_dev(dev->device))
1560 continue;
1561 if (!translate_phb(dev))
1562 continue;
1563
1564 tce_space = bus_info[dev->bus->number].tce_space;
1565 if (!tce_space)
1566 continue;
1567
1568 calgary_fixup_one_tce_space(dev);
1569
1570 } while (1);
1571
1572 return 0;
1573}
1574
1575/*
1576 * We need to be call after pcibios_assign_resources (fs_initcall level)
1577 * and before device_initcall.
1578 */
1579rootfs_initcall(calgary_fixup_tce_spaces);
diff --git a/arch/x86_64/kernel/pci-dma.c b/arch/x86_64/kernel/pci-dma.c
index 90f6315d02d4..05d745ede561 100644
--- a/arch/x86_64/kernel/pci-dma.c
+++ b/arch/x86_64/kernel/pci-dma.c
@@ -8,7 +8,7 @@
8#include <linux/pci.h> 8#include <linux/pci.h>
9#include <linux/module.h> 9#include <linux/module.h>
10#include <asm/io.h> 10#include <asm/io.h>
11#include <asm/proto.h> 11#include <asm/iommu.h>
12#include <asm/calgary.h> 12#include <asm/calgary.h>
13 13
14int iommu_merge __read_mostly = 0; 14int iommu_merge __read_mostly = 0;
@@ -321,6 +321,11 @@ static int __init pci_iommu_init(void)
321 return 0; 321 return 0;
322} 322}
323 323
324void pci_iommu_shutdown(void)
325{
326 gart_iommu_shutdown();
327}
328
324#ifdef CONFIG_PCI 329#ifdef CONFIG_PCI
325/* Many VIA bridges seem to corrupt data for DAC. Disable it here */ 330/* Many VIA bridges seem to corrupt data for DAC. Disable it here */
326 331
diff --git a/arch/x86_64/kernel/pci-gart.c b/arch/x86_64/kernel/pci-gart.c
index ae091cdc1a4d..4918c575d582 100644
--- a/arch/x86_64/kernel/pci-gart.c
+++ b/arch/x86_64/kernel/pci-gart.c
@@ -28,6 +28,7 @@
28#include <asm/mtrr.h> 28#include <asm/mtrr.h>
29#include <asm/pgtable.h> 29#include <asm/pgtable.h>
30#include <asm/proto.h> 30#include <asm/proto.h>
31#include <asm/iommu.h>
31#include <asm/cacheflush.h> 32#include <asm/cacheflush.h>
32#include <asm/swiotlb.h> 33#include <asm/swiotlb.h>
33#include <asm/dma.h> 34#include <asm/dma.h>
@@ -235,7 +236,7 @@ static dma_addr_t gart_map_simple(struct device *dev, char *buf,
235} 236}
236 237
237/* Map a single area into the IOMMU */ 238/* Map a single area into the IOMMU */
238dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir) 239static dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir)
239{ 240{
240 unsigned long phys_mem, bus; 241 unsigned long phys_mem, bus;
241 242
@@ -253,7 +254,7 @@ dma_addr_t gart_map_single(struct device *dev, void *addr, size_t size, int dir)
253/* 254/*
254 * Free a DMA mapping. 255 * Free a DMA mapping.
255 */ 256 */
256void gart_unmap_single(struct device *dev, dma_addr_t dma_addr, 257static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
257 size_t size, int direction) 258 size_t size, int direction)
258{ 259{
259 unsigned long iommu_page; 260 unsigned long iommu_page;
@@ -275,7 +276,7 @@ void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
275/* 276/*
276 * Wrapper for pci_unmap_single working with scatterlists. 277 * Wrapper for pci_unmap_single working with scatterlists.
277 */ 278 */
278void gart_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir) 279static void gart_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
279{ 280{
280 int i; 281 int i;
281 282
@@ -571,6 +572,26 @@ static const struct dma_mapping_ops gart_dma_ops = {
571 .unmap_sg = gart_unmap_sg, 572 .unmap_sg = gart_unmap_sg,
572}; 573};
573 574
575void gart_iommu_shutdown(void)
576{
577 struct pci_dev *dev;
578 int i;
579
580 if (no_agp && (dma_ops != &gart_dma_ops))
581 return;
582
583 for (i = 0; i < num_k8_northbridges; i++) {
584 u32 ctl;
585
586 dev = k8_northbridges[i];
587 pci_read_config_dword(dev, 0x90, &ctl);
588
589 ctl &= ~1;
590
591 pci_write_config_dword(dev, 0x90, ctl);
592 }
593}
594
574void __init gart_iommu_init(void) 595void __init gart_iommu_init(void)
575{ 596{
576 struct agp_kern_info info; 597 struct agp_kern_info info;
diff --git a/arch/x86_64/kernel/pci-nommu.c b/arch/x86_64/kernel/pci-nommu.c
index 6dade0c867cc..2a34c6c025a9 100644
--- a/arch/x86_64/kernel/pci-nommu.c
+++ b/arch/x86_64/kernel/pci-nommu.c
@@ -6,7 +6,7 @@
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/dma-mapping.h> 7#include <linux/dma-mapping.h>
8 8
9#include <asm/proto.h> 9#include <asm/iommu.h>
10#include <asm/processor.h> 10#include <asm/processor.h>
11#include <asm/dma.h> 11#include <asm/dma.h>
12 12
@@ -34,7 +34,7 @@ nommu_map_single(struct device *hwdev, void *ptr, size_t size,
34 return bus; 34 return bus;
35} 35}
36 36
37void nommu_unmap_single(struct device *dev, dma_addr_t addr,size_t size, 37static void nommu_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
38 int direction) 38 int direction)
39{ 39{
40} 40}
@@ -54,7 +54,7 @@ void nommu_unmap_single(struct device *dev, dma_addr_t addr,size_t size,
54 * Device ownership issues as mentioned above for pci_map_single are 54 * Device ownership issues as mentioned above for pci_map_single are
55 * the same here. 55 * the same here.
56 */ 56 */
57int nommu_map_sg(struct device *hwdev, struct scatterlist *sg, 57static int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
58 int nents, int direction) 58 int nents, int direction)
59{ 59{
60 int i; 60 int i;
@@ -74,7 +74,7 @@ int nommu_map_sg(struct device *hwdev, struct scatterlist *sg,
74 * Again, cpu read rules concerning calls here are the same as for 74 * Again, cpu read rules concerning calls here are the same as for
75 * pci_unmap_single() above. 75 * pci_unmap_single() above.
76 */ 76 */
77void nommu_unmap_sg(struct device *dev, struct scatterlist *sg, 77static void nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
78 int nents, int dir) 78 int nents, int dir)
79{ 79{
80} 80}
diff --git a/arch/x86_64/kernel/pci-swiotlb.c b/arch/x86_64/kernel/pci-swiotlb.c
index 4b4569abc60c..b2f405ea7c85 100644
--- a/arch/x86_64/kernel/pci-swiotlb.c
+++ b/arch/x86_64/kernel/pci-swiotlb.c
@@ -5,7 +5,7 @@
5#include <linux/module.h> 5#include <linux/module.h>
6#include <linux/dma-mapping.h> 6#include <linux/dma-mapping.h>
7 7
8#include <asm/proto.h> 8#include <asm/iommu.h>
9#include <asm/swiotlb.h> 9#include <asm/swiotlb.h>
10#include <asm/dma.h> 10#include <asm/dma.h>
11 11
diff --git a/arch/x86_64/kernel/process.c b/arch/x86_64/kernel/process.c
index 5909039f37aa..e7ac629d4c46 100644
--- a/arch/x86_64/kernel/process.c
+++ b/arch/x86_64/kernel/process.c
@@ -207,6 +207,7 @@ void cpu_idle (void)
207 if (__get_cpu_var(cpu_idle_state)) 207 if (__get_cpu_var(cpu_idle_state))
208 __get_cpu_var(cpu_idle_state) = 0; 208 __get_cpu_var(cpu_idle_state) = 0;
209 209
210 check_pgt_cache();
210 rmb(); 211 rmb();
211 idle = pm_idle; 212 idle = pm_idle;
212 if (!idle) 213 if (!idle)
@@ -278,7 +279,7 @@ void __cpuinit select_idle_routine(const struct cpuinfo_x86 *c)
278 */ 279 */
279 if (!pm_idle) { 280 if (!pm_idle) {
280 if (!printed) { 281 if (!printed) {
281 printk("using mwait in idle threads.\n"); 282 printk(KERN_INFO "using mwait in idle threads.\n");
282 printed = 1; 283 printed = 1;
283 } 284 }
284 pm_idle = mwait_idle; 285 pm_idle = mwait_idle;
@@ -305,6 +306,7 @@ early_param("idle", idle_setup);
305void __show_regs(struct pt_regs * regs) 306void __show_regs(struct pt_regs * regs)
306{ 307{
307 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs; 308 unsigned long cr0 = 0L, cr2 = 0L, cr3 = 0L, cr4 = 0L, fs, gs, shadowgs;
309 unsigned long d0, d1, d2, d3, d6, d7;
308 unsigned int fsindex,gsindex; 310 unsigned int fsindex,gsindex;
309 unsigned int ds,cs,es; 311 unsigned int ds,cs,es;
310 312
@@ -340,15 +342,24 @@ void __show_regs(struct pt_regs * regs)
340 rdmsrl(MSR_GS_BASE, gs); 342 rdmsrl(MSR_GS_BASE, gs);
341 rdmsrl(MSR_KERNEL_GS_BASE, shadowgs); 343 rdmsrl(MSR_KERNEL_GS_BASE, shadowgs);
342 344
343 asm("movq %%cr0, %0": "=r" (cr0)); 345 cr0 = read_cr0();
344 asm("movq %%cr2, %0": "=r" (cr2)); 346 cr2 = read_cr2();
345 asm("movq %%cr3, %0": "=r" (cr3)); 347 cr3 = read_cr3();
346 asm("movq %%cr4, %0": "=r" (cr4)); 348 cr4 = read_cr4();
347 349
348 printk("FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n", 350 printk("FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n",
349 fs,fsindex,gs,gsindex,shadowgs); 351 fs,fsindex,gs,gsindex,shadowgs);
350 printk("CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds, es, cr0); 352 printk("CS: %04x DS: %04x ES: %04x CR0: %016lx\n", cs, ds, es, cr0);
351 printk("CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3, cr4); 353 printk("CR2: %016lx CR3: %016lx CR4: %016lx\n", cr2, cr3, cr4);
354
355 get_debugreg(d0, 0);
356 get_debugreg(d1, 1);
357 get_debugreg(d2, 2);
358 printk("DR0: %016lx DR1: %016lx DR2: %016lx\n", d0, d1, d2);
359 get_debugreg(d3, 3);
360 get_debugreg(d6, 6);
361 get_debugreg(d7, 7);
362 printk("DR3: %016lx DR6: %016lx DR7: %016lx\n", d3, d6, d7);
352} 363}
353 364
354void show_regs(struct pt_regs *regs) 365void show_regs(struct pt_regs *regs)
diff --git a/arch/x86_64/kernel/reboot.c b/arch/x86_64/kernel/reboot.c
index 7503068e788d..368db2b9c5ac 100644
--- a/arch/x86_64/kernel/reboot.c
+++ b/arch/x86_64/kernel/reboot.c
@@ -16,6 +16,7 @@
16#include <asm/pgtable.h> 16#include <asm/pgtable.h>
17#include <asm/tlbflush.h> 17#include <asm/tlbflush.h>
18#include <asm/apic.h> 18#include <asm/apic.h>
19#include <asm/iommu.h>
19 20
20/* 21/*
21 * Power off function, if any 22 * Power off function, if any
@@ -81,6 +82,7 @@ static inline void kb_wait(void)
81void machine_shutdown(void) 82void machine_shutdown(void)
82{ 83{
83 unsigned long flags; 84 unsigned long flags;
85
84 /* Stop the cpus and apics */ 86 /* Stop the cpus and apics */
85#ifdef CONFIG_SMP 87#ifdef CONFIG_SMP
86 int reboot_cpu_id; 88 int reboot_cpu_id;
@@ -111,6 +113,8 @@ void machine_shutdown(void)
111 disable_IO_APIC(); 113 disable_IO_APIC();
112 114
113 local_irq_restore(flags); 115 local_irq_restore(flags);
116
117 pci_iommu_shutdown();
114} 118}
115 119
116void machine_emergency_restart(void) 120void machine_emergency_restart(void)
diff --git a/arch/x86_64/kernel/setup.c b/arch/x86_64/kernel/setup.c
index 33ef718f8cb5..af838f6b0b7f 100644
--- a/arch/x86_64/kernel/setup.c
+++ b/arch/x86_64/kernel/setup.c
@@ -575,6 +575,8 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
575 level = cpuid_eax(1); 575 level = cpuid_eax(1);
576 if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58)) 576 if (c->x86 == 15 && ((level >= 0x0f48 && level < 0x0f50) || level >= 0x0f58))
577 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability); 577 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
578 if (c->x86 == 0x10)
579 set_bit(X86_FEATURE_REP_GOOD, &c->x86_capability);
578 580
579 /* Enable workaround for FXSAVE leak */ 581 /* Enable workaround for FXSAVE leak */
580 if (c->x86 >= 6) 582 if (c->x86 >= 6)
@@ -600,8 +602,14 @@ static void __cpuinit init_amd(struct cpuinfo_x86 *c)
600 if (c->extended_cpuid_level >= 0x80000008) 602 if (c->extended_cpuid_level >= 0x80000008)
601 amd_detect_cmp(c); 603 amd_detect_cmp(c);
602 604
603 /* Fix cpuid4 emulation for more */ 605 if (c->extended_cpuid_level >= 0x80000006 &&
604 num_cache_leaves = 3; 606 (cpuid_edx(0x80000006) & 0xf000))
607 num_cache_leaves = 4;
608 else
609 num_cache_leaves = 3;
610
611 if (c->x86 == 0xf || c->x86 == 0x10 || c->x86 == 0x11)
612 set_bit(X86_FEATURE_K8, &c->x86_capability);
605 613
606 /* RDTSC can be speculated around */ 614 /* RDTSC can be speculated around */
607 clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability); 615 clear_bit(X86_FEATURE_SYNC_RDTSC, &c->x86_capability);
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 290f5d8037cd..739175b01e06 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -26,6 +26,7 @@
26#include <asm/i387.h> 26#include <asm/i387.h>
27#include <asm/proto.h> 27#include <asm/proto.h>
28#include <asm/ia32_unistd.h> 28#include <asm/ia32_unistd.h>
29#include <asm/mce.h>
29 30
30/* #define DEBUG_SIG 1 */ 31/* #define DEBUG_SIG 1 */
31 32
@@ -472,6 +473,12 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
472 clear_thread_flag(TIF_SINGLESTEP); 473 clear_thread_flag(TIF_SINGLESTEP);
473 } 474 }
474 475
476#ifdef CONFIG_X86_MCE
477 /* notify userspace of pending MCEs */
478 if (thread_info_flags & _TIF_MCE_NOTIFY)
479 mce_notify_user();
480#endif /* CONFIG_X86_MCE */
481
475 /* deal with pending signal delivery */ 482 /* deal with pending signal delivery */
476 if (thread_info_flags & (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK)) 483 if (thread_info_flags & (_TIF_SIGPENDING|_TIF_RESTORE_SIGMASK))
477 do_signal(regs); 484 do_signal(regs);
@@ -480,7 +487,7 @@ do_notify_resume(struct pt_regs *regs, void *unused, __u32 thread_info_flags)
480void signal_fault(struct pt_regs *regs, void __user *frame, char *where) 487void signal_fault(struct pt_regs *regs, void __user *frame, char *where)
481{ 488{
482 struct task_struct *me = current; 489 struct task_struct *me = current;
483 if (exception_trace) 490 if (show_unhandled_signals && printk_ratelimit())
484 printk("%s[%d] bad frame in %s frame:%p rip:%lx rsp:%lx orax:%lx\n", 491 printk("%s[%d] bad frame in %s frame:%p rip:%lx rsp:%lx orax:%lx\n",
485 me->comm,me->pid,where,frame,regs->rip,regs->rsp,regs->orig_rax); 492 me->comm,me->pid,where,frame,regs->rip,regs->rsp,regs->orig_rax);
486 493
diff --git a/arch/x86_64/kernel/smp.c b/arch/x86_64/kernel/smp.c
index 0694940b2e73..673a300b5944 100644
--- a/arch/x86_64/kernel/smp.c
+++ b/arch/x86_64/kernel/smp.c
@@ -241,7 +241,7 @@ void flush_tlb_mm (struct mm_struct * mm)
241 } 241 }
242 if (!cpus_empty(cpu_mask)) 242 if (!cpus_empty(cpu_mask))
243 flush_tlb_others(cpu_mask, mm, FLUSH_ALL); 243 flush_tlb_others(cpu_mask, mm, FLUSH_ALL);
244 244 check_pgt_cache();
245 preempt_enable(); 245 preempt_enable();
246} 246}
247EXPORT_SYMBOL(flush_tlb_mm); 247EXPORT_SYMBOL(flush_tlb_mm);
@@ -386,9 +386,9 @@ int smp_call_function_single (int cpu, void (*func) (void *info), void *info,
386 return 0; 386 return 0;
387 } 387 }
388 388
389 spin_lock_bh(&call_lock); 389 spin_lock(&call_lock);
390 __smp_call_function_single(cpu, func, info, nonatomic, wait); 390 __smp_call_function_single(cpu, func, info, nonatomic, wait);
391 spin_unlock_bh(&call_lock); 391 spin_unlock(&call_lock);
392 put_cpu(); 392 put_cpu();
393 return 0; 393 return 0;
394} 394}
diff --git a/arch/x86_64/kernel/suspend.c b/arch/x86_64/kernel/suspend.c
index 6a5a98f2a75c..ea83a9f91965 100644
--- a/arch/x86_64/kernel/suspend.c
+++ b/arch/x86_64/kernel/suspend.c
@@ -55,11 +55,11 @@ void __save_processor_state(struct saved_context *ctxt)
55 * control registers 55 * control registers
56 */ 56 */
57 rdmsrl(MSR_EFER, ctxt->efer); 57 rdmsrl(MSR_EFER, ctxt->efer);
58 asm volatile ("movq %%cr0, %0" : "=r" (ctxt->cr0)); 58 ctxt->cr0 = read_cr0();
59 asm volatile ("movq %%cr2, %0" : "=r" (ctxt->cr2)); 59 ctxt->cr2 = read_cr2();
60 asm volatile ("movq %%cr3, %0" : "=r" (ctxt->cr3)); 60 ctxt->cr3 = read_cr3();
61 asm volatile ("movq %%cr4, %0" : "=r" (ctxt->cr4)); 61 ctxt->cr4 = read_cr4();
62 asm volatile ("movq %%cr8, %0" : "=r" (ctxt->cr8)); 62 ctxt->cr8 = read_cr8();
63} 63}
64 64
65void save_processor_state(void) 65void save_processor_state(void)
@@ -81,11 +81,11 @@ void __restore_processor_state(struct saved_context *ctxt)
81 * control registers 81 * control registers
82 */ 82 */
83 wrmsrl(MSR_EFER, ctxt->efer); 83 wrmsrl(MSR_EFER, ctxt->efer);
84 asm volatile ("movq %0, %%cr8" :: "r" (ctxt->cr8)); 84 write_cr8(ctxt->cr8);
85 asm volatile ("movq %0, %%cr4" :: "r" (ctxt->cr4)); 85 write_cr4(ctxt->cr4);
86 asm volatile ("movq %0, %%cr3" :: "r" (ctxt->cr3)); 86 write_cr3(ctxt->cr3);
87 asm volatile ("movq %0, %%cr2" :: "r" (ctxt->cr2)); 87 write_cr2(ctxt->cr2);
88 asm volatile ("movq %0, %%cr0" :: "r" (ctxt->cr0)); 88 write_cr0(ctxt->cr0);
89 89
90 /* 90 /*
91 * now restore the descriptor tables to their proper values 91 * now restore the descriptor tables to their proper values
diff --git a/arch/x86_64/kernel/tce.c b/arch/x86_64/kernel/tce.c
index f61fb8e4f129..3aeae2fa2e24 100644
--- a/arch/x86_64/kernel/tce.c
+++ b/arch/x86_64/kernel/tce.c
@@ -136,9 +136,9 @@ int build_tce_table(struct pci_dev *dev, void __iomem *bbar)
136 struct iommu_table *tbl; 136 struct iommu_table *tbl;
137 int ret; 137 int ret;
138 138
139 if (dev->sysdata) { 139 if (pci_iommu(dev->bus)) {
140 printk(KERN_ERR "Calgary: dev %p has sysdata %p\n", 140 printk(KERN_ERR "Calgary: dev %p has sysdata->iommu %p\n",
141 dev, dev->sysdata); 141 dev, pci_iommu(dev->bus));
142 BUG(); 142 BUG();
143 } 143 }
144 144
@@ -155,11 +155,7 @@ int build_tce_table(struct pci_dev *dev, void __iomem *bbar)
155 155
156 tbl->bbar = bbar; 156 tbl->bbar = bbar;
157 157
158 /* 158 set_pci_iommu(dev->bus, tbl);
159 * NUMA is already using the bus's sysdata pointer, so we use
160 * the bus's pci_dev's sysdata instead.
161 */
162 dev->sysdata = tbl;
163 159
164 return 0; 160 return 0;
165 161
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c
index 4a0895bacf51..6d48a4e826d9 100644
--- a/arch/x86_64/kernel/time.c
+++ b/arch/x86_64/kernel/time.c
@@ -33,6 +33,7 @@
33#include <acpi/acpi_bus.h> 33#include <acpi/acpi_bus.h>
34#endif 34#endif
35#include <asm/8253pit.h> 35#include <asm/8253pit.h>
36#include <asm/i8253.h>
36#include <asm/pgtable.h> 37#include <asm/pgtable.h>
37#include <asm/vsyscall.h> 38#include <asm/vsyscall.h>
38#include <asm/timex.h> 39#include <asm/timex.h>
@@ -44,12 +45,14 @@
44#include <asm/hpet.h> 45#include <asm/hpet.h>
45#include <asm/mpspec.h> 46#include <asm/mpspec.h>
46#include <asm/nmi.h> 47#include <asm/nmi.h>
48#include <asm/vgtod.h>
47 49
48static char *timename = NULL; 50static char *timename = NULL;
49 51
50DEFINE_SPINLOCK(rtc_lock); 52DEFINE_SPINLOCK(rtc_lock);
51EXPORT_SYMBOL(rtc_lock); 53EXPORT_SYMBOL(rtc_lock);
52DEFINE_SPINLOCK(i8253_lock); 54DEFINE_SPINLOCK(i8253_lock);
55EXPORT_SYMBOL(i8253_lock);
53 56
54volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES; 57volatile unsigned long __jiffies __section_jiffies = INITIAL_JIFFIES;
55 58
@@ -79,8 +82,9 @@ EXPORT_SYMBOL(profile_pc);
79 * sheet for details. 82 * sheet for details.
80 */ 83 */
81 84
82static void set_rtc_mmss(unsigned long nowtime) 85static int set_rtc_mmss(unsigned long nowtime)
83{ 86{
87 int retval = 0;
84 int real_seconds, real_minutes, cmos_minutes; 88 int real_seconds, real_minutes, cmos_minutes;
85 unsigned char control, freq_select; 89 unsigned char control, freq_select;
86 90
@@ -120,6 +124,7 @@ static void set_rtc_mmss(unsigned long nowtime)
120 if (abs(real_minutes - cmos_minutes) >= 30) { 124 if (abs(real_minutes - cmos_minutes) >= 30) {
121 printk(KERN_WARNING "time.c: can't update CMOS clock " 125 printk(KERN_WARNING "time.c: can't update CMOS clock "
122 "from %d to %d\n", cmos_minutes, real_minutes); 126 "from %d to %d\n", cmos_minutes, real_minutes);
127 retval = -1;
123 } else { 128 } else {
124 BIN_TO_BCD(real_seconds); 129 BIN_TO_BCD(real_seconds);
125 BIN_TO_BCD(real_minutes); 130 BIN_TO_BCD(real_minutes);
@@ -139,12 +144,17 @@ static void set_rtc_mmss(unsigned long nowtime)
139 CMOS_WRITE(freq_select, RTC_FREQ_SELECT); 144 CMOS_WRITE(freq_select, RTC_FREQ_SELECT);
140 145
141 spin_unlock(&rtc_lock); 146 spin_unlock(&rtc_lock);
147
148 return retval;
142} 149}
143 150
151int update_persistent_clock(struct timespec now)
152{
153 return set_rtc_mmss(now.tv_sec);
154}
144 155
145void main_timer_handler(void) 156void main_timer_handler(void)
146{ 157{
147 static unsigned long rtc_update = 0;
148/* 158/*
149 * Here we are in the timer irq handler. We have irqs locally disabled (so we 159 * Here we are in the timer irq handler. We have irqs locally disabled (so we
150 * don't need spin_lock_irqsave()) but we don't know if the timer_bh is running 160 * don't need spin_lock_irqsave()) but we don't know if the timer_bh is running
@@ -172,20 +182,6 @@ void main_timer_handler(void)
172 if (!using_apic_timer) 182 if (!using_apic_timer)
173 smp_local_timer_interrupt(); 183 smp_local_timer_interrupt();
174 184
175/*
176 * If we have an externally synchronized Linux clock, then update CMOS clock
177 * accordingly every ~11 minutes. set_rtc_mmss() will be called in the jiffy
178 * closest to exactly 500 ms before the next second. If the update fails, we
179 * don't care, as it'll be updated on the next turn, and the problem (time way
180 * off) isn't likely to go away much sooner anyway.
181 */
182
183 if (ntp_synced() && xtime.tv_sec > rtc_update &&
184 abs(xtime.tv_nsec - 500000000) <= tick_nsec / 2) {
185 set_rtc_mmss(xtime.tv_sec);
186 rtc_update = xtime.tv_sec + 660;
187 }
188
189 write_sequnlock(&xtime_lock); 185 write_sequnlock(&xtime_lock);
190} 186}
191 187
@@ -199,7 +195,7 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id)
199 return IRQ_HANDLED; 195 return IRQ_HANDLED;
200} 196}
201 197
202static unsigned long get_cmos_time(void) 198unsigned long read_persistent_clock(void)
203{ 199{
204 unsigned int year, mon, day, hour, min, sec; 200 unsigned int year, mon, day, hour, min, sec;
205 unsigned long flags; 201 unsigned long flags;
@@ -226,7 +222,7 @@ static unsigned long get_cmos_time(void)
226 /* 222 /*
227 * We know that x86-64 always uses BCD format, no need to check the 223 * We know that x86-64 always uses BCD format, no need to check the
228 * config register. 224 * config register.
229 */ 225 */
230 226
231 BCD_TO_BIN(sec); 227 BCD_TO_BIN(sec);
232 BCD_TO_BIN(min); 228 BCD_TO_BIN(min);
@@ -239,11 +235,11 @@ static unsigned long get_cmos_time(void)
239 BCD_TO_BIN(century); 235 BCD_TO_BIN(century);
240 year += century * 100; 236 year += century * 100;
241 printk(KERN_INFO "Extended CMOS year: %d\n", century * 100); 237 printk(KERN_INFO "Extended CMOS year: %d\n", century * 100);
242 } else { 238 } else {
243 /* 239 /*
244 * x86-64 systems only exists since 2002. 240 * x86-64 systems only exists since 2002.
245 * This will work up to Dec 31, 2100 241 * This will work up to Dec 31, 2100
246 */ 242 */
247 year += 2000; 243 year += 2000;
248 } 244 }
249 245
@@ -255,45 +251,45 @@ static unsigned long get_cmos_time(void)
255#define TICK_COUNT 100000000 251#define TICK_COUNT 100000000
256static unsigned int __init tsc_calibrate_cpu_khz(void) 252static unsigned int __init tsc_calibrate_cpu_khz(void)
257{ 253{
258 int tsc_start, tsc_now; 254 int tsc_start, tsc_now;
259 int i, no_ctr_free; 255 int i, no_ctr_free;
260 unsigned long evntsel3 = 0, pmc3 = 0, pmc_now = 0; 256 unsigned long evntsel3 = 0, pmc3 = 0, pmc_now = 0;
261 unsigned long flags; 257 unsigned long flags;
262 258
263 for (i = 0; i < 4; i++) 259 for (i = 0; i < 4; i++)
264 if (avail_to_resrv_perfctr_nmi_bit(i)) 260 if (avail_to_resrv_perfctr_nmi_bit(i))
265 break; 261 break;
266 no_ctr_free = (i == 4); 262 no_ctr_free = (i == 4);
267 if (no_ctr_free) { 263 if (no_ctr_free) {
268 i = 3; 264 i = 3;
269 rdmsrl(MSR_K7_EVNTSEL3, evntsel3); 265 rdmsrl(MSR_K7_EVNTSEL3, evntsel3);
270 wrmsrl(MSR_K7_EVNTSEL3, 0); 266 wrmsrl(MSR_K7_EVNTSEL3, 0);
271 rdmsrl(MSR_K7_PERFCTR3, pmc3); 267 rdmsrl(MSR_K7_PERFCTR3, pmc3);
272 } else { 268 } else {
273 reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i); 269 reserve_perfctr_nmi(MSR_K7_PERFCTR0 + i);
274 reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i); 270 reserve_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
275 } 271 }
276 local_irq_save(flags); 272 local_irq_save(flags);
277 /* start meauring cycles, incrementing from 0 */ 273 /* start meauring cycles, incrementing from 0 */
278 wrmsrl(MSR_K7_PERFCTR0 + i, 0); 274 wrmsrl(MSR_K7_PERFCTR0 + i, 0);
279 wrmsrl(MSR_K7_EVNTSEL0 + i, 1 << 22 | 3 << 16 | 0x76); 275 wrmsrl(MSR_K7_EVNTSEL0 + i, 1 << 22 | 3 << 16 | 0x76);
280 rdtscl(tsc_start); 276 rdtscl(tsc_start);
281 do { 277 do {
282 rdmsrl(MSR_K7_PERFCTR0 + i, pmc_now); 278 rdmsrl(MSR_K7_PERFCTR0 + i, pmc_now);
283 tsc_now = get_cycles_sync(); 279 tsc_now = get_cycles_sync();
284 } while ((tsc_now - tsc_start) < TICK_COUNT); 280 } while ((tsc_now - tsc_start) < TICK_COUNT);
285 281
286 local_irq_restore(flags); 282 local_irq_restore(flags);
287 if (no_ctr_free) { 283 if (no_ctr_free) {
288 wrmsrl(MSR_K7_EVNTSEL3, 0); 284 wrmsrl(MSR_K7_EVNTSEL3, 0);
289 wrmsrl(MSR_K7_PERFCTR3, pmc3); 285 wrmsrl(MSR_K7_PERFCTR3, pmc3);
290 wrmsrl(MSR_K7_EVNTSEL3, evntsel3); 286 wrmsrl(MSR_K7_EVNTSEL3, evntsel3);
291 } else { 287 } else {
292 release_perfctr_nmi(MSR_K7_PERFCTR0 + i); 288 release_perfctr_nmi(MSR_K7_PERFCTR0 + i);
293 release_evntsel_nmi(MSR_K7_EVNTSEL0 + i); 289 release_evntsel_nmi(MSR_K7_EVNTSEL0 + i);
294 } 290 }
295 291
296 return pmc_now * tsc_khz / (tsc_now - tsc_start); 292 return pmc_now * tsc_khz / (tsc_now - tsc_start);
297} 293}
298 294
299/* 295/*
@@ -321,7 +317,7 @@ static unsigned int __init pit_calibrate_tsc(void)
321 end = get_cycles_sync(); 317 end = get_cycles_sync();
322 318
323 spin_unlock_irqrestore(&i8253_lock, flags); 319 spin_unlock_irqrestore(&i8253_lock, flags);
324 320
325 return (end - start) / 50; 321 return (end - start) / 50;
326} 322}
327 323
@@ -366,25 +362,20 @@ static struct irqaction irq0 = {
366 .handler = timer_interrupt, 362 .handler = timer_interrupt,
367 .flags = IRQF_DISABLED | IRQF_IRQPOLL, 363 .flags = IRQF_DISABLED | IRQF_IRQPOLL,
368 .mask = CPU_MASK_NONE, 364 .mask = CPU_MASK_NONE,
369 .name = "timer" 365 .name = "timer"
370}; 366};
371 367
372void __init time_init(void) 368void __init time_init(void)
373{ 369{
374 if (nohpet) 370 if (nohpet)
375 hpet_address = 0; 371 hpet_address = 0;
376 xtime.tv_sec = get_cmos_time();
377 xtime.tv_nsec = 0;
378
379 set_normalized_timespec(&wall_to_monotonic,
380 -xtime.tv_sec, -xtime.tv_nsec);
381 372
382 if (hpet_arch_init()) 373 if (hpet_arch_init())
383 hpet_address = 0; 374 hpet_address = 0;
384 375
385 if (hpet_use_timer) { 376 if (hpet_use_timer) {
386 /* set tick_nsec to use the proper rate for HPET */ 377 /* set tick_nsec to use the proper rate for HPET */
387 tick_nsec = TICK_NSEC_HPET; 378 tick_nsec = TICK_NSEC_HPET;
388 tsc_khz = hpet_calibrate_tsc(); 379 tsc_khz = hpet_calibrate_tsc();
389 timename = "HPET"; 380 timename = "HPET";
390 } else { 381 } else {
@@ -415,54 +406,21 @@ void __init time_init(void)
415 setup_irq(0, &irq0); 406 setup_irq(0, &irq0);
416} 407}
417 408
418
419static long clock_cmos_diff;
420static unsigned long sleep_start;
421
422/* 409/*
423 * sysfs support for the timer. 410 * sysfs support for the timer.
424 */ 411 */
425 412
426static int timer_suspend(struct sys_device *dev, pm_message_t state) 413static int timer_suspend(struct sys_device *dev, pm_message_t state)
427{ 414{
428 /*
429 * Estimate time zone so that set_time can update the clock
430 */
431 long cmos_time = get_cmos_time();
432
433 clock_cmos_diff = -cmos_time;
434 clock_cmos_diff += get_seconds();
435 sleep_start = cmos_time;
436 return 0; 415 return 0;
437} 416}
438 417
439static int timer_resume(struct sys_device *dev) 418static int timer_resume(struct sys_device *dev)
440{ 419{
441 unsigned long flags;
442 unsigned long sec;
443 unsigned long ctime = get_cmos_time();
444 long sleep_length = (ctime - sleep_start) * HZ;
445
446 if (sleep_length < 0) {
447 printk(KERN_WARNING "Time skew detected in timer resume!\n");
448 /* The time after the resume must not be earlier than the time
449 * before the suspend or some nasty things will happen
450 */
451 sleep_length = 0;
452 ctime = sleep_start;
453 }
454 if (hpet_address) 420 if (hpet_address)
455 hpet_reenable(); 421 hpet_reenable();
456 else 422 else
457 i8254_timer_resume(); 423 i8254_timer_resume();
458
459 sec = ctime + clock_cmos_diff;
460 write_seqlock_irqsave(&xtime_lock,flags);
461 xtime.tv_sec = sec;
462 xtime.tv_nsec = 0;
463 jiffies += sleep_length;
464 write_sequnlock_irqrestore(&xtime_lock,flags);
465 touch_softlockup_watchdog();
466 return 0; 424 return 0;
467} 425}
468 426
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 8713ad4a4db1..03888420775d 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -584,7 +584,8 @@ static void __kprobes do_trap(int trapnr, int signr, char *str,
584 tsk->thread.error_code = error_code; 584 tsk->thread.error_code = error_code;
585 tsk->thread.trap_no = trapnr; 585 tsk->thread.trap_no = trapnr;
586 586
587 if (exception_trace && unhandled_signal(tsk, signr)) 587 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
588 printk_ratelimit())
588 printk(KERN_INFO 589 printk(KERN_INFO
589 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n", 590 "%s[%d] trap %s rip:%lx rsp:%lx error:%lx\n",
590 tsk->comm, tsk->pid, str, 591 tsk->comm, tsk->pid, str,
@@ -688,7 +689,8 @@ asmlinkage void __kprobes do_general_protection(struct pt_regs * regs,
688 tsk->thread.error_code = error_code; 689 tsk->thread.error_code = error_code;
689 tsk->thread.trap_no = 13; 690 tsk->thread.trap_no = 13;
690 691
691 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) 692 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
693 printk_ratelimit())
692 printk(KERN_INFO 694 printk(KERN_INFO
693 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n", 695 "%s[%d] general protection rip:%lx rsp:%lx error:%lx\n",
694 tsk->comm, tsk->pid, 696 tsk->comm, tsk->pid,
diff --git a/arch/x86_64/kernel/tsc.c b/arch/x86_64/kernel/tsc.c
index e850aa01e1b3..9b76b03d0600 100644
--- a/arch/x86_64/kernel/tsc.c
+++ b/arch/x86_64/kernel/tsc.c
@@ -61,25 +61,9 @@ inline int check_tsc_unstable(void)
61 * first tick after the change will be slightly wrong. 61 * first tick after the change will be slightly wrong.
62 */ 62 */
63 63
64#include <linux/workqueue.h> 64static unsigned int ref_freq;
65 65static unsigned long loops_per_jiffy_ref;
66static unsigned int cpufreq_delayed_issched = 0; 66static unsigned long tsc_khz_ref;
67static unsigned int cpufreq_init = 0;
68static struct work_struct cpufreq_delayed_get_work;
69
70static void handle_cpufreq_delayed_get(struct work_struct *v)
71{
72 unsigned int cpu;
73 for_each_online_cpu(cpu) {
74 cpufreq_get(cpu);
75 }
76 cpufreq_delayed_issched = 0;
77}
78
79static unsigned int ref_freq = 0;
80static unsigned long loops_per_jiffy_ref = 0;
81
82static unsigned long tsc_khz_ref = 0;
83 67
84static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val, 68static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
85 void *data) 69 void *data)
@@ -125,10 +109,8 @@ static struct notifier_block time_cpufreq_notifier_block = {
125 109
126static int __init cpufreq_tsc(void) 110static int __init cpufreq_tsc(void)
127{ 111{
128 INIT_WORK(&cpufreq_delayed_get_work, handle_cpufreq_delayed_get); 112 cpufreq_register_notifier(&time_cpufreq_notifier_block,
129 if (!cpufreq_register_notifier(&time_cpufreq_notifier_block, 113 CPUFREQ_TRANSITION_NOTIFIER);
130 CPUFREQ_TRANSITION_NOTIFIER))
131 cpufreq_init = 1;
132 return 0; 114 return 0;
133} 115}
134 116
@@ -153,17 +135,18 @@ __cpuinit int unsynchronized_tsc(void)
153#endif 135#endif
154 /* Most intel systems have synchronized TSCs except for 136 /* Most intel systems have synchronized TSCs except for
155 multi node systems */ 137 multi node systems */
156 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) { 138 if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) {
157#ifdef CONFIG_ACPI 139#ifdef CONFIG_ACPI
158 /* But TSC doesn't tick in C3 so don't use it there */ 140 /* But TSC doesn't tick in C3 so don't use it there */
159 if (acpi_gbl_FADT.header.length > 0 && acpi_gbl_FADT.C3latency < 1000) 141 if (acpi_gbl_FADT.header.length > 0 &&
142 acpi_gbl_FADT.C3latency < 1000)
160 return 1; 143 return 1;
161#endif 144#endif
162 return 0; 145 return 0;
163 } 146 }
164 147
165 /* Assume multi socket systems are not synchronized */ 148 /* Assume multi socket systems are not synchronized */
166 return num_present_cpus() > 1; 149 return num_present_cpus() > 1;
167} 150}
168 151
169int __init notsc_setup(char *s) 152int __init notsc_setup(char *s)
diff --git a/arch/x86_64/kernel/vmlinux.lds.S b/arch/x86_64/kernel/vmlinux.lds.S
index 5c57ea4591c1..ba8ea97abd21 100644
--- a/arch/x86_64/kernel/vmlinux.lds.S
+++ b/arch/x86_64/kernel/vmlinux.lds.S
@@ -28,7 +28,7 @@ SECTIONS
28 _text = .; /* Text and read-only data */ 28 _text = .; /* Text and read-only data */
29 .text : AT(ADDR(.text) - LOAD_OFFSET) { 29 .text : AT(ADDR(.text) - LOAD_OFFSET) {
30 /* First the code that has to be first for bootstrapping */ 30 /* First the code that has to be first for bootstrapping */
31 *(.bootstrap.text) 31 *(.text.head)
32 _stext = .; 32 _stext = .;
33 /* Then the rest */ 33 /* Then the rest */
34 TEXT_TEXT 34 TEXT_TEXT
@@ -54,6 +54,13 @@ SECTIONS
54 54
55 RODATA 55 RODATA
56 56
57 . = ALIGN(4);
58 .tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {
59 __tracedata_start = .;
60 *(.tracedata)
61 __tracedata_end = .;
62 }
63
57 . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */ 64 . = ALIGN(PAGE_SIZE); /* Align data segment to page size boundary */
58 /* Data */ 65 /* Data */
59 .data : AT(ADDR(.data) - LOAD_OFFSET) { 66 .data : AT(ADDR(.data) - LOAD_OFFSET) {
@@ -93,6 +100,9 @@ SECTIONS
93 .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data)) 100 .vsyscall_gtod_data : AT(VLOAD(.vsyscall_gtod_data))
94 { *(.vsyscall_gtod_data) } 101 { *(.vsyscall_gtod_data) }
95 vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data); 102 vsyscall_gtod_data = VVIRT(.vsyscall_gtod_data);
103 .vsyscall_clock : AT(VLOAD(.vsyscall_clock))
104 { *(.vsyscall_clock) }
105 vsyscall_clock = VVIRT(.vsyscall_clock);
96 106
97 107
98 .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1)) 108 .vsyscall_1 ADDR(.vsyscall_0) + 1024: AT(VLOAD(.vsyscall_1))
@@ -133,20 +143,11 @@ SECTIONS
133 /* might get freed after init */ 143 /* might get freed after init */
134 . = ALIGN(4096); 144 . = ALIGN(4096);
135 __smp_alt_begin = .; 145 __smp_alt_begin = .;
136 __smp_alt_instructions = .;
137 .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) {
138 *(.smp_altinstructions)
139 }
140 __smp_alt_instructions_end = .;
141 . = ALIGN(8);
142 __smp_locks = .; 146 __smp_locks = .;
143 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) { 147 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
144 *(.smp_locks) 148 *(.smp_locks)
145 } 149 }
146 __smp_locks_end = .; 150 __smp_locks_end = .;
147 .smp_altinstr_replacement : AT(ADDR(.smp_altinstr_replacement) - LOAD_OFFSET) {
148 *(.smp_altinstr_replacement)
149 }
150 . = ALIGN(4096); 151 . = ALIGN(4096);
151 __smp_alt_end = .; 152 __smp_alt_end = .;
152 153
@@ -189,6 +190,12 @@ SECTIONS
189 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } 190 .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) }
190 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } 191 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) }
191 192
193/* vdso blob that is mapped into user space */
194 vdso_start = . ;
195 .vdso : AT(ADDR(.vdso) - LOAD_OFFSET) { *(.vdso) }
196 . = ALIGN(4096);
197 vdso_end = .;
198
192#ifdef CONFIG_BLK_DEV_INITRD 199#ifdef CONFIG_BLK_DEV_INITRD
193 . = ALIGN(4096); 200 . = ALIGN(4096);
194 __initramfs_start = .; 201 __initramfs_start = .;
diff --git a/arch/x86_64/kernel/vsyscall.c b/arch/x86_64/kernel/vsyscall.c
index 57660d58d500..06c34949bfdc 100644
--- a/arch/x86_64/kernel/vsyscall.c
+++ b/arch/x86_64/kernel/vsyscall.c
@@ -42,6 +42,7 @@
42#include <asm/segment.h> 42#include <asm/segment.h>
43#include <asm/desc.h> 43#include <asm/desc.h>
44#include <asm/topology.h> 44#include <asm/topology.h>
45#include <asm/vgtod.h>
45 46
46#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr))) 47#define __vsyscall(nr) __attribute__ ((unused,__section__(".vsyscall_" #nr)))
47#define __syscall_clobber "r11","rcx","memory" 48#define __syscall_clobber "r11","rcx","memory"
@@ -57,26 +58,9 @@
57 * - writen by timer interrupt or systcl (/proc/sys/kernel/vsyscall64) 58 * - writen by timer interrupt or systcl (/proc/sys/kernel/vsyscall64)
58 * Try to keep this structure as small as possible to avoid cache line ping pongs 59 * Try to keep this structure as small as possible to avoid cache line ping pongs
59 */ 60 */
60struct vsyscall_gtod_data_t {
61 seqlock_t lock;
62
63 /* open coded 'struct timespec' */
64 time_t wall_time_sec;
65 u32 wall_time_nsec;
66
67 int sysctl_enabled;
68 struct timezone sys_tz;
69 struct { /* extract of a clocksource struct */
70 cycle_t (*vread)(void);
71 cycle_t cycle_last;
72 cycle_t mask;
73 u32 mult;
74 u32 shift;
75 } clock;
76};
77int __vgetcpu_mode __section_vgetcpu_mode; 61int __vgetcpu_mode __section_vgetcpu_mode;
78 62
79struct vsyscall_gtod_data_t __vsyscall_gtod_data __section_vsyscall_gtod_data = 63struct vsyscall_gtod_data __vsyscall_gtod_data __section_vsyscall_gtod_data =
80{ 64{
81 .lock = SEQLOCK_UNLOCKED, 65 .lock = SEQLOCK_UNLOCKED,
82 .sysctl_enabled = 1, 66 .sysctl_enabled = 1,
@@ -96,6 +80,8 @@ void update_vsyscall(struct timespec *wall_time, struct clocksource *clock)
96 vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec; 80 vsyscall_gtod_data.wall_time_sec = wall_time->tv_sec;
97 vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec; 81 vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
98 vsyscall_gtod_data.sys_tz = sys_tz; 82 vsyscall_gtod_data.sys_tz = sys_tz;
83 vsyscall_gtod_data.wall_time_nsec = wall_time->tv_nsec;
84 vsyscall_gtod_data.wall_to_monotonic = wall_to_monotonic;
99 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags); 85 write_sequnlock_irqrestore(&vsyscall_gtod_data.lock, flags);
100} 86}
101 87
diff --git a/arch/x86_64/mm/fault.c b/arch/x86_64/mm/fault.c
index 84f11728fc76..327c9f2fa626 100644
--- a/arch/x86_64/mm/fault.c
+++ b/arch/x86_64/mm/fault.c
@@ -159,7 +159,7 @@ void dump_pagetable(unsigned long address)
159 pmd_t *pmd; 159 pmd_t *pmd;
160 pte_t *pte; 160 pte_t *pte;
161 161
162 asm("movq %%cr3,%0" : "=r" (pgd)); 162 pgd = (pgd_t *)read_cr3();
163 163
164 pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK); 164 pgd = __va((unsigned long)pgd & PHYSICAL_PAGE_MASK);
165 pgd += pgd_index(address); 165 pgd += pgd_index(address);
@@ -221,16 +221,6 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
221 return 0; 221 return 0;
222} 222}
223 223
224int unhandled_signal(struct task_struct *tsk, int sig)
225{
226 if (is_init(tsk))
227 return 1;
228 if (tsk->ptrace & PT_PTRACED)
229 return 0;
230 return (tsk->sighand->action[sig-1].sa.sa_handler == SIG_IGN) ||
231 (tsk->sighand->action[sig-1].sa.sa_handler == SIG_DFL);
232}
233
234static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs, 224static noinline void pgtable_bad(unsigned long address, struct pt_regs *regs,
235 unsigned long error_code) 225 unsigned long error_code)
236{ 226{
@@ -301,8 +291,8 @@ static int vmalloc_fault(unsigned long address)
301 return 0; 291 return 0;
302} 292}
303 293
304int page_fault_trace = 0; 294static int page_fault_trace;
305int exception_trace = 1; 295int show_unhandled_signals = 1;
306 296
307/* 297/*
308 * This routine handles page faults. It determines the address, 298 * This routine handles page faults. It determines the address,
@@ -326,7 +316,7 @@ asmlinkage void __kprobes do_page_fault(struct pt_regs *regs,
326 prefetchw(&mm->mmap_sem); 316 prefetchw(&mm->mmap_sem);
327 317
328 /* get the address */ 318 /* get the address */
329 __asm__("movq %%cr2,%0":"=r" (address)); 319 address = read_cr2();
330 320
331 info.si_code = SEGV_MAPERR; 321 info.si_code = SEGV_MAPERR;
332 322
@@ -494,7 +484,8 @@ bad_area_nosemaphore:
494 (address >> 32)) 484 (address >> 32))
495 return; 485 return;
496 486
497 if (exception_trace && unhandled_signal(tsk, SIGSEGV)) { 487 if (show_unhandled_signals && unhandled_signal(tsk, SIGSEGV) &&
488 printk_ratelimit()) {
498 printk( 489 printk(
499 "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n", 490 "%s%s[%d]: segfault at %016lx rip %016lx rsp %016lx error %lx\n",
500 tsk->pid > 1 ? KERN_INFO : KERN_EMERG, 491 tsk->pid > 1 ? KERN_INFO : KERN_EMERG,
@@ -568,7 +559,7 @@ out_of_memory:
568 } 559 }
569 printk("VM: killing process %s\n", tsk->comm); 560 printk("VM: killing process %s\n", tsk->comm);
570 if (error_code & 4) 561 if (error_code & 4)
571 do_exit(SIGKILL); 562 do_group_exit(SIGKILL);
572 goto no_context; 563 goto no_context;
573 564
574do_sigbus: 565do_sigbus:
diff --git a/arch/x86_64/mm/init.c b/arch/x86_64/mm/init.c
index 9a0e98accf04..38f5d6368006 100644
--- a/arch/x86_64/mm/init.c
+++ b/arch/x86_64/mm/init.c
@@ -383,7 +383,7 @@ void __meminit init_memory_mapping(unsigned long start, unsigned long end)
383 } 383 }
384 384
385 if (!after_bootmem) 385 if (!after_bootmem)
386 asm volatile("movq %%cr4,%0" : "=r" (mmu_cr4_features)); 386 mmu_cr4_features = read_cr4();
387 __flush_tlb_all(); 387 __flush_tlb_all();
388} 388}
389 389
@@ -600,16 +600,6 @@ void mark_rodata_ro(void)
600{ 600{
601 unsigned long start = (unsigned long)_stext, end; 601 unsigned long start = (unsigned long)_stext, end;
602 602
603#ifdef CONFIG_HOTPLUG_CPU
604 /* It must still be possible to apply SMP alternatives. */
605 if (num_possible_cpus() > 1)
606 start = (unsigned long)_etext;
607#endif
608
609#ifdef CONFIG_KPROBES
610 start = (unsigned long)__start_rodata;
611#endif
612
613 end = (unsigned long)__end_rodata; 603 end = (unsigned long)__end_rodata;
614 start = (start + PAGE_SIZE - 1) & PAGE_MASK; 604 start = (start + PAGE_SIZE - 1) & PAGE_MASK;
615 end &= PAGE_MASK; 605 end &= PAGE_MASK;
@@ -697,41 +687,6 @@ int kern_addr_valid(unsigned long addr)
697 return pfn_valid(pte_pfn(*pte)); 687 return pfn_valid(pte_pfn(*pte));
698} 688}
699 689
700#ifdef CONFIG_SYSCTL
701#include <linux/sysctl.h>
702
703extern int exception_trace, page_fault_trace;
704
705static ctl_table debug_table2[] = {
706 {
707 .ctl_name = 99,
708 .procname = "exception-trace",
709 .data = &exception_trace,
710 .maxlen = sizeof(int),
711 .mode = 0644,
712 .proc_handler = proc_dointvec
713 },
714 {}
715};
716
717static ctl_table debug_root_table2[] = {
718 {
719 .ctl_name = CTL_DEBUG,
720 .procname = "debug",
721 .mode = 0555,
722 .child = debug_table2
723 },
724 {}
725};
726
727static __init int x8664_sysctl_init(void)
728{
729 register_sysctl_table(debug_root_table2);
730 return 0;
731}
732__initcall(x8664_sysctl_init);
733#endif
734
735/* A pseudo VMA to allow ptrace access for the vsyscall page. This only 690/* A pseudo VMA to allow ptrace access for the vsyscall page. This only
736 covers the 64bit vsyscall page now. 32bit has a real VMA now and does 691 covers the 64bit vsyscall page now. 32bit has a real VMA now and does
737 not need special handling anymore. */ 692 not need special handling anymore. */
@@ -769,8 +724,17 @@ int in_gate_area_no_task(unsigned long addr)
769 return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END); 724 return (addr >= VSYSCALL_START) && (addr < VSYSCALL_END);
770} 725}
771 726
772void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size) 727void * __init alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
773{ 728{
774 return __alloc_bootmem_core(pgdat->bdata, size, 729 return __alloc_bootmem_core(pgdat->bdata, size,
775 SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0); 730 SMP_CACHE_BYTES, (4UL*1024*1024*1024), 0);
776} 731}
732
733const char *arch_vma_name(struct vm_area_struct *vma)
734{
735 if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
736 return "[vdso]";
737 if (vma == &gate_vma)
738 return "[vsyscall]";
739 return NULL;
740}
diff --git a/arch/x86_64/mm/k8topology.c b/arch/x86_64/mm/k8topology.c
index f983c75825d0..a96006f7ae0c 100644
--- a/arch/x86_64/mm/k8topology.c
+++ b/arch/x86_64/mm/k8topology.c
@@ -44,12 +44,12 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
44{ 44{
45 unsigned long prevbase; 45 unsigned long prevbase;
46 struct bootnode nodes[8]; 46 struct bootnode nodes[8];
47 int nodeid, i, nb; 47 int nodeid, i, j, nb;
48 unsigned char nodeids[8]; 48 unsigned char nodeids[8];
49 int found = 0; 49 int found = 0;
50 u32 reg; 50 u32 reg;
51 unsigned numnodes; 51 unsigned numnodes;
52 unsigned dualcore = 0; 52 unsigned num_cores;
53 53
54 if (!early_pci_allowed()) 54 if (!early_pci_allowed())
55 return -1; 55 return -1;
@@ -60,6 +60,9 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
60 60
61 printk(KERN_INFO "Scanning NUMA topology in Northbridge %d\n", nb); 61 printk(KERN_INFO "Scanning NUMA topology in Northbridge %d\n", nb);
62 62
63 num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
64 printk(KERN_INFO "CPU has %d num_cores\n", num_cores);
65
63 reg = read_pci_config(0, nb, 0, 0x60); 66 reg = read_pci_config(0, nb, 0, 0x60);
64 numnodes = ((reg >> 4) & 0xF) + 1; 67 numnodes = ((reg >> 4) & 0xF) + 1;
65 if (numnodes <= 1) 68 if (numnodes <= 1)
@@ -73,8 +76,6 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
73 unsigned long base,limit; 76 unsigned long base,limit;
74 u32 nodeid; 77 u32 nodeid;
75 78
76 /* Undefined before E stepping, but hopefully 0 */
77 dualcore |= ((read_pci_config(0, nb, 3, 0xe8) >> 12) & 3) == 1;
78 base = read_pci_config(0, nb, 1, 0x40 + i*8); 79 base = read_pci_config(0, nb, 1, 0x40 + i*8);
79 limit = read_pci_config(0, nb, 1, 0x44 + i*8); 80 limit = read_pci_config(0, nb, 1, 0x44 + i*8);
80 81
@@ -170,8 +171,8 @@ int __init k8_scan_nodes(unsigned long start, unsigned long end)
170 for (i = 0; i < 8; i++) { 171 for (i = 0; i < 8; i++) {
171 if (nodes[i].start != nodes[i].end) { 172 if (nodes[i].start != nodes[i].end) {
172 nodeid = nodeids[i]; 173 nodeid = nodeids[i];
173 apicid_to_node[nodeid << dualcore] = i; 174 for (j = 0; j < num_cores; j++)
174 apicid_to_node[(nodeid << dualcore) + dualcore] = i; 175 apicid_to_node[(nodeid * num_cores) + j] = i;
175 setup_node_bootmem(i, nodes[i].start, nodes[i].end); 176 setup_node_bootmem(i, nodes[i].start, nodes[i].end);
176 } 177 }
177 } 178 }
diff --git a/arch/x86_64/mm/numa.c b/arch/x86_64/mm/numa.c
index 51548947ad3b..6da235522269 100644
--- a/arch/x86_64/mm/numa.c
+++ b/arch/x86_64/mm/numa.c
@@ -273,9 +273,6 @@ void __init numa_init_array(void)
273 273
274#ifdef CONFIG_NUMA_EMU 274#ifdef CONFIG_NUMA_EMU
275/* Numa emulation */ 275/* Numa emulation */
276#define E820_ADDR_HOLE_SIZE(start, end) \
277 (e820_hole_size((start) >> PAGE_SHIFT, (end) >> PAGE_SHIFT) << \
278 PAGE_SHIFT)
279char *cmdline __initdata; 276char *cmdline __initdata;
280 277
281/* 278/*
@@ -319,7 +316,7 @@ static int __init split_nodes_equally(struct bootnode *nodes, u64 *addr,
319 return -1; 316 return -1;
320 if (num_nodes > MAX_NUMNODES) 317 if (num_nodes > MAX_NUMNODES)
321 num_nodes = MAX_NUMNODES; 318 num_nodes = MAX_NUMNODES;
322 size = (max_addr - *addr - E820_ADDR_HOLE_SIZE(*addr, max_addr)) / 319 size = (max_addr - *addr - e820_hole_size(*addr, max_addr)) /
323 num_nodes; 320 num_nodes;
324 /* 321 /*
325 * Calculate the number of big nodes that can be allocated as a result 322 * Calculate the number of big nodes that can be allocated as a result
@@ -347,7 +344,7 @@ static int __init split_nodes_equally(struct bootnode *nodes, u64 *addr,
347 if (i == num_nodes + node_start - 1) 344 if (i == num_nodes + node_start - 1)
348 end = max_addr; 345 end = max_addr;
349 else 346 else
350 while (end - *addr - E820_ADDR_HOLE_SIZE(*addr, end) < 347 while (end - *addr - e820_hole_size(*addr, end) <
351 size) { 348 size) {
352 end += FAKE_NODE_MIN_SIZE; 349 end += FAKE_NODE_MIN_SIZE;
353 if (end > max_addr) { 350 if (end > max_addr) {
@@ -476,18 +473,22 @@ out:
476 473
477 /* 474 /*
478 * We need to vacate all active ranges that may have been registered by 475 * We need to vacate all active ranges that may have been registered by
479 * SRAT. 476 * SRAT and set acpi_numa to -1 so that srat_disabled() always returns
477 * true. NUMA emulation has succeeded so we will not scan ACPI nodes.
480 */ 478 */
481 remove_all_active_ranges(); 479 remove_all_active_ranges();
480#ifdef CONFIG_ACPI_NUMA
481 acpi_numa = -1;
482#endif
482 for_each_node_mask(i, node_possible_map) { 483 for_each_node_mask(i, node_possible_map) {
483 e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT, 484 e820_register_active_regions(i, nodes[i].start >> PAGE_SHIFT,
484 nodes[i].end >> PAGE_SHIFT); 485 nodes[i].end >> PAGE_SHIFT);
485 setup_node_bootmem(i, nodes[i].start, nodes[i].end); 486 setup_node_bootmem(i, nodes[i].start, nodes[i].end);
486 } 487 }
488 acpi_fake_nodes(nodes, num_nodes);
487 numa_init_array(); 489 numa_init_array();
488 return 0; 490 return 0;
489} 491}
490#undef E820_ADDR_HOLE_SIZE
491#endif /* CONFIG_NUMA_EMU */ 492#endif /* CONFIG_NUMA_EMU */
492 493
493void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn) 494void __init numa_initmem_init(unsigned long start_pfn, unsigned long end_pfn)
diff --git a/arch/x86_64/mm/pageattr.c b/arch/x86_64/mm/pageattr.c
index 9148f4a4cec6..7e161c698af4 100644
--- a/arch/x86_64/mm/pageattr.c
+++ b/arch/x86_64/mm/pageattr.c
@@ -13,7 +13,7 @@
13#include <asm/tlbflush.h> 13#include <asm/tlbflush.h>
14#include <asm/io.h> 14#include <asm/io.h>
15 15
16static inline pte_t *lookup_address(unsigned long address) 16pte_t *lookup_address(unsigned long address)
17{ 17{
18 pgd_t *pgd = pgd_offset_k(address); 18 pgd_t *pgd = pgd_offset_k(address);
19 pud_t *pud; 19 pud_t *pud;
@@ -74,14 +74,12 @@ static void flush_kernel_map(void *arg)
74 struct page *pg; 74 struct page *pg;
75 75
76 /* When clflush is available always use it because it is 76 /* When clflush is available always use it because it is
77 much cheaper than WBINVD. Disable clflush for now because 77 much cheaper than WBINVD. */
78 the high level code is not ready yet */ 78 if (!cpu_has_clflush)
79 if (1 || !cpu_has_clflush)
80 asm volatile("wbinvd" ::: "memory"); 79 asm volatile("wbinvd" ::: "memory");
81 else list_for_each_entry(pg, l, lru) { 80 else list_for_each_entry(pg, l, lru) {
82 void *adr = page_address(pg); 81 void *adr = page_address(pg);
83 if (cpu_has_clflush) 82 cache_flush_page(adr);
84 cache_flush_page(adr);
85 } 83 }
86 __flush_tlb_all(); 84 __flush_tlb_all();
87} 85}
@@ -95,7 +93,8 @@ static LIST_HEAD(deferred_pages); /* protected by init_mm.mmap_sem */
95 93
96static inline void save_page(struct page *fpage) 94static inline void save_page(struct page *fpage)
97{ 95{
98 list_add(&fpage->lru, &deferred_pages); 96 if (!test_and_set_bit(PG_arch_1, &fpage->flags))
97 list_add(&fpage->lru, &deferred_pages);
99} 98}
100 99
101/* 100/*
@@ -129,9 +128,12 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
129 pte_t *kpte; 128 pte_t *kpte;
130 struct page *kpte_page; 129 struct page *kpte_page;
131 pgprot_t ref_prot2; 130 pgprot_t ref_prot2;
131
132 kpte = lookup_address(address); 132 kpte = lookup_address(address);
133 if (!kpte) return 0; 133 if (!kpte) return 0;
134 kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK); 134 kpte_page = virt_to_page(((unsigned long)kpte) & PAGE_MASK);
135 BUG_ON(PageLRU(kpte_page));
136 BUG_ON(PageCompound(kpte_page));
135 if (pgprot_val(prot) != pgprot_val(ref_prot)) { 137 if (pgprot_val(prot) != pgprot_val(ref_prot)) {
136 if (!pte_huge(*kpte)) { 138 if (!pte_huge(*kpte)) {
137 set_pte(kpte, pfn_pte(pfn, prot)); 139 set_pte(kpte, pfn_pte(pfn, prot));
@@ -159,10 +161,9 @@ __change_page_attr(unsigned long address, unsigned long pfn, pgprot_t prot,
159 /* on x86-64 the direct mapping set at boot is not using 4k pages */ 161 /* on x86-64 the direct mapping set at boot is not using 4k pages */
160 BUG_ON(PageReserved(kpte_page)); 162 BUG_ON(PageReserved(kpte_page));
161 163
162 if (page_private(kpte_page) == 0) { 164 save_page(kpte_page);
163 save_page(kpte_page); 165 if (page_private(kpte_page) == 0)
164 revert_page(address, ref_prot); 166 revert_page(address, ref_prot);
165 }
166 return 0; 167 return 0;
167} 168}
168 169
@@ -234,6 +235,10 @@ void global_flush_tlb(void)
234 flush_map(&l); 235 flush_map(&l);
235 236
236 list_for_each_entry_safe(pg, next, &l, lru) { 237 list_for_each_entry_safe(pg, next, &l, lru) {
238 list_del(&pg->lru);
239 clear_bit(PG_arch_1, &pg->flags);
240 if (page_private(pg) != 0)
241 continue;
237 ClearPagePrivate(pg); 242 ClearPagePrivate(pg);
238 __free_page(pg); 243 __free_page(pg);
239 } 244 }
diff --git a/arch/x86_64/mm/srat.c b/arch/x86_64/mm/srat.c
index 1e76bb0a7277..acdf03e19146 100644
--- a/arch/x86_64/mm/srat.c
+++ b/arch/x86_64/mm/srat.c
@@ -106,9 +106,9 @@ static __init int slit_valid(struct acpi_table_slit *slit)
106 for (j = 0; j < d; j++) { 106 for (j = 0; j < d; j++) {
107 u8 val = slit->entry[d*i + j]; 107 u8 val = slit->entry[d*i + j];
108 if (i == j) { 108 if (i == j) {
109 if (val != 10) 109 if (val != LOCAL_DISTANCE)
110 return 0; 110 return 0;
111 } else if (val <= 10) 111 } else if (val <= LOCAL_DISTANCE)
112 return 0; 112 return 0;
113 } 113 }
114 } 114 }
@@ -350,7 +350,7 @@ acpi_numa_memory_affinity_init(struct acpi_srat_mem_affinity *ma)
350 350
351/* Sanity check to catch more bad SRATs (they are amazingly common). 351/* Sanity check to catch more bad SRATs (they are amazingly common).
352 Make sure the PXMs cover all memory. */ 352 Make sure the PXMs cover all memory. */
353static int nodes_cover_memory(void) 353static int __init nodes_cover_memory(const struct bootnode *nodes)
354{ 354{
355 int i; 355 int i;
356 unsigned long pxmram, e820ram; 356 unsigned long pxmram, e820ram;
@@ -394,6 +394,9 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
394{ 394{
395 int i; 395 int i;
396 396
397 if (acpi_numa <= 0)
398 return -1;
399
397 /* First clean up the node list */ 400 /* First clean up the node list */
398 for (i = 0; i < MAX_NUMNODES; i++) { 401 for (i = 0; i < MAX_NUMNODES; i++) {
399 cutoff_node(i, start, end); 402 cutoff_node(i, start, end);
@@ -403,10 +406,7 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
403 } 406 }
404 } 407 }
405 408
406 if (acpi_numa <= 0) 409 if (!nodes_cover_memory(nodes)) {
407 return -1;
408
409 if (!nodes_cover_memory()) {
410 bad_srat(); 410 bad_srat();
411 return -1; 411 return -1;
412 } 412 }
@@ -440,6 +440,86 @@ int __init acpi_scan_nodes(unsigned long start, unsigned long end)
440 return 0; 440 return 0;
441} 441}
442 442
443#ifdef CONFIG_NUMA_EMU
444static int __init find_node_by_addr(unsigned long addr)
445{
446 int ret = NUMA_NO_NODE;
447 int i;
448
449 for_each_node_mask(i, nodes_parsed) {
450 /*
451 * Find the real node that this emulated node appears on. For
452 * the sake of simplicity, we only use a real node's starting
453 * address to determine which emulated node it appears on.
454 */
455 if (addr >= nodes[i].start && addr < nodes[i].end) {
456 ret = i;
457 break;
458 }
459 }
460 return i;
461}
462
463/*
464 * In NUMA emulation, we need to setup proximity domain (_PXM) to node ID
465 * mappings that respect the real ACPI topology but reflect our emulated
466 * environment. For each emulated node, we find which real node it appears on
467 * and create PXM to NID mappings for those fake nodes which mirror that
468 * locality. SLIT will now represent the correct distances between emulated
469 * nodes as a result of the real topology.
470 */
471void __init acpi_fake_nodes(const struct bootnode *fake_nodes, int num_nodes)
472{
473 int i, j;
474 int fake_node_to_pxm_map[MAX_NUMNODES] = {
475 [0 ... MAX_NUMNODES-1] = PXM_INVAL
476 };
477 unsigned char fake_apicid_to_node[MAX_LOCAL_APIC] = {
478 [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE
479 };
480
481 printk(KERN_INFO "Faking PXM affinity for fake nodes on real "
482 "topology.\n");
483 for (i = 0; i < num_nodes; i++) {
484 int nid, pxm;
485
486 nid = find_node_by_addr(fake_nodes[i].start);
487 if (nid == NUMA_NO_NODE)
488 continue;
489 pxm = node_to_pxm(nid);
490 if (pxm == PXM_INVAL)
491 continue;
492 fake_node_to_pxm_map[i] = pxm;
493 /*
494 * For each apicid_to_node mapping that exists for this real
495 * node, it must now point to the fake node ID.
496 */
497 for (j = 0; j < MAX_LOCAL_APIC; j++)
498 if (apicid_to_node[j] == nid)
499 fake_apicid_to_node[j] = i;
500 }
501 for (i = 0; i < num_nodes; i++)
502 __acpi_map_pxm_to_node(fake_node_to_pxm_map[i], i);
503 memcpy(apicid_to_node, fake_apicid_to_node, sizeof(apicid_to_node));
504
505 nodes_clear(nodes_parsed);
506 for (i = 0; i < num_nodes; i++)
507 if (fake_nodes[i].start != fake_nodes[i].end)
508 node_set(i, nodes_parsed);
509 WARN_ON(!nodes_cover_memory(fake_nodes));
510}
511
512static int null_slit_node_compare(int a, int b)
513{
514 return node_to_pxm(a) == node_to_pxm(b);
515}
516#else
517static int null_slit_node_compare(int a, int b)
518{
519 return a == b;
520}
521#endif /* CONFIG_NUMA_EMU */
522
443void __init srat_reserve_add_area(int nodeid) 523void __init srat_reserve_add_area(int nodeid)
444{ 524{
445 if (found_add_area && nodes_add[nodeid].end) { 525 if (found_add_area && nodes_add[nodeid].end) {
@@ -464,7 +544,8 @@ int __node_distance(int a, int b)
464 int index; 544 int index;
465 545
466 if (!acpi_slit) 546 if (!acpi_slit)
467 return a == b ? 10 : 20; 547 return null_slit_node_compare(a, b) ? LOCAL_DISTANCE :
548 REMOTE_DISTANCE;
468 index = acpi_slit->locality_count * node_to_pxm(a); 549 index = acpi_slit->locality_count * node_to_pxm(a);
469 return acpi_slit->entry[index + node_to_pxm(b)]; 550 return acpi_slit->entry[index + node_to_pxm(b)];
470} 551}
diff --git a/arch/x86_64/pci/k8-bus.c b/arch/x86_64/pci/k8-bus.c
index 3acf60ded2a0..9cc813e29706 100644
--- a/arch/x86_64/pci/k8-bus.c
+++ b/arch/x86_64/pci/k8-bus.c
@@ -59,6 +59,8 @@ fill_mp_bus_to_cpumask(void)
59 j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus); 59 j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
60 j++) { 60 j++) {
61 struct pci_bus *bus; 61 struct pci_bus *bus;
62 struct pci_sysdata *sd;
63
62 long node = NODE_ID(nid); 64 long node = NODE_ID(nid);
63 /* Algorithm a bit dumb, but 65 /* Algorithm a bit dumb, but
64 it shouldn't matter here */ 66 it shouldn't matter here */
@@ -67,7 +69,9 @@ fill_mp_bus_to_cpumask(void)
67 continue; 69 continue;
68 if (!node_online(node)) 70 if (!node_online(node))
69 node = 0; 71 node = 0;
70 bus->sysdata = (void *)node; 72
73 sd = bus->sysdata;
74 sd->node = node;
71 } 75 }
72 } 76 }
73 } 77 }
diff --git a/arch/x86_64/vdso/Makefile b/arch/x86_64/vdso/Makefile
new file mode 100644
index 000000000000..faaa72fb250c
--- /dev/null
+++ b/arch/x86_64/vdso/Makefile
@@ -0,0 +1,49 @@
1#
2# x86-64 vDSO.
3#
4
5# files to link into the vdso
6# vdso-start.o has to be first
7vobjs-y := vdso-start.o vdso-note.o vclock_gettime.o vgetcpu.o vvar.o
8
9# files to link into kernel
10obj-y := vma.o vdso.o vdso-syms.o
11
12vobjs := $(foreach F,$(vobjs-y),$(obj)/$F)
13
14$(obj)/vdso.o: $(obj)/vdso.so
15
16targets += vdso.so vdso.lds $(vobjs-y) vdso-syms.o
17
18# The DSO images are built using a special linker script.
19quiet_cmd_syscall = SYSCALL $@
20 cmd_syscall = $(CC) -m elf_x86_64 -nostdlib $(SYSCFLAGS_$(@F)) \
21 -Wl,-T,$(filter-out FORCE,$^) -o $@
22
23export CPPFLAGS_vdso.lds += -P -C -U$(ARCH)
24
25vdso-flags = -fPIC -shared -Wl,-soname=linux-vdso.so.1 \
26 $(call ld-option, -Wl$(comma)--hash-style=sysv) \
27 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
28SYSCFLAGS_vdso.so = $(vdso-flags)
29
30$(obj)/vdso.o: $(src)/vdso.S $(obj)/vdso.so
31
32$(obj)/vdso.so: $(src)/vdso.lds $(vobjs) FORCE
33 $(call if_changed,syscall)
34
35CF := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64
36
37$(obj)/vclock_gettime.o: CFLAGS = $(CF)
38$(obj)/vgetcpu.o: CFLAGS = $(CF)
39
40# We also create a special relocatable object that should mirror the symbol
41# table and layout of the linked DSO. With ld -R we can then refer to
42# these symbols in the kernel code rather than hand-coded addresses.
43extra-y += vdso-syms.o
44$(obj)/built-in.o: $(obj)/vdso-syms.o
45$(obj)/built-in.o: ld_flags += -R $(obj)/vdso-syms.o
46
47SYSCFLAGS_vdso-syms.o = -r -d
48$(obj)/vdso-syms.o: $(src)/vdso.lds $(vobjs) FORCE
49 $(call if_changed,syscall)
diff --git a/arch/x86_64/vdso/vclock_gettime.c b/arch/x86_64/vdso/vclock_gettime.c
new file mode 100644
index 000000000000..17f6a00de712
--- /dev/null
+++ b/arch/x86_64/vdso/vclock_gettime.c
@@ -0,0 +1,120 @@
1/*
2 * Copyright 2006 Andi Kleen, SUSE Labs.
3 * Subject to the GNU Public License, v.2
4 *
5 * Fast user context implementation of clock_gettime and gettimeofday.
6 *
7 * The code should have no internal unresolved relocations.
8 * Check with readelf after changing.
9 * Also alternative() doesn't work.
10 */
11
12#include <linux/kernel.h>
13#include <linux/posix-timers.h>
14#include <linux/time.h>
15#include <linux/string.h>
16#include <asm/vsyscall.h>
17#include <asm/vgtod.h>
18#include <asm/timex.h>
19#include <asm/hpet.h>
20#include <asm/unistd.h>
21#include <asm/io.h>
22#include <asm/vgtod.h>
23#include "vextern.h"
24
25#define gtod vdso_vsyscall_gtod_data
26
27static long vdso_fallback_gettime(long clock, struct timespec *ts)
28{
29 long ret;
30 asm("syscall" : "=a" (ret) :
31 "0" (__NR_clock_gettime),"D" (clock), "S" (ts) : "memory");
32 return ret;
33}
34
35static inline long vgetns(void)
36{
37 cycles_t (*vread)(void);
38 vread = gtod->clock.vread;
39 return ((vread() - gtod->clock.cycle_last) * gtod->clock.mult) >>
40 gtod->clock.shift;
41}
42
43static noinline int do_realtime(struct timespec *ts)
44{
45 unsigned long seq, ns;
46 do {
47 seq = read_seqbegin(&gtod->lock);
48 ts->tv_sec = gtod->wall_time_sec;
49 ts->tv_nsec = gtod->wall_time_nsec;
50 ns = vgetns();
51 } while (unlikely(read_seqretry(&gtod->lock, seq)));
52 timespec_add_ns(ts, ns);
53 return 0;
54}
55
56/* Copy of the version in kernel/time.c which we cannot directly access */
57static void vset_normalized_timespec(struct timespec *ts, long sec, long nsec)
58{
59 while (nsec >= NSEC_PER_SEC) {
60 nsec -= NSEC_PER_SEC;
61 ++sec;
62 }
63 while (nsec < 0) {
64 nsec += NSEC_PER_SEC;
65 --sec;
66 }
67 ts->tv_sec = sec;
68 ts->tv_nsec = nsec;
69}
70
71static noinline int do_monotonic(struct timespec *ts)
72{
73 unsigned long seq, ns, secs;
74 do {
75 seq = read_seqbegin(&gtod->lock);
76 secs = gtod->wall_time_sec;
77 ns = gtod->wall_time_nsec + vgetns();
78 secs += gtod->wall_to_monotonic.tv_sec;
79 ns += gtod->wall_to_monotonic.tv_nsec;
80 } while (unlikely(read_seqretry(&gtod->lock, seq)));
81 vset_normalized_timespec(ts, secs, ns);
82 return 0;
83}
84
85int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
86{
87 if (likely(gtod->sysctl_enabled && gtod->clock.vread))
88 switch (clock) {
89 case CLOCK_REALTIME:
90 return do_realtime(ts);
91 case CLOCK_MONOTONIC:
92 return do_monotonic(ts);
93 }
94 return vdso_fallback_gettime(clock, ts);
95}
96int clock_gettime(clockid_t, struct timespec *)
97 __attribute__((weak, alias("__vdso_clock_gettime")));
98
99int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
100{
101 long ret;
102 if (likely(gtod->sysctl_enabled && gtod->clock.vread)) {
103 BUILD_BUG_ON(offsetof(struct timeval, tv_usec) !=
104 offsetof(struct timespec, tv_nsec) ||
105 sizeof(*tv) != sizeof(struct timespec));
106 do_realtime((struct timespec *)tv);
107 tv->tv_usec /= 1000;
108 if (unlikely(tz != NULL)) {
109 /* This relies on gcc inlining the memcpy. We'll notice
110 if it ever fails to do so. */
111 memcpy(tz, &gtod->sys_tz, sizeof(struct timezone));
112 }
113 return 0;
114 }
115 asm("syscall" : "=a" (ret) :
116 "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
117 return ret;
118}
119int gettimeofday(struct timeval *, struct timezone *)
120 __attribute__((weak, alias("__vdso_gettimeofday")));
diff --git a/arch/x86_64/vdso/vdso-note.S b/arch/x86_64/vdso/vdso-note.S
new file mode 100644
index 000000000000..79a071e4357e
--- /dev/null
+++ b/arch/x86_64/vdso/vdso-note.S
@@ -0,0 +1,12 @@
1/*
2 * This supplies .note.* sections to go into the PT_NOTE inside the vDSO text.
3 * Here we can supply some information useful to userland.
4 */
5
6#include <linux/uts.h>
7#include <linux/version.h>
8#include <linux/elfnote.h>
9
10ELFNOTE_START(Linux, 0, "a")
11 .long LINUX_VERSION_CODE
12ELFNOTE_END
diff --git a/arch/x86_64/vdso/vdso-start.S b/arch/x86_64/vdso/vdso-start.S
new file mode 100644
index 000000000000..2dc2cdb84d67
--- /dev/null
+++ b/arch/x86_64/vdso/vdso-start.S
@@ -0,0 +1,2 @@
1 .globl vdso_kernel_start
2vdso_kernel_start:
diff --git a/arch/x86_64/vdso/vdso.S b/arch/x86_64/vdso/vdso.S
new file mode 100644
index 000000000000..92e80c1972a7
--- /dev/null
+++ b/arch/x86_64/vdso/vdso.S
@@ -0,0 +1,2 @@
1 .section ".vdso","a"
2 .incbin "arch/x86_64/vdso/vdso.so"
diff --git a/arch/x86_64/vdso/vdso.lds.S b/arch/x86_64/vdso/vdso.lds.S
new file mode 100644
index 000000000000..b9a60e665d08
--- /dev/null
+++ b/arch/x86_64/vdso/vdso.lds.S
@@ -0,0 +1,77 @@
1/*
2 * Linker script for vsyscall DSO. The vsyscall page is an ELF shared
3 * object prelinked to its virtual address, and with only one read-only
4 * segment (that fits in one page). This script controls its layout.
5 */
6#include <asm/asm-offsets.h>
7#include "voffset.h"
8
9#define VDSO_PRELINK 0xffffffffff700000
10
11SECTIONS
12{
13 . = VDSO_PRELINK + SIZEOF_HEADERS;
14
15 .hash : { *(.hash) } :text
16 .gnu.hash : { *(.gnu.hash) }
17 .dynsym : { *(.dynsym) }
18 .dynstr : { *(.dynstr) }
19 .gnu.version : { *(.gnu.version) }
20 .gnu.version_d : { *(.gnu.version_d) }
21 .gnu.version_r : { *(.gnu.version_r) }
22
23 /* This linker script is used both with -r and with -shared.
24 For the layouts to match, we need to skip more than enough
25 space for the dynamic symbol table et al. If this amount
26 is insufficient, ld -shared will barf. Just increase it here. */
27 . = VDSO_PRELINK + VDSO_TEXT_OFFSET;
28
29 .text : { *(.text) } :text
30 .text.ptr : { *(.text.ptr) } :text
31 . = VDSO_PRELINK + 0x900;
32 .data : { *(.data) } :text
33 .bss : { *(.bss) } :text
34
35 .altinstructions : { *(.altinstructions) } :text
36 .altinstr_replacement : { *(.altinstr_replacement) } :text
37
38 .note : { *(.note.*) } :text :note
39 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
40 .eh_frame : { KEEP (*(.eh_frame)) } :text
41 .dynamic : { *(.dynamic) } :text :dynamic
42 .useless : {
43 *(.got.plt) *(.got)
44 *(.gnu.linkonce.d.*)
45 *(.dynbss)
46 *(.gnu.linkonce.b.*)
47 } :text
48}
49
50/*
51 * We must supply the ELF program headers explicitly to get just one
52 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
53 */
54PHDRS
55{
56 text PT_LOAD FILEHDR PHDRS FLAGS(5); /* PF_R|PF_X */
57 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
58 note PT_NOTE FLAGS(4); /* PF_R */
59 eh_frame_hdr 0x6474e550; /* PT_GNU_EH_FRAME, but ld doesn't match the name */
60}
61
62/*
63 * This controls what symbols we export from the DSO.
64 */
65VERSION
66{
67 LINUX_2.6 {
68 global:
69 clock_gettime;
70 __vdso_clock_gettime;
71 gettimeofday;
72 __vdso_gettimeofday;
73 getcpu;
74 __vdso_getcpu;
75 local: *;
76 };
77}
diff --git a/arch/x86_64/vdso/vextern.h b/arch/x86_64/vdso/vextern.h
new file mode 100644
index 000000000000..1683ba2ae3e8
--- /dev/null
+++ b/arch/x86_64/vdso/vextern.h
@@ -0,0 +1,16 @@
1#ifndef VEXTERN
2#include <asm/vsyscall.h>
3#define VEXTERN(x) \
4 extern typeof(x) *vdso_ ## x __attribute__((visibility("hidden")));
5#endif
6
7#define VMAGIC 0xfeedbabeabcdefabUL
8
9/* Any kernel variables used in the vDSO must be exported in the main
10 kernel's vmlinux.lds.S/vsyscall.h/proper __section and
11 put into vextern.h and be referenced as a pointer with vdso prefix.
12 The main kernel later fills in the values. */
13
14VEXTERN(jiffies)
15VEXTERN(vgetcpu_mode)
16VEXTERN(vsyscall_gtod_data)
diff --git a/arch/x86_64/vdso/vgetcpu.c b/arch/x86_64/vdso/vgetcpu.c
new file mode 100644
index 000000000000..91f6e85d0fc2
--- /dev/null
+++ b/arch/x86_64/vdso/vgetcpu.c
@@ -0,0 +1,50 @@
1/*
2 * Copyright 2006 Andi Kleen, SUSE Labs.
3 * Subject to the GNU Public License, v.2
4 *
5 * Fast user context implementation of getcpu()
6 */
7
8#include <linux/kernel.h>
9#include <linux/getcpu.h>
10#include <linux/jiffies.h>
11#include <linux/time.h>
12#include <asm/vsyscall.h>
13#include <asm/vgtod.h>
14#include "vextern.h"
15
16long __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
17{
18 unsigned int dummy, p;
19 unsigned long j = 0;
20
21 /* Fast cache - only recompute value once per jiffies and avoid
22 relatively costly rdtscp/cpuid otherwise.
23 This works because the scheduler usually keeps the process
24 on the same CPU and this syscall doesn't guarantee its
25 results anyways.
26 We do this here because otherwise user space would do it on
27 its own in a likely inferior way (no access to jiffies).
28 If you don't like it pass NULL. */
29 if (tcache && tcache->blob[0] == (j = *vdso_jiffies)) {
30 p = tcache->blob[1];
31 } else if (*vdso_vgetcpu_mode == VGETCPU_RDTSCP) {
32 /* Load per CPU data from RDTSCP */
33 rdtscp(dummy, dummy, p);
34 } else {
35 /* Load per CPU data from GDT */
36 asm("lsl %1,%0" : "=r" (p) : "r" (__PER_CPU_SEG));
37 }
38 if (tcache) {
39 tcache->blob[0] = j;
40 tcache->blob[1] = p;
41 }
42 if (cpu)
43 *cpu = p & 0xfff;
44 if (node)
45 *node = p >> 12;
46 return 0;
47}
48
49long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
50 __attribute__((weak, alias("__vdso_getcpu")));
diff --git a/arch/x86_64/vdso/vma.c b/arch/x86_64/vdso/vma.c
new file mode 100644
index 000000000000..d4cb83a6c066
--- /dev/null
+++ b/arch/x86_64/vdso/vma.c
@@ -0,0 +1,139 @@
1/*
2 * Set up the VMAs to tell the VM about the vDSO.
3 * Copyright 2007 Andi Kleen, SUSE Labs.
4 * Subject to the GPL, v.2
5 */
6#include <linux/mm.h>
7#include <linux/sched.h>
8#include <linux/init.h>
9#include <linux/random.h>
10#include <asm/vsyscall.h>
11#include <asm/vgtod.h>
12#include <asm/proto.h>
13#include "voffset.h"
14
15int vdso_enabled = 1;
16
17#define VEXTERN(x) extern typeof(__ ## x) *vdso_ ## x;
18#include "vextern.h"
19#undef VEXTERN
20
21extern char vdso_kernel_start[], vdso_start[], vdso_end[];
22extern unsigned short vdso_sync_cpuid;
23
24struct page **vdso_pages;
25
26static inline void *var_ref(void *vbase, char *var, char *name)
27{
28 unsigned offset = var - &vdso_kernel_start[0] + VDSO_TEXT_OFFSET;
29 void *p = vbase + offset;
30 if (*(void **)p != (void *)VMAGIC) {
31 printk("VDSO: variable %s broken\n", name);
32 vdso_enabled = 0;
33 }
34 return p;
35}
36
37static int __init init_vdso_vars(void)
38{
39 int npages = (vdso_end - vdso_start + PAGE_SIZE - 1) / PAGE_SIZE;
40 int i;
41 char *vbase;
42
43 vdso_pages = kmalloc(sizeof(struct page *) * npages, GFP_KERNEL);
44 if (!vdso_pages)
45 goto oom;
46 for (i = 0; i < npages; i++) {
47 struct page *p;
48 p = alloc_page(GFP_KERNEL);
49 if (!p)
50 goto oom;
51 vdso_pages[i] = p;
52 copy_page(page_address(p), vdso_start + i*PAGE_SIZE);
53 }
54
55 vbase = vmap(vdso_pages, npages, 0, PAGE_KERNEL);
56 if (!vbase)
57 goto oom;
58
59 if (memcmp(vbase, "\177ELF", 4)) {
60 printk("VDSO: I'm broken; not ELF\n");
61 vdso_enabled = 0;
62 }
63
64#define V(x) *(typeof(x) *) var_ref(vbase, (char *)RELOC_HIDE(&x, 0), #x)
65#define VEXTERN(x) \
66 V(vdso_ ## x) = &__ ## x;
67#include "vextern.h"
68#undef VEXTERN
69 return 0;
70
71 oom:
72 printk("Cannot allocate vdso\n");
73 vdso_enabled = 0;
74 return -ENOMEM;
75}
76__initcall(init_vdso_vars);
77
78struct linux_binprm;
79
80/* Put the vdso above the (randomized) stack with another randomized offset.
81 This way there is no hole in the middle of address space.
82 To save memory make sure it is still in the same PTE as the stack top.
83 This doesn't give that many random bits */
84static unsigned long vdso_addr(unsigned long start, unsigned len)
85{
86 unsigned long addr, end;
87 unsigned offset;
88 end = (start + PMD_SIZE - 1) & PMD_MASK;
89 if (end >= TASK_SIZE64)
90 end = TASK_SIZE64;
91 end -= len;
92 /* This loses some more bits than a modulo, but is cheaper */
93 offset = get_random_int() & (PTRS_PER_PTE - 1);
94 addr = start + (offset << PAGE_SHIFT);
95 if (addr >= end)
96 addr = end;
97 return addr;
98}
99
100/* Setup a VMA at program startup for the vsyscall page.
101 Not called for compat tasks */
102int arch_setup_additional_pages(struct linux_binprm *bprm, int exstack)
103{
104 struct mm_struct *mm = current->mm;
105 unsigned long addr;
106 int ret;
107 unsigned len = round_up(vdso_end - vdso_start, PAGE_SIZE);
108
109 if (!vdso_enabled)
110 return 0;
111
112 down_write(&mm->mmap_sem);
113 addr = vdso_addr(mm->start_stack, len);
114 addr = get_unmapped_area(NULL, addr, len, 0, 0);
115 if (IS_ERR_VALUE(addr)) {
116 ret = addr;
117 goto up_fail;
118 }
119
120 ret = install_special_mapping(mm, addr, len,
121 VM_READ|VM_EXEC|
122 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC|
123 VM_ALWAYSDUMP,
124 vdso_pages);
125 if (ret)
126 goto up_fail;
127
128 current->mm->context.vdso = (void *)addr;
129up_fail:
130 up_write(&mm->mmap_sem);
131 return ret;
132}
133
134static __init int vdso_setup(char *s)
135{
136 vdso_enabled = simple_strtoul(s, NULL, 0);
137 return 0;
138}
139__setup("vdso=", vdso_setup);
diff --git a/arch/x86_64/vdso/voffset.h b/arch/x86_64/vdso/voffset.h
new file mode 100644
index 000000000000..5304204911f2
--- /dev/null
+++ b/arch/x86_64/vdso/voffset.h
@@ -0,0 +1 @@
#define VDSO_TEXT_OFFSET 0x500
diff --git a/arch/x86_64/vdso/vvar.c b/arch/x86_64/vdso/vvar.c
new file mode 100644
index 000000000000..6fc22219a472
--- /dev/null
+++ b/arch/x86_64/vdso/vvar.c
@@ -0,0 +1,12 @@
1/* Define pointer to external vDSO variables.
2 These are part of the vDSO. The kernel fills in the real addresses
3 at boot time. This is done because when the vdso is linked the
4 kernel isn't yet and we don't know the final addresses. */
5#include <linux/kernel.h>
6#include <linux/time.h>
7#include <asm/vsyscall.h>
8#include <asm/timex.h>
9#include <asm/vgtod.h>
10
11#define VEXTERN(x) typeof (__ ## x) *vdso_ ## x = (void *)VMAGIC;
12#include "vextern.h"
diff --git a/block/Kconfig b/block/Kconfig
index 0768741d6813..ca2ef4e08497 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -53,7 +53,7 @@ endif # BLOCK
53 53
54config BLK_DEV_BSG 54config BLK_DEV_BSG
55 bool "Block layer SG support v4 (EXPERIMENTAL)" 55 bool "Block layer SG support v4 (EXPERIMENTAL)"
56 depends on (SCSI=y) && EXPERIMENTAL 56 depends on EXPERIMENTAL
57 ---help--- 57 ---help---
58 Saying Y here will enable generic SG (SCSI generic) v4 support 58 Saying Y here will enable generic SG (SCSI generic) v4 support
59 for any block device. 59 for any block device.
diff --git a/block/bsg.c b/block/bsg.c
index f2992e72b841..b571869928a8 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -932,24 +932,34 @@ void bsg_unregister_queue(struct request_queue *q)
932{ 932{
933 struct bsg_class_device *bcd = &q->bsg_dev; 933 struct bsg_class_device *bcd = &q->bsg_dev;
934 934
935 WARN_ON(!bcd->class_dev); 935 if (!bcd->class_dev)
936 return;
936 937
937 mutex_lock(&bsg_mutex); 938 mutex_lock(&bsg_mutex);
938 sysfs_remove_link(&q->kobj, "bsg"); 939 sysfs_remove_link(&q->kobj, "bsg");
939 class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor)); 940 class_device_unregister(bcd->class_dev);
941 put_device(bcd->dev);
940 bcd->class_dev = NULL; 942 bcd->class_dev = NULL;
943 bcd->dev = NULL;
941 list_del_init(&bcd->list); 944 list_del_init(&bcd->list);
942 bsg_device_nr--; 945 bsg_device_nr--;
943 mutex_unlock(&bsg_mutex); 946 mutex_unlock(&bsg_mutex);
944} 947}
945EXPORT_SYMBOL_GPL(bsg_unregister_queue); 948EXPORT_SYMBOL_GPL(bsg_unregister_queue);
946 949
947int bsg_register_queue(struct request_queue *q, const char *name) 950int bsg_register_queue(struct request_queue *q, struct device *gdev,
951 const char *name)
948{ 952{
949 struct bsg_class_device *bcd, *__bcd; 953 struct bsg_class_device *bcd, *__bcd;
950 dev_t dev; 954 dev_t dev;
951 int ret = -EMFILE; 955 int ret = -EMFILE;
952 struct class_device *class_dev = NULL; 956 struct class_device *class_dev = NULL;
957 const char *devname;
958
959 if (name)
960 devname = name;
961 else
962 devname = gdev->bus_id;
953 963
954 /* 964 /*
955 * we need a proper transport to send commands, not a stacked device 965 * we need a proper transport to send commands, not a stacked device
@@ -982,18 +992,20 @@ retry:
982 bsg_minor_idx = 0; 992 bsg_minor_idx = 0;
983 993
984 bcd->queue = q; 994 bcd->queue = q;
995 bcd->dev = get_device(gdev);
985 dev = MKDEV(bsg_major, bcd->minor); 996 dev = MKDEV(bsg_major, bcd->minor);
986 class_dev = class_device_create(bsg_class, NULL, dev, bcd->dev, "%s", name); 997 class_dev = class_device_create(bsg_class, NULL, dev, gdev, "%s",
998 devname);
987 if (IS_ERR(class_dev)) { 999 if (IS_ERR(class_dev)) {
988 ret = PTR_ERR(class_dev); 1000 ret = PTR_ERR(class_dev);
989 goto err; 1001 goto err_put;
990 } 1002 }
991 bcd->class_dev = class_dev; 1003 bcd->class_dev = class_dev;
992 1004
993 if (q->kobj.sd) { 1005 if (q->kobj.sd) {
994 ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg"); 1006 ret = sysfs_create_link(&q->kobj, &bcd->class_dev->kobj, "bsg");
995 if (ret) 1007 if (ret)
996 goto err; 1008 goto err_unregister;
997 } 1009 }
998 1010
999 list_add_tail(&bcd->list, &bsg_class_list); 1011 list_add_tail(&bcd->list, &bsg_class_list);
@@ -1001,37 +1013,17 @@ retry:
1001 1013
1002 mutex_unlock(&bsg_mutex); 1014 mutex_unlock(&bsg_mutex);
1003 return 0; 1015 return 0;
1016
1017err_unregister:
1018 class_device_unregister(class_dev);
1019err_put:
1020 put_device(gdev);
1004err: 1021err:
1005 if (class_dev)
1006 class_device_destroy(bsg_class, MKDEV(bsg_major, bcd->minor));
1007 mutex_unlock(&bsg_mutex); 1022 mutex_unlock(&bsg_mutex);
1008 return ret; 1023 return ret;
1009} 1024}
1010EXPORT_SYMBOL_GPL(bsg_register_queue); 1025EXPORT_SYMBOL_GPL(bsg_register_queue);
1011 1026
1012static int bsg_add(struct class_device *cl_dev, struct class_interface *cl_intf)
1013{
1014 int ret;
1015 struct scsi_device *sdp = to_scsi_device(cl_dev->dev);
1016 struct request_queue *rq = sdp->request_queue;
1017
1018 if (rq->kobj.parent)
1019 ret = bsg_register_queue(rq, kobject_name(rq->kobj.parent));
1020 else
1021 ret = bsg_register_queue(rq, kobject_name(&sdp->sdev_gendev.kobj));
1022 return ret;
1023}
1024
1025static void bsg_remove(struct class_device *cl_dev, struct class_interface *cl_intf)
1026{
1027 bsg_unregister_queue(to_scsi_device(cl_dev->dev)->request_queue);
1028}
1029
1030static struct class_interface bsg_intf = {
1031 .add = bsg_add,
1032 .remove = bsg_remove,
1033};
1034
1035static struct cdev bsg_cdev = { 1027static struct cdev bsg_cdev = {
1036 .kobj = {.name = "bsg", }, 1028 .kobj = {.name = "bsg", },
1037 .owner = THIS_MODULE, 1029 .owner = THIS_MODULE,
@@ -1069,16 +1061,9 @@ static int __init bsg_init(void)
1069 if (ret) 1061 if (ret)
1070 goto unregister_chrdev; 1062 goto unregister_chrdev;
1071 1063
1072 ret = scsi_register_interface(&bsg_intf);
1073 if (ret)
1074 goto remove_cdev;
1075
1076 printk(KERN_INFO BSG_DESCRIPTION " version " BSG_VERSION 1064 printk(KERN_INFO BSG_DESCRIPTION " version " BSG_VERSION
1077 " loaded (major %d)\n", bsg_major); 1065 " loaded (major %d)\n", bsg_major);
1078 return 0; 1066 return 0;
1079remove_cdev:
1080 printk(KERN_ERR "bsg: failed register scsi interface %d\n", ret);
1081 cdev_del(&bsg_cdev);
1082unregister_chrdev: 1067unregister_chrdev:
1083 unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS); 1068 unregister_chrdev_region(MKDEV(bsg_major, 0), BSG_MAX_DEVS);
1084destroy_bsg_class: 1069destroy_bsg_class:
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 71bdf88884b2..d359a715bbc8 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -214,8 +214,8 @@ int blk_verify_command(unsigned char *cmd, int has_write_perm)
214} 214}
215EXPORT_SYMBOL_GPL(blk_verify_command); 215EXPORT_SYMBOL_GPL(blk_verify_command);
216 216
217int blk_fill_sghdr_rq(request_queue_t *q, struct request *rq, 217static int blk_fill_sghdr_rq(request_queue_t *q, struct request *rq,
218 struct sg_io_hdr *hdr, int has_write_perm) 218 struct sg_io_hdr *hdr, int has_write_perm)
219{ 219{
220 memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */ 220 memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
221 221
@@ -238,22 +238,20 @@ int blk_fill_sghdr_rq(request_queue_t *q, struct request *rq,
238 238
239 return 0; 239 return 0;
240} 240}
241EXPORT_SYMBOL_GPL(blk_fill_sghdr_rq);
242 241
243/* 242/*
244 * unmap a request that was previously mapped to this sg_io_hdr. handles 243 * unmap a request that was previously mapped to this sg_io_hdr. handles
245 * both sg and non-sg sg_io_hdr. 244 * both sg and non-sg sg_io_hdr.
246 */ 245 */
247int blk_unmap_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr) 246static int blk_unmap_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr)
248{ 247{
249 blk_rq_unmap_user(rq->bio); 248 blk_rq_unmap_user(rq->bio);
250 blk_put_request(rq); 249 blk_put_request(rq);
251 return 0; 250 return 0;
252} 251}
253EXPORT_SYMBOL_GPL(blk_unmap_sghdr_rq);
254 252
255int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, 253static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
256 struct bio *bio) 254 struct bio *bio)
257{ 255{
258 int r, ret = 0; 256 int r, ret = 0;
259 257
@@ -287,7 +285,6 @@ int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
287 285
288 return r; 286 return r;
289} 287}
290EXPORT_SYMBOL_GPL(blk_complete_sghdr_rq);
291 288
292static int sg_io(struct file *file, request_queue_t *q, 289static int sg_io(struct file *file, request_queue_t *q,
293 struct gendisk *bd_disk, struct sg_io_hdr *hdr) 290 struct gendisk *bd_disk, struct sg_io_hdr *hdr)
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 139f41f033d8..408b45168aba 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -2,16 +2,12 @@
2# ACPI Configuration 2# ACPI Configuration
3# 3#
4 4
5menu "ACPI (Advanced Configuration and Power Interface) Support" 5menuconfig ACPI
6 bool "ACPI Support (Advanced Configuration and Power Interface) Support"
6 depends on !X86_NUMAQ 7 depends on !X86_NUMAQ
7 depends on !X86_VISWS 8 depends on !X86_VISWS
8 depends on !IA64_HP_SIM 9 depends on !IA64_HP_SIM
9 depends on IA64 || X86 10 depends on IA64 || X86
10 depends on PM
11
12config ACPI
13 bool "ACPI Support"
14 depends on IA64 || X86
15 depends on PCI 11 depends on PCI
16 depends on PM 12 depends on PM
17 select PNP 13 select PNP
@@ -49,7 +45,6 @@ if ACPI
49config ACPI_SLEEP 45config ACPI_SLEEP
50 bool "Sleep States" 46 bool "Sleep States"
51 depends on X86 && (!SMP || SUSPEND_SMP) 47 depends on X86 && (!SMP || SUSPEND_SMP)
52 depends on PM
53 default y 48 default y
54 ---help--- 49 ---help---
55 This option adds support for ACPI suspend states. 50 This option adds support for ACPI suspend states.
@@ -82,7 +77,6 @@ config ACPI_SLEEP_PROC_SLEEP
82 77
83config ACPI_PROCFS 78config ACPI_PROCFS
84 bool "Procfs interface (deprecated)" 79 bool "Procfs interface (deprecated)"
85 depends on ACPI
86 default y 80 default y
87 ---help--- 81 ---help---
88 The Procfs interface for ACPI is made optional for backward compatibility. 82 The Procfs interface for ACPI is made optional for backward compatibility.
@@ -124,7 +118,7 @@ config ACPI_BUTTON
124 118
125config ACPI_VIDEO 119config ACPI_VIDEO
126 tristate "Video" 120 tristate "Video"
127 depends on X86 && BACKLIGHT_CLASS_DEVICE 121 depends on X86 && BACKLIGHT_CLASS_DEVICE && VIDEO_OUTPUT_CONTROL
128 help 122 help
129 This driver implement the ACPI Extensions For Display Adapters 123 This driver implement the ACPI Extensions For Display Adapters
130 for integrated graphics devices on motherboard, as specified in 124 for integrated graphics devices on motherboard, as specified in
@@ -280,6 +274,14 @@ config ACPI_DEBUG
280 of verbosity. Saying Y enables these statements. This will increase 274 of verbosity. Saying Y enables these statements. This will increase
281 your kernel size by around 50K. 275 your kernel size by around 50K.
282 276
277config ACPI_DEBUG_FUNC_TRACE
278 bool "Additionally enable ACPI function tracing"
279 default n
280 depends on ACPI_DEBUG
281 help
282 ACPI Debug Statements slow down ACPI processing. Function trace
283 is about half of the penalty and is rarely useful.
284
283config ACPI_EC 285config ACPI_EC
284 bool 286 bool
285 default y 287 default y
@@ -330,7 +332,6 @@ config ACPI_CONTAINER
330 332
331config ACPI_HOTPLUG_MEMORY 333config ACPI_HOTPLUG_MEMORY
332 tristate "Memory Hotplug" 334 tristate "Memory Hotplug"
333 depends on ACPI
334 depends on MEMORY_HOTPLUG 335 depends on MEMORY_HOTPLUG
335 default n 336 default n
336 help 337 help
@@ -359,5 +360,3 @@ config ACPI_SBS
359 to today's ACPI "Control Method" battery. 360 to today's ACPI "Control Method" battery.
360 361
361endif # ACPI 362endif # ACPI
362
363endmenu
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index e64c76c8b726..cad932de383d 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -43,21 +43,30 @@
43#define ACPI_BATTERY_CLASS "battery" 43#define ACPI_BATTERY_CLASS "battery"
44#define ACPI_BATTERY_HID "PNP0C0A" 44#define ACPI_BATTERY_HID "PNP0C0A"
45#define ACPI_BATTERY_DEVICE_NAME "Battery" 45#define ACPI_BATTERY_DEVICE_NAME "Battery"
46#define ACPI_BATTERY_FILE_INFO "info"
47#define ACPI_BATTERY_FILE_STATUS "state"
48#define ACPI_BATTERY_FILE_ALARM "alarm"
49#define ACPI_BATTERY_NOTIFY_STATUS 0x80 46#define ACPI_BATTERY_NOTIFY_STATUS 0x80
50#define ACPI_BATTERY_NOTIFY_INFO 0x81 47#define ACPI_BATTERY_NOTIFY_INFO 0x81
51#define ACPI_BATTERY_UNITS_WATTS "mW" 48#define ACPI_BATTERY_UNITS_WATTS "mW"
52#define ACPI_BATTERY_UNITS_AMPS "mA" 49#define ACPI_BATTERY_UNITS_AMPS "mA"
53 50
54#define _COMPONENT ACPI_BATTERY_COMPONENT 51#define _COMPONENT ACPI_BATTERY_COMPONENT
52
53#define ACPI_BATTERY_UPDATE_TIME 0
54
55#define ACPI_BATTERY_NONE_UPDATE 0
56#define ACPI_BATTERY_EASY_UPDATE 1
57#define ACPI_BATTERY_INIT_UPDATE 2
58
55ACPI_MODULE_NAME("battery"); 59ACPI_MODULE_NAME("battery");
56 60
57MODULE_AUTHOR("Paul Diefenbaugh"); 61MODULE_AUTHOR("Paul Diefenbaugh");
58MODULE_DESCRIPTION("ACPI Battery Driver"); 62MODULE_DESCRIPTION("ACPI Battery Driver");
59MODULE_LICENSE("GPL"); 63MODULE_LICENSE("GPL");
60 64
65static unsigned int update_time = ACPI_BATTERY_UPDATE_TIME;
66
67/* 0 - every time, > 0 - by update_time */
68module_param(update_time, uint, 0644);
69
61extern struct proc_dir_entry *acpi_lock_battery_dir(void); 70extern struct proc_dir_entry *acpi_lock_battery_dir(void);
62extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir); 71extern void *acpi_unlock_battery_dir(struct proc_dir_entry *acpi_battery_dir);
63 72
@@ -76,7 +85,7 @@ static struct acpi_driver acpi_battery_driver = {
76 }, 85 },
77}; 86};
78 87
79struct acpi_battery_status { 88struct acpi_battery_state {
80 acpi_integer state; 89 acpi_integer state;
81 acpi_integer present_rate; 90 acpi_integer present_rate;
82 acpi_integer remaining_capacity; 91 acpi_integer remaining_capacity;
@@ -99,33 +108,111 @@ struct acpi_battery_info {
99 acpi_string oem_info; 108 acpi_string oem_info;
100}; 109};
101 110
102struct acpi_battery_flags { 111enum acpi_battery_files{
103 u8 present:1; /* Bay occupied? */ 112 ACPI_BATTERY_INFO = 0,
104 u8 power_unit:1; /* 0=watts, 1=apms */ 113 ACPI_BATTERY_STATE,
105 u8 alarm:1; /* _BTP present? */ 114 ACPI_BATTERY_ALARM,
106 u8 reserved:5; 115 ACPI_BATTERY_NUMFILES,
107}; 116};
108 117
109struct acpi_battery_trips { 118struct acpi_battery_flags {
110 unsigned long warning; 119 u8 battery_present_prev;
111 unsigned long low; 120 u8 alarm_present;
121 u8 init_update;
122 u8 update[ACPI_BATTERY_NUMFILES];
123 u8 power_unit;
112}; 124};
113 125
114struct acpi_battery { 126struct acpi_battery {
115 struct acpi_device * device; 127 struct mutex mutex;
128 struct acpi_device *device;
116 struct acpi_battery_flags flags; 129 struct acpi_battery_flags flags;
117 struct acpi_battery_trips trips; 130 struct acpi_buffer bif_data;
131 struct acpi_buffer bst_data;
118 unsigned long alarm; 132 unsigned long alarm;
119 struct acpi_battery_info *info; 133 unsigned long update_time[ACPI_BATTERY_NUMFILES];
120}; 134};
121 135
136inline int acpi_battery_present(struct acpi_battery *battery)
137{
138 return battery->device->status.battery_present;
139}
140inline char *acpi_battery_power_units(struct acpi_battery *battery)
141{
142 if (battery->flags.power_unit)
143 return ACPI_BATTERY_UNITS_AMPS;
144 else
145 return ACPI_BATTERY_UNITS_WATTS;
146}
147
148inline acpi_handle acpi_battery_handle(struct acpi_battery *battery)
149{
150 return battery->device->handle;
151}
152
122/* -------------------------------------------------------------------------- 153/* --------------------------------------------------------------------------
123 Battery Management 154 Battery Management
124 -------------------------------------------------------------------------- */ 155 -------------------------------------------------------------------------- */
125 156
126static int 157static void acpi_battery_check_result(struct acpi_battery *battery, int result)
127acpi_battery_get_info(struct acpi_battery *battery, 158{
128 struct acpi_battery_info **bif) 159 if (!battery)
160 return;
161
162 if (result) {
163 battery->flags.init_update = 1;
164 }
165}
166
167static int acpi_battery_extract_package(struct acpi_battery *battery,
168 union acpi_object *package,
169 struct acpi_buffer *format,
170 struct acpi_buffer *data,
171 char *package_name)
172{
173 acpi_status status = AE_OK;
174 struct acpi_buffer data_null = { 0, NULL };
175
176 status = acpi_extract_package(package, format, &data_null);
177 if (status != AE_BUFFER_OVERFLOW) {
178 ACPI_EXCEPTION((AE_INFO, status, "Extracting size %s",
179 package_name));
180 return -ENODEV;
181 }
182
183 if (data_null.length != data->length) {
184 kfree(data->pointer);
185 data->pointer = kzalloc(data_null.length, GFP_KERNEL);
186 if (!data->pointer) {
187 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, "kzalloc()"));
188 return -ENOMEM;
189 }
190 data->length = data_null.length;
191 }
192
193 status = acpi_extract_package(package, format, data);
194 if (ACPI_FAILURE(status)) {
195 ACPI_EXCEPTION((AE_INFO, status, "Extracting %s",
196 package_name));
197 return -ENODEV;
198 }
199
200 return 0;
201}
202
203static int acpi_battery_get_status(struct acpi_battery *battery)
204{
205 int result = 0;
206
207 result = acpi_bus_get_status(battery->device);
208 if (result) {
209 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Evaluating _STA"));
210 return -ENODEV;
211 }
212 return result;
213}
214
215static int acpi_battery_get_info(struct acpi_battery *battery)
129{ 216{
130 int result = 0; 217 int result = 0;
131 acpi_status status = 0; 218 acpi_status status = 0;
@@ -133,16 +220,20 @@ acpi_battery_get_info(struct acpi_battery *battery,
133 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF), 220 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BIF),
134 ACPI_BATTERY_FORMAT_BIF 221 ACPI_BATTERY_FORMAT_BIF
135 }; 222 };
136 struct acpi_buffer data = { 0, NULL };
137 union acpi_object *package = NULL; 223 union acpi_object *package = NULL;
224 struct acpi_buffer *data = NULL;
225 struct acpi_battery_info *bif = NULL;
138 226
227 battery->update_time[ACPI_BATTERY_INFO] = get_seconds();
139 228
140 if (!battery || !bif) 229 if (!acpi_battery_present(battery))
141 return -EINVAL; 230 return 0;
142 231
143 /* Evalute _BIF */ 232 /* Evaluate _BIF */
144 233
145 status = acpi_evaluate_object(battery->device->handle, "_BIF", NULL, &buffer); 234 status =
235 acpi_evaluate_object(acpi_battery_handle(battery), "_BIF", NULL,
236 &buffer);
146 if (ACPI_FAILURE(status)) { 237 if (ACPI_FAILURE(status)) {
147 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF")); 238 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BIF"));
148 return -ENODEV; 239 return -ENODEV;
@@ -150,41 +241,29 @@ acpi_battery_get_info(struct acpi_battery *battery,
150 241
151 package = buffer.pointer; 242 package = buffer.pointer;
152 243
153 /* Extract Package Data */ 244 data = &battery->bif_data;
154
155 status = acpi_extract_package(package, &format, &data);
156 if (status != AE_BUFFER_OVERFLOW) {
157 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF"));
158 result = -ENODEV;
159 goto end;
160 }
161 245
162 data.pointer = kzalloc(data.length, GFP_KERNEL); 246 /* Extract Package Data */
163 if (!data.pointer) {
164 result = -ENOMEM;
165 goto end;
166 }
167 247
168 status = acpi_extract_package(package, &format, &data); 248 result =
169 if (ACPI_FAILURE(status)) { 249 acpi_battery_extract_package(battery, package, &format, data,
170 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BIF")); 250 "_BIF");
171 kfree(data.pointer); 251 if (result)
172 result = -ENODEV;
173 goto end; 252 goto end;
174 }
175 253
176 end: 254 end:
255
177 kfree(buffer.pointer); 256 kfree(buffer.pointer);
178 257
179 if (!result) 258 if (!result) {
180 (*bif) = data.pointer; 259 bif = data->pointer;
260 battery->flags.power_unit = bif->power_unit;
261 }
181 262
182 return result; 263 return result;
183} 264}
184 265
185static int 266static int acpi_battery_get_state(struct acpi_battery *battery)
186acpi_battery_get_status(struct acpi_battery *battery,
187 struct acpi_battery_status **bst)
188{ 267{
189 int result = 0; 268 int result = 0;
190 acpi_status status = 0; 269 acpi_status status = 0;
@@ -192,16 +271,19 @@ acpi_battery_get_status(struct acpi_battery *battery,
192 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST), 271 struct acpi_buffer format = { sizeof(ACPI_BATTERY_FORMAT_BST),
193 ACPI_BATTERY_FORMAT_BST 272 ACPI_BATTERY_FORMAT_BST
194 }; 273 };
195 struct acpi_buffer data = { 0, NULL };
196 union acpi_object *package = NULL; 274 union acpi_object *package = NULL;
275 struct acpi_buffer *data = NULL;
197 276
277 battery->update_time[ACPI_BATTERY_STATE] = get_seconds();
198 278
199 if (!battery || !bst) 279 if (!acpi_battery_present(battery))
200 return -EINVAL; 280 return 0;
201 281
202 /* Evalute _BST */ 282 /* Evaluate _BST */
203 283
204 status = acpi_evaluate_object(battery->device->handle, "_BST", NULL, &buffer); 284 status =
285 acpi_evaluate_object(acpi_battery_handle(battery), "_BST", NULL,
286 &buffer);
205 if (ACPI_FAILURE(status)) { 287 if (ACPI_FAILURE(status)) {
206 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST")); 288 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _BST"));
207 return -ENODEV; 289 return -ENODEV;
@@ -209,55 +291,49 @@ acpi_battery_get_status(struct acpi_battery *battery,
209 291
210 package = buffer.pointer; 292 package = buffer.pointer;
211 293
212 /* Extract Package Data */ 294 data = &battery->bst_data;
213
214 status = acpi_extract_package(package, &format, &data);
215 if (status != AE_BUFFER_OVERFLOW) {
216 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST"));
217 result = -ENODEV;
218 goto end;
219 }
220 295
221 data.pointer = kzalloc(data.length, GFP_KERNEL); 296 /* Extract Package Data */
222 if (!data.pointer) {
223 result = -ENOMEM;
224 goto end;
225 }
226 297
227 status = acpi_extract_package(package, &format, &data); 298 result =
228 if (ACPI_FAILURE(status)) { 299 acpi_battery_extract_package(battery, package, &format, data,
229 ACPI_EXCEPTION((AE_INFO, status, "Extracting _BST")); 300 "_BST");
230 kfree(data.pointer); 301 if (result)
231 result = -ENODEV;
232 goto end; 302 goto end;
233 }
234 303
235 end: 304 end:
236 kfree(buffer.pointer); 305 kfree(buffer.pointer);
237 306
238 if (!result)
239 (*bst) = data.pointer;
240
241 return result; 307 return result;
242} 308}
243 309
244static int 310static int acpi_battery_get_alarm(struct acpi_battery *battery)
245acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm) 311{
312 battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
313
314 return 0;
315}
316
317static int acpi_battery_set_alarm(struct acpi_battery *battery,
318 unsigned long alarm)
246{ 319{
247 acpi_status status = 0; 320 acpi_status status = 0;
248 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 321 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
249 struct acpi_object_list arg_list = { 1, &arg0 }; 322 struct acpi_object_list arg_list = { 1, &arg0 };
250 323
324 battery->update_time[ACPI_BATTERY_ALARM] = get_seconds();
251 325
252 if (!battery) 326 if (!acpi_battery_present(battery))
253 return -EINVAL; 327 return -ENODEV;
254 328
255 if (!battery->flags.alarm) 329 if (!battery->flags.alarm_present)
256 return -ENODEV; 330 return -ENODEV;
257 331
258 arg0.integer.value = alarm; 332 arg0.integer.value = alarm;
259 333
260 status = acpi_evaluate_object(battery->device->handle, "_BTP", &arg_list, NULL); 334 status =
335 acpi_evaluate_object(acpi_battery_handle(battery), "_BTP",
336 &arg_list, NULL);
261 if (ACPI_FAILURE(status)) 337 if (ACPI_FAILURE(status))
262 return -ENODEV; 338 return -ENODEV;
263 339
@@ -268,65 +344,114 @@ acpi_battery_set_alarm(struct acpi_battery *battery, unsigned long alarm)
268 return 0; 344 return 0;
269} 345}
270 346
271static int acpi_battery_check(struct acpi_battery *battery) 347static int acpi_battery_init_alarm(struct acpi_battery *battery)
272{ 348{
273 int result = 0; 349 int result = 0;
274 acpi_status status = AE_OK; 350 acpi_status status = AE_OK;
275 acpi_handle handle = NULL; 351 acpi_handle handle = NULL;
276 struct acpi_device *device = NULL; 352 struct acpi_battery_info *bif = battery->bif_data.pointer;
277 struct acpi_battery_info *bif = NULL; 353 unsigned long alarm = battery->alarm;
278 354
355 /* See if alarms are supported, and if so, set default */
279 356
280 if (!battery) 357 status = acpi_get_handle(acpi_battery_handle(battery), "_BTP", &handle);
281 return -EINVAL; 358 if (ACPI_SUCCESS(status)) {
282 359 battery->flags.alarm_present = 1;
283 device = battery->device; 360 if (!alarm && bif) {
361 alarm = bif->design_capacity_warning;
362 }
363 result = acpi_battery_set_alarm(battery, alarm);
364 if (result)
365 goto end;
366 } else {
367 battery->flags.alarm_present = 0;
368 }
284 369
285 result = acpi_bus_get_status(device); 370 end:
286 if (result)
287 return result;
288 371
289 /* Insertion? */ 372 return result;
373}
290 374
291 if (!battery->flags.present && device->status.battery_present) { 375static int acpi_battery_init_update(struct acpi_battery *battery)
376{
377 int result = 0;
292 378
293 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Battery inserted\n")); 379 result = acpi_battery_get_status(battery);
380 if (result)
381 return result;
294 382
295 /* Evalute _BIF to get certain static information */ 383 battery->flags.battery_present_prev = acpi_battery_present(battery);
296 384
297 result = acpi_battery_get_info(battery, &bif); 385 if (acpi_battery_present(battery)) {
386 result = acpi_battery_get_info(battery);
387 if (result)
388 return result;
389 result = acpi_battery_get_state(battery);
298 if (result) 390 if (result)
299 return result; 391 return result;
300 392
301 battery->flags.power_unit = bif->power_unit; 393 acpi_battery_init_alarm(battery);
302 battery->trips.warning = bif->design_capacity_warning; 394 }
303 battery->trips.low = bif->design_capacity_low; 395
304 kfree(bif); 396 return result;
397}
305 398
306 /* See if alarms are supported, and if so, set default */ 399static int acpi_battery_update(struct acpi_battery *battery,
400 int update, int *update_result_ptr)
401{
402 int result = 0;
403 int update_result = ACPI_BATTERY_NONE_UPDATE;
404
405 if (!acpi_battery_present(battery)) {
406 update = 1;
407 }
307 408
308 status = acpi_get_handle(battery->device->handle, "_BTP", &handle); 409 if (battery->flags.init_update) {
309 if (ACPI_SUCCESS(status)) { 410 result = acpi_battery_init_update(battery);
310 battery->flags.alarm = 1; 411 if (result)
311 acpi_battery_set_alarm(battery, battery->trips.warning); 412 goto end;
413 update_result = ACPI_BATTERY_INIT_UPDATE;
414 } else if (update) {
415 result = acpi_battery_get_status(battery);
416 if (result)
417 goto end;
418 if ((!battery->flags.battery_present_prev & acpi_battery_present(battery))
419 || (battery->flags.battery_present_prev & !acpi_battery_present(battery))) {
420 result = acpi_battery_init_update(battery);
421 if (result)
422 goto end;
423 update_result = ACPI_BATTERY_INIT_UPDATE;
424 } else {
425 update_result = ACPI_BATTERY_EASY_UPDATE;
312 } 426 }
313 } 427 }
314 428
315 /* Removal? */ 429 end:
316 430
317 else if (battery->flags.present && !device->status.battery_present) { 431 battery->flags.init_update = (result != 0);
318 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Battery removed\n"));
319 }
320 432
321 battery->flags.present = device->status.battery_present; 433 *update_result_ptr = update_result;
322 434
323 return result; 435 return result;
324} 436}
325 437
326static void acpi_battery_check_present(struct acpi_battery *battery) 438static void acpi_battery_notify_update(struct acpi_battery *battery)
327{ 439{
328 if (!battery->flags.present) { 440 acpi_battery_get_status(battery);
329 acpi_battery_check(battery); 441
442 if (battery->flags.init_update) {
443 return;
444 }
445
446 if ((!battery->flags.battery_present_prev &
447 acpi_battery_present(battery)) ||
448 (battery->flags.battery_present_prev &
449 !acpi_battery_present(battery))) {
450 battery->flags.init_update = 1;
451 } else {
452 battery->flags.update[ACPI_BATTERY_INFO] = 1;
453 battery->flags.update[ACPI_BATTERY_STATE] = 1;
454 battery->flags.update[ACPI_BATTERY_ALARM] = 1;
330 } 455 }
331} 456}
332 457
@@ -335,37 +460,33 @@ static void acpi_battery_check_present(struct acpi_battery *battery)
335 -------------------------------------------------------------------------- */ 460 -------------------------------------------------------------------------- */
336 461
337static struct proc_dir_entry *acpi_battery_dir; 462static struct proc_dir_entry *acpi_battery_dir;
338static int acpi_battery_read_info(struct seq_file *seq, void *offset) 463
464static int acpi_battery_print_info(struct seq_file *seq, int result)
339{ 465{
340 int result = 0;
341 struct acpi_battery *battery = seq->private; 466 struct acpi_battery *battery = seq->private;
342 struct acpi_battery_info *bif = NULL; 467 struct acpi_battery_info *bif = NULL;
343 char *units = "?"; 468 char *units = "?";
344 469
345 470 if (result)
346 if (!battery)
347 goto end; 471 goto end;
348 472
349 acpi_battery_check_present(battery); 473 if (acpi_battery_present(battery))
350
351 if (battery->flags.present)
352 seq_printf(seq, "present: yes\n"); 474 seq_printf(seq, "present: yes\n");
353 else { 475 else {
354 seq_printf(seq, "present: no\n"); 476 seq_printf(seq, "present: no\n");
355 goto end; 477 goto end;
356 } 478 }
357 479
358 /* Battery Info (_BIF) */ 480 bif = battery->bif_data.pointer;
359 481 if (!bif) {
360 result = acpi_battery_get_info(battery, &bif); 482 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BIF buffer is NULL"));
361 if (result || !bif) { 483 result = -ENODEV;
362 seq_printf(seq, "ERROR: Unable to read battery information\n");
363 goto end; 484 goto end;
364 } 485 }
365 486
366 units = 487 /* Battery Units */
367 bif-> 488
368 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS; 489 units = acpi_battery_power_units(battery);
369 490
370 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN) 491 if (bif->design_capacity == ACPI_BATTERY_VALUE_UNKNOWN)
371 seq_printf(seq, "design capacity: unknown\n"); 492 seq_printf(seq, "design capacity: unknown\n");
@@ -396,7 +517,6 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
396 else 517 else
397 seq_printf(seq, "design voltage: %d mV\n", 518 seq_printf(seq, "design voltage: %d mV\n",
398 (u32) bif->design_voltage); 519 (u32) bif->design_voltage);
399
400 seq_printf(seq, "design capacity warning: %d %sh\n", 520 seq_printf(seq, "design capacity warning: %d %sh\n",
401 (u32) bif->design_capacity_warning, units); 521 (u32) bif->design_capacity_warning, units);
402 seq_printf(seq, "design capacity low: %d %sh\n", 522 seq_printf(seq, "design capacity low: %d %sh\n",
@@ -411,50 +531,40 @@ static int acpi_battery_read_info(struct seq_file *seq, void *offset)
411 seq_printf(seq, "OEM info: %s\n", bif->oem_info); 531 seq_printf(seq, "OEM info: %s\n", bif->oem_info);
412 532
413 end: 533 end:
414 kfree(bif);
415 534
416 return 0; 535 if (result)
417} 536 seq_printf(seq, "ERROR: Unable to read battery info\n");
418 537
419static int acpi_battery_info_open_fs(struct inode *inode, struct file *file) 538 return result;
420{
421 return single_open(file, acpi_battery_read_info, PDE(inode)->data);
422} 539}
423 540
424static int acpi_battery_read_state(struct seq_file *seq, void *offset) 541static int acpi_battery_print_state(struct seq_file *seq, int result)
425{ 542{
426 int result = 0;
427 struct acpi_battery *battery = seq->private; 543 struct acpi_battery *battery = seq->private;
428 struct acpi_battery_status *bst = NULL; 544 struct acpi_battery_state *bst = NULL;
429 char *units = "?"; 545 char *units = "?";
430 546
431 547 if (result)
432 if (!battery)
433 goto end; 548 goto end;
434 549
435 acpi_battery_check_present(battery); 550 if (acpi_battery_present(battery))
436
437 if (battery->flags.present)
438 seq_printf(seq, "present: yes\n"); 551 seq_printf(seq, "present: yes\n");
439 else { 552 else {
440 seq_printf(seq, "present: no\n"); 553 seq_printf(seq, "present: no\n");
441 goto end; 554 goto end;
442 } 555 }
443 556
444 /* Battery Units */ 557 bst = battery->bst_data.pointer;
445 558 if (!bst) {
446 units = 559 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "BST buffer is NULL"));
447 battery->flags. 560 result = -ENODEV;
448 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
449
450 /* Battery Status (_BST) */
451
452 result = acpi_battery_get_status(battery, &bst);
453 if (result || !bst) {
454 seq_printf(seq, "ERROR: Unable to read battery status\n");
455 goto end; 561 goto end;
456 } 562 }
457 563
564 /* Battery Units */
565
566 units = acpi_battery_power_units(battery);
567
458 if (!(bst->state & 0x04)) 568 if (!(bst->state & 0x04))
459 seq_printf(seq, "capacity state: ok\n"); 569 seq_printf(seq, "capacity state: ok\n");
460 else 570 else
@@ -490,48 +600,43 @@ static int acpi_battery_read_state(struct seq_file *seq, void *offset)
490 (u32) bst->present_voltage); 600 (u32) bst->present_voltage);
491 601
492 end: 602 end:
493 kfree(bst);
494 603
495 return 0; 604 if (result) {
496} 605 seq_printf(seq, "ERROR: Unable to read battery state\n");
606 }
497 607
498static int acpi_battery_state_open_fs(struct inode *inode, struct file *file) 608 return result;
499{
500 return single_open(file, acpi_battery_read_state, PDE(inode)->data);
501} 609}
502 610
503static int acpi_battery_read_alarm(struct seq_file *seq, void *offset) 611static int acpi_battery_print_alarm(struct seq_file *seq, int result)
504{ 612{
505 struct acpi_battery *battery = seq->private; 613 struct acpi_battery *battery = seq->private;
506 char *units = "?"; 614 char *units = "?";
507 615
508 616 if (result)
509 if (!battery)
510 goto end; 617 goto end;
511 618
512 acpi_battery_check_present(battery); 619 if (!acpi_battery_present(battery)) {
513
514 if (!battery->flags.present) {
515 seq_printf(seq, "present: no\n"); 620 seq_printf(seq, "present: no\n");
516 goto end; 621 goto end;
517 } 622 }
518 623
519 /* Battery Units */ 624 /* Battery Units */
520 625
521 units = 626 units = acpi_battery_power_units(battery);
522 battery->flags.
523 power_unit ? ACPI_BATTERY_UNITS_AMPS : ACPI_BATTERY_UNITS_WATTS;
524
525 /* Battery Alarm */
526 627
527 seq_printf(seq, "alarm: "); 628 seq_printf(seq, "alarm: ");
528 if (!battery->alarm) 629 if (!battery->alarm)
529 seq_printf(seq, "unsupported\n"); 630 seq_printf(seq, "unsupported\n");
530 else 631 else
531 seq_printf(seq, "%d %sh\n", (u32) battery->alarm, units); 632 seq_printf(seq, "%lu %sh\n", battery->alarm, units);
532 633
533 end: 634 end:
534 return 0; 635
636 if (result)
637 seq_printf(seq, "ERROR: Unable to read battery alarm\n");
638
639 return result;
535} 640}
536 641
537static ssize_t 642static ssize_t
@@ -543,27 +648,113 @@ acpi_battery_write_alarm(struct file *file,
543 char alarm_string[12] = { '\0' }; 648 char alarm_string[12] = { '\0' };
544 struct seq_file *m = file->private_data; 649 struct seq_file *m = file->private_data;
545 struct acpi_battery *battery = m->private; 650 struct acpi_battery *battery = m->private;
546 651 int update_result = ACPI_BATTERY_NONE_UPDATE;
547 652
548 if (!battery || (count > sizeof(alarm_string) - 1)) 653 if (!battery || (count > sizeof(alarm_string) - 1))
549 return -EINVAL; 654 return -EINVAL;
550 655
551 acpi_battery_check_present(battery); 656 mutex_lock(&battery->mutex);
552 657
553 if (!battery->flags.present) 658 result = acpi_battery_update(battery, 1, &update_result);
554 return -ENODEV; 659 if (result) {
660 result = -ENODEV;
661 goto end;
662 }
663
664 if (!acpi_battery_present(battery)) {
665 result = -ENODEV;
666 goto end;
667 }
555 668
556 if (copy_from_user(alarm_string, buffer, count)) 669 if (copy_from_user(alarm_string, buffer, count)) {
557 return -EFAULT; 670 result = -EFAULT;
671 goto end;
672 }
558 673
559 alarm_string[count] = '\0'; 674 alarm_string[count] = '\0';
560 675
561 result = acpi_battery_set_alarm(battery, 676 result = acpi_battery_set_alarm(battery,
562 simple_strtoul(alarm_string, NULL, 0)); 677 simple_strtoul(alarm_string, NULL, 0));
563 if (result) 678 if (result)
564 return result; 679 goto end;
680
681 end:
565 682
566 return count; 683 acpi_battery_check_result(battery, result);
684
685 if (!result)
686 result = count;
687
688 mutex_unlock(&battery->mutex);
689
690 return result;
691}
692
693typedef int(*print_func)(struct seq_file *seq, int result);
694typedef int(*get_func)(struct acpi_battery *battery);
695
696static struct acpi_read_mux {
697 print_func print;
698 get_func get;
699} acpi_read_funcs[ACPI_BATTERY_NUMFILES] = {
700 {.get = acpi_battery_get_info, .print = acpi_battery_print_info},
701 {.get = acpi_battery_get_state, .print = acpi_battery_print_state},
702 {.get = acpi_battery_get_alarm, .print = acpi_battery_print_alarm},
703};
704
705static int acpi_battery_read(int fid, struct seq_file *seq)
706{
707 struct acpi_battery *battery = seq->private;
708 int result = 0;
709 int update_result = ACPI_BATTERY_NONE_UPDATE;
710 int update = 0;
711
712 mutex_lock(&battery->mutex);
713
714 update = (get_seconds() - battery->update_time[fid] >= update_time);
715 update = (update | battery->flags.update[fid]);
716
717 result = acpi_battery_update(battery, update, &update_result);
718 if (result)
719 goto end;
720
721 if (update_result == ACPI_BATTERY_EASY_UPDATE) {
722 result = acpi_read_funcs[fid].get(battery);
723 if (result)
724 goto end;
725 }
726
727 end:
728 result = acpi_read_funcs[fid].print(seq, result);
729 acpi_battery_check_result(battery, result);
730 battery->flags.update[fid] = result;
731 mutex_unlock(&battery->mutex);
732 return result;
733}
734
735static int acpi_battery_read_info(struct seq_file *seq, void *offset)
736{
737 return acpi_battery_read(ACPI_BATTERY_INFO, seq);
738}
739
740static int acpi_battery_read_state(struct seq_file *seq, void *offset)
741{
742 return acpi_battery_read(ACPI_BATTERY_STATE, seq);
743}
744
745static int acpi_battery_read_alarm(struct seq_file *seq, void *offset)
746{
747 return acpi_battery_read(ACPI_BATTERY_ALARM, seq);
748}
749
750static int acpi_battery_info_open_fs(struct inode *inode, struct file *file)
751{
752 return single_open(file, acpi_battery_read_info, PDE(inode)->data);
753}
754
755static int acpi_battery_state_open_fs(struct inode *inode, struct file *file)
756{
757 return single_open(file, acpi_battery_read_state, PDE(inode)->data);
567} 758}
568 759
569static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file) 760static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
@@ -571,35 +762,51 @@ static int acpi_battery_alarm_open_fs(struct inode *inode, struct file *file)
571 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data); 762 return single_open(file, acpi_battery_read_alarm, PDE(inode)->data);
572} 763}
573 764
574static const struct file_operations acpi_battery_info_ops = { 765static struct battery_file {
766 struct file_operations ops;
767 mode_t mode;
768 char *name;
769} acpi_battery_file[] = {
770 {
771 .name = "info",
772 .mode = S_IRUGO,
773 .ops = {
575 .open = acpi_battery_info_open_fs, 774 .open = acpi_battery_info_open_fs,
576 .read = seq_read, 775 .read = seq_read,
577 .llseek = seq_lseek, 776 .llseek = seq_lseek,
578 .release = single_release, 777 .release = single_release,
579 .owner = THIS_MODULE, 778 .owner = THIS_MODULE,
580}; 779 },
581 780 },
582static const struct file_operations acpi_battery_state_ops = { 781 {
782 .name = "state",
783 .mode = S_IRUGO,
784 .ops = {
583 .open = acpi_battery_state_open_fs, 785 .open = acpi_battery_state_open_fs,
584 .read = seq_read, 786 .read = seq_read,
585 .llseek = seq_lseek, 787 .llseek = seq_lseek,
586 .release = single_release, 788 .release = single_release,
587 .owner = THIS_MODULE, 789 .owner = THIS_MODULE,
588}; 790 },
589 791 },
590static const struct file_operations acpi_battery_alarm_ops = { 792 {
793 .name = "alarm",
794 .mode = S_IFREG | S_IRUGO | S_IWUSR,
795 .ops = {
591 .open = acpi_battery_alarm_open_fs, 796 .open = acpi_battery_alarm_open_fs,
592 .read = seq_read, 797 .read = seq_read,
593 .write = acpi_battery_write_alarm, 798 .write = acpi_battery_write_alarm,
594 .llseek = seq_lseek, 799 .llseek = seq_lseek,
595 .release = single_release, 800 .release = single_release,
596 .owner = THIS_MODULE, 801 .owner = THIS_MODULE,
802 },
803 },
597}; 804};
598 805
599static int acpi_battery_add_fs(struct acpi_device *device) 806static int acpi_battery_add_fs(struct acpi_device *device)
600{ 807{
601 struct proc_dir_entry *entry = NULL; 808 struct proc_dir_entry *entry = NULL;
602 809 int i;
603 810
604 if (!acpi_device_dir(device)) { 811 if (!acpi_device_dir(device)) {
605 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device), 812 acpi_device_dir(device) = proc_mkdir(acpi_device_bid(device),
@@ -609,38 +816,16 @@ static int acpi_battery_add_fs(struct acpi_device *device)
609 acpi_device_dir(device)->owner = THIS_MODULE; 816 acpi_device_dir(device)->owner = THIS_MODULE;
610 } 817 }
611 818
612 /* 'info' [R] */ 819 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
613 entry = create_proc_entry(ACPI_BATTERY_FILE_INFO, 820 entry = create_proc_entry(acpi_battery_file[i].name,
614 S_IRUGO, acpi_device_dir(device)); 821 acpi_battery_file[i].mode, acpi_device_dir(device));
615 if (!entry) 822 if (!entry)
616 return -ENODEV; 823 return -ENODEV;
617 else { 824 else {
618 entry->proc_fops = &acpi_battery_info_ops; 825 entry->proc_fops = &acpi_battery_file[i].ops;
619 entry->data = acpi_driver_data(device); 826 entry->data = acpi_driver_data(device);
620 entry->owner = THIS_MODULE; 827 entry->owner = THIS_MODULE;
621 } 828 }
622
623 /* 'status' [R] */
624 entry = create_proc_entry(ACPI_BATTERY_FILE_STATUS,
625 S_IRUGO, acpi_device_dir(device));
626 if (!entry)
627 return -ENODEV;
628 else {
629 entry->proc_fops = &acpi_battery_state_ops;
630 entry->data = acpi_driver_data(device);
631 entry->owner = THIS_MODULE;
632 }
633
634 /* 'alarm' [R/W] */
635 entry = create_proc_entry(ACPI_BATTERY_FILE_ALARM,
636 S_IFREG | S_IRUGO | S_IWUSR,
637 acpi_device_dir(device));
638 if (!entry)
639 return -ENODEV;
640 else {
641 entry->proc_fops = &acpi_battery_alarm_ops;
642 entry->data = acpi_driver_data(device);
643 entry->owner = THIS_MODULE;
644 } 829 }
645 830
646 return 0; 831 return 0;
@@ -648,15 +833,12 @@ static int acpi_battery_add_fs(struct acpi_device *device)
648 833
649static int acpi_battery_remove_fs(struct acpi_device *device) 834static int acpi_battery_remove_fs(struct acpi_device *device)
650{ 835{
651 836 int i;
652 if (acpi_device_dir(device)) { 837 if (acpi_device_dir(device)) {
653 remove_proc_entry(ACPI_BATTERY_FILE_ALARM, 838 for (i = 0; i < ACPI_BATTERY_NUMFILES; ++i) {
839 remove_proc_entry(acpi_battery_file[i].name,
654 acpi_device_dir(device)); 840 acpi_device_dir(device));
655 remove_proc_entry(ACPI_BATTERY_FILE_STATUS, 841 }
656 acpi_device_dir(device));
657 remove_proc_entry(ACPI_BATTERY_FILE_INFO,
658 acpi_device_dir(device));
659
660 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir); 842 remove_proc_entry(acpi_device_bid(device), acpi_battery_dir);
661 acpi_device_dir(device) = NULL; 843 acpi_device_dir(device) = NULL;
662 } 844 }
@@ -673,7 +855,6 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
673 struct acpi_battery *battery = data; 855 struct acpi_battery *battery = data;
674 struct acpi_device *device = NULL; 856 struct acpi_device *device = NULL;
675 857
676
677 if (!battery) 858 if (!battery)
678 return; 859 return;
679 860
@@ -684,8 +865,10 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
684 case ACPI_BATTERY_NOTIFY_INFO: 865 case ACPI_BATTERY_NOTIFY_INFO:
685 case ACPI_NOTIFY_BUS_CHECK: 866 case ACPI_NOTIFY_BUS_CHECK:
686 case ACPI_NOTIFY_DEVICE_CHECK: 867 case ACPI_NOTIFY_DEVICE_CHECK:
687 acpi_battery_check(battery); 868 device = battery->device;
688 acpi_bus_generate_event(device, event, battery->flags.present); 869 acpi_battery_notify_update(battery);
870 acpi_bus_generate_event(device, event,
871 acpi_battery_present(battery));
689 break; 872 break;
690 default: 873 default:
691 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 874 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -702,7 +885,6 @@ static int acpi_battery_add(struct acpi_device *device)
702 acpi_status status = 0; 885 acpi_status status = 0;
703 struct acpi_battery *battery = NULL; 886 struct acpi_battery *battery = NULL;
704 887
705
706 if (!device) 888 if (!device)
707 return -EINVAL; 889 return -EINVAL;
708 890
@@ -710,15 +892,21 @@ static int acpi_battery_add(struct acpi_device *device)
710 if (!battery) 892 if (!battery)
711 return -ENOMEM; 893 return -ENOMEM;
712 894
895 mutex_init(&battery->mutex);
896
897 mutex_lock(&battery->mutex);
898
713 battery->device = device; 899 battery->device = device;
714 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME); 900 strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
715 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS); 901 strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
716 acpi_driver_data(device) = battery; 902 acpi_driver_data(device) = battery;
717 903
718 result = acpi_battery_check(battery); 904 result = acpi_battery_get_status(battery);
719 if (result) 905 if (result)
720 goto end; 906 goto end;
721 907
908 battery->flags.init_update = 1;
909
722 result = acpi_battery_add_fs(device); 910 result = acpi_battery_add_fs(device);
723 if (result) 911 if (result)
724 goto end; 912 goto end;
@@ -727,6 +915,7 @@ static int acpi_battery_add(struct acpi_device *device)
727 ACPI_ALL_NOTIFY, 915 ACPI_ALL_NOTIFY,
728 acpi_battery_notify, battery); 916 acpi_battery_notify, battery);
729 if (ACPI_FAILURE(status)) { 917 if (ACPI_FAILURE(status)) {
918 ACPI_EXCEPTION((AE_INFO, status, "Installing notify handler"));
730 result = -ENODEV; 919 result = -ENODEV;
731 goto end; 920 goto end;
732 } 921 }
@@ -736,11 +925,14 @@ static int acpi_battery_add(struct acpi_device *device)
736 device->status.battery_present ? "present" : "absent"); 925 device->status.battery_present ? "present" : "absent");
737 926
738 end: 927 end:
928
739 if (result) { 929 if (result) {
740 acpi_battery_remove_fs(device); 930 acpi_battery_remove_fs(device);
741 kfree(battery); 931 kfree(battery);
742 } 932 }
743 933
934 mutex_unlock(&battery->mutex);
935
744 return result; 936 return result;
745} 937}
746 938
@@ -749,18 +941,27 @@ static int acpi_battery_remove(struct acpi_device *device, int type)
749 acpi_status status = 0; 941 acpi_status status = 0;
750 struct acpi_battery *battery = NULL; 942 struct acpi_battery *battery = NULL;
751 943
752
753 if (!device || !acpi_driver_data(device)) 944 if (!device || !acpi_driver_data(device))
754 return -EINVAL; 945 return -EINVAL;
755 946
756 battery = acpi_driver_data(device); 947 battery = acpi_driver_data(device);
757 948
949 mutex_lock(&battery->mutex);
950
758 status = acpi_remove_notify_handler(device->handle, 951 status = acpi_remove_notify_handler(device->handle,
759 ACPI_ALL_NOTIFY, 952 ACPI_ALL_NOTIFY,
760 acpi_battery_notify); 953 acpi_battery_notify);
761 954
762 acpi_battery_remove_fs(device); 955 acpi_battery_remove_fs(device);
763 956
957 kfree(battery->bif_data.pointer);
958
959 kfree(battery->bst_data.pointer);
960
961 mutex_unlock(&battery->mutex);
962
963 mutex_destroy(&battery->mutex);
964
764 kfree(battery); 965 kfree(battery);
765 966
766 return 0; 967 return 0;
@@ -775,7 +976,10 @@ static int acpi_battery_resume(struct acpi_device *device)
775 return -EINVAL; 976 return -EINVAL;
776 977
777 battery = device->driver_data; 978 battery = device->driver_data;
778 return acpi_battery_check(battery); 979
980 battery->flags.init_update = 1;
981
982 return 0;
779} 983}
780 984
781static int __init acpi_battery_init(void) 985static int __init acpi_battery_init(void)
@@ -800,7 +1004,6 @@ static int __init acpi_battery_init(void)
800 1004
801static void __exit acpi_battery_exit(void) 1005static void __exit acpi_battery_exit(void)
802{ 1006{
803
804 acpi_bus_unregister_driver(&acpi_battery_driver); 1007 acpi_bus_unregister_driver(&acpi_battery_driver);
805 1008
806 acpi_unlock_battery_dir(acpi_battery_dir); 1009 acpi_unlock_battery_dir(acpi_battery_dir);
diff --git a/drivers/acpi/bay.c b/drivers/acpi/bay.c
index fb3f31b5e69f..56a5b3fffeb3 100644
--- a/drivers/acpi/bay.c
+++ b/drivers/acpi/bay.c
@@ -288,6 +288,11 @@ static int bay_add(acpi_handle handle, int id)
288 new_bay->pdev = pdev; 288 new_bay->pdev = pdev;
289 platform_set_drvdata(pdev, new_bay); 289 platform_set_drvdata(pdev, new_bay);
290 290
291 /*
292 * we want the bay driver to be able to send uevents
293 */
294 pdev->dev.uevent_suppress = 0;
295
291 if (acpi_bay_add_fs(new_bay)) { 296 if (acpi_bay_add_fs(new_bay)) {
292 platform_device_unregister(new_bay->pdev); 297 platform_device_unregister(new_bay->pdev);
293 goto bay_add_err; 298 goto bay_add_err;
@@ -328,18 +333,12 @@ static void bay_notify(acpi_handle handle, u32 event, void *data)
328{ 333{
329 struct bay *bay_dev = (struct bay *)data; 334 struct bay *bay_dev = (struct bay *)data;
330 struct device *dev = &bay_dev->pdev->dev; 335 struct device *dev = &bay_dev->pdev->dev;
336 char event_string[12];
337 char *envp[] = { event_string, NULL };
331 338
332 bay_dprintk(handle, "Bay event"); 339 bay_dprintk(handle, "Bay event");
333 340 sprintf(event_string, "BAY_EVENT=%d\n", event);
334 switch(event) { 341 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
335 case ACPI_NOTIFY_BUS_CHECK:
336 case ACPI_NOTIFY_DEVICE_CHECK:
337 case ACPI_NOTIFY_EJECT_REQUEST:
338 kobject_uevent(&dev->kobj, KOBJ_CHANGE);
339 break;
340 default:
341 printk(KERN_ERR PREFIX "Bay: unknown event %d\n", event);
342 }
343} 342}
344 343
345static acpi_status 344static acpi_status
diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
index e5084ececb6f..6b2658c96242 100644
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -292,6 +292,10 @@ int acpi_bus_generate_event(struct acpi_device *device, u8 type, int data)
292 if (!device) 292 if (!device)
293 return -EINVAL; 293 return -EINVAL;
294 294
295 if (acpi_bus_generate_genetlink_event(device, type, data))
296 printk(KERN_WARNING PREFIX
297 "Failed to generate an ACPI event via genetlink!\n");
298
295 /* drop event on the floor if no one's listening */ 299 /* drop event on the floor if no one's listening */
296 if (!event_is_open) 300 if (!event_is_open)
297 return 0; 301 return 0;
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 4546bf873aea..6192c8be66df 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -40,8 +40,15 @@ MODULE_AUTHOR("Kristen Carlson Accardi");
40MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION); 40MODULE_DESCRIPTION(ACPI_DOCK_DRIVER_DESCRIPTION);
41MODULE_LICENSE("GPL"); 41MODULE_LICENSE("GPL");
42 42
43static int immediate_undock = 1;
44module_param(immediate_undock, bool, 0644);
45MODULE_PARM_DESC(immediate_undock, "1 (default) will cause the driver to "
46 "undock immediately when the undock button is pressed, 0 will cause"
47 " the driver to wait for userspace to write the undock sysfs file "
48 " before undocking");
49
43static struct atomic_notifier_head dock_notifier_list; 50static struct atomic_notifier_head dock_notifier_list;
44static struct platform_device dock_device; 51static struct platform_device *dock_device;
45static char dock_device_name[] = "dock"; 52static char dock_device_name[] = "dock";
46 53
47struct dock_station { 54struct dock_station {
@@ -63,6 +70,7 @@ struct dock_dependent_device {
63}; 70};
64 71
65#define DOCK_DOCKING 0x00000001 72#define DOCK_DOCKING 0x00000001
73#define DOCK_UNDOCKING 0x00000002
66#define DOCK_EVENT 3 74#define DOCK_EVENT 3
67#define UNDOCK_EVENT 2 75#define UNDOCK_EVENT 2
68 76
@@ -327,12 +335,20 @@ static void hotplug_dock_devices(struct dock_station *ds, u32 event)
327 335
328static void dock_event(struct dock_station *ds, u32 event, int num) 336static void dock_event(struct dock_station *ds, u32 event, int num)
329{ 337{
330 struct device *dev = &dock_device.dev; 338 struct device *dev = &dock_device->dev;
339 char event_string[7];
340 char *envp[] = { event_string, NULL };
341
342 if (num == UNDOCK_EVENT)
343 sprintf(event_string, "UNDOCK");
344 else
345 sprintf(event_string, "DOCK");
346
331 /* 347 /*
332 * Indicate that the status of the dock station has 348 * Indicate that the status of the dock station has
333 * changed. 349 * changed.
334 */ 350 */
335 kobject_uevent(&dev->kobj, KOBJ_CHANGE); 351 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
336} 352}
337 353
338/** 354/**
@@ -380,12 +396,11 @@ static void handle_dock(struct dock_station *ds, int dock)
380 union acpi_object arg; 396 union acpi_object arg;
381 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 397 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
382 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 398 struct acpi_buffer name_buffer = { ACPI_ALLOCATE_BUFFER, NULL };
383 union acpi_object *obj;
384 399
385 acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer); 400 acpi_get_name(ds->handle, ACPI_FULL_PATHNAME, &name_buffer);
386 obj = name_buffer.pointer;
387 401
388 printk(KERN_INFO PREFIX "%s\n", dock ? "docking" : "undocking"); 402 printk(KERN_INFO PREFIX "%s - %s\n",
403 (char *)name_buffer.pointer, dock ? "docking" : "undocking");
389 404
390 /* _DCK method has one argument */ 405 /* _DCK method has one argument */
391 arg_list.count = 1; 406 arg_list.count = 1;
@@ -394,7 +409,8 @@ static void handle_dock(struct dock_station *ds, int dock)
394 arg.integer.value = dock; 409 arg.integer.value = dock;
395 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer); 410 status = acpi_evaluate_object(ds->handle, "_DCK", &arg_list, &buffer);
396 if (ACPI_FAILURE(status)) 411 if (ACPI_FAILURE(status))
397 pr_debug("%s: failed to execute _DCK\n", obj->string.pointer); 412 printk(KERN_ERR PREFIX "%s - failed to execute _DCK\n",
413 (char *)name_buffer.pointer);
398 kfree(buffer.pointer); 414 kfree(buffer.pointer);
399 kfree(name_buffer.pointer); 415 kfree(name_buffer.pointer);
400} 416}
@@ -420,6 +436,16 @@ static inline void complete_dock(struct dock_station *ds)
420 ds->last_dock_time = jiffies; 436 ds->last_dock_time = jiffies;
421} 437}
422 438
439static inline void begin_undock(struct dock_station *ds)
440{
441 ds->flags |= DOCK_UNDOCKING;
442}
443
444static inline void complete_undock(struct dock_station *ds)
445{
446 ds->flags &= ~(DOCK_UNDOCKING);
447}
448
423/** 449/**
424 * dock_in_progress - see if we are in the middle of handling a dock event 450 * dock_in_progress - see if we are in the middle of handling a dock event
425 * @ds: the dock station 451 * @ds: the dock station
@@ -550,7 +576,7 @@ static int handle_eject_request(struct dock_station *ds, u32 event)
550 printk(KERN_ERR PREFIX "Unable to undock!\n"); 576 printk(KERN_ERR PREFIX "Unable to undock!\n");
551 return -EBUSY; 577 return -EBUSY;
552 } 578 }
553 579 complete_undock(ds);
554 return 0; 580 return 0;
555} 581}
556 582
@@ -594,7 +620,11 @@ static void dock_notify(acpi_handle handle, u32 event, void *data)
594 * to the driver who wish to hotplug. 620 * to the driver who wish to hotplug.
595 */ 621 */
596 case ACPI_NOTIFY_EJECT_REQUEST: 622 case ACPI_NOTIFY_EJECT_REQUEST:
597 handle_eject_request(ds, event); 623 begin_undock(ds);
624 if (immediate_undock)
625 handle_eject_request(ds, event);
626 else
627 dock_event(ds, event, UNDOCK_EVENT);
598 break; 628 break;
599 default: 629 default:
600 printk(KERN_ERR PREFIX "Unknown dock event %d\n", event); 630 printk(KERN_ERR PREFIX "Unknown dock event %d\n", event);
@@ -653,6 +683,17 @@ static ssize_t show_docked(struct device *dev,
653DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL); 683DEVICE_ATTR(docked, S_IRUGO, show_docked, NULL);
654 684
655/* 685/*
686 * show_flags - read method for flags file in sysfs
687 */
688static ssize_t show_flags(struct device *dev,
689 struct device_attribute *attr, char *buf)
690{
691 return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
692
693}
694DEVICE_ATTR(flags, S_IRUGO, show_flags, NULL);
695
696/*
656 * write_undock - write method for "undock" file in sysfs 697 * write_undock - write method for "undock" file in sysfs
657 */ 698 */
658static ssize_t write_undock(struct device *dev, struct device_attribute *attr, 699static ssize_t write_undock(struct device *dev, struct device_attribute *attr,
@@ -675,16 +716,15 @@ static ssize_t show_dock_uid(struct device *dev,
675 struct device_attribute *attr, char *buf) 716 struct device_attribute *attr, char *buf)
676{ 717{
677 unsigned long lbuf; 718 unsigned long lbuf;
678 acpi_status status = acpi_evaluate_integer(dock_station->handle, "_UID", NULL, &lbuf); 719 acpi_status status = acpi_evaluate_integer(dock_station->handle,
679 if(ACPI_FAILURE(status)) { 720 "_UID", NULL, &lbuf);
721 if (ACPI_FAILURE(status))
680 return 0; 722 return 0;
681 } 723
682 return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf); 724 return snprintf(buf, PAGE_SIZE, "%lx\n", lbuf);
683} 725}
684DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL); 726DEVICE_ATTR(uid, S_IRUGO, show_dock_uid, NULL);
685 727
686
687
688/** 728/**
689 * dock_add - add a new dock station 729 * dock_add - add a new dock station
690 * @handle: the dock station handle 730 * @handle: the dock station handle
@@ -711,33 +751,53 @@ static int dock_add(acpi_handle handle)
711 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list); 751 ATOMIC_INIT_NOTIFIER_HEAD(&dock_notifier_list);
712 752
713 /* initialize platform device stuff */ 753 /* initialize platform device stuff */
714 dock_device.name = dock_device_name; 754 dock_device =
715 ret = platform_device_register(&dock_device); 755 platform_device_register_simple(dock_device_name, 0, NULL, 0);
756 if (IS_ERR(dock_device)) {
757 kfree(dock_station);
758 dock_station = NULL;
759 return PTR_ERR(dock_device);
760 }
761
762 /* we want the dock device to send uevents */
763 dock_device->dev.uevent_suppress = 0;
764
765 ret = device_create_file(&dock_device->dev, &dev_attr_docked);
716 if (ret) { 766 if (ret) {
717 printk(KERN_ERR PREFIX "Error %d registering dock device\n", ret); 767 printk("Error %d adding sysfs file\n", ret);
768 platform_device_unregister(dock_device);
718 kfree(dock_station); 769 kfree(dock_station);
770 dock_station = NULL;
719 return ret; 771 return ret;
720 } 772 }
721 ret = device_create_file(&dock_device.dev, &dev_attr_docked); 773 ret = device_create_file(&dock_device->dev, &dev_attr_undock);
722 if (ret) { 774 if (ret) {
723 printk("Error %d adding sysfs file\n", ret); 775 printk("Error %d adding sysfs file\n", ret);
724 platform_device_unregister(&dock_device); 776 device_remove_file(&dock_device->dev, &dev_attr_docked);
777 platform_device_unregister(dock_device);
725 kfree(dock_station); 778 kfree(dock_station);
779 dock_station = NULL;
726 return ret; 780 return ret;
727 } 781 }
728 ret = device_create_file(&dock_device.dev, &dev_attr_undock); 782 ret = device_create_file(&dock_device->dev, &dev_attr_uid);
729 if (ret) { 783 if (ret) {
730 printk("Error %d adding sysfs file\n", ret); 784 printk("Error %d adding sysfs file\n", ret);
731 device_remove_file(&dock_device.dev, &dev_attr_docked); 785 device_remove_file(&dock_device->dev, &dev_attr_docked);
732 platform_device_unregister(&dock_device); 786 device_remove_file(&dock_device->dev, &dev_attr_undock);
787 platform_device_unregister(dock_device);
733 kfree(dock_station); 788 kfree(dock_station);
789 dock_station = NULL;
734 return ret; 790 return ret;
735 } 791 }
736 ret = device_create_file(&dock_device.dev, &dev_attr_uid); 792 ret = device_create_file(&dock_device->dev, &dev_attr_flags);
737 if (ret) { 793 if (ret) {
738 printk("Error %d adding sysfs file\n", ret); 794 printk("Error %d adding sysfs file\n", ret);
739 platform_device_unregister(&dock_device); 795 device_remove_file(&dock_device->dev, &dev_attr_docked);
796 device_remove_file(&dock_device->dev, &dev_attr_undock);
797 device_remove_file(&dock_device->dev, &dev_attr_uid);
798 platform_device_unregister(dock_device);
740 kfree(dock_station); 799 kfree(dock_station);
800 dock_station = NULL;
741 return ret; 801 return ret;
742 } 802 }
743 803
@@ -750,6 +810,7 @@ static int dock_add(acpi_handle handle)
750 dd = alloc_dock_dependent_device(handle); 810 dd = alloc_dock_dependent_device(handle);
751 if (!dd) { 811 if (!dd) {
752 kfree(dock_station); 812 kfree(dock_station);
813 dock_station = NULL;
753 ret = -ENOMEM; 814 ret = -ENOMEM;
754 goto dock_add_err_unregister; 815 goto dock_add_err_unregister;
755 } 816 }
@@ -773,10 +834,13 @@ static int dock_add(acpi_handle handle)
773dock_add_err: 834dock_add_err:
774 kfree(dd); 835 kfree(dd);
775dock_add_err_unregister: 836dock_add_err_unregister:
776 device_remove_file(&dock_device.dev, &dev_attr_docked); 837 device_remove_file(&dock_device->dev, &dev_attr_docked);
777 device_remove_file(&dock_device.dev, &dev_attr_undock); 838 device_remove_file(&dock_device->dev, &dev_attr_undock);
778 platform_device_unregister(&dock_device); 839 device_remove_file(&dock_device->dev, &dev_attr_uid);
840 device_remove_file(&dock_device->dev, &dev_attr_flags);
841 platform_device_unregister(dock_device);
779 kfree(dock_station); 842 kfree(dock_station);
843 dock_station = NULL;
780 return ret; 844 return ret;
781} 845}
782 846
@@ -804,12 +868,15 @@ static int dock_remove(void)
804 printk(KERN_ERR "Error removing notify handler\n"); 868 printk(KERN_ERR "Error removing notify handler\n");
805 869
806 /* cleanup sysfs */ 870 /* cleanup sysfs */
807 device_remove_file(&dock_device.dev, &dev_attr_docked); 871 device_remove_file(&dock_device->dev, &dev_attr_docked);
808 device_remove_file(&dock_device.dev, &dev_attr_undock); 872 device_remove_file(&dock_device->dev, &dev_attr_undock);
809 platform_device_unregister(&dock_device); 873 device_remove_file(&dock_device->dev, &dev_attr_uid);
874 device_remove_file(&dock_device->dev, &dev_attr_flags);
875 platform_device_unregister(dock_device);
810 876
811 /* free dock station memory */ 877 /* free dock station memory */
812 kfree(dock_station); 878 kfree(dock_station);
879 dock_station = NULL;
813 return 0; 880 return 0;
814} 881}
815 882
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c
index 82f496c07675..10e851021eca 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -34,25 +34,26 @@
34#include <linux/proc_fs.h> 34#include <linux/proc_fs.h>
35#include <linux/seq_file.h> 35#include <linux/seq_file.h>
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/list.h>
37#include <asm/io.h> 38#include <asm/io.h>
38#include <acpi/acpi_bus.h> 39#include <acpi/acpi_bus.h>
39#include <acpi/acpi_drivers.h> 40#include <acpi/acpi_drivers.h>
40#include <acpi/actypes.h> 41#include <acpi/actypes.h>
41 42
42#define _COMPONENT ACPI_EC_COMPONENT
43ACPI_MODULE_NAME("ec");
44#define ACPI_EC_COMPONENT 0x00100000
45#define ACPI_EC_CLASS "embedded_controller" 43#define ACPI_EC_CLASS "embedded_controller"
46#define ACPI_EC_HID "PNP0C09" 44#define ACPI_EC_HID "PNP0C09"
47#define ACPI_EC_DEVICE_NAME "Embedded Controller" 45#define ACPI_EC_DEVICE_NAME "Embedded Controller"
48#define ACPI_EC_FILE_INFO "info" 46#define ACPI_EC_FILE_INFO "info"
47
49#undef PREFIX 48#undef PREFIX
50#define PREFIX "ACPI: EC: " 49#define PREFIX "ACPI: EC: "
50
51/* EC status register */ 51/* EC status register */
52#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ 52#define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */
53#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ 53#define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */
54#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ 54#define ACPI_EC_FLAG_BURST 0x10 /* burst mode */
55#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ 55#define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */
56
56/* EC commands */ 57/* EC commands */
57enum ec_command { 58enum ec_command {
58 ACPI_EC_COMMAND_READ = 0x80, 59 ACPI_EC_COMMAND_READ = 0x80,
@@ -61,6 +62,7 @@ enum ec_command {
61 ACPI_EC_BURST_DISABLE = 0x83, 62 ACPI_EC_BURST_DISABLE = 0x83,
62 ACPI_EC_COMMAND_QUERY = 0x84, 63 ACPI_EC_COMMAND_QUERY = 0x84,
63}; 64};
65
64/* EC events */ 66/* EC events */
65enum ec_event { 67enum ec_event {
66 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */ 68 ACPI_EC_EVENT_OBF_1 = 1, /* Output buffer full */
@@ -94,6 +96,16 @@ static struct acpi_driver acpi_ec_driver = {
94 96
95/* If we find an EC via the ECDT, we need to keep a ptr to its context */ 97/* If we find an EC via the ECDT, we need to keep a ptr to its context */
96/* External interfaces use first EC only, so remember */ 98/* External interfaces use first EC only, so remember */
99typedef int (*acpi_ec_query_func) (void *data);
100
101struct acpi_ec_query_handler {
102 struct list_head node;
103 acpi_ec_query_func func;
104 acpi_handle handle;
105 void *data;
106 u8 query_bit;
107};
108
97static struct acpi_ec { 109static struct acpi_ec {
98 acpi_handle handle; 110 acpi_handle handle;
99 unsigned long gpe; 111 unsigned long gpe;
@@ -104,6 +116,7 @@ static struct acpi_ec {
104 atomic_t query_pending; 116 atomic_t query_pending;
105 atomic_t event_count; 117 atomic_t event_count;
106 wait_queue_head_t wait; 118 wait_queue_head_t wait;
119 struct list_head list;
107} *boot_ec, *first_ec; 120} *boot_ec, *first_ec;
108 121
109/* -------------------------------------------------------------------------- 122/* --------------------------------------------------------------------------
@@ -245,7 +258,7 @@ static int acpi_ec_transaction(struct acpi_ec *ec, u8 command,
245 258
246 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0, 0); 259 status = acpi_ec_wait(ec, ACPI_EC_EVENT_IBF_0, 0, 0);
247 if (status) { 260 if (status) {
248 printk(KERN_DEBUG PREFIX 261 printk(KERN_ERR PREFIX
249 "input buffer is not empty, aborting transaction\n"); 262 "input buffer is not empty, aborting transaction\n");
250 goto end; 263 goto end;
251 } 264 }
@@ -394,21 +407,67 @@ static int acpi_ec_query(struct acpi_ec *ec, u8 * data)
394/* -------------------------------------------------------------------------- 407/* --------------------------------------------------------------------------
395 Event Management 408 Event Management
396 -------------------------------------------------------------------------- */ 409 -------------------------------------------------------------------------- */
410int acpi_ec_add_query_handler(struct acpi_ec *ec, u8 query_bit,
411 acpi_handle handle, acpi_ec_query_func func,
412 void *data)
413{
414 struct acpi_ec_query_handler *handler =
415 kzalloc(sizeof(struct acpi_ec_query_handler), GFP_KERNEL);
416 if (!handler)
417 return -ENOMEM;
418
419 handler->query_bit = query_bit;
420 handler->handle = handle;
421 handler->func = func;
422 handler->data = data;
423 mutex_lock(&ec->lock);
424 list_add_tail(&handler->node, &ec->list);
425 mutex_unlock(&ec->lock);
426 return 0;
427}
428
429EXPORT_SYMBOL_GPL(acpi_ec_add_query_handler);
430
431void acpi_ec_remove_query_handler(struct acpi_ec *ec, u8 query_bit)
432{
433 struct acpi_ec_query_handler *handler;
434 mutex_lock(&ec->lock);
435 list_for_each_entry(handler, &ec->list, node) {
436 if (query_bit == handler->query_bit) {
437 list_del(&handler->node);
438 kfree(handler);
439 break;
440 }
441 }
442 mutex_unlock(&ec->lock);
443}
444
445EXPORT_SYMBOL_GPL(acpi_ec_remove_query_handler);
397 446
398static void acpi_ec_gpe_query(void *ec_cxt) 447static void acpi_ec_gpe_query(void *ec_cxt)
399{ 448{
400 struct acpi_ec *ec = ec_cxt; 449 struct acpi_ec *ec = ec_cxt;
401 u8 value = 0; 450 u8 value = 0;
402 char object_name[8]; 451 struct acpi_ec_query_handler *handler, copy;
403 452
404 if (!ec || acpi_ec_query(ec, &value)) 453 if (!ec || acpi_ec_query(ec, &value))
405 return; 454 return;
406 455 mutex_lock(&ec->lock);
407 snprintf(object_name, 8, "_Q%2.2X", value); 456 list_for_each_entry(handler, &ec->list, node) {
408 457 if (value == handler->query_bit) {
409 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluating %s", object_name)); 458 /* have custom handler for this bit */
410 459 memcpy(&copy, handler, sizeof(copy));
411 acpi_evaluate_object(ec->handle, object_name, NULL, NULL); 460 mutex_unlock(&ec->lock);
461 if (copy.func) {
462 copy.func(copy.data);
463 } else if (copy.handle) {
464 acpi_evaluate_object(copy.handle, NULL, NULL, NULL);
465 }
466 return;
467 }
468 }
469 mutex_unlock(&ec->lock);
470 printk(KERN_ERR PREFIX "Handler for query 0x%x is not found!\n", value);
412} 471}
413 472
414static u32 acpi_ec_gpe_handler(void *data) 473static u32 acpi_ec_gpe_handler(void *data)
@@ -427,8 +486,7 @@ static u32 acpi_ec_gpe_handler(void *data)
427 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) { 486 if ((value & ACPI_EC_FLAG_SCI) && !atomic_read(&ec->query_pending)) {
428 atomic_set(&ec->query_pending, 1); 487 atomic_set(&ec->query_pending, 1);
429 status = 488 status =
430 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, 489 acpi_os_execute(OSL_EC_BURST_HANDLER, acpi_ec_gpe_query, ec);
431 ec);
432 } 490 }
433 491
434 return status == AE_OK ? 492 return status == AE_OK ?
@@ -454,57 +512,35 @@ acpi_ec_space_setup(acpi_handle region_handle,
454} 512}
455 513
456static acpi_status 514static acpi_status
457acpi_ec_space_handler(u32 function, 515acpi_ec_space_handler(u32 function, acpi_physical_address address,
458 acpi_physical_address address, 516 u32 bits, acpi_integer *value,
459 u32 bit_width,
460 acpi_integer * value,
461 void *handler_context, void *region_context) 517 void *handler_context, void *region_context)
462{ 518{
463 int result = 0;
464 struct acpi_ec *ec = handler_context; 519 struct acpi_ec *ec = handler_context;
465 u64 temp = *value; 520 int result = 0, i = 0;
466 acpi_integer f_v = 0; 521 u8 temp = 0;
467 int i = 0;
468 522
469 if ((address > 0xFF) || !value || !handler_context) 523 if ((address > 0xFF) || !value || !handler_context)
470 return AE_BAD_PARAMETER; 524 return AE_BAD_PARAMETER;
471 525
472 if (bit_width != 8 && acpi_strict) { 526 if (function != ACPI_READ && function != ACPI_WRITE)
473 return AE_BAD_PARAMETER; 527 return AE_BAD_PARAMETER;
474 }
475
476 next_byte:
477 switch (function) {
478 case ACPI_READ:
479 temp = 0;
480 result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
481 break;
482 case ACPI_WRITE:
483 result = acpi_ec_write(ec, (u8) address, (u8) temp);
484 break;
485 default:
486 result = -EINVAL;
487 goto out;
488 break;
489 }
490 528
491 bit_width -= 8; 529 if (bits != 8 && acpi_strict)
492 if (bit_width) { 530 return AE_BAD_PARAMETER;
493 if (function == ACPI_READ)
494 f_v |= temp << 8 * i;
495 if (function == ACPI_WRITE)
496 temp >>= 8;
497 i++;
498 address++;
499 goto next_byte;
500 }
501 531
502 if (function == ACPI_READ) { 532 while (bits - i > 0) {
503 f_v |= temp << 8 * i; 533 if (function == ACPI_READ) {
504 *value = f_v; 534 result = acpi_ec_read(ec, address, &temp);
535 (*value) |= ((acpi_integer)temp) << i;
536 } else {
537 temp = 0xff & ((*value) >> i);
538 result = acpi_ec_write(ec, address, temp);
539 }
540 i += 8;
541 ++address;
505 } 542 }
506 543
507 out:
508 switch (result) { 544 switch (result) {
509 case -EINVAL: 545 case -EINVAL:
510 return AE_BAD_PARAMETER; 546 return AE_BAD_PARAMETER;
@@ -597,9 +633,6 @@ static int acpi_ec_remove_fs(struct acpi_device *device)
597static acpi_status 633static acpi_status
598ec_parse_io_ports(struct acpi_resource *resource, void *context); 634ec_parse_io_ports(struct acpi_resource *resource, void *context);
599 635
600static acpi_status
601ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval);
602
603static struct acpi_ec *make_acpi_ec(void) 636static struct acpi_ec *make_acpi_ec(void)
604{ 637{
605 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL); 638 struct acpi_ec *ec = kzalloc(sizeof(struct acpi_ec), GFP_KERNEL);
@@ -610,13 +643,52 @@ static struct acpi_ec *make_acpi_ec(void)
610 atomic_set(&ec->event_count, 1); 643 atomic_set(&ec->event_count, 1);
611 mutex_init(&ec->lock); 644 mutex_init(&ec->lock);
612 init_waitqueue_head(&ec->wait); 645 init_waitqueue_head(&ec->wait);
646 INIT_LIST_HEAD(&ec->list);
613 647
614 return ec; 648 return ec;
615} 649}
616 650
651static acpi_status
652acpi_ec_register_query_methods(acpi_handle handle, u32 level,
653 void *context, void **return_value)
654{
655 struct acpi_namespace_node *node = handle;
656 struct acpi_ec *ec = context;
657 int value = 0;
658 if (sscanf(node->name.ascii, "_Q%x", &value) == 1) {
659 acpi_ec_add_query_handler(ec, value, handle, NULL, NULL);
660 }
661 return AE_OK;
662}
663
664static int ec_parse_device(struct acpi_ec *ec, acpi_handle handle)
665{
666 if (ACPI_FAILURE(acpi_walk_resources(handle, METHOD_NAME__CRS,
667 ec_parse_io_ports, ec)))
668 return -EINVAL;
669
670 /* Get GPE bit assignment (EC events). */
671 /* TODO: Add support for _GPE returning a package */
672 if (ACPI_FAILURE(acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe)))
673 return -EINVAL;
674
675 /* Use the global lock for all EC transactions? */
676 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
677
678 /* Find and register all query methods */
679 acpi_walk_namespace(ACPI_TYPE_METHOD, handle, 1,
680 acpi_ec_register_query_methods, ec, NULL);
681
682 ec->handle = handle;
683
684 printk(KERN_INFO PREFIX "GPE = 0x%lx, I/O: command/status = 0x%lx, data = 0x%lx",
685 ec->gpe, ec->command_addr, ec->data_addr);
686
687 return 0;
688}
689
617static int acpi_ec_add(struct acpi_device *device) 690static int acpi_ec_add(struct acpi_device *device)
618{ 691{
619 acpi_status status = AE_OK;
620 struct acpi_ec *ec = NULL; 692 struct acpi_ec *ec = NULL;
621 693
622 if (!device) 694 if (!device)
@@ -629,8 +701,7 @@ static int acpi_ec_add(struct acpi_device *device)
629 if (!ec) 701 if (!ec)
630 return -ENOMEM; 702 return -ENOMEM;
631 703
632 status = ec_parse_device(device->handle, 0, ec, NULL); 704 if (ec_parse_device(ec, device->handle)) {
633 if (status != AE_CTRL_TERMINATE) {
634 kfree(ec); 705 kfree(ec);
635 return -EINVAL; 706 return -EINVAL;
636 } 707 }
@@ -641,6 +712,8 @@ static int acpi_ec_add(struct acpi_device *device)
641 /* We might have incorrect info for GL at boot time */ 712 /* We might have incorrect info for GL at boot time */
642 mutex_lock(&boot_ec->lock); 713 mutex_lock(&boot_ec->lock);
643 boot_ec->global_lock = ec->global_lock; 714 boot_ec->global_lock = ec->global_lock;
715 /* Copy handlers from new ec into boot ec */
716 list_splice(&ec->list, &boot_ec->list);
644 mutex_unlock(&boot_ec->lock); 717 mutex_unlock(&boot_ec->lock);
645 kfree(ec); 718 kfree(ec);
646 ec = boot_ec; 719 ec = boot_ec;
@@ -651,22 +724,24 @@ static int acpi_ec_add(struct acpi_device *device)
651 acpi_driver_data(device) = ec; 724 acpi_driver_data(device) = ec;
652 725
653 acpi_ec_add_fs(device); 726 acpi_ec_add_fs(device);
654
655 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%s [%s] (gpe %d) interrupt mode.",
656 acpi_device_name(device), acpi_device_bid(device),
657 (u32) ec->gpe));
658
659 return 0; 727 return 0;
660} 728}
661 729
662static int acpi_ec_remove(struct acpi_device *device, int type) 730static int acpi_ec_remove(struct acpi_device *device, int type)
663{ 731{
664 struct acpi_ec *ec; 732 struct acpi_ec *ec;
733 struct acpi_ec_query_handler *handler;
665 734
666 if (!device) 735 if (!device)
667 return -EINVAL; 736 return -EINVAL;
668 737
669 ec = acpi_driver_data(device); 738 ec = acpi_driver_data(device);
739 mutex_lock(&ec->lock);
740 list_for_each_entry(handler, &ec->list, node) {
741 list_del(&handler->node);
742 kfree(handler);
743 }
744 mutex_unlock(&ec->lock);
670 acpi_ec_remove_fs(device); 745 acpi_ec_remove_fs(device);
671 acpi_driver_data(device) = NULL; 746 acpi_driver_data(device) = NULL;
672 if (ec == first_ec) 747 if (ec == first_ec)
@@ -722,15 +797,13 @@ static int ec_install_handlers(struct acpi_ec *ec)
722 return -ENODEV; 797 return -ENODEV;
723 } 798 }
724 799
725 /* EC is fully operational, allow queries */
726 atomic_set(&ec->query_pending, 0);
727
728 return 0; 800 return 0;
729} 801}
730 802
731static int acpi_ec_start(struct acpi_device *device) 803static int acpi_ec_start(struct acpi_device *device)
732{ 804{
733 struct acpi_ec *ec; 805 struct acpi_ec *ec;
806 int ret = 0;
734 807
735 if (!device) 808 if (!device)
736 return -EINVAL; 809 return -EINVAL;
@@ -740,14 +813,14 @@ static int acpi_ec_start(struct acpi_device *device)
740 if (!ec) 813 if (!ec)
741 return -EINVAL; 814 return -EINVAL;
742 815
743 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "gpe=0x%02lx, ports=0x%2lx,0x%2lx",
744 ec->gpe, ec->command_addr, ec->data_addr));
745
746 /* Boot EC is already working */ 816 /* Boot EC is already working */
747 if (ec == boot_ec) 817 if (ec != boot_ec)
748 return 0; 818 ret = ec_install_handlers(ec);
819
820 /* EC is fully operational, allow queries */
821 atomic_set(&ec->query_pending, 0);
749 822
750 return ec_install_handlers(ec); 823 return ret;
751} 824}
752 825
753static int acpi_ec_stop(struct acpi_device *device, int type) 826static int acpi_ec_stop(struct acpi_device *device, int type)
@@ -779,34 +852,6 @@ static int acpi_ec_stop(struct acpi_device *device, int type)
779 return 0; 852 return 0;
780} 853}
781 854
782static acpi_status
783ec_parse_device(acpi_handle handle, u32 Level, void *context, void **retval)
784{
785 acpi_status status;
786
787 struct acpi_ec *ec = context;
788 status = acpi_walk_resources(handle, METHOD_NAME__CRS,
789 ec_parse_io_ports, ec);
790 if (ACPI_FAILURE(status))
791 return status;
792
793 /* Get GPE bit assignment (EC events). */
794 /* TODO: Add support for _GPE returning a package */
795 status = acpi_evaluate_integer(handle, "_GPE", NULL, &ec->gpe);
796 if (ACPI_FAILURE(status))
797 return status;
798
799 /* Use the global lock for all EC transactions? */
800 acpi_evaluate_integer(handle, "_GLK", NULL, &ec->global_lock);
801
802 ec->handle = handle;
803
804 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "GPE=0x%02lx, ports=0x%2lx, 0x%2lx",
805 ec->gpe, ec->command_addr, ec->data_addr));
806
807 return AE_CTRL_TERMINATE;
808}
809
810int __init acpi_ec_ecdt_probe(void) 855int __init acpi_ec_ecdt_probe(void)
811{ 856{
812 int ret; 857 int ret;
@@ -825,7 +870,7 @@ int __init acpi_ec_ecdt_probe(void)
825 if (ACPI_FAILURE(status)) 870 if (ACPI_FAILURE(status))
826 goto error; 871 goto error;
827 872
828 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found ECDT")); 873 printk(KERN_INFO PREFIX "EC description table is found, configuring boot EC\n");
829 874
830 boot_ec->command_addr = ecdt_ptr->control.address; 875 boot_ec->command_addr = ecdt_ptr->control.address;
831 boot_ec->data_addr = ecdt_ptr->data.address; 876 boot_ec->data_addr = ecdt_ptr->data.address;
diff --git a/drivers/acpi/event.c b/drivers/acpi/event.c
index 3b23562e6f92..dfa5853b17f0 100644
--- a/drivers/acpi/event.c
+++ b/drivers/acpi/event.c
@@ -11,6 +11,8 @@
11#include <linux/init.h> 11#include <linux/init.h>
12#include <linux/poll.h> 12#include <linux/poll.h>
13#include <acpi/acpi_drivers.h> 13#include <acpi/acpi_drivers.h>
14#include <net/netlink.h>
15#include <net/genetlink.h>
14 16
15#define _COMPONENT ACPI_SYSTEM_COMPONENT 17#define _COMPONENT ACPI_SYSTEM_COMPONENT
16ACPI_MODULE_NAME("event"); 18ACPI_MODULE_NAME("event");
@@ -48,7 +50,6 @@ acpi_system_read_event(struct file *file, char __user * buffer, size_t count,
48 static int chars_remaining = 0; 50 static int chars_remaining = 0;
49 static char *ptr; 51 static char *ptr;
50 52
51
52 if (!chars_remaining) { 53 if (!chars_remaining) {
53 memset(&event, 0, sizeof(struct acpi_bus_event)); 54 memset(&event, 0, sizeof(struct acpi_bus_event));
54 55
@@ -106,23 +107,161 @@ static const struct file_operations acpi_system_event_ops = {
106 .poll = acpi_system_poll_event, 107 .poll = acpi_system_poll_event,
107}; 108};
108 109
110#ifdef CONFIG_NET
111unsigned int acpi_event_seqnum;
112struct acpi_genl_event {
113 acpi_device_class device_class;
114 char bus_id[15];
115 u32 type;
116 u32 data;
117};
118
119/* attributes of acpi_genl_family */
120enum {
121 ACPI_GENL_ATTR_UNSPEC,
122 ACPI_GENL_ATTR_EVENT, /* ACPI event info needed by user space */
123 __ACPI_GENL_ATTR_MAX,
124};
125#define ACPI_GENL_ATTR_MAX (__ACPI_GENL_ATTR_MAX - 1)
126
127/* commands supported by the acpi_genl_family */
128enum {
129 ACPI_GENL_CMD_UNSPEC,
130 ACPI_GENL_CMD_EVENT, /* kernel->user notifications for ACPI events */
131 __ACPI_GENL_CMD_MAX,
132};
133#define ACPI_GENL_CMD_MAX (__ACPI_GENL_CMD_MAX - 1)
134
135#define ACPI_GENL_FAMILY_NAME "acpi_event"
136#define ACPI_GENL_VERSION 0x01
137#define ACPI_GENL_MCAST_GROUP_NAME "acpi_mc_group"
138
139static struct genl_family acpi_event_genl_family = {
140 .id = GENL_ID_GENERATE,
141 .name = ACPI_GENL_FAMILY_NAME,
142 .version = ACPI_GENL_VERSION,
143 .maxattr = ACPI_GENL_ATTR_MAX,
144};
145
146static struct genl_multicast_group acpi_event_mcgrp = {
147 .name = ACPI_GENL_MCAST_GROUP_NAME,
148};
149
150int acpi_bus_generate_genetlink_event(struct acpi_device *device,
151 u8 type, int data)
152{
153 struct sk_buff *skb;
154 struct nlattr *attr;
155 struct acpi_genl_event *event;
156 void *msg_header;
157 int size;
158 int result;
159
160 /* allocate memory */
161 size = nla_total_size(sizeof(struct acpi_genl_event)) +
162 nla_total_size(0);
163
164 skb = genlmsg_new(size, GFP_ATOMIC);
165 if (!skb)
166 return -ENOMEM;
167
168 /* add the genetlink message header */
169 msg_header = genlmsg_put(skb, 0, acpi_event_seqnum++,
170 &acpi_event_genl_family, 0,
171 ACPI_GENL_CMD_EVENT);
172 if (!msg_header) {
173 nlmsg_free(skb);
174 return -ENOMEM;
175 }
176
177 /* fill the data */
178 attr =
179 nla_reserve(skb, ACPI_GENL_ATTR_EVENT,
180 sizeof(struct acpi_genl_event));
181 if (!attr) {
182 nlmsg_free(skb);
183 return -EINVAL;
184 }
185
186 event = nla_data(attr);
187 if (!event) {
188 nlmsg_free(skb);
189 return -EINVAL;
190 }
191
192 memset(event, 0, sizeof(struct acpi_genl_event));
193
194 strcpy(event->device_class, device->pnp.device_class);
195 strcpy(event->bus_id, device->dev.bus_id);
196 event->type = type;
197 event->data = data;
198
199 /* send multicast genetlink message */
200 result = genlmsg_end(skb, msg_header);
201 if (result < 0) {
202 nlmsg_free(skb);
203 return result;
204 }
205
206 result =
207 genlmsg_multicast(skb, 0, acpi_event_mcgrp.id, GFP_ATOMIC);
208 if (result)
209 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
210 "Failed to send a Genetlink message!\n"));
211 return 0;
212}
213
214static int acpi_event_genetlink_init(void)
215{
216 int result;
217
218 result = genl_register_family(&acpi_event_genl_family);
219 if (result)
220 return result;
221
222 result = genl_register_mc_group(&acpi_event_genl_family,
223 &acpi_event_mcgrp);
224 if (result)
225 genl_unregister_family(&acpi_event_genl_family);
226
227 return result;
228}
229
230#else
231int acpi_bus_generate_genetlink_event(struct acpi_device *device, u8 type,
232 int data)
233{
234 return 0;
235}
236
237static int acpi_event_genetlink_init(void)
238{
239 return -ENODEV;
240}
241#endif
242
109static int __init acpi_event_init(void) 243static int __init acpi_event_init(void)
110{ 244{
111 struct proc_dir_entry *entry; 245 struct proc_dir_entry *entry;
112 int error = 0; 246 int error = 0;
113 247
114
115 if (acpi_disabled) 248 if (acpi_disabled)
116 return 0; 249 return 0;
117 250
251 /* create genetlink for acpi event */
252 error = acpi_event_genetlink_init();
253 if (error)
254 printk(KERN_WARNING PREFIX
255 "Failed to create genetlink family for ACPI event\n");
256
118 /* 'event' [R] */ 257 /* 'event' [R] */
119 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir); 258 entry = create_proc_entry("event", S_IRUSR, acpi_root_dir);
120 if (entry) 259 if (entry)
121 entry->proc_fops = &acpi_system_event_ops; 260 entry->proc_fops = &acpi_system_event_ops;
122 else { 261 else
123 error = -ENODEV; 262 return -ENODEV;
124 } 263
125 return error; 264 return 0;
126} 265}
127 266
128subsys_initcall(acpi_event_init); 267fs_initcall(acpi_event_init);
diff --git a/drivers/acpi/events/evgpeblk.c b/drivers/acpi/events/evgpeblk.c
index 902c287b3a4f..361ebe6c4a6f 100644
--- a/drivers/acpi/events/evgpeblk.c
+++ b/drivers/acpi/events/evgpeblk.c
@@ -586,6 +586,10 @@ acpi_ev_delete_gpe_xrupt(struct acpi_gpe_xrupt_info *gpe_xrupt)
586 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock); 586 flags = acpi_os_acquire_lock(acpi_gbl_gpe_lock);
587 if (gpe_xrupt->previous) { 587 if (gpe_xrupt->previous) {
588 gpe_xrupt->previous->next = gpe_xrupt->next; 588 gpe_xrupt->previous->next = gpe_xrupt->next;
589 } else {
590 /* No previous, update list head */
591
592 acpi_gbl_gpe_xrupt_list_head = gpe_xrupt->next;
589 } 593 }
590 594
591 if (gpe_xrupt->next) { 595 if (gpe_xrupt->next) {
diff --git a/drivers/acpi/events/evrgnini.c b/drivers/acpi/events/evrgnini.c
index 400d90fca966..23ee7bc4a705 100644
--- a/drivers/acpi/events/evrgnini.c
+++ b/drivers/acpi/events/evrgnini.c
@@ -284,6 +284,7 @@ acpi_ev_pci_config_region_setup(acpi_handle handle,
284 } 284 }
285 285
286 if (!pci_device_node) { 286 if (!pci_device_node) {
287 ACPI_FREE(pci_id);
287 return_ACPI_STATUS(AE_AML_OPERAND_TYPE); 288 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
288 } 289 }
289 290
diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c
index 41427a41f620..4893e256e399 100644
--- a/drivers/acpi/glue.c
+++ b/drivers/acpi/glue.c
@@ -16,7 +16,7 @@
16#if ACPI_GLUE_DEBUG 16#if ACPI_GLUE_DEBUG
17#define DBG(x...) printk(PREFIX x) 17#define DBG(x...) printk(PREFIX x)
18#else 18#else
19#define DBG(x...) 19#define DBG(x...) do { } while(0)
20#endif 20#endif
21static LIST_HEAD(bus_type_list); 21static LIST_HEAD(bus_type_list);
22static DECLARE_RWSEM(bus_type_sem); 22static DECLARE_RWSEM(bus_type_sem);
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 0c9f15c54e8c..ab04d848b19d 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -36,13 +36,11 @@
36ACPI_MODULE_NAME("numa"); 36ACPI_MODULE_NAME("numa");
37 37
38static nodemask_t nodes_found_map = NODE_MASK_NONE; 38static nodemask_t nodes_found_map = NODE_MASK_NONE;
39#define PXM_INVAL -1
40#define NID_INVAL -1
41 39
42/* maps to convert between proximity domain and logical node ID */ 40/* maps to convert between proximity domain and logical node ID */
43static int pxm_to_node_map[MAX_PXM_DOMAINS] 41static int __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS]
44 = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL }; 42 = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL };
45static int node_to_pxm_map[MAX_NUMNODES] 43static int __cpuinitdata node_to_pxm_map[MAX_NUMNODES]
46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL }; 44 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
47 45
48int pxm_to_node(int pxm) 46int pxm_to_node(int pxm)
@@ -59,6 +57,12 @@ int node_to_pxm(int node)
59 return node_to_pxm_map[node]; 57 return node_to_pxm_map[node];
60} 58}
61 59
60void __acpi_map_pxm_to_node(int pxm, int node)
61{
62 pxm_to_node_map[pxm] = node;
63 node_to_pxm_map[node] = pxm;
64}
65
62int acpi_map_pxm_to_node(int pxm) 66int acpi_map_pxm_to_node(int pxm)
63{ 67{
64 int node = pxm_to_node_map[pxm]; 68 int node = pxm_to_node_map[pxm];
@@ -67,8 +71,7 @@ int acpi_map_pxm_to_node(int pxm)
67 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES) 71 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
68 return NID_INVAL; 72 return NID_INVAL;
69 node = first_unset_node(nodes_found_map); 73 node = first_unset_node(nodes_found_map);
70 pxm_to_node_map[pxm] = node; 74 __acpi_map_pxm_to_node(pxm, node);
71 node_to_pxm_map[node] = pxm;
72 node_set(node, nodes_found_map); 75 node_set(node, nodes_found_map);
73 } 76 }
74 77
@@ -83,7 +86,8 @@ void __cpuinit acpi_unmap_pxm_to_node(int node)
83 node_clear(node, nodes_found_map); 86 node_clear(node, nodes_found_map);
84} 87}
85 88
86void __init acpi_table_print_srat_entry(struct acpi_subtable_header * header) 89static void __init
90acpi_table_print_srat_entry(struct acpi_subtable_header *header)
87{ 91{
88 92
89 ACPI_FUNCTION_NAME("acpi_table_print_srat_entry"); 93 ACPI_FUNCTION_NAME("acpi_table_print_srat_entry");
@@ -200,7 +204,7 @@ static int __init acpi_parse_srat(struct acpi_table_header *table)
200 return 0; 204 return 0;
201} 205}
202 206
203int __init 207static int __init
204acpi_table_parse_srat(enum acpi_srat_type id, 208acpi_table_parse_srat(enum acpi_srat_type id,
205 acpi_table_entry_handler handler, unsigned int max_entries) 209 acpi_table_entry_handler handler, unsigned int max_entries)
206{ 210{
@@ -211,14 +215,13 @@ acpi_table_parse_srat(enum acpi_srat_type id,
211 215
212int __init acpi_numa_init(void) 216int __init acpi_numa_init(void)
213{ 217{
214 int result;
215
216 /* SRAT: Static Resource Affinity Table */ 218 /* SRAT: Static Resource Affinity Table */
217 if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) { 219 if (!acpi_table_parse(ACPI_SIG_SRAT, acpi_parse_srat)) {
218 result = acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY, 220 acpi_table_parse_srat(ACPI_SRAT_TYPE_CPU_AFFINITY,
219 acpi_parse_processor_affinity, 221 acpi_parse_processor_affinity, NR_CPUS);
220 NR_CPUS); 222 acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY,
221 result = acpi_table_parse_srat(ACPI_SRAT_TYPE_MEMORY_AFFINITY, acpi_parse_memory_affinity, NR_NODE_MEMBLKS); // IA64 specific 223 acpi_parse_memory_affinity,
224 NR_NODE_MEMBLKS);
222 } 225 }
223 226
224 /* SLIT: System Locality Information Table */ 227 /* SLIT: System Locality Information Table */
diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c
index 00d53c2fd1e8..12c09fafce9a 100644
--- a/drivers/acpi/osl.c
+++ b/drivers/acpi/osl.c
@@ -77,13 +77,7 @@ static struct workqueue_struct *kacpi_notify_wq;
77#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */ 77#define OSI_STRING_LENGTH_MAX 64 /* arbitrary */
78static char osi_additional_string[OSI_STRING_LENGTH_MAX]; 78static char osi_additional_string[OSI_STRING_LENGTH_MAX];
79 79
80#define OSI_LINUX_ENABLED 80static int osi_linux; /* disable _OSI(Linux) by default */
81#ifdef OSI_LINUX_ENABLED
82int osi_linux = 1; /* enable _OSI(Linux) by default */
83#else
84int osi_linux; /* disable _OSI(Linux) by default */
85#endif
86
87 81
88#ifdef CONFIG_DMI 82#ifdef CONFIG_DMI
89static struct __initdata dmi_system_id acpi_osl_dmi_table[]; 83static struct __initdata dmi_system_id acpi_osl_dmi_table[];
@@ -1183,17 +1177,10 @@ acpi_os_validate_interface (char *interface)
1183 if (!strcmp("Linux", interface)) { 1177 if (!strcmp("Linux", interface)) {
1184 printk(KERN_WARNING PREFIX 1178 printk(KERN_WARNING PREFIX
1185 "System BIOS is requesting _OSI(Linux)\n"); 1179 "System BIOS is requesting _OSI(Linux)\n");
1186#ifdef OSI_LINUX_ENABLED
1187 printk(KERN_WARNING PREFIX
1188 "Please test with \"acpi_osi=!Linux\"\n"
1189 "Please send dmidecode "
1190 "to linux-acpi@vger.kernel.org\n");
1191#else
1192 printk(KERN_WARNING PREFIX 1180 printk(KERN_WARNING PREFIX
1193 "If \"acpi_osi=Linux\" works better,\n" 1181 "If \"acpi_osi=Linux\" works better,\n"
1194 "Please send dmidecode " 1182 "Please send dmidecode "
1195 "to linux-acpi@vger.kernel.org\n"); 1183 "to linux-acpi@vger.kernel.org\n");
1196#endif
1197 if(osi_linux) 1184 if(osi_linux)
1198 return AE_OK; 1185 return AE_OK;
1199 } 1186 }
@@ -1227,36 +1214,14 @@ acpi_os_validate_address (
1227} 1214}
1228 1215
1229#ifdef CONFIG_DMI 1216#ifdef CONFIG_DMI
1230#ifdef OSI_LINUX_ENABLED
1231static int dmi_osi_not_linux(struct dmi_system_id *d)
1232{
1233 printk(KERN_NOTICE "%s detected: requires not _OSI(Linux)\n", d->ident);
1234 enable_osi_linux(0);
1235 return 0;
1236}
1237#else
1238static int dmi_osi_linux(struct dmi_system_id *d) 1217static int dmi_osi_linux(struct dmi_system_id *d)
1239{ 1218{
1240 printk(KERN_NOTICE "%s detected: requires _OSI(Linux)\n", d->ident); 1219 printk(KERN_NOTICE "%s detected: enabling _OSI(Linux)\n", d->ident);
1241 enable_osi_linux(1); 1220 enable_osi_linux(1);
1242 return 0; 1221 return 0;
1243} 1222}
1244#endif
1245 1223
1246static struct dmi_system_id acpi_osl_dmi_table[] __initdata = { 1224static struct dmi_system_id acpi_osl_dmi_table[] __initdata = {
1247#ifdef OSI_LINUX_ENABLED
1248 /*
1249 * Boxes that need NOT _OSI(Linux)
1250 */
1251 {
1252 .callback = dmi_osi_not_linux,
1253 .ident = "Toshiba Satellite P100",
1254 .matches = {
1255 DMI_MATCH(DMI_BOARD_VENDOR, "TOSHIBA"),
1256 DMI_MATCH(DMI_BOARD_NAME, "Satellite P100"),
1257 },
1258 },
1259#else
1260 /* 1225 /*
1261 * Boxes that need _OSI(Linux) 1226 * Boxes that need _OSI(Linux)
1262 */ 1227 */
@@ -1268,7 +1233,6 @@ static struct dmi_system_id acpi_osl_dmi_table[] __initdata = {
1268 DMI_MATCH(DMI_BOARD_NAME, "MPAD-MSAE Customer Reference Boards"), 1233 DMI_MATCH(DMI_BOARD_NAME, "MPAD-MSAE Customer Reference Boards"),
1269 }, 1234 },
1270 }, 1235 },
1271#endif
1272 {} 1236 {}
1273}; 1237};
1274#endif /* CONFIG_DMI */ 1238#endif /* CONFIG_DMI */
diff --git a/drivers/acpi/pci_link.c b/drivers/acpi/pci_link.c
index acc594771379..3448edd61dc4 100644
--- a/drivers/acpi/pci_link.c
+++ b/drivers/acpi/pci_link.c
@@ -733,7 +733,7 @@ static int acpi_pci_link_add(struct acpi_device *device)
733 /* query and set link->irq.active */ 733 /* query and set link->irq.active */
734 acpi_pci_link_get_current(link); 734 acpi_pci_link_get_current(link);
735 735
736 printk(PREFIX "%s [%s] (IRQs", acpi_device_name(device), 736 printk(KERN_INFO PREFIX "%s [%s] (IRQs", acpi_device_name(device),
737 acpi_device_bid(device)); 737 acpi_device_bid(device));
738 for (i = 0; i < link->irq.possible_count; i++) { 738 for (i = 0; i < link->irq.possible_count; i++) {
739 if (link->irq.active == link->irq.possible[i]) { 739 if (link->irq.active == link->irq.possible[i]) {
diff --git a/drivers/acpi/processor_core.c b/drivers/acpi/processor_core.c
index e1ca86dfdd66..81aceb5da7c7 100644
--- a/drivers/acpi/processor_core.c
+++ b/drivers/acpi/processor_core.c
@@ -66,6 +66,7 @@
66#define ACPI_PROCESSOR_FILE_LIMIT "limit" 66#define ACPI_PROCESSOR_FILE_LIMIT "limit"
67#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80 67#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80
68#define ACPI_PROCESSOR_NOTIFY_POWER 0x81 68#define ACPI_PROCESSOR_NOTIFY_POWER 0x81
69#define ACPI_PROCESSOR_NOTIFY_THROTTLING 0x82
69 70
70#define ACPI_PROCESSOR_LIMIT_USER 0 71#define ACPI_PROCESSOR_LIMIT_USER 0
71#define ACPI_PROCESSOR_LIMIT_THERMAL 1 72#define ACPI_PROCESSOR_LIMIT_THERMAL 1
@@ -84,6 +85,8 @@ static int acpi_processor_info_open_fs(struct inode *inode, struct file *file);
84static void acpi_processor_notify(acpi_handle handle, u32 event, void *data); 85static void acpi_processor_notify(acpi_handle handle, u32 event, void *data);
85static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu); 86static acpi_status acpi_processor_hotadd_init(acpi_handle handle, int *p_cpu);
86static int acpi_processor_handle_eject(struct acpi_processor *pr); 87static int acpi_processor_handle_eject(struct acpi_processor *pr);
88extern int acpi_processor_tstate_has_changed(struct acpi_processor *pr);
89
87 90
88static struct acpi_driver acpi_processor_driver = { 91static struct acpi_driver acpi_processor_driver = {
89 .name = "processor", 92 .name = "processor",
@@ -696,6 +699,9 @@ static void acpi_processor_notify(acpi_handle handle, u32 event, void *data)
696 acpi_processor_cst_has_changed(pr); 699 acpi_processor_cst_has_changed(pr);
697 acpi_bus_generate_event(device, event, 0); 700 acpi_bus_generate_event(device, event, 0);
698 break; 701 break;
702 case ACPI_PROCESSOR_NOTIFY_THROTTLING:
703 acpi_processor_tstate_has_changed(pr);
704 acpi_bus_generate_event(device, event, 0);
699 default: 705 default:
700 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 706 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
701 "Unsupported event [0x%x]\n", event)); 707 "Unsupported event [0x%x]\n", event));
diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
index bb5d23be4260..a898991f77cb 100644
--- a/drivers/acpi/processor_idle.c
+++ b/drivers/acpi/processor_idle.c
@@ -490,7 +490,17 @@ static void acpi_processor_idle(void)
490 490
491 case ACPI_STATE_C3: 491 case ACPI_STATE_C3:
492 492
493 if (pr->flags.bm_check) { 493 /*
494 * disable bus master
495 * bm_check implies we need ARB_DIS
496 * !bm_check implies we need cache flush
497 * bm_control implies whether we can do ARB_DIS
498 *
499 * That leaves a case where bm_check is set and bm_control is
500 * not set. In that case we cannot do much, we enter C3
501 * without doing anything.
502 */
503 if (pr->flags.bm_check && pr->flags.bm_control) {
494 if (atomic_inc_return(&c3_cpu_count) == 504 if (atomic_inc_return(&c3_cpu_count) ==
495 num_online_cpus()) { 505 num_online_cpus()) {
496 /* 506 /*
@@ -499,7 +509,7 @@ static void acpi_processor_idle(void)
499 */ 509 */
500 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1); 510 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 1);
501 } 511 }
502 } else { 512 } else if (!pr->flags.bm_check) {
503 /* SMP with no shared cache... Invalidate cache */ 513 /* SMP with no shared cache... Invalidate cache */
504 ACPI_FLUSH_CPU_CACHE(); 514 ACPI_FLUSH_CPU_CACHE();
505 } 515 }
@@ -511,7 +521,7 @@ static void acpi_processor_idle(void)
511 acpi_cstate_enter(cx); 521 acpi_cstate_enter(cx);
512 /* Get end time (ticks) */ 522 /* Get end time (ticks) */
513 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address); 523 t2 = inl(acpi_gbl_FADT.xpm_timer_block.address);
514 if (pr->flags.bm_check) { 524 if (pr->flags.bm_check && pr->flags.bm_control) {
515 /* Enable bus master arbitration */ 525 /* Enable bus master arbitration */
516 atomic_dec(&c3_cpu_count); 526 atomic_dec(&c3_cpu_count);
517 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0); 527 acpi_set_register(ACPI_BITREG_ARB_DISABLE, 0);
@@ -961,9 +971,9 @@ static void acpi_processor_power_verify_c3(struct acpi_processor *pr,
961 if (pr->flags.bm_check) { 971 if (pr->flags.bm_check) {
962 /* bus mastering control is necessary */ 972 /* bus mastering control is necessary */
963 if (!pr->flags.bm_control) { 973 if (!pr->flags.bm_control) {
974 /* In this case we enter C3 without bus mastering */
964 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 975 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
965 "C3 support requires bus mastering control\n")); 976 "C3 support without bus mastering control\n"));
966 return;
967 } 977 }
968 } else { 978 } else {
969 /* 979 /*
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index b33486009f41..3f55d1f90c11 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -44,17 +44,231 @@
44#define _COMPONENT ACPI_PROCESSOR_COMPONENT 44#define _COMPONENT ACPI_PROCESSOR_COMPONENT
45ACPI_MODULE_NAME("processor_throttling"); 45ACPI_MODULE_NAME("processor_throttling");
46 46
47static int acpi_processor_get_throttling(struct acpi_processor *pr);
48int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
49
50static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
51{
52 acpi_status status = 0;
53 unsigned long tpc = 0;
54
55 if (!pr)
56 return -EINVAL;
57 status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc);
58 if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
59 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC"));
60 return -ENODEV;
61 }
62 pr->throttling_platform_limit = (int)tpc;
63 return 0;
64}
65
66int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
67{
68 return acpi_processor_get_platform_limit(pr);
69}
70
71/* --------------------------------------------------------------------------
72 _PTC, _TSS, _TSD support
73 -------------------------------------------------------------------------- */
74static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
75{
76 int result = 0;
77 acpi_status status = 0;
78 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
79 union acpi_object *ptc = NULL;
80 union acpi_object obj = { 0 };
81
82 status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
83 if (ACPI_FAILURE(status)) {
84 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PTC"));
85 return -ENODEV;
86 }
87
88 ptc = (union acpi_object *)buffer.pointer;
89 if (!ptc || (ptc->type != ACPI_TYPE_PACKAGE)
90 || (ptc->package.count != 2)) {
91 printk(KERN_ERR PREFIX "Invalid _PTC data\n");
92 result = -EFAULT;
93 goto end;
94 }
95
96 /*
97 * control_register
98 */
99
100 obj = ptc->package.elements[0];
101
102 if ((obj.type != ACPI_TYPE_BUFFER)
103 || (obj.buffer.length < sizeof(struct acpi_ptc_register))
104 || (obj.buffer.pointer == NULL)) {
105 printk(KERN_ERR PREFIX
106 "Invalid _PTC data (control_register)\n");
107 result = -EFAULT;
108 goto end;
109 }
110 memcpy(&pr->throttling.control_register, obj.buffer.pointer,
111 sizeof(struct acpi_ptc_register));
112
113 /*
114 * status_register
115 */
116
117 obj = ptc->package.elements[1];
118
119 if ((obj.type != ACPI_TYPE_BUFFER)
120 || (obj.buffer.length < sizeof(struct acpi_ptc_register))
121 || (obj.buffer.pointer == NULL)) {
122 printk(KERN_ERR PREFIX "Invalid _PTC data (status_register)\n");
123 result = -EFAULT;
124 goto end;
125 }
126
127 memcpy(&pr->throttling.status_register, obj.buffer.pointer,
128 sizeof(struct acpi_ptc_register));
129
130 end:
131 kfree(buffer.pointer);
132
133 return result;
134}
135static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
136{
137 int result = 0;
138 acpi_status status = AE_OK;
139 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
140 struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
141 struct acpi_buffer state = { 0, NULL };
142 union acpi_object *tss = NULL;
143 int i;
144
145 status = acpi_evaluate_object(pr->handle, "_TSS", NULL, &buffer);
146 if (ACPI_FAILURE(status)) {
147 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSS"));
148 return -ENODEV;
149 }
150
151 tss = buffer.pointer;
152 if (!tss || (tss->type != ACPI_TYPE_PACKAGE)) {
153 printk(KERN_ERR PREFIX "Invalid _TSS data\n");
154 result = -EFAULT;
155 goto end;
156 }
157
158 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
159 tss->package.count));
160
161 pr->throttling.state_count = tss->package.count;
162 pr->throttling.states_tss =
163 kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
164 GFP_KERNEL);
165 if (!pr->throttling.states_tss) {
166 result = -ENOMEM;
167 goto end;
168 }
169
170 for (i = 0; i < pr->throttling.state_count; i++) {
171
172 struct acpi_processor_tx_tss *tx =
173 (struct acpi_processor_tx_tss *)&(pr->throttling.
174 states_tss[i]);
175
176 state.length = sizeof(struct acpi_processor_tx_tss);
177 state.pointer = tx;
178
179 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
180
181 status = acpi_extract_package(&(tss->package.elements[i]),
182 &format, &state);
183 if (ACPI_FAILURE(status)) {
184 ACPI_EXCEPTION((AE_INFO, status, "Invalid _TSS data"));
185 result = -EFAULT;
186 kfree(pr->throttling.states_tss);
187 goto end;
188 }
189
190 if (!tx->freqpercentage) {
191 printk(KERN_ERR PREFIX
192 "Invalid _TSS data: freq is zero\n");
193 result = -EFAULT;
194 kfree(pr->throttling.states_tss);
195 goto end;
196 }
197 }
198
199 end:
200 kfree(buffer.pointer);
201
202 return result;
203}
204static int acpi_processor_get_tsd(struct acpi_processor *pr)
205{
206 int result = 0;
207 acpi_status status = AE_OK;
208 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
209 struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
210 struct acpi_buffer state = { 0, NULL };
211 union acpi_object *tsd = NULL;
212 struct acpi_tsd_package *pdomain;
213
214 status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer);
215 if (ACPI_FAILURE(status)) {
216 return -ENODEV;
217 }
218
219 tsd = buffer.pointer;
220 if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) {
221 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
222 result = -EFAULT;
223 goto end;
224 }
225
226 if (tsd->package.count != 1) {
227 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
228 result = -EFAULT;
229 goto end;
230 }
231
232 pdomain = &(pr->throttling.domain_info);
233
234 state.length = sizeof(struct acpi_tsd_package);
235 state.pointer = pdomain;
236
237 status = acpi_extract_package(&(tsd->package.elements[0]),
238 &format, &state);
239 if (ACPI_FAILURE(status)) {
240 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
241 result = -EFAULT;
242 goto end;
243 }
244
245 if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) {
246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:num_entries\n"));
247 result = -EFAULT;
248 goto end;
249 }
250
251 if (pdomain->revision != ACPI_TSD_REV0_REVISION) {
252 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:revision\n"));
253 result = -EFAULT;
254 goto end;
255 }
256
257 end:
258 kfree(buffer.pointer);
259 return result;
260}
261
47/* -------------------------------------------------------------------------- 262/* --------------------------------------------------------------------------
48 Throttling Control 263 Throttling Control
49 -------------------------------------------------------------------------- */ 264 -------------------------------------------------------------------------- */
50static int acpi_processor_get_throttling(struct acpi_processor *pr) 265static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
51{ 266{
52 int state = 0; 267 int state = 0;
53 u32 value = 0; 268 u32 value = 0;
54 u32 duty_mask = 0; 269 u32 duty_mask = 0;
55 u32 duty_value = 0; 270 u32 duty_value = 0;
56 271
57
58 if (!pr) 272 if (!pr)
59 return -EINVAL; 273 return -EINVAL;
60 274
@@ -94,13 +308,115 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
94 return 0; 308 return 0;
95} 309}
96 310
97int acpi_processor_set_throttling(struct acpi_processor *pr, int state) 311static int acpi_read_throttling_status(struct acpi_processor_throttling
312 *throttling)
313{
314 int value = -1;
315 switch (throttling->status_register.space_id) {
316 case ACPI_ADR_SPACE_SYSTEM_IO:
317 acpi_os_read_port((acpi_io_address) throttling->status_register.
318 address, &value,
319 (u32) throttling->status_register.bit_width *
320 8);
321 break;
322 case ACPI_ADR_SPACE_FIXED_HARDWARE:
323 printk(KERN_ERR PREFIX
324 "HARDWARE addr space,NOT supported yet\n");
325 break;
326 default:
327 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
328 (u32) (throttling->status_register.space_id));
329 }
330 return value;
331}
332
333static int acpi_write_throttling_state(struct acpi_processor_throttling
334 *throttling, int value)
335{
336 int ret = -1;
337
338 switch (throttling->control_register.space_id) {
339 case ACPI_ADR_SPACE_SYSTEM_IO:
340 acpi_os_write_port((acpi_io_address) throttling->
341 control_register.address, value,
342 (u32) throttling->control_register.
343 bit_width * 8);
344 ret = 0;
345 break;
346 case ACPI_ADR_SPACE_FIXED_HARDWARE:
347 printk(KERN_ERR PREFIX
348 "HARDWARE addr space,NOT supported yet\n");
349 break;
350 default:
351 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
352 (u32) (throttling->control_register.space_id));
353 }
354 return ret;
355}
356
357static int acpi_get_throttling_state(struct acpi_processor *pr, int value)
358{
359 int i;
360
361 for (i = 0; i < pr->throttling.state_count; i++) {
362 struct acpi_processor_tx_tss *tx =
363 (struct acpi_processor_tx_tss *)&(pr->throttling.
364 states_tss[i]);
365 if (tx->control == value)
366 break;
367 }
368 if (i > pr->throttling.state_count)
369 i = -1;
370 return i;
371}
372
373static int acpi_get_throttling_value(struct acpi_processor *pr, int state)
374{
375 int value = -1;
376 if (state >= 0 && state <= pr->throttling.state_count) {
377 struct acpi_processor_tx_tss *tx =
378 (struct acpi_processor_tx_tss *)&(pr->throttling.
379 states_tss[state]);
380 value = tx->control;
381 }
382 return value;
383}
384
385static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
386{
387 int state = 0;
388 u32 value = 0;
389
390 if (!pr)
391 return -EINVAL;
392
393 if (!pr->flags.throttling)
394 return -ENODEV;
395
396 pr->throttling.state = 0;
397 local_irq_disable();
398 value = acpi_read_throttling_status(&pr->throttling);
399 if (value >= 0) {
400 state = acpi_get_throttling_state(pr, value);
401 pr->throttling.state = state;
402 }
403 local_irq_enable();
404
405 return 0;
406}
407
408static int acpi_processor_get_throttling(struct acpi_processor *pr)
409{
410 return pr->throttling.acpi_processor_get_throttling(pr);
411}
412
413static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
414 int state)
98{ 415{
99 u32 value = 0; 416 u32 value = 0;
100 u32 duty_mask = 0; 417 u32 duty_mask = 0;
101 u32 duty_value = 0; 418 u32 duty_value = 0;
102 419
103
104 if (!pr) 420 if (!pr)
105 return -EINVAL; 421 return -EINVAL;
106 422
@@ -113,6 +429,8 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
113 if (state == pr->throttling.state) 429 if (state == pr->throttling.state)
114 return 0; 430 return 0;
115 431
432 if (state < pr->throttling_platform_limit)
433 return -EPERM;
116 /* 434 /*
117 * Calculate the duty_value and duty_mask. 435 * Calculate the duty_value and duty_mask.
118 */ 436 */
@@ -165,12 +483,51 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
165 return 0; 483 return 0;
166} 484}
167 485
486static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
487 int state)
488{
489 u32 value = 0;
490
491 if (!pr)
492 return -EINVAL;
493
494 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
495 return -EINVAL;
496
497 if (!pr->flags.throttling)
498 return -ENODEV;
499
500 if (state == pr->throttling.state)
501 return 0;
502
503 if (state < pr->throttling_platform_limit)
504 return -EPERM;
505
506 local_irq_disable();
507
508 value = acpi_get_throttling_value(pr, state);
509 if (value >= 0) {
510 acpi_write_throttling_state(&pr->throttling, value);
511 pr->throttling.state = state;
512 }
513 local_irq_enable();
514
515 return 0;
516}
517
518int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
519{
520 return pr->throttling.acpi_processor_set_throttling(pr, state);
521}
522
168int acpi_processor_get_throttling_info(struct acpi_processor *pr) 523int acpi_processor_get_throttling_info(struct acpi_processor *pr)
169{ 524{
170 int result = 0; 525 int result = 0;
171 int step = 0; 526 int step = 0;
172 int i = 0; 527 int i = 0;
173 528 int no_ptc = 0;
529 int no_tss = 0;
530 int no_tsd = 0;
174 531
175 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 532 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
176 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n", 533 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -182,6 +539,21 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
182 return -EINVAL; 539 return -EINVAL;
183 540
184 /* TBD: Support ACPI 2.0 objects */ 541 /* TBD: Support ACPI 2.0 objects */
542 no_ptc = acpi_processor_get_throttling_control(pr);
543 no_tss = acpi_processor_get_throttling_states(pr);
544 no_tsd = acpi_processor_get_tsd(pr);
545
546 if (no_ptc || no_tss) {
547 pr->throttling.acpi_processor_get_throttling =
548 &acpi_processor_get_throttling_fadt;
549 pr->throttling.acpi_processor_set_throttling =
550 &acpi_processor_set_throttling_fadt;
551 } else {
552 pr->throttling.acpi_processor_get_throttling =
553 &acpi_processor_get_throttling_ptc;
554 pr->throttling.acpi_processor_set_throttling =
555 &acpi_processor_set_throttling_ptc;
556 }
185 557
186 if (!pr->throttling.address) { 558 if (!pr->throttling.address) {
187 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n")); 559 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
@@ -262,7 +634,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
262 int i = 0; 634 int i = 0;
263 int result = 0; 635 int result = 0;
264 636
265
266 if (!pr) 637 if (!pr)
267 goto end; 638 goto end;
268 639
@@ -280,15 +651,25 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
280 } 651 }
281 652
282 seq_printf(seq, "state count: %d\n" 653 seq_printf(seq, "state count: %d\n"
283 "active state: T%d\n", 654 "active state: T%d\n"
284 pr->throttling.state_count, pr->throttling.state); 655 "state available: T%d to T%d\n",
656 pr->throttling.state_count, pr->throttling.state,
657 pr->throttling_platform_limit,
658 pr->throttling.state_count - 1);
285 659
286 seq_puts(seq, "states:\n"); 660 seq_puts(seq, "states:\n");
287 for (i = 0; i < pr->throttling.state_count; i++) 661 if (acpi_processor_get_throttling == acpi_processor_get_throttling_fadt)
288 seq_printf(seq, " %cT%d: %02d%%\n", 662 for (i = 0; i < pr->throttling.state_count; i++)
289 (i == pr->throttling.state ? '*' : ' '), i, 663 seq_printf(seq, " %cT%d: %02d%%\n",
290 (pr->throttling.states[i].performance ? pr-> 664 (i == pr->throttling.state ? '*' : ' '), i,
291 throttling.states[i].performance / 10 : 0)); 665 (pr->throttling.states[i].performance ? pr->
666 throttling.states[i].performance / 10 : 0));
667 else
668 for (i = 0; i < pr->throttling.state_count; i++)
669 seq_printf(seq, " %cT%d: %02d%%\n",
670 (i == pr->throttling.state ? '*' : ' '), i,
671 (int)pr->throttling.states_tss[i].
672 freqpercentage);
292 673
293 end: 674 end:
294 return 0; 675 return 0;
@@ -301,7 +682,7 @@ static int acpi_processor_throttling_open_fs(struct inode *inode,
301 PDE(inode)->data); 682 PDE(inode)->data);
302} 683}
303 684
304static ssize_t acpi_processor_write_throttling(struct file * file, 685static ssize_t acpi_processor_write_throttling(struct file *file,
305 const char __user * buffer, 686 const char __user * buffer,
306 size_t count, loff_t * data) 687 size_t count, loff_t * data)
307{ 688{
@@ -310,7 +691,6 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
310 struct acpi_processor *pr = m->private; 691 struct acpi_processor *pr = m->private;
311 char state_string[12] = { '\0' }; 692 char state_string[12] = { '\0' };
312 693
313
314 if (!pr || (count > sizeof(state_string) - 1)) 694 if (!pr || (count > sizeof(state_string) - 1))
315 return -EINVAL; 695 return -EINVAL;
316 696
diff --git a/drivers/acpi/sbs.c b/drivers/acpi/sbs.c
index c1bae106833c..974d00ccfe84 100644
--- a/drivers/acpi/sbs.c
+++ b/drivers/acpi/sbs.c
@@ -127,7 +127,7 @@ static int acpi_sbs_resume(struct acpi_device *device);
127static struct acpi_driver acpi_sbs_driver = { 127static struct acpi_driver acpi_sbs_driver = {
128 .name = "sbs", 128 .name = "sbs",
129 .class = ACPI_SBS_CLASS, 129 .class = ACPI_SBS_CLASS,
130 .ids = ACPI_SBS_HID, 130 .ids = "ACPI0001,ACPI0005",
131 .ops = { 131 .ops = {
132 .add = acpi_sbs_add, 132 .add = acpi_sbs_add,
133 .remove = acpi_sbs_remove, 133 .remove = acpi_sbs_remove,
@@ -176,10 +176,8 @@ struct acpi_battery {
176}; 176};
177 177
178struct acpi_sbs { 178struct acpi_sbs {
179 acpi_handle handle;
180 int base; 179 int base;
181 struct acpi_device *device; 180 struct acpi_device *device;
182 struct acpi_ec_smbus *smbus;
183 struct mutex mutex; 181 struct mutex mutex;
184 int sbsm_present; 182 int sbsm_present;
185 int sbsm_batteries_supported; 183 int sbsm_batteries_supported;
@@ -511,7 +509,7 @@ static int acpi_sbsm_get_info(struct acpi_sbs *sbs)
511 "acpi_sbs_read_word() failed")); 509 "acpi_sbs_read_word() failed"));
512 goto end; 510 goto end;
513 } 511 }
514 512 sbs->sbsm_present = 1;
515 sbs->sbsm_batteries_supported = battery_system_info & 0x000f; 513 sbs->sbsm_batteries_supported = battery_system_info & 0x000f;
516 514
517 end: 515 end:
@@ -1630,13 +1628,12 @@ static int acpi_sbs_add(struct acpi_device *device)
1630{ 1628{
1631 struct acpi_sbs *sbs = NULL; 1629 struct acpi_sbs *sbs = NULL;
1632 int result = 0, remove_result = 0; 1630 int result = 0, remove_result = 0;
1633 unsigned long sbs_obj;
1634 int id; 1631 int id;
1635 acpi_status status = AE_OK; 1632 acpi_status status = AE_OK;
1636 unsigned long val; 1633 unsigned long val;
1637 1634
1638 status = 1635 status =
1639 acpi_evaluate_integer(device->parent->handle, "_EC", NULL, &val); 1636 acpi_evaluate_integer(device->handle, "_EC", NULL, &val);
1640 if (ACPI_FAILURE(status)) { 1637 if (ACPI_FAILURE(status)) {
1641 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Error obtaining _EC")); 1638 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "Error obtaining _EC"));
1642 return -EIO; 1639 return -EIO;
@@ -1653,7 +1650,7 @@ static int acpi_sbs_add(struct acpi_device *device)
1653 1650
1654 sbs_mutex_lock(sbs); 1651 sbs_mutex_lock(sbs);
1655 1652
1656 sbs->base = (val & 0xff00ull) >> 8; 1653 sbs->base = 0xff & (val >> 8);
1657 sbs->device = device; 1654 sbs->device = device;
1658 1655
1659 strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME); 1656 strcpy(acpi_device_name(device), ACPI_SBS_DEVICE_NAME);
@@ -1665,24 +1662,10 @@ static int acpi_sbs_add(struct acpi_device *device)
1665 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "acpi_ac_add() failed")); 1662 ACPI_EXCEPTION((AE_INFO, AE_ERROR, "acpi_ac_add() failed"));
1666 goto end; 1663 goto end;
1667 } 1664 }
1668 status = acpi_evaluate_integer(device->handle, "_SBS", NULL, &sbs_obj);
1669 if (status) {
1670 ACPI_EXCEPTION((AE_INFO, status,
1671 "acpi_evaluate_integer() failed"));
1672 result = -EIO;
1673 goto end;
1674 }
1675 if (sbs_obj > 0) {
1676 result = acpi_sbsm_get_info(sbs);
1677 if (result) {
1678 ACPI_EXCEPTION((AE_INFO, AE_ERROR,
1679 "acpi_sbsm_get_info() failed"));
1680 goto end;
1681 }
1682 sbs->sbsm_present = 1;
1683 }
1684 1665
1685 if (sbs->sbsm_present == 0) { 1666 acpi_sbsm_get_info(sbs);
1667
1668 if (!sbs->sbsm_present) {
1686 result = acpi_battery_add(sbs, 0); 1669 result = acpi_battery_add(sbs, 0);
1687 if (result) { 1670 if (result) {
1688 ACPI_EXCEPTION((AE_INFO, AE_ERROR, 1671 ACPI_EXCEPTION((AE_INFO, AE_ERROR,
@@ -1702,8 +1685,6 @@ static int acpi_sbs_add(struct acpi_device *device)
1702 } 1685 }
1703 } 1686 }
1704 1687
1705 sbs->handle = device->handle;
1706
1707 init_timer(&sbs->update_timer); 1688 init_timer(&sbs->update_timer);
1708 result = acpi_check_update_proc(sbs); 1689 result = acpi_check_update_proc(sbs);
1709 if (result) 1690 if (result)
diff --git a/drivers/acpi/sleep/main.c b/drivers/acpi/sleep/main.c
index 42127c0d612c..3279e72a94f8 100644
--- a/drivers/acpi/sleep/main.c
+++ b/drivers/acpi/sleep/main.c
@@ -210,11 +210,6 @@ static void acpi_hibernation_finish(void)
210 210
211 /* reset firmware waking vector */ 211 /* reset firmware waking vector */
212 acpi_set_firmware_waking_vector((acpi_physical_address) 0); 212 acpi_set_firmware_waking_vector((acpi_physical_address) 0);
213
214 if (init_8259A_after_S1) {
215 printk("Broken toshiba laptop -> kicking interrupts\n");
216 init_8259A(0);
217 }
218} 213}
219 214
220static int acpi_hibernation_pre_restore(void) 215static int acpi_hibernation_pre_restore(void)
diff --git a/drivers/acpi/system.c b/drivers/acpi/system.c
index 83a8d3097904..edee2806e37b 100644
--- a/drivers/acpi/system.c
+++ b/drivers/acpi/system.c
@@ -39,15 +39,12 @@ ACPI_MODULE_NAME("system");
39 39
40#define ACPI_SYSTEM_CLASS "system" 40#define ACPI_SYSTEM_CLASS "system"
41#define ACPI_SYSTEM_DEVICE_NAME "System" 41#define ACPI_SYSTEM_DEVICE_NAME "System"
42#define ACPI_SYSTEM_FILE_INFO "info"
43#define ACPI_SYSTEM_FILE_EVENT "event"
44#define ACPI_SYSTEM_FILE_DSDT "dsdt"
45#define ACPI_SYSTEM_FILE_FADT "fadt"
46 42
47/* 43/*
48 * Make ACPICA version work as module param 44 * Make ACPICA version work as module param
49 */ 45 */
50static int param_get_acpica_version(char *buffer, struct kernel_param *kp) { 46static int param_get_acpica_version(char *buffer, struct kernel_param *kp)
47{
51 int result; 48 int result;
52 49
53 result = sprintf(buffer, "%x", ACPI_CA_VERSION); 50 result = sprintf(buffer, "%x", ACPI_CA_VERSION);
@@ -58,9 +55,126 @@ static int param_get_acpica_version(char *buffer, struct kernel_param *kp) {
58module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444); 55module_param_call(acpica_version, NULL, param_get_acpica_version, NULL, 0444);
59 56
60/* -------------------------------------------------------------------------- 57/* --------------------------------------------------------------------------
58 FS Interface (/sys)
59 -------------------------------------------------------------------------- */
60static LIST_HEAD(acpi_table_attr_list);
61static struct kobject tables_kobj;
62
63struct acpi_table_attr {
64 struct bin_attribute attr;
65 char name[8];
66 int instance;
67 struct list_head node;
68};
69
70static ssize_t acpi_table_show(struct kobject *kobj,
71 struct bin_attribute *bin_attr, char *buf,
72 loff_t offset, size_t count)
73{
74 struct acpi_table_attr *table_attr =
75 container_of(bin_attr, struct acpi_table_attr, attr);
76 struct acpi_table_header *table_header = NULL;
77 acpi_status status;
78 ssize_t ret_count = count;
79
80 status =
81 acpi_get_table(table_attr->name, table_attr->instance,
82 &table_header);
83 if (ACPI_FAILURE(status))
84 return -ENODEV;
85
86 if (offset >= table_header->length) {
87 ret_count = 0;
88 goto end;
89 }
90
91 if (offset + ret_count > table_header->length)
92 ret_count = table_header->length - offset;
93
94 memcpy(buf, ((char *)table_header) + offset, ret_count);
95
96 end:
97 return ret_count;
98}
99
100static void acpi_table_attr_init(struct acpi_table_attr *table_attr,
101 struct acpi_table_header *table_header)
102{
103 struct acpi_table_header *header = NULL;
104 struct acpi_table_attr *attr = NULL;
105
106 memcpy(table_attr->name, table_header->signature, ACPI_NAME_SIZE);
107
108 list_for_each_entry(attr, &acpi_table_attr_list, node) {
109 if (!memcmp(table_header->signature, attr->name,
110 ACPI_NAME_SIZE))
111 if (table_attr->instance < attr->instance)
112 table_attr->instance = attr->instance;
113 }
114 table_attr->instance++;
115
116 if (table_attr->instance > 1 || (table_attr->instance == 1 &&
117 !acpi_get_table(table_header->
118 signature, 2,
119 &header)))
120 sprintf(table_attr->name + 4, "%d", table_attr->instance);
121
122 table_attr->attr.size = 0;
123 table_attr->attr.read = acpi_table_show;
124 table_attr->attr.attr.name = table_attr->name;
125 table_attr->attr.attr.mode = 0444;
126 table_attr->attr.attr.owner = THIS_MODULE;
127
128 return;
129}
130
131static int acpi_system_sysfs_init(void)
132{
133 struct acpi_table_attr *table_attr;
134 struct acpi_table_header *table_header = NULL;
135 int table_index = 0;
136 int result;
137
138 tables_kobj.parent = &acpi_subsys.kobj;
139 kobject_set_name(&tables_kobj, "tables");
140 result = kobject_register(&tables_kobj);
141 if (result)
142 return result;
143
144 do {
145 result = acpi_get_table_by_index(table_index, &table_header);
146 if (!result) {
147 table_index++;
148 table_attr = NULL;
149 table_attr =
150 kzalloc(sizeof(struct acpi_table_attr), GFP_KERNEL);
151 if (!table_attr)
152 return -ENOMEM;
153
154 acpi_table_attr_init(table_attr, table_header);
155 result =
156 sysfs_create_bin_file(&tables_kobj,
157 &table_attr->attr);
158 if (result) {
159 kfree(table_attr);
160 return result;
161 } else
162 list_add_tail(&table_attr->node,
163 &acpi_table_attr_list);
164 }
165 } while (!result);
166
167 return 0;
168}
169
170/* --------------------------------------------------------------------------
61 FS Interface (/proc) 171 FS Interface (/proc)
62 -------------------------------------------------------------------------- */ 172 -------------------------------------------------------------------------- */
63#ifdef CONFIG_ACPI_PROCFS 173#ifdef CONFIG_ACPI_PROCFS
174#define ACPI_SYSTEM_FILE_INFO "info"
175#define ACPI_SYSTEM_FILE_EVENT "event"
176#define ACPI_SYSTEM_FILE_DSDT "dsdt"
177#define ACPI_SYSTEM_FILE_FADT "fadt"
64 178
65static int acpi_system_read_info(struct seq_file *seq, void *offset) 179static int acpi_system_read_info(struct seq_file *seq, void *offset)
66{ 180{
@@ -80,7 +194,6 @@ static const struct file_operations acpi_system_info_ops = {
80 .llseek = seq_lseek, 194 .llseek = seq_lseek,
81 .release = single_release, 195 .release = single_release,
82}; 196};
83#endif
84 197
85static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t, 198static ssize_t acpi_system_read_dsdt(struct file *, char __user *, size_t,
86 loff_t *); 199 loff_t *);
@@ -97,13 +210,11 @@ acpi_system_read_dsdt(struct file *file,
97 struct acpi_table_header *dsdt = NULL; 210 struct acpi_table_header *dsdt = NULL;
98 ssize_t res; 211 ssize_t res;
99 212
100
101 status = acpi_get_table(ACPI_SIG_DSDT, 1, &dsdt); 213 status = acpi_get_table(ACPI_SIG_DSDT, 1, &dsdt);
102 if (ACPI_FAILURE(status)) 214 if (ACPI_FAILURE(status))
103 return -ENODEV; 215 return -ENODEV;
104 216
105 res = simple_read_from_buffer(buffer, count, ppos, 217 res = simple_read_from_buffer(buffer, count, ppos, dsdt, dsdt->length);
106 dsdt, dsdt->length);
107 218
108 return res; 219 return res;
109} 220}
@@ -123,28 +234,21 @@ acpi_system_read_fadt(struct file *file,
123 struct acpi_table_header *fadt = NULL; 234 struct acpi_table_header *fadt = NULL;
124 ssize_t res; 235 ssize_t res;
125 236
126
127 status = acpi_get_table(ACPI_SIG_FADT, 1, &fadt); 237 status = acpi_get_table(ACPI_SIG_FADT, 1, &fadt);
128 if (ACPI_FAILURE(status)) 238 if (ACPI_FAILURE(status))
129 return -ENODEV; 239 return -ENODEV;
130 240
131 res = simple_read_from_buffer(buffer, count, ppos, 241 res = simple_read_from_buffer(buffer, count, ppos, fadt, fadt->length);
132 fadt, fadt->length);
133 242
134 return res; 243 return res;
135} 244}
136 245
137static int __init acpi_system_init(void) 246static int acpi_system_procfs_init(void)
138{ 247{
139 struct proc_dir_entry *entry; 248 struct proc_dir_entry *entry;
140 int error = 0; 249 int error = 0;
141 char *name; 250 char *name;
142 251
143
144 if (acpi_disabled)
145 return 0;
146
147#ifdef CONFIG_ACPI_PROCFS
148 /* 'info' [R] */ 252 /* 'info' [R] */
149 name = ACPI_SYSTEM_FILE_INFO; 253 name = ACPI_SYSTEM_FILE_INFO;
150 entry = create_proc_entry(name, S_IRUGO, acpi_root_dir); 254 entry = create_proc_entry(name, S_IRUGO, acpi_root_dir);
@@ -153,7 +257,6 @@ static int __init acpi_system_init(void)
153 else { 257 else {
154 entry->proc_fops = &acpi_system_info_ops; 258 entry->proc_fops = &acpi_system_info_ops;
155 } 259 }
156#endif
157 260
158 /* 'dsdt' [R] */ 261 /* 'dsdt' [R] */
159 name = ACPI_SYSTEM_FILE_DSDT; 262 name = ACPI_SYSTEM_FILE_DSDT;
@@ -177,12 +280,32 @@ static int __init acpi_system_init(void)
177 Error: 280 Error:
178 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir); 281 remove_proc_entry(ACPI_SYSTEM_FILE_FADT, acpi_root_dir);
179 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir); 282 remove_proc_entry(ACPI_SYSTEM_FILE_DSDT, acpi_root_dir);
180#ifdef CONFIG_ACPI_PROCFS
181 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir); 283 remove_proc_entry(ACPI_SYSTEM_FILE_INFO, acpi_root_dir);
182#endif
183 284
184 error = -EFAULT; 285 error = -EFAULT;
185 goto Done; 286 goto Done;
186} 287}
288#else
289static int acpi_system_procfs_init(void)
290{
291 return 0;
292}
293#endif
294
295static int __init acpi_system_init(void)
296{
297 int result = 0;
298
299 if (acpi_disabled)
300 return 0;
301
302 result = acpi_system_procfs_init();
303 if (result)
304 return result;
305
306 result = acpi_system_sysfs_init();
307
308 return result;
309}
187 310
188subsys_initcall(acpi_system_init); 311subsys_initcall(acpi_system_init);
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/tables/tbfadt.c
index 1285e91474fb..002bb33003af 100644
--- a/drivers/acpi/tables/tbfadt.c
+++ b/drivers/acpi/tables/tbfadt.c
@@ -211,14 +211,17 @@ void acpi_tb_parse_fadt(acpi_native_uint table_index, u8 flags)
211 * DESCRIPTION: Get a local copy of the FADT and convert it to a common format. 211 * DESCRIPTION: Get a local copy of the FADT and convert it to a common format.
212 * Performs validation on some important FADT fields. 212 * Performs validation on some important FADT fields.
213 * 213 *
214 * NOTE: We create a local copy of the FADT regardless of the version.
215 *
214 ******************************************************************************/ 216 ******************************************************************************/
215 217
216void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) 218void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
217{ 219{
218 220
219 /* 221 /*
220 * Check if the FADT is larger than what we know about (ACPI 2.0 version). 222 * Check if the FADT is larger than the largest table that we expect
221 * Truncate the table, but make some noise. 223 * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue
224 * a warning.
222 */ 225 */
223 if (length > sizeof(struct acpi_table_fadt)) { 226 if (length > sizeof(struct acpi_table_fadt)) {
224 ACPI_WARNING((AE_INFO, 227 ACPI_WARNING((AE_INFO,
@@ -227,10 +230,12 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
227 sizeof(struct acpi_table_fadt))); 230 sizeof(struct acpi_table_fadt)));
228 } 231 }
229 232
230 /* Copy the entire FADT locally. Zero first for tb_convert_fadt */ 233 /* Clear the entire local FADT */
231 234
232 ACPI_MEMSET(&acpi_gbl_FADT, 0, sizeof(struct acpi_table_fadt)); 235 ACPI_MEMSET(&acpi_gbl_FADT, 0, sizeof(struct acpi_table_fadt));
233 236
237 /* Copy the original FADT, up to sizeof (struct acpi_table_fadt) */
238
234 ACPI_MEMCPY(&acpi_gbl_FADT, table, 239 ACPI_MEMCPY(&acpi_gbl_FADT, table,
235 ACPI_MIN(length, sizeof(struct acpi_table_fadt))); 240 ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
236 241
@@ -251,7 +256,7 @@ void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length)
251 * RETURN: None 256 * RETURN: None
252 * 257 *
253 * DESCRIPTION: Converts all versions of the FADT to a common internal format. 258 * DESCRIPTION: Converts all versions of the FADT to a common internal format.
254 * -> Expand all 32-bit addresses to 64-bit. 259 * Expand all 32-bit addresses to 64-bit.
255 * 260 *
256 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), 261 * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt),
257 * and must contain a copy of the actual FADT. 262 * and must contain a copy of the actual FADT.
@@ -292,8 +297,23 @@ static void acpi_tb_convert_fadt(void)
292 } 297 }
293 298
294 /* 299 /*
295 * Expand the 32-bit V1.0 addresses to the 64-bit "X" generic address 300 * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which
296 * structures as necessary. 301 * should be zero are indeed zero. This will workaround BIOSs that
302 * inadvertently place values in these fields.
303 *
304 * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at
305 * offset 45, 55, 95, and the word located at offset 109, 110.
306 */
307 if (acpi_gbl_FADT.header.revision < 3) {
308 acpi_gbl_FADT.preferred_profile = 0;
309 acpi_gbl_FADT.pstate_control = 0;
310 acpi_gbl_FADT.cst_control = 0;
311 acpi_gbl_FADT.boot_flags = 0;
312 }
313
314 /*
315 * Expand the ACPI 1.0 32-bit V1.0 addresses to the ACPI 2.0 64-bit "X"
316 * generic address structures as necessary.
297 */ 317 */
298 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { 318 for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) {
299 target = 319 target =
@@ -349,18 +369,6 @@ static void acpi_tb_convert_fadt(void)
349 acpi_gbl_FADT.xpm1a_event_block.space_id; 369 acpi_gbl_FADT.xpm1a_event_block.space_id;
350 370
351 } 371 }
352
353 /*
354 * For ACPI 1.0 FADTs, ensure that reserved fields (which should be zero)
355 * are indeed zero. This will workaround BIOSs that inadvertently placed
356 * values in these fields.
357 */
358 if (acpi_gbl_FADT.header.revision < 3) {
359 acpi_gbl_FADT.preferred_profile = 0;
360 acpi_gbl_FADT.pstate_control = 0;
361 acpi_gbl_FADT.cst_control = 0;
362 acpi_gbl_FADT.boot_flags = 0;
363 }
364} 372}
365 373
366/****************************************************************************** 374/******************************************************************************
diff --git a/drivers/acpi/utilities/uteval.c b/drivers/acpi/utilities/uteval.c
index 8ec6f8e48138..f112af433e36 100644
--- a/drivers/acpi/utilities/uteval.c
+++ b/drivers/acpi/utilities/uteval.c
@@ -62,16 +62,13 @@ acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc,
62static char *acpi_interfaces_supported[] = { 62static char *acpi_interfaces_supported[] = {
63 /* Operating System Vendor Strings */ 63 /* Operating System Vendor Strings */
64 64
65 "Windows 2000", 65 "Windows 2000", /* Windows 2000 */
66 "Windows 2001", 66 "Windows 2001", /* Windows XP */
67 "Windows 2001 SP0", 67 "Windows 2001 SP1", /* Windows XP SP1 */
68 "Windows 2001 SP1", 68 "Windows 2001 SP2", /* Windows XP SP2 */
69 "Windows 2001 SP2", 69 "Windows 2001.1", /* Windows Server 2003 */
70 "Windows 2001 SP3", 70 "Windows 2001.1 SP1", /* Windows Server 2003 SP1 - Added 03/2006 */
71 "Windows 2001 SP4", 71 "Windows 2006", /* Windows Vista - Added 03/2006 */
72 "Windows 2001.1",
73 "Windows 2001.1 SP1", /* Added 03/2006 */
74 "Windows 2006", /* Added 03/2006 */
75 72
76 /* Feature Group Strings */ 73 /* Feature Group Strings */
77 74
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 00d25b347255..04ea697f72bf 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -33,6 +33,7 @@
33#include <linux/seq_file.h> 33#include <linux/seq_file.h>
34 34
35#include <linux/backlight.h> 35#include <linux/backlight.h>
36#include <linux/video_output.h>
36#include <asm/uaccess.h> 37#include <asm/uaccess.h>
37 38
38#include <acpi/acpi_bus.h> 39#include <acpi/acpi_bus.h>
@@ -169,6 +170,7 @@ struct acpi_video_device {
169 struct acpi_device *dev; 170 struct acpi_device *dev;
170 struct acpi_video_device_brightness *brightness; 171 struct acpi_video_device_brightness *brightness;
171 struct backlight_device *backlight; 172 struct backlight_device *backlight;
173 struct output_device *output_dev;
172}; 174};
173 175
174/* bus */ 176/* bus */
@@ -272,13 +274,17 @@ static int acpi_video_get_next_level(struct acpi_video_device *device,
272 u32 level_current, u32 event); 274 u32 level_current, u32 event);
273static void acpi_video_switch_brightness(struct acpi_video_device *device, 275static void acpi_video_switch_brightness(struct acpi_video_device *device,
274 int event); 276 int event);
277static int acpi_video_device_get_state(struct acpi_video_device *device,
278 unsigned long *state);
279static int acpi_video_output_get(struct output_device *od);
280static int acpi_video_device_set_state(struct acpi_video_device *device, int state);
275 281
276/*backlight device sysfs support*/ 282/*backlight device sysfs support*/
277static int acpi_video_get_brightness(struct backlight_device *bd) 283static int acpi_video_get_brightness(struct backlight_device *bd)
278{ 284{
279 unsigned long cur_level; 285 unsigned long cur_level;
280 struct acpi_video_device *vd = 286 struct acpi_video_device *vd =
281 (struct acpi_video_device *)class_get_devdata(&bd->class_dev); 287 (struct acpi_video_device *)bl_get_data(bd);
282 acpi_video_device_lcd_get_level_current(vd, &cur_level); 288 acpi_video_device_lcd_get_level_current(vd, &cur_level);
283 return (int) cur_level; 289 return (int) cur_level;
284} 290}
@@ -287,7 +293,7 @@ static int acpi_video_set_brightness(struct backlight_device *bd)
287{ 293{
288 int request_level = bd->props.brightness; 294 int request_level = bd->props.brightness;
289 struct acpi_video_device *vd = 295 struct acpi_video_device *vd =
290 (struct acpi_video_device *)class_get_devdata(&bd->class_dev); 296 (struct acpi_video_device *)bl_get_data(bd);
291 acpi_video_device_lcd_set_level(vd, request_level); 297 acpi_video_device_lcd_set_level(vd, request_level);
292 return 0; 298 return 0;
293} 299}
@@ -297,6 +303,28 @@ static struct backlight_ops acpi_backlight_ops = {
297 .update_status = acpi_video_set_brightness, 303 .update_status = acpi_video_set_brightness,
298}; 304};
299 305
306/*video output device sysfs support*/
307static int acpi_video_output_get(struct output_device *od)
308{
309 unsigned long state;
310 struct acpi_video_device *vd =
311 (struct acpi_video_device *)class_get_devdata(&od->class_dev);
312 acpi_video_device_get_state(vd, &state);
313 return (int)state;
314}
315
316static int acpi_video_output_set(struct output_device *od)
317{
318 unsigned long state = od->request_state;
319 struct acpi_video_device *vd=
320 (struct acpi_video_device *)class_get_devdata(&od->class_dev);
321 return acpi_video_device_set_state(vd, state);
322}
323
324static struct output_properties acpi_output_properties = {
325 .set_state = acpi_video_output_set,
326 .get_status = acpi_video_output_get,
327};
300/* -------------------------------------------------------------------------- 328/* --------------------------------------------------------------------------
301 Video Management 329 Video Management
302 -------------------------------------------------------------------------- */ 330 -------------------------------------------------------------------------- */
@@ -531,7 +559,6 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
531 559
532static void acpi_video_device_find_cap(struct acpi_video_device *device) 560static void acpi_video_device_find_cap(struct acpi_video_device *device)
533{ 561{
534 acpi_integer status;
535 acpi_handle h_dummy1; 562 acpi_handle h_dummy1;
536 int i; 563 int i;
537 u32 max_level = 0; 564 u32 max_level = 0;
@@ -565,50 +592,55 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
565 device->cap._DSS = 1; 592 device->cap._DSS = 1;
566 } 593 }
567 594
568 status = acpi_video_device_lcd_query_levels(device, &obj); 595 if (ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device, &obj))) {
569 596
570 if (obj && obj->type == ACPI_TYPE_PACKAGE && obj->package.count >= 2) { 597 if (obj->package.count >= 2) {
571 int count = 0; 598 int count = 0;
572 union acpi_object *o; 599 union acpi_object *o;
573 600
574 br = kzalloc(sizeof(*br), GFP_KERNEL); 601 br = kzalloc(sizeof(*br), GFP_KERNEL);
575 if (!br) { 602 if (!br) {
576 printk(KERN_ERR "can't allocate memory\n"); 603 printk(KERN_ERR "can't allocate memory\n");
577 } else {
578 br->levels = kmalloc(obj->package.count *
579 sizeof *(br->levels), GFP_KERNEL);
580 if (!br->levels)
581 goto out;
582
583 for (i = 0; i < obj->package.count; i++) {
584 o = (union acpi_object *)&obj->package.
585 elements[i];
586 if (o->type != ACPI_TYPE_INTEGER) {
587 printk(KERN_ERR PREFIX "Invalid data\n");
588 continue;
589 }
590 br->levels[count] = (u32) o->integer.value;
591 if (br->levels[count] > max_level)
592 max_level = br->levels[count];
593 count++;
594 }
595 out:
596 if (count < 2) {
597 kfree(br->levels);
598 kfree(br);
599 } else { 604 } else {
600 br->count = count; 605 br->levels = kmalloc(obj->package.count *
601 device->brightness = br; 606 sizeof *(br->levels), GFP_KERNEL);
602 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 607 if (!br->levels)
603 "found %d brightness levels\n", 608 goto out;
604 count)); 609
610 for (i = 0; i < obj->package.count; i++) {
611 o = (union acpi_object *)&obj->package.
612 elements[i];
613 if (o->type != ACPI_TYPE_INTEGER) {
614 printk(KERN_ERR PREFIX "Invalid data\n");
615 continue;
616 }
617 br->levels[count] = (u32) o->integer.value;
618
619 if (br->levels[count] > max_level)
620 max_level = br->levels[count];
621 count++;
622 }
623 out:
624 if (count < 2) {
625 kfree(br->levels);
626 kfree(br);
627 } else {
628 br->count = count;
629 device->brightness = br;
630 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
631 "found %d brightness levels\n",
632 count));
633 }
605 } 634 }
606 } 635 }
636
637 } else {
638 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available LCD brightness level\n"));
607 } 639 }
608 640
609 kfree(obj); 641 kfree(obj);
610 642
611 if (device->cap._BCL && device->cap._BCM && device->cap._BQC){ 643 if (device->cap._BCL && device->cap._BCM && device->cap._BQC && max_level > 0){
612 unsigned long tmp; 644 unsigned long tmp;
613 static int count = 0; 645 static int count = 0;
614 char *name; 646 char *name;
@@ -626,6 +658,17 @@ static void acpi_video_device_find_cap(struct acpi_video_device *device)
626 658
627 kfree(name); 659 kfree(name);
628 } 660 }
661 if (device->cap._DCS && device->cap._DSS){
662 static int count = 0;
663 char *name;
664 name = kzalloc(MAX_NAME_LEN, GFP_KERNEL);
665 if (!name)
666 return;
667 sprintf(name, "acpi_video%d", count++);
668 device->output_dev = video_output_register(name,
669 NULL, device, &acpi_output_properties);
670 kfree(name);
671 }
629 return; 672 return;
630} 673}
631 674
@@ -1669,6 +1712,7 @@ static int acpi_video_bus_put_one_device(struct acpi_video_device *device)
1669 ACPI_DEVICE_NOTIFY, 1712 ACPI_DEVICE_NOTIFY,
1670 acpi_video_device_notify); 1713 acpi_video_device_notify);
1671 backlight_device_unregister(device->backlight); 1714 backlight_device_unregister(device->backlight);
1715 video_output_unregister(device->output_dev);
1672 return 0; 1716 return 0;
1673} 1717}
1674 1718
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index a9ab30fefffc..2b0c601e422e 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -142,6 +142,7 @@ void set_trace_device(struct device *dev)
142{ 142{
143 dev_hash_value = hash_string(DEVSEED, dev->bus_id, DEVHASH); 143 dev_hash_value = hash_string(DEVSEED, dev->bus_id, DEVHASH);
144} 144}
145EXPORT_SYMBOL(set_trace_device);
145 146
146/* 147/*
147 * We could just take the "tracedata" index into the .tracedata 148 * We could just take the "tracedata" index into the .tracedata
@@ -162,6 +163,7 @@ void generate_resume_trace(void *tracedata, unsigned int user)
162 file_hash_value = hash_string(lineno, file, FILEHASH); 163 file_hash_value = hash_string(lineno, file, FILEHASH);
163 set_magic_time(user_hash_value, file_hash_value, dev_hash_value); 164 set_magic_time(user_hash_value, file_hash_value, dev_hash_value);
164} 165}
166EXPORT_SYMBOL(generate_resume_trace);
165 167
166extern char __tracedata_start, __tracedata_end; 168extern char __tracedata_start, __tracedata_end;
167static int show_file_hash(unsigned int value) 169static int show_file_hash(unsigned int value)
@@ -170,7 +172,8 @@ static int show_file_hash(unsigned int value)
170 char *tracedata; 172 char *tracedata;
171 173
172 match = 0; 174 match = 0;
173 for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ; tracedata += 6) { 175 for (tracedata = &__tracedata_start ; tracedata < &__tracedata_end ;
176 tracedata += 2 + sizeof(unsigned long)) {
174 unsigned short lineno = *(unsigned short *)tracedata; 177 unsigned short lineno = *(unsigned short *)tracedata;
175 const char *file = *(const char **)(tracedata + 2); 178 const char *file = *(const char **)(tracedata + 2);
176 unsigned int hash = hash_string(lineno, file, FILEHASH); 179 unsigned int hash = hash_string(lineno, file, FILEHASH);
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 819c829125fb..a7a099027fca 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -8,6 +8,7 @@
8obj-$(CONFIG_MAC_FLOPPY) += swim3.o 8obj-$(CONFIG_MAC_FLOPPY) += swim3.o
9obj-$(CONFIG_BLK_DEV_FD) += floppy.o 9obj-$(CONFIG_BLK_DEV_FD) += floppy.o
10obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o 10obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o
11obj-$(CONFIG_PS3_DISK) += ps3disk.o
11obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o 12obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
12obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o 13obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
13obj-$(CONFIG_BLK_DEV_RAM) += rd.o 14obj-$(CONFIG_BLK_DEV_RAM) += rd.o
diff --git a/drivers/block/ps3disk.c b/drivers/block/ps3disk.c
new file mode 100644
index 000000000000..170fb33dba97
--- /dev/null
+++ b/drivers/block/ps3disk.c
@@ -0,0 +1,630 @@
1/*
2 * PS3 Disk Storage Driver
3 *
4 * Copyright (C) 2007 Sony Computer Entertainment Inc.
5 * Copyright 2007 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <linux/ata.h>
22#include <linux/blkdev.h>
23
24#include <asm/lv1call.h>
25#include <asm/ps3stor.h>
26#include <asm/firmware.h>
27
28
29#define DEVICE_NAME "ps3disk"
30
31#define BOUNCE_SIZE (64*1024)
32
33#define PS3DISK_MAX_DISKS 16
34#define PS3DISK_MINORS 16
35
36
37#define PS3DISK_NAME "ps3d%c"
38
39
40struct ps3disk_private {
41 spinlock_t lock; /* Request queue spinlock */
42 struct request_queue *queue;
43 struct gendisk *gendisk;
44 unsigned int blocking_factor;
45 struct request *req;
46 u64 raw_capacity;
47 unsigned char model[ATA_ID_PROD_LEN+1];
48};
49
50
51#define LV1_STORAGE_SEND_ATA_COMMAND (2)
52#define LV1_STORAGE_ATA_HDDOUT (0x23)
53
54struct lv1_ata_cmnd_block {
55 u16 features;
56 u16 sector_count;
57 u16 LBA_low;
58 u16 LBA_mid;
59 u16 LBA_high;
60 u8 device;
61 u8 command;
62 u32 is_ext;
63 u32 proto;
64 u32 in_out;
65 u32 size;
66 u64 buffer;
67 u32 arglen;
68};
69
70enum lv1_ata_proto {
71 NON_DATA_PROTO = 0,
72 PIO_DATA_IN_PROTO = 1,
73 PIO_DATA_OUT_PROTO = 2,
74 DMA_PROTO = 3
75};
76
77enum lv1_ata_in_out {
78 DIR_WRITE = 0, /* memory -> device */
79 DIR_READ = 1 /* device -> memory */
80};
81
82static int ps3disk_major;
83
84
85static struct block_device_operations ps3disk_fops = {
86 .owner = THIS_MODULE,
87};
88
89
90static void ps3disk_scatter_gather(struct ps3_storage_device *dev,
91 struct request *req, int gather)
92{
93 unsigned int offset = 0;
94 struct bio *bio;
95 sector_t sector;
96 struct bio_vec *bvec;
97 unsigned int i = 0, j;
98 size_t size;
99 void *buf;
100
101 rq_for_each_bio(bio, req) {
102 sector = bio->bi_sector;
103 dev_dbg(&dev->sbd.core,
104 "%s:%u: bio %u: %u segs %u sectors from %lu\n",
105 __func__, __LINE__, i, bio_segments(bio),
106 bio_sectors(bio), sector);
107 bio_for_each_segment(bvec, bio, j) {
108 size = bvec->bv_len;
109 buf = __bio_kmap_atomic(bio, j, KM_IRQ0);
110 if (gather)
111 memcpy(dev->bounce_buf+offset, buf, size);
112 else
113 memcpy(buf, dev->bounce_buf+offset, size);
114 offset += size;
115 flush_kernel_dcache_page(bio_iovec_idx(bio, j)->bv_page);
116 __bio_kunmap_atomic(bio, KM_IRQ0);
117 }
118 i++;
119 }
120}
121
122static int ps3disk_submit_request_sg(struct ps3_storage_device *dev,
123 struct request *req)
124{
125 struct ps3disk_private *priv = dev->sbd.core.driver_data;
126 int write = rq_data_dir(req), res;
127 const char *op = write ? "write" : "read";
128 u64 start_sector, sectors;
129 unsigned int region_id = dev->regions[dev->region_idx].id;
130
131#ifdef DEBUG
132 unsigned int n = 0;
133 struct bio *bio;
134
135 rq_for_each_bio(bio, req)
136 n++;
137 dev_dbg(&dev->sbd.core,
138 "%s:%u: %s req has %u bios for %lu sectors %lu hard sectors\n",
139 __func__, __LINE__, op, n, req->nr_sectors,
140 req->hard_nr_sectors);
141#endif
142
143 start_sector = req->sector * priv->blocking_factor;
144 sectors = req->nr_sectors * priv->blocking_factor;
145 dev_dbg(&dev->sbd.core, "%s:%u: %s %lu sectors starting at %lu\n",
146 __func__, __LINE__, op, sectors, start_sector);
147
148 if (write) {
149 ps3disk_scatter_gather(dev, req, 1);
150
151 res = lv1_storage_write(dev->sbd.dev_id, region_id,
152 start_sector, sectors, 0,
153 dev->bounce_lpar, &dev->tag);
154 } else {
155 res = lv1_storage_read(dev->sbd.dev_id, region_id,
156 start_sector, sectors, 0,
157 dev->bounce_lpar, &dev->tag);
158 }
159 if (res) {
160 dev_err(&dev->sbd.core, "%s:%u: %s failed %d\n", __func__,
161 __LINE__, op, res);
162 end_request(req, 0);
163 return 0;
164 }
165
166 priv->req = req;
167 return 1;
168}
169
170static int ps3disk_submit_flush_request(struct ps3_storage_device *dev,
171 struct request *req)
172{
173 struct ps3disk_private *priv = dev->sbd.core.driver_data;
174 u64 res;
175
176 dev_dbg(&dev->sbd.core, "%s:%u: flush request\n", __func__, __LINE__);
177
178 res = lv1_storage_send_device_command(dev->sbd.dev_id,
179 LV1_STORAGE_ATA_HDDOUT, 0, 0, 0,
180 0, &dev->tag);
181 if (res) {
182 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%lx\n",
183 __func__, __LINE__, res);
184 end_request(req, 0);
185 return 0;
186 }
187
188 priv->req = req;
189 return 1;
190}
191
192static void ps3disk_do_request(struct ps3_storage_device *dev,
193 request_queue_t *q)
194{
195 struct request *req;
196
197 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
198
199 while ((req = elv_next_request(q))) {
200 if (blk_fs_request(req)) {
201 if (ps3disk_submit_request_sg(dev, req))
202 break;
203 } else if (req->cmd_type == REQ_TYPE_FLUSH) {
204 if (ps3disk_submit_flush_request(dev, req))
205 break;
206 } else {
207 blk_dump_rq_flags(req, DEVICE_NAME " bad request");
208 end_request(req, 0);
209 continue;
210 }
211 }
212}
213
214static void ps3disk_request(request_queue_t *q)
215{
216 struct ps3_storage_device *dev = q->queuedata;
217 struct ps3disk_private *priv = dev->sbd.core.driver_data;
218
219 if (priv->req) {
220 dev_dbg(&dev->sbd.core, "%s:%u busy\n", __func__, __LINE__);
221 return;
222 }
223
224 ps3disk_do_request(dev, q);
225}
226
227static irqreturn_t ps3disk_interrupt(int irq, void *data)
228{
229 struct ps3_storage_device *dev = data;
230 struct ps3disk_private *priv;
231 struct request *req;
232 int res, read, uptodate;
233 u64 tag, status;
234 unsigned long num_sectors;
235 const char *op;
236
237 res = lv1_storage_get_async_status(dev->sbd.dev_id, &tag, &status);
238
239 if (tag != dev->tag)
240 dev_err(&dev->sbd.core,
241 "%s:%u: tag mismatch, got %lx, expected %lx\n",
242 __func__, __LINE__, tag, dev->tag);
243
244 if (res) {
245 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n",
246 __func__, __LINE__, res, status);
247 return IRQ_HANDLED;
248 }
249
250 priv = dev->sbd.core.driver_data;
251 req = priv->req;
252 if (!req) {
253 dev_dbg(&dev->sbd.core,
254 "%s:%u non-block layer request completed\n", __func__,
255 __LINE__);
256 dev->lv1_status = status;
257 complete(&dev->done);
258 return IRQ_HANDLED;
259 }
260
261 if (req->cmd_type == REQ_TYPE_FLUSH) {
262 read = 0;
263 num_sectors = req->hard_cur_sectors;
264 op = "flush";
265 } else {
266 read = !rq_data_dir(req);
267 num_sectors = req->nr_sectors;
268 op = read ? "read" : "write";
269 }
270 if (status) {
271 dev_dbg(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__,
272 __LINE__, op, status);
273 uptodate = 0;
274 } else {
275 dev_dbg(&dev->sbd.core, "%s:%u: %s completed\n", __func__,
276 __LINE__, op);
277 uptodate = 1;
278 if (read)
279 ps3disk_scatter_gather(dev, req, 0);
280 }
281
282 spin_lock(&priv->lock);
283 if (!end_that_request_first(req, uptodate, num_sectors)) {
284 add_disk_randomness(req->rq_disk);
285 blkdev_dequeue_request(req);
286 end_that_request_last(req, uptodate);
287 }
288 priv->req = NULL;
289 ps3disk_do_request(dev, priv->queue);
290 spin_unlock(&priv->lock);
291
292 return IRQ_HANDLED;
293}
294
295static int ps3disk_sync_cache(struct ps3_storage_device *dev)
296{
297 u64 res;
298
299 dev_dbg(&dev->sbd.core, "%s:%u: sync cache\n", __func__, __LINE__);
300
301 res = ps3stor_send_command(dev, LV1_STORAGE_ATA_HDDOUT, 0, 0, 0, 0);
302 if (res) {
303 dev_err(&dev->sbd.core, "%s:%u: sync cache failed 0x%lx\n",
304 __func__, __LINE__, res);
305 return -EIO;
306 }
307 return 0;
308}
309
310
311/* ATA helpers copied from drivers/ata/libata-core.c */
312
313static void swap_buf_le16(u16 *buf, unsigned int buf_words)
314{
315#ifdef __BIG_ENDIAN
316 unsigned int i;
317
318 for (i = 0; i < buf_words; i++)
319 buf[i] = le16_to_cpu(buf[i]);
320#endif /* __BIG_ENDIAN */
321}
322
323static u64 ata_id_n_sectors(const u16 *id)
324{
325 if (ata_id_has_lba(id)) {
326 if (ata_id_has_lba48(id))
327 return ata_id_u64(id, 100);
328 else
329 return ata_id_u32(id, 60);
330 } else {
331 if (ata_id_current_chs_valid(id))
332 return ata_id_u32(id, 57);
333 else
334 return id[1] * id[3] * id[6];
335 }
336}
337
338static void ata_id_string(const u16 *id, unsigned char *s, unsigned int ofs,
339 unsigned int len)
340{
341 unsigned int c;
342
343 while (len > 0) {
344 c = id[ofs] >> 8;
345 *s = c;
346 s++;
347
348 c = id[ofs] & 0xff;
349 *s = c;
350 s++;
351
352 ofs++;
353 len -= 2;
354 }
355}
356
357static void ata_id_c_string(const u16 *id, unsigned char *s, unsigned int ofs,
358 unsigned int len)
359{
360 unsigned char *p;
361
362 WARN_ON(!(len & 1));
363
364 ata_id_string(id, s, ofs, len - 1);
365
366 p = s + strnlen(s, len - 1);
367 while (p > s && p[-1] == ' ')
368 p--;
369 *p = '\0';
370}
371
372static int ps3disk_identify(struct ps3_storage_device *dev)
373{
374 struct ps3disk_private *priv = dev->sbd.core.driver_data;
375 struct lv1_ata_cmnd_block ata_cmnd;
376 u16 *id = dev->bounce_buf;
377 u64 res;
378
379 dev_dbg(&dev->sbd.core, "%s:%u: identify disk\n", __func__, __LINE__);
380
381 memset(&ata_cmnd, 0, sizeof(struct lv1_ata_cmnd_block));
382 ata_cmnd.command = ATA_CMD_ID_ATA;
383 ata_cmnd.sector_count = 1;
384 ata_cmnd.size = ata_cmnd.arglen = ATA_ID_WORDS * 2;
385 ata_cmnd.buffer = dev->bounce_lpar;
386 ata_cmnd.proto = PIO_DATA_IN_PROTO;
387 ata_cmnd.in_out = DIR_READ;
388
389 res = ps3stor_send_command(dev, LV1_STORAGE_SEND_ATA_COMMAND,
390 ps3_mm_phys_to_lpar(__pa(&ata_cmnd)),
391 sizeof(ata_cmnd), ata_cmnd.buffer,
392 ata_cmnd.arglen);
393 if (res) {
394 dev_err(&dev->sbd.core, "%s:%u: identify disk failed 0x%lx\n",
395 __func__, __LINE__, res);
396 return -EIO;
397 }
398
399 swap_buf_le16(id, ATA_ID_WORDS);
400
401 /* All we're interested in are raw capacity and model name */
402 priv->raw_capacity = ata_id_n_sectors(id);
403 ata_id_c_string(id, priv->model, ATA_ID_PROD, sizeof(priv->model));
404 return 0;
405}
406
407static void ps3disk_prepare_flush(request_queue_t *q, struct request *req)
408{
409 struct ps3_storage_device *dev = q->queuedata;
410
411 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
412
413 memset(req->cmd, 0, sizeof(req->cmd));
414 req->cmd_type = REQ_TYPE_FLUSH;
415}
416
417static int ps3disk_issue_flush(request_queue_t *q, struct gendisk *gendisk,
418 sector_t *sector)
419{
420 struct ps3_storage_device *dev = q->queuedata;
421 struct request *req;
422 int res;
423
424 dev_dbg(&dev->sbd.core, "%s:%u\n", __func__, __LINE__);
425
426 req = blk_get_request(q, WRITE, __GFP_WAIT);
427 ps3disk_prepare_flush(q, req);
428 res = blk_execute_rq(q, gendisk, req, 0);
429 if (res)
430 dev_err(&dev->sbd.core, "%s:%u: flush request failed %d\n",
431 __func__, __LINE__, res);
432 blk_put_request(req);
433 return res;
434}
435
436
437static unsigned long ps3disk_mask;
438
439static DEFINE_MUTEX(ps3disk_mask_mutex);
440
441static int __devinit ps3disk_probe(struct ps3_system_bus_device *_dev)
442{
443 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
444 struct ps3disk_private *priv;
445 int error;
446 unsigned int devidx;
447 struct request_queue *queue;
448 struct gendisk *gendisk;
449
450 if (dev->blk_size < 512) {
451 dev_err(&dev->sbd.core,
452 "%s:%u: cannot handle block size %lu\n", __func__,
453 __LINE__, dev->blk_size);
454 return -EINVAL;
455 }
456
457 BUILD_BUG_ON(PS3DISK_MAX_DISKS > BITS_PER_LONG);
458 mutex_lock(&ps3disk_mask_mutex);
459 devidx = find_first_zero_bit(&ps3disk_mask, PS3DISK_MAX_DISKS);
460 if (devidx >= PS3DISK_MAX_DISKS) {
461 dev_err(&dev->sbd.core, "%s:%u: Too many disks\n", __func__,
462 __LINE__);
463 mutex_unlock(&ps3disk_mask_mutex);
464 return -ENOSPC;
465 }
466 __set_bit(devidx, &ps3disk_mask);
467 mutex_unlock(&ps3disk_mask_mutex);
468
469 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
470 if (!priv) {
471 error = -ENOMEM;
472 goto fail;
473 }
474
475 dev->sbd.core.driver_data = priv;
476 spin_lock_init(&priv->lock);
477
478 dev->bounce_size = BOUNCE_SIZE;
479 dev->bounce_buf = kmalloc(BOUNCE_SIZE, GFP_DMA);
480 if (!dev->bounce_buf) {
481 error = -ENOMEM;
482 goto fail_free_priv;
483 }
484
485 error = ps3stor_setup(dev, ps3disk_interrupt);
486 if (error)
487 goto fail_free_bounce;
488
489 ps3disk_identify(dev);
490
491 queue = blk_init_queue(ps3disk_request, &priv->lock);
492 if (!queue) {
493 dev_err(&dev->sbd.core, "%s:%u: blk_init_queue failed\n",
494 __func__, __LINE__);
495 error = -ENOMEM;
496 goto fail_teardown;
497 }
498
499 priv->queue = queue;
500 queue->queuedata = dev;
501
502 blk_queue_bounce_limit(queue, BLK_BOUNCE_HIGH);
503
504 blk_queue_max_sectors(queue, dev->bounce_size >> 9);
505 blk_queue_segment_boundary(queue, -1UL);
506 blk_queue_dma_alignment(queue, dev->blk_size-1);
507 blk_queue_hardsect_size(queue, dev->blk_size);
508
509 blk_queue_issue_flush_fn(queue, ps3disk_issue_flush);
510 blk_queue_ordered(queue, QUEUE_ORDERED_DRAIN_FLUSH,
511 ps3disk_prepare_flush);
512
513 blk_queue_max_phys_segments(queue, -1);
514 blk_queue_max_hw_segments(queue, -1);
515 blk_queue_max_segment_size(queue, dev->bounce_size);
516
517 gendisk = alloc_disk(PS3DISK_MINORS);
518 if (!gendisk) {
519 dev_err(&dev->sbd.core, "%s:%u: alloc_disk failed\n", __func__,
520 __LINE__);
521 error = -ENOMEM;
522 goto fail_cleanup_queue;
523 }
524
525 priv->gendisk = gendisk;
526 gendisk->major = ps3disk_major;
527 gendisk->first_minor = devidx * PS3DISK_MINORS;
528 gendisk->fops = &ps3disk_fops;
529 gendisk->queue = queue;
530 gendisk->private_data = dev;
531 gendisk->driverfs_dev = &dev->sbd.core;
532 snprintf(gendisk->disk_name, sizeof(gendisk->disk_name), PS3DISK_NAME,
533 devidx+'a');
534 priv->blocking_factor = dev->blk_size >> 9;
535 set_capacity(gendisk,
536 dev->regions[dev->region_idx].size*priv->blocking_factor);
537
538 dev_info(&dev->sbd.core,
539 "%s is a %s (%lu MiB total, %lu MiB for OtherOS)\n",
540 gendisk->disk_name, priv->model, priv->raw_capacity >> 11,
541 get_capacity(gendisk) >> 11);
542
543 add_disk(gendisk);
544 return 0;
545
546fail_cleanup_queue:
547 blk_cleanup_queue(queue);
548fail_teardown:
549 ps3stor_teardown(dev);
550fail_free_bounce:
551 kfree(dev->bounce_buf);
552fail_free_priv:
553 kfree(priv);
554 dev->sbd.core.driver_data = NULL;
555fail:
556 mutex_lock(&ps3disk_mask_mutex);
557 __clear_bit(devidx, &ps3disk_mask);
558 mutex_unlock(&ps3disk_mask_mutex);
559 return error;
560}
561
562static int ps3disk_remove(struct ps3_system_bus_device *_dev)
563{
564 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
565 struct ps3disk_private *priv = dev->sbd.core.driver_data;
566
567 mutex_lock(&ps3disk_mask_mutex);
568 __clear_bit(priv->gendisk->first_minor / PS3DISK_MINORS,
569 &ps3disk_mask);
570 mutex_unlock(&ps3disk_mask_mutex);
571 del_gendisk(priv->gendisk);
572 blk_cleanup_queue(priv->queue);
573 put_disk(priv->gendisk);
574 dev_notice(&dev->sbd.core, "Synchronizing disk cache\n");
575 ps3disk_sync_cache(dev);
576 ps3stor_teardown(dev);
577 kfree(dev->bounce_buf);
578 kfree(priv);
579 dev->sbd.core.driver_data = NULL;
580 return 0;
581}
582
583static struct ps3_system_bus_driver ps3disk = {
584 .match_id = PS3_MATCH_ID_STOR_DISK,
585 .core.name = DEVICE_NAME,
586 .core.owner = THIS_MODULE,
587 .probe = ps3disk_probe,
588 .remove = ps3disk_remove,
589 .shutdown = ps3disk_remove,
590};
591
592
593static int __init ps3disk_init(void)
594{
595 int error;
596
597 if (!firmware_has_feature(FW_FEATURE_PS3_LV1))
598 return -ENODEV;
599
600 error = register_blkdev(0, DEVICE_NAME);
601 if (error <= 0) {
602 printk(KERN_ERR "%s:%u: register_blkdev failed %d\n", __func__,
603 __LINE__, error);
604 return error;
605 }
606 ps3disk_major = error;
607
608 pr_info("%s:%u: registered block device major %d\n", __func__,
609 __LINE__, ps3disk_major);
610
611 error = ps3_system_bus_driver_register(&ps3disk);
612 if (error)
613 unregister_blkdev(ps3disk_major, DEVICE_NAME);
614
615 return error;
616}
617
618static void __exit ps3disk_exit(void)
619{
620 ps3_system_bus_driver_unregister(&ps3disk);
621 unregister_blkdev(ps3disk_major, DEVICE_NAME);
622}
623
624module_init(ps3disk_init);
625module_exit(ps3disk_exit);
626
627MODULE_LICENSE("GPL");
628MODULE_DESCRIPTION("PS3 Disk Storage Driver");
629MODULE_AUTHOR("Sony Corporation");
630MODULE_ALIAS(PS3_MODULE_ALIAS_STOR_DISK);
diff --git a/drivers/char/Makefile b/drivers/char/Makefile
index 4e6f387fd189..8fecaf4010b1 100644
--- a/drivers/char/Makefile
+++ b/drivers/char/Makefile
@@ -107,6 +107,8 @@ obj-$(CONFIG_IPMI_HANDLER) += ipmi/
107obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o 107obj-$(CONFIG_HANGCHECK_TIMER) += hangcheck-timer.o
108obj-$(CONFIG_TCG_TPM) += tpm/ 108obj-$(CONFIG_TCG_TPM) += tpm/
109 109
110obj-$(CONFIG_PS3_FLASH) += ps3flash.o
111
110# Files generated that shall be removed upon make clean 112# Files generated that shall be removed upon make clean
111clean-files := consolemap_deftbl.c defkeymap.c 113clean-files := consolemap_deftbl.c defkeymap.c
112 114
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c
index b37f1d5a5be6..a08f8f981c11 100644
--- a/drivers/char/hvc_iseries.c
+++ b/drivers/char/hvc_iseries.c
@@ -472,7 +472,7 @@ static void hvc_handle_event(struct HvLpEvent *event)
472 } 472 }
473} 473}
474 474
475static int send_open(HvLpIndex remoteLp, void *sem) 475static int __init send_open(HvLpIndex remoteLp, void *sem)
476{ 476{
477 return HvCallEvent_signalLpEventFast(remoteLp, 477 return HvCallEvent_signalLpEventFast(remoteLp,
478 HvLpEvent_Type_VirtualIo, 478 HvLpEvent_Type_VirtualIo,
@@ -484,7 +484,7 @@ static int send_open(HvLpIndex remoteLp, void *sem)
484 0, 0, 0, 0); 484 0, 0, 0, 0);
485} 485}
486 486
487static int hvc_vio_init(void) 487static int __init hvc_vio_init(void)
488{ 488{
489 atomic_t wait_flag; 489 atomic_t wait_flag;
490 int rc; 490 int rc;
@@ -552,14 +552,14 @@ static int hvc_vio_init(void)
552} 552}
553module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */ 553module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
554 554
555static void hvc_vio_exit(void) 555static void __exit hvc_vio_exit(void)
556{ 556{
557 vio_unregister_driver(&hvc_vio_driver); 557 vio_unregister_driver(&hvc_vio_driver);
558} 558}
559module_exit(hvc_vio_exit); 559module_exit(hvc_vio_exit);
560 560
561/* the device tree order defines our numbering */ 561/* the device tree order defines our numbering */
562static int hvc_find_vtys(void) 562static int __init hvc_find_vtys(void)
563{ 563{
564 struct device_node *vty; 564 struct device_node *vty;
565 int num_found = 0; 565 int num_found = 0;
diff --git a/drivers/char/hvc_rtas.c b/drivers/char/hvc_rtas.c
index 4b97eaf18602..bb09413d5a21 100644
--- a/drivers/char/hvc_rtas.c
+++ b/drivers/char/hvc_rtas.c
@@ -115,7 +115,7 @@ static void __exit hvc_rtas_exit(void)
115module_exit(hvc_rtas_exit); 115module_exit(hvc_rtas_exit);
116 116
117/* This will happen prior to module init. There is no tty at this time? */ 117/* This will happen prior to module init. There is no tty at this time? */
118static int hvc_rtas_console_init(void) 118static int __init hvc_rtas_console_init(void)
119{ 119{
120 rtascons_put_char_token = rtas_token("put-term-char"); 120 rtascons_put_char_token = rtas_token("put-term-char");
121 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE) 121 if (rtascons_put_char_token == RTAS_UNKNOWN_SERVICE)
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c
index 17f96e04266f..69d8866de783 100644
--- a/drivers/char/hvcs.c
+++ b/drivers/char/hvcs.c
@@ -210,9 +210,9 @@ static struct ktermios hvcs_tty_termios = {
210static int hvcs_parm_num_devs = -1; 210static int hvcs_parm_num_devs = -1;
211module_param(hvcs_parm_num_devs, int, 0); 211module_param(hvcs_parm_num_devs, int, 0);
212 212
213char hvcs_driver_name[] = "hvcs"; 213static const char hvcs_driver_name[] = "hvcs";
214char hvcs_device_node[] = "hvcs"; 214static const char hvcs_device_node[] = "hvcs";
215char hvcs_driver_string[] 215static const char hvcs_driver_string[]
216 = "IBM hvcs (Hypervisor Virtual Console Server) Driver"; 216 = "IBM hvcs (Hypervisor Virtual Console Server) Driver";
217 217
218/* Status of partner info rescan triggered via sysfs. */ 218/* Status of partner info rescan triggered via sysfs. */
@@ -1092,7 +1092,7 @@ static int hvcs_enable_device(struct hvcs_struct *hvcsd, uint32_t unit_address,
1092 * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when 1092 * NOTICE: Do NOT hold either the hvcs_struct.lock or hvcs_structs_lock when
1093 * calling this function or you will get deadlock. 1093 * calling this function or you will get deadlock.
1094 */ 1094 */
1095struct hvcs_struct *hvcs_get_by_index(int index) 1095static struct hvcs_struct *hvcs_get_by_index(int index)
1096{ 1096{
1097 struct hvcs_struct *hvcsd = NULL; 1097 struct hvcs_struct *hvcsd = NULL;
1098 unsigned long flags; 1098 unsigned long flags;
diff --git a/drivers/char/hw_random/Kconfig b/drivers/char/hw_random/Kconfig
index 7cda04b33534..2d7cd486e025 100644
--- a/drivers/char/hw_random/Kconfig
+++ b/drivers/char/hw_random/Kconfig
@@ -41,7 +41,7 @@ config HW_RANDOM_AMD
41 41
42config HW_RANDOM_GEODE 42config HW_RANDOM_GEODE
43 tristate "AMD Geode HW Random Number Generator support" 43 tristate "AMD Geode HW Random Number Generator support"
44 depends on HW_RANDOM && X86 && PCI 44 depends on HW_RANDOM && X86_32 && PCI
45 default HW_RANDOM 45 default HW_RANDOM
46 ---help--- 46 ---help---
47 This driver provides kernel-side support for the Random Number 47 This driver provides kernel-side support for the Random Number
diff --git a/drivers/char/ps3flash.c b/drivers/char/ps3flash.c
new file mode 100644
index 000000000000..79b6f461be75
--- /dev/null
+++ b/drivers/char/ps3flash.c
@@ -0,0 +1,440 @@
1/*
2 * PS3 FLASH ROM Storage Driver
3 *
4 * Copyright (C) 2007 Sony Computer Entertainment Inc.
5 * Copyright 2007 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <linux/fs.h>
22#include <linux/miscdevice.h>
23#include <linux/uaccess.h>
24
25#include <asm/lv1call.h>
26#include <asm/ps3stor.h>
27
28
29#define DEVICE_NAME "ps3flash"
30
31#define FLASH_BLOCK_SIZE (256*1024)
32
33
34struct ps3flash_private {
35 struct mutex mutex; /* Bounce buffer mutex */
36};
37
38static struct ps3_storage_device *ps3flash_dev;
39
40static ssize_t ps3flash_read_write_sectors(struct ps3_storage_device *dev,
41 u64 lpar, u64 start_sector,
42 u64 sectors, int write)
43{
44 u64 res = ps3stor_read_write_sectors(dev, lpar, start_sector, sectors,
45 write);
46 if (res) {
47 dev_err(&dev->sbd.core, "%s:%u: %s failed 0x%lx\n", __func__,
48 __LINE__, write ? "write" : "read", res);
49 return -EIO;
50 }
51 return sectors;
52}
53
54static ssize_t ps3flash_read_sectors(struct ps3_storage_device *dev,
55 u64 start_sector, u64 sectors,
56 unsigned int sector_offset)
57{
58 u64 max_sectors, lpar;
59
60 max_sectors = dev->bounce_size / dev->blk_size;
61 if (sectors > max_sectors) {
62 dev_dbg(&dev->sbd.core, "%s:%u Limiting sectors to %lu\n",
63 __func__, __LINE__, max_sectors);
64 sectors = max_sectors;
65 }
66
67 lpar = dev->bounce_lpar + sector_offset * dev->blk_size;
68 return ps3flash_read_write_sectors(dev, lpar, start_sector, sectors,
69 0);
70}
71
72static ssize_t ps3flash_write_chunk(struct ps3_storage_device *dev,
73 u64 start_sector)
74{
75 u64 sectors = dev->bounce_size / dev->blk_size;
76 return ps3flash_read_write_sectors(dev, dev->bounce_lpar, start_sector,
77 sectors, 1);
78}
79
80static loff_t ps3flash_llseek(struct file *file, loff_t offset, int origin)
81{
82 struct ps3_storage_device *dev = ps3flash_dev;
83 loff_t res;
84
85 mutex_lock(&file->f_mapping->host->i_mutex);
86 switch (origin) {
87 case 1:
88 offset += file->f_pos;
89 break;
90 case 2:
91 offset += dev->regions[dev->region_idx].size*dev->blk_size;
92 break;
93 }
94 if (offset < 0) {
95 res = -EINVAL;
96 goto out;
97 }
98
99 file->f_pos = offset;
100 res = file->f_pos;
101
102out:
103 mutex_unlock(&file->f_mapping->host->i_mutex);
104 return res;
105}
106
107static ssize_t ps3flash_read(struct file *file, char __user *buf, size_t count,
108 loff_t *pos)
109{
110 struct ps3_storage_device *dev = ps3flash_dev;
111 struct ps3flash_private *priv = dev->sbd.core.driver_data;
112 u64 size, start_sector, end_sector, offset;
113 ssize_t sectors_read;
114 size_t remaining, n;
115
116 dev_dbg(&dev->sbd.core,
117 "%s:%u: Reading %zu bytes at position %lld to user 0x%p\n",
118 __func__, __LINE__, count, *pos, buf);
119
120 size = dev->regions[dev->region_idx].size*dev->blk_size;
121 if (*pos >= size || !count)
122 return 0;
123
124 if (*pos + count > size) {
125 dev_dbg(&dev->sbd.core,
126 "%s:%u Truncating count from %zu to %llu\n", __func__,
127 __LINE__, count, size - *pos);
128 count = size - *pos;
129 }
130
131 start_sector = *pos / dev->blk_size;
132 offset = *pos % dev->blk_size;
133 end_sector = DIV_ROUND_UP(*pos + count, dev->blk_size);
134
135 remaining = count;
136 do {
137 mutex_lock(&priv->mutex);
138
139 sectors_read = ps3flash_read_sectors(dev, start_sector,
140 end_sector-start_sector,
141 0);
142 if (sectors_read < 0) {
143 mutex_unlock(&priv->mutex);
144 goto fail;
145 }
146
147 n = min(remaining, sectors_read*dev->blk_size-offset);
148 dev_dbg(&dev->sbd.core,
149 "%s:%u: copy %lu bytes from 0x%p to user 0x%p\n",
150 __func__, __LINE__, n, dev->bounce_buf+offset, buf);
151 if (copy_to_user(buf, dev->bounce_buf+offset, n)) {
152 mutex_unlock(&priv->mutex);
153 sectors_read = -EFAULT;
154 goto fail;
155 }
156
157 mutex_unlock(&priv->mutex);
158
159 *pos += n;
160 buf += n;
161 remaining -= n;
162 start_sector += sectors_read;
163 offset = 0;
164 } while (remaining > 0);
165
166 return count;
167
168fail:
169 return sectors_read;
170}
171
172static ssize_t ps3flash_write(struct file *file, const char __user *buf,
173 size_t count, loff_t *pos)
174{
175 struct ps3_storage_device *dev = ps3flash_dev;
176 struct ps3flash_private *priv = dev->sbd.core.driver_data;
177 u64 size, chunk_sectors, start_write_sector, end_write_sector,
178 end_read_sector, start_read_sector, head, tail, offset;
179 ssize_t res;
180 size_t remaining, n;
181 unsigned int sec_off;
182
183 dev_dbg(&dev->sbd.core,
184 "%s:%u: Writing %zu bytes at position %lld from user 0x%p\n",
185 __func__, __LINE__, count, *pos, buf);
186
187 size = dev->regions[dev->region_idx].size*dev->blk_size;
188 if (*pos >= size || !count)
189 return 0;
190
191 if (*pos + count > size) {
192 dev_dbg(&dev->sbd.core,
193 "%s:%u Truncating count from %zu to %llu\n", __func__,
194 __LINE__, count, size - *pos);
195 count = size - *pos;
196 }
197
198 chunk_sectors = dev->bounce_size / dev->blk_size;
199
200 start_write_sector = *pos / dev->bounce_size * chunk_sectors;
201 offset = *pos % dev->bounce_size;
202 end_write_sector = DIV_ROUND_UP(*pos + count, dev->bounce_size) *
203 chunk_sectors;
204
205 end_read_sector = DIV_ROUND_UP(*pos, dev->blk_size);
206 start_read_sector = (*pos + count) / dev->blk_size;
207
208 /*
209 * As we have to write in 256 KiB chunks, while we can read in blk_size
210 * (usually 512 bytes) chunks, we perform the following steps:
211 * 1. Read from start_write_sector to end_read_sector ("head")
212 * 2. Read from start_read_sector to end_write_sector ("tail")
213 * 3. Copy data to buffer
214 * 4. Write from start_write_sector to end_write_sector
215 * All of this is complicated by using only one 256 KiB bounce buffer.
216 */
217
218 head = end_read_sector - start_write_sector;
219 tail = end_write_sector - start_read_sector;
220
221 remaining = count;
222 do {
223 mutex_lock(&priv->mutex);
224
225 if (end_read_sector >= start_read_sector) {
226 /* Merge head and tail */
227 dev_dbg(&dev->sbd.core,
228 "Merged head and tail: %lu sectors at %lu\n",
229 chunk_sectors, start_write_sector);
230 res = ps3flash_read_sectors(dev, start_write_sector,
231 chunk_sectors, 0);
232 if (res < 0)
233 goto fail;
234 } else {
235 if (head) {
236 /* Read head */
237 dev_dbg(&dev->sbd.core,
238 "head: %lu sectors at %lu\n", head,
239 start_write_sector);
240 res = ps3flash_read_sectors(dev,
241 start_write_sector,
242 head, 0);
243 if (res < 0)
244 goto fail;
245 }
246 if (start_read_sector <
247 start_write_sector+chunk_sectors) {
248 /* Read tail */
249 dev_dbg(&dev->sbd.core,
250 "tail: %lu sectors at %lu\n", tail,
251 start_read_sector);
252 sec_off = start_read_sector-start_write_sector;
253 res = ps3flash_read_sectors(dev,
254 start_read_sector,
255 tail, sec_off);
256 if (res < 0)
257 goto fail;
258 }
259 }
260
261 n = min(remaining, dev->bounce_size-offset);
262 dev_dbg(&dev->sbd.core,
263 "%s:%u: copy %lu bytes from user 0x%p to 0x%p\n",
264 __func__, __LINE__, n, buf, dev->bounce_buf+offset);
265 if (copy_from_user(dev->bounce_buf+offset, buf, n)) {
266 res = -EFAULT;
267 goto fail;
268 }
269
270 res = ps3flash_write_chunk(dev, start_write_sector);
271 if (res < 0)
272 goto fail;
273
274 mutex_unlock(&priv->mutex);
275
276 *pos += n;
277 buf += n;
278 remaining -= n;
279 start_write_sector += chunk_sectors;
280 head = 0;
281 offset = 0;
282 } while (remaining > 0);
283
284 return count;
285
286fail:
287 mutex_unlock(&priv->mutex);
288 return res;
289}
290
291
292static irqreturn_t ps3flash_interrupt(int irq, void *data)
293{
294 struct ps3_storage_device *dev = data;
295 int res;
296 u64 tag, status;
297
298 res = lv1_storage_get_async_status(dev->sbd.dev_id, &tag, &status);
299
300 if (tag != dev->tag)
301 dev_err(&dev->sbd.core,
302 "%s:%u: tag mismatch, got %lx, expected %lx\n",
303 __func__, __LINE__, tag, dev->tag);
304
305 if (res) {
306 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n",
307 __func__, __LINE__, res, status);
308 } else {
309 dev->lv1_status = status;
310 complete(&dev->done);
311 }
312 return IRQ_HANDLED;
313}
314
315
316static const struct file_operations ps3flash_fops = {
317 .owner = THIS_MODULE,
318 .llseek = ps3flash_llseek,
319 .read = ps3flash_read,
320 .write = ps3flash_write,
321};
322
323static struct miscdevice ps3flash_misc = {
324 .minor = MISC_DYNAMIC_MINOR,
325 .name = DEVICE_NAME,
326 .fops = &ps3flash_fops,
327};
328
329static int __devinit ps3flash_probe(struct ps3_system_bus_device *_dev)
330{
331 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
332 struct ps3flash_private *priv;
333 int error;
334 unsigned long tmp;
335
336 tmp = dev->regions[dev->region_idx].start*dev->blk_size;
337 if (tmp % FLASH_BLOCK_SIZE) {
338 dev_err(&dev->sbd.core,
339 "%s:%u region start %lu is not aligned\n", __func__,
340 __LINE__, tmp);
341 return -EINVAL;
342 }
343 tmp = dev->regions[dev->region_idx].size*dev->blk_size;
344 if (tmp % FLASH_BLOCK_SIZE) {
345 dev_err(&dev->sbd.core,
346 "%s:%u region size %lu is not aligned\n", __func__,
347 __LINE__, tmp);
348 return -EINVAL;
349 }
350
351 /* use static buffer, kmalloc cannot allocate 256 KiB */
352 if (!ps3flash_bounce_buffer.address)
353 return -ENODEV;
354
355 if (ps3flash_dev) {
356 dev_err(&dev->sbd.core,
357 "Only one FLASH device is supported\n");
358 return -EBUSY;
359 }
360
361 ps3flash_dev = dev;
362
363 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
364 if (!priv) {
365 error = -ENOMEM;
366 goto fail;
367 }
368
369 dev->sbd.core.driver_data = priv;
370 mutex_init(&priv->mutex);
371
372 dev->bounce_size = ps3flash_bounce_buffer.size;
373 dev->bounce_buf = ps3flash_bounce_buffer.address;
374
375 error = ps3stor_setup(dev, ps3flash_interrupt);
376 if (error)
377 goto fail_free_priv;
378
379 ps3flash_misc.parent = &dev->sbd.core;
380 error = misc_register(&ps3flash_misc);
381 if (error) {
382 dev_err(&dev->sbd.core, "%s:%u: misc_register failed %d\n",
383 __func__, __LINE__, error);
384 goto fail_teardown;
385 }
386
387 dev_info(&dev->sbd.core, "%s:%u: registered misc device %d\n",
388 __func__, __LINE__, ps3flash_misc.minor);
389 return 0;
390
391fail_teardown:
392 ps3stor_teardown(dev);
393fail_free_priv:
394 kfree(priv);
395 dev->sbd.core.driver_data = NULL;
396fail:
397 ps3flash_dev = NULL;
398 return error;
399}
400
401static int ps3flash_remove(struct ps3_system_bus_device *_dev)
402{
403 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
404
405 misc_deregister(&ps3flash_misc);
406 ps3stor_teardown(dev);
407 kfree(dev->sbd.core.driver_data);
408 dev->sbd.core.driver_data = NULL;
409 ps3flash_dev = NULL;
410 return 0;
411}
412
413
414static struct ps3_system_bus_driver ps3flash = {
415 .match_id = PS3_MATCH_ID_STOR_FLASH,
416 .core.name = DEVICE_NAME,
417 .core.owner = THIS_MODULE,
418 .probe = ps3flash_probe,
419 .remove = ps3flash_remove,
420 .shutdown = ps3flash_remove,
421};
422
423
424static int __init ps3flash_init(void)
425{
426 return ps3_system_bus_driver_register(&ps3flash);
427}
428
429static void __exit ps3flash_exit(void)
430{
431 ps3_system_bus_driver_unregister(&ps3flash);
432}
433
434module_init(ps3flash_init);
435module_exit(ps3flash_exit);
436
437MODULE_LICENSE("GPL");
438MODULE_DESCRIPTION("PS3 FLASH ROM Storage Driver");
439MODULE_AUTHOR("Sony Corporation");
440MODULE_ALIAS(PS3_MODULE_ALIAS_STOR_FLASH);
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c
index 30c3f54c7666..ec6b65ec69ea 100644
--- a/drivers/char/rtc.c
+++ b/drivers/char/rtc.c
@@ -82,7 +82,7 @@
82#include <asm/uaccess.h> 82#include <asm/uaccess.h>
83#include <asm/system.h> 83#include <asm/system.h>
84 84
85#if defined(__i386__) 85#ifdef CONFIG_X86
86#include <asm/hpet.h> 86#include <asm/hpet.h>
87#endif 87#endif
88 88
diff --git a/drivers/char/watchdog/Kconfig b/drivers/char/watchdog/Kconfig
index ad5cc5f6862f..16fb23125e96 100644
--- a/drivers/char/watchdog/Kconfig
+++ b/drivers/char/watchdog/Kconfig
@@ -187,6 +187,22 @@ config PNX4008_WATCHDOG
187 187
188 Say N if you are unsure. 188 Say N if you are unsure.
189 189
190config IOP_WATCHDOG
191 tristate "IOP Watchdog"
192 depends on WATCHDOG && PLAT_IOP
193 select WATCHDOG_NOWAYOUT if (ARCH_IOP32X || ARCH_IOP33X)
194 help
195 Say Y here if to include support for the watchdog timer
196 in the Intel IOP3XX & IOP13XX I/O Processors. This driver can
197 be built as a module by choosing M. The module will
198 be called iop_wdt.
199
200 Note: The IOP13XX watchdog does an Internal Bus Reset which will
201 affect both cores and the peripherals of the IOP. The ATU-X
202 and/or ATUe configuration registers will remain intact, but if
203 operating as an Root Complex and/or Central Resource, the PCI-X
204 and/or PCIe busses will also be reset. THIS IS A VERY BIG HAMMER.
205
190# AVR32 Architecture 206# AVR32 Architecture
191 207
192config AT32AP700X_WDT 208config AT32AP700X_WDT
diff --git a/drivers/char/watchdog/Makefile b/drivers/char/watchdog/Makefile
index 3907ec04a4e5..bdb9d5e3bb41 100644
--- a/drivers/char/watchdog/Makefile
+++ b/drivers/char/watchdog/Makefile
@@ -35,6 +35,7 @@ obj-$(CONFIG_SA1100_WATCHDOG) += sa1100_wdt.o
35obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o 35obj-$(CONFIG_MPCORE_WATCHDOG) += mpcore_wdt.o
36obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o 36obj-$(CONFIG_EP93XX_WATCHDOG) += ep93xx_wdt.o
37obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o 37obj-$(CONFIG_PNX4008_WATCHDOG) += pnx4008_wdt.o
38obj-$(CONFIG_IOP_WATCHDOG) += iop_wdt.o
38 39
39# AVR32 Architecture 40# AVR32 Architecture
40obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o 41obj-$(CONFIG_AT32AP700X_WDT) += at32ap700x_wdt.o
diff --git a/drivers/char/watchdog/iop_wdt.c b/drivers/char/watchdog/iop_wdt.c
new file mode 100644
index 000000000000..bbbd91af754d
--- /dev/null
+++ b/drivers/char/watchdog/iop_wdt.c
@@ -0,0 +1,262 @@
1/*
2 * drivers/char/watchdog/iop_wdt.c
3 *
4 * WDT driver for Intel I/O Processors
5 * Copyright (C) 2005, Intel Corporation.
6 *
7 * Based on ixp4xx driver, Copyright 2004 (c) MontaVista, Software, Inc.
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms and conditions of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 * Place - Suite 330, Boston, MA 02111-1307 USA.
21 *
22 * Curt E Bruns <curt.e.bruns@intel.com>
23 * Peter Milne <peter.milne@d-tacq.com>
24 * Dan Williams <dan.j.williams@intel.com>
25 */
26
27#include <linux/module.h>
28#include <linux/kernel.h>
29#include <linux/fs.h>
30#include <linux/init.h>
31#include <linux/device.h>
32#include <linux/miscdevice.h>
33#include <linux/watchdog.h>
34#include <linux/uaccess.h>
35#include <asm/hardware.h>
36
37static int nowayout = WATCHDOG_NOWAYOUT;
38static unsigned long wdt_status;
39static unsigned long boot_status;
40
41#define WDT_IN_USE 0
42#define WDT_OK_TO_CLOSE 1
43#define WDT_ENABLED 2
44
45static unsigned long iop_watchdog_timeout(void)
46{
47 return (0xffffffffUL / get_iop_tick_rate());
48}
49
50/**
51 * wdt_supports_disable - determine if we are accessing a iop13xx watchdog
52 * or iop3xx by whether it has a disable command
53 */
54static int wdt_supports_disable(void)
55{
56 int can_disable;
57
58 if (IOP_WDTCR_EN_ARM != IOP_WDTCR_DIS_ARM)
59 can_disable = 1;
60 else
61 can_disable = 0;
62
63 return can_disable;
64}
65
66static void wdt_enable(void)
67{
68 /* Arm and enable the Timer to starting counting down from 0xFFFF.FFFF
69 * Takes approx. 10.7s to timeout
70 */
71 write_wdtcr(IOP_WDTCR_EN_ARM);
72 write_wdtcr(IOP_WDTCR_EN);
73}
74
75/* returns 0 if the timer was successfully disabled */
76static int wdt_disable(void)
77{
78 /* Stop Counting */
79 if (wdt_supports_disable()) {
80 write_wdtcr(IOP_WDTCR_DIS_ARM);
81 write_wdtcr(IOP_WDTCR_DIS);
82 clear_bit(WDT_ENABLED, &wdt_status);
83 printk(KERN_INFO "WATCHDOG: Disabled\n");
84 return 0;
85 } else
86 return 1;
87}
88
89static int iop_wdt_open(struct inode *inode, struct file *file)
90{
91 if (test_and_set_bit(WDT_IN_USE, &wdt_status))
92 return -EBUSY;
93
94 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
95
96 wdt_enable();
97
98 set_bit(WDT_ENABLED, &wdt_status);
99
100 return nonseekable_open(inode, file);
101}
102
103static ssize_t
104iop_wdt_write(struct file *file, const char *data, size_t len,
105 loff_t *ppos)
106{
107 if (len) {
108 if (!nowayout) {
109 size_t i;
110
111 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
112
113 for (i = 0; i != len; i++) {
114 char c;
115
116 if (get_user(c, data + i))
117 return -EFAULT;
118 if (c == 'V')
119 set_bit(WDT_OK_TO_CLOSE, &wdt_status);
120 }
121 }
122 wdt_enable();
123 }
124
125 return len;
126}
127
128static struct watchdog_info ident = {
129 .options = WDIOF_CARDRESET | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
130 .identity = "iop watchdog",
131};
132
133static int
134iop_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
135 unsigned long arg)
136{
137 int options;
138 int ret = -ENOTTY;
139
140 switch (cmd) {
141 case WDIOC_GETSUPPORT:
142 if (copy_to_user
143 ((struct watchdog_info *)arg, &ident, sizeof ident))
144 ret = -EFAULT;
145 else
146 ret = 0;
147 break;
148
149 case WDIOC_GETSTATUS:
150 ret = put_user(0, (int *)arg);
151 break;
152
153 case WDIOC_GETBOOTSTATUS:
154 ret = put_user(boot_status, (int *)arg);
155 break;
156
157 case WDIOC_GETTIMEOUT:
158 ret = put_user(iop_watchdog_timeout(), (int *)arg);
159 break;
160
161 case WDIOC_KEEPALIVE:
162 wdt_enable();
163 ret = 0;
164 break;
165
166 case WDIOC_SETOPTIONS:
167 if (get_user(options, (int *)arg))
168 return -EFAULT;
169
170 if (options & WDIOS_DISABLECARD) {
171 if (!nowayout) {
172 if (wdt_disable() == 0) {
173 set_bit(WDT_OK_TO_CLOSE, &wdt_status);
174 ret = 0;
175 } else
176 ret = -ENXIO;
177 } else
178 ret = 0;
179 }
180
181 if (options & WDIOS_ENABLECARD) {
182 wdt_enable();
183 ret = 0;
184 }
185 break;
186 }
187
188 return ret;
189}
190
191static int iop_wdt_release(struct inode *inode, struct file *file)
192{
193 int state = 1;
194 if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
195 if (test_bit(WDT_ENABLED, &wdt_status))
196 state = wdt_disable();
197
198 /* if the timer is not disbaled reload and notify that we are still
199 * going down
200 */
201 if (state != 0) {
202 wdt_enable();
203 printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
204 "reset in %lu seconds\n", iop_watchdog_timeout());
205 }
206
207 clear_bit(WDT_IN_USE, &wdt_status);
208 clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
209
210 return 0;
211}
212
213static const struct file_operations iop_wdt_fops = {
214 .owner = THIS_MODULE,
215 .llseek = no_llseek,
216 .write = iop_wdt_write,
217 .ioctl = iop_wdt_ioctl,
218 .open = iop_wdt_open,
219 .release = iop_wdt_release,
220};
221
222static struct miscdevice iop_wdt_miscdev = {
223 .minor = WATCHDOG_MINOR,
224 .name = "watchdog",
225 .fops = &iop_wdt_fops,
226};
227
228static int __init iop_wdt_init(void)
229{
230 int ret;
231
232 ret = misc_register(&iop_wdt_miscdev);
233 if (ret == 0)
234 printk("iop watchdog timer: timeout %lu sec\n",
235 iop_watchdog_timeout());
236
237 /* check if the reset was caused by the watchdog timer */
238 boot_status = (read_rcsr() & IOP_RCSR_WDT) ? WDIOF_CARDRESET : 0;
239
240 /* Configure Watchdog Timeout to cause an Internal Bus (IB) Reset
241 * NOTE: An IB Reset will Reset both cores in the IOP342
242 */
243 write_wdtsr(IOP13XX_WDTCR_IB_RESET);
244
245 return ret;
246}
247
248static void __exit iop_wdt_exit(void)
249{
250 misc_deregister(&iop_wdt_miscdev);
251}
252
253module_init(iop_wdt_init);
254module_exit(iop_wdt_exit);
255
256module_param(nowayout, int, 0);
257MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started");
258
259MODULE_AUTHOR("Curt E Bruns <curt.e.bruns@intel.com>");
260MODULE_DESCRIPTION("iop watchdog timer driver");
261MODULE_LICENSE("GPL");
262MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
diff --git a/drivers/clocksource/acpi_pm.c b/drivers/clocksource/acpi_pm.c
index e783dbf0f162..7b46faf22318 100644
--- a/drivers/clocksource/acpi_pm.c
+++ b/drivers/clocksource/acpi_pm.c
@@ -71,7 +71,7 @@ static struct clocksource clocksource_acpi_pm = {
71 .rating = 200, 71 .rating = 200,
72 .read = acpi_pm_read, 72 .read = acpi_pm_read,
73 .mask = (cycle_t)ACPI_PM_MASK, 73 .mask = (cycle_t)ACPI_PM_MASK,
74 .mult = 0, /*to be caluclated*/ 74 .mult = 0, /*to be calculated*/
75 .shift = 22, 75 .shift = 22,
76 .flags = CLOCK_SOURCE_IS_CONTINUOUS, 76 .flags = CLOCK_SOURCE_IS_CONTINUOUS,
77 77
diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c
index fc984474162c..3e4a369d0057 100644
--- a/drivers/firewire/fw-sbp2.c
+++ b/drivers/firewire/fw-sbp2.c
@@ -1160,7 +1160,7 @@ static struct device_attribute *sbp2_scsi_sysfs_attrs[] = {
1160static struct scsi_host_template scsi_driver_template = { 1160static struct scsi_host_template scsi_driver_template = {
1161 .module = THIS_MODULE, 1161 .module = THIS_MODULE,
1162 .name = "SBP-2 IEEE-1394", 1162 .name = "SBP-2 IEEE-1394",
1163 .proc_name = (char *)sbp2_driver_name, 1163 .proc_name = sbp2_driver_name,
1164 .queuecommand = sbp2_scsi_queuecommand, 1164 .queuecommand = sbp2_scsi_queuecommand,
1165 .slave_alloc = sbp2_scsi_slave_alloc, 1165 .slave_alloc = sbp2_scsi_slave_alloc,
1166 .slave_configure = sbp2_scsi_slave_configure, 1166 .slave_configure = sbp2_scsi_slave_configure,
diff --git a/drivers/input/misc/pcspkr.c b/drivers/input/misc/pcspkr.c
index 31989dcd922c..906bf5e8de89 100644
--- a/drivers/input/misc/pcspkr.c
+++ b/drivers/input/misc/pcspkr.c
@@ -24,7 +24,12 @@ MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
24MODULE_DESCRIPTION("PC Speaker beeper driver"); 24MODULE_DESCRIPTION("PC Speaker beeper driver");
25MODULE_LICENSE("GPL"); 25MODULE_LICENSE("GPL");
26 26
27static DEFINE_SPINLOCK(i8253_beep_lock); 27#ifdef CONFIG_X86
28/* Use the global PIT lock ! */
29#include <asm/i8253.h>
30#else
31static DEFINE_SPINLOCK(i8253_lock);
32#endif
28 33
29static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value) 34static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
30{ 35{
@@ -43,7 +48,7 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
43 if (value > 20 && value < 32767) 48 if (value > 20 && value < 32767)
44 count = PIT_TICK_RATE / value; 49 count = PIT_TICK_RATE / value;
45 50
46 spin_lock_irqsave(&i8253_beep_lock, flags); 51 spin_lock_irqsave(&i8253_lock, flags);
47 52
48 if (count) { 53 if (count) {
49 /* enable counter 2 */ 54 /* enable counter 2 */
@@ -58,7 +63,7 @@ static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int c
58 outb(inb_p(0x61) & 0xFC, 0x61); 63 outb(inb_p(0x61) & 0xFC, 0x61);
59 } 64 }
60 65
61 spin_unlock_irqrestore(&i8253_beep_lock, flags); 66 spin_unlock_irqrestore(&i8253_lock, flags);
62 67
63 return 0; 68 return 0;
64} 69}
diff --git a/drivers/isdn/Kconfig b/drivers/isdn/Kconfig
index cf906c8cee4d..66f946aa30b3 100644
--- a/drivers/isdn/Kconfig
+++ b/drivers/isdn/Kconfig
@@ -21,9 +21,7 @@ menuconfig ISDN
21 21
22if ISDN 22if ISDN
23 23
24menu "Old ISDN4Linux" 24menuconfig ISDN_I4L
25
26config ISDN_I4L
27 tristate "Old ISDN4Linux (deprecated)" 25 tristate "Old ISDN4Linux (deprecated)"
28 ---help--- 26 ---help---
29 This driver allows you to use an ISDN adapter for networking 27 This driver allows you to use an ISDN adapter for networking
@@ -45,12 +43,8 @@ if ISDN_I4L
45source "drivers/isdn/i4l/Kconfig" 43source "drivers/isdn/i4l/Kconfig"
46endif 44endif
47 45
48endmenu 46menuconfig ISDN_CAPI
49 47 tristate "CAPI 2.0 subsystem"
50comment "CAPI subsystem"
51
52config ISDN_CAPI
53 tristate "CAPI2.0 support"
54 help 48 help
55 This provides the CAPI (Common ISDN Application Programming 49 This provides the CAPI (Common ISDN Application Programming
56 Interface, a standard making it easy for programs to access ISDN 50 Interface, a standard making it easy for programs to access ISDN
diff --git a/drivers/isdn/act2000/Kconfig b/drivers/isdn/act2000/Kconfig
index 78e6ad8d57c5..3fc1a5434ef7 100644
--- a/drivers/isdn/act2000/Kconfig
+++ b/drivers/isdn/act2000/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config ISDN_DRV_ACT2000 4config ISDN_DRV_ACT2000
5 tristate "IBM Active 2000 support" 5 tristate "IBM Active 2000 support"
6 depends on ISDN_I4L && ISA 6 depends on ISA
7 help 7 help
8 Say Y here if you have an IBM Active 2000 ISDN card. In order to use 8 Say Y here if you have an IBM Active 2000 ISDN card. In order to use
9 this card, additional firmware is necessary, which has to be loaded 9 this card, additional firmware is necessary, which has to be loaded
diff --git a/drivers/isdn/gigaset/Kconfig b/drivers/isdn/gigaset/Kconfig
index bcbb6502a773..0017e50c6948 100644
--- a/drivers/isdn/gigaset/Kconfig
+++ b/drivers/isdn/gigaset/Kconfig
@@ -1,9 +1,5 @@
1menu "Siemens Gigaset" 1menuconfig ISDN_DRV_GIGASET
2 depends on ISDN_I4L
3
4config ISDN_DRV_GIGASET
5 tristate "Siemens Gigaset support (isdn)" 2 tristate "Siemens Gigaset support (isdn)"
6 depends on ISDN_I4L
7 select CRC_CCITT 3 select CRC_CCITT
8 select BITREVERSE 4 select BITREVERSE
9 help 5 help
@@ -55,6 +51,4 @@ config GIGASET_UNDOCREQ
55 features like configuration mode of M105, say yes. If you 51 features like configuration mode of M105, say yes. If you
56 care about your device, say no. 52 care about your device, say no.
57 53
58endif 54endif # ISDN_DRV_GIGASET != n
59
60endmenu
diff --git a/drivers/isdn/hisax/Kconfig b/drivers/isdn/hisax/Kconfig
index 12d91fb9f8cb..a3b945ac3256 100644
--- a/drivers/isdn/hisax/Kconfig
+++ b/drivers/isdn/hisax/Kconfig
@@ -1,6 +1,5 @@
1 1
2menu "Passive cards" 2menu "Passive cards"
3 depends on ISDN_I4L
4 3
5config ISDN_DRV_HISAX 4config ISDN_DRV_HISAX
6 tristate "HiSax SiemensChipSet driver support" 5 tristate "HiSax SiemensChipSet driver support"
diff --git a/drivers/isdn/i4l/Kconfig b/drivers/isdn/i4l/Kconfig
index e91c187992dd..36778b270c30 100644
--- a/drivers/isdn/i4l/Kconfig
+++ b/drivers/isdn/i4l/Kconfig
@@ -99,7 +99,6 @@ config ISDN_DRV_LOOP
99 99
100config ISDN_DIVERSION 100config ISDN_DIVERSION
101 tristate "Support isdn diversion services" 101 tristate "Support isdn diversion services"
102 depends on ISDN_I4L
103 help 102 help
104 This option allows you to use some supplementary diversion 103 This option allows you to use some supplementary diversion
105 services in conjunction with the HiSax driver on an EURO/DSS1 104 services in conjunction with the HiSax driver on an EURO/DSS1
@@ -119,13 +118,11 @@ config ISDN_DIVERSION
119endmenu 118endmenu
120 119
121comment "ISDN4Linux hardware drivers" 120comment "ISDN4Linux hardware drivers"
122 depends on ISDN_I4L
123 121
124source "drivers/isdn/hisax/Kconfig" 122source "drivers/isdn/hisax/Kconfig"
125 123
126 124
127menu "Active cards" 125menu "Active cards"
128 depends on ISDN_I4L!=n
129 126
130source "drivers/isdn/icn/Kconfig" 127source "drivers/isdn/icn/Kconfig"
131 128
diff --git a/drivers/isdn/icn/Kconfig b/drivers/isdn/icn/Kconfig
index fcb99f5f0b26..89d15eed765e 100644
--- a/drivers/isdn/icn/Kconfig
+++ b/drivers/isdn/icn/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config ISDN_DRV_ICN 4config ISDN_DRV_ICN
5 tristate "ICN 2B and 4B support" 5 tristate "ICN 2B and 4B support"
6 depends on ISDN_I4L && ISA 6 depends on ISA
7 help 7 help
8 This enables support for two kinds of ISDN-cards made by a German 8 This enables support for two kinds of ISDN-cards made by a German
9 company called ICN. 2B is the standard version for a single ISDN 9 company called ICN. 2B is the standard version for a single ISDN
diff --git a/drivers/isdn/pcbit/Kconfig b/drivers/isdn/pcbit/Kconfig
index 0933881ab0c2..ffba6eca1244 100644
--- a/drivers/isdn/pcbit/Kconfig
+++ b/drivers/isdn/pcbit/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config ISDN_DRV_PCBIT 4config ISDN_DRV_PCBIT
5 tristate "PCBIT-D support" 5 tristate "PCBIT-D support"
6 depends on ISDN_I4L && ISA && (BROKEN || X86) 6 depends on ISA && (BROKEN || X86)
7 help 7 help
8 This enables support for the PCBIT ISDN-card. This card is 8 This enables support for the PCBIT ISDN-card. This card is
9 manufactured in Portugal by Octal. For running this card, 9 manufactured in Portugal by Octal. For running this card,
diff --git a/drivers/isdn/sc/Kconfig b/drivers/isdn/sc/Kconfig
index 5346e33d816c..e6510ca7bf43 100644
--- a/drivers/isdn/sc/Kconfig
+++ b/drivers/isdn/sc/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4config ISDN_DRV_SC 4config ISDN_DRV_SC
5 tristate "Spellcaster support" 5 tristate "Spellcaster support"
6 depends on ISDN_I4L && ISA 6 depends on ISA
7 help 7 help
8 This enables support for the Spellcaster BRI ISDN boards. This 8 This enables support for the Spellcaster BRI ISDN boards. This
9 driver currently builds only in a modularized version. 9 driver currently builds only in a modularized version.
diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index 2f661e5f0dae..6cecc396e040 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -11,6 +11,7 @@ if VIRTUALIZATION
11config KVM 11config KVM
12 tristate "Kernel-based Virtual Machine (KVM) support" 12 tristate "Kernel-based Virtual Machine (KVM) support"
13 depends on X86 && EXPERIMENTAL 13 depends on X86 && EXPERIMENTAL
14 select ANON_INODES
14 ---help--- 15 ---help---
15 Support hosting fully virtualized guest machines using hardware 16 Support hosting fully virtualized guest machines using hardware
16 virtualization extensions. You will need a fairly recent 17 virtualization extensions. You will need a fairly recent
diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c
index d99d2fe53dca..1a87ba9d5156 100644
--- a/drivers/kvm/mmu.c
+++ b/drivers/kvm/mmu.c
@@ -244,7 +244,7 @@ static int mmu_topup_memory_cache_page(struct kvm_mmu_memory_cache *cache,
244static void mmu_free_memory_cache_page(struct kvm_mmu_memory_cache *mc) 244static void mmu_free_memory_cache_page(struct kvm_mmu_memory_cache *mc)
245{ 245{
246 while (mc->nobjs) 246 while (mc->nobjs)
247 __free_page(mc->objects[--mc->nobjs]); 247 free_page((unsigned long)mc->objects[--mc->nobjs]);
248} 248}
249 249
250static int __mmu_topup_memory_caches(struct kvm_vcpu *vcpu, gfp_t gfp_flags) 250static int __mmu_topup_memory_caches(struct kvm_vcpu *vcpu, gfp_t gfp_flags)
diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 87d2046f866c..4468cb3a8d24 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -1,9 +1,6 @@
1 1menuconfig NEW_LEDS
2menu "LED devices"
3 depends on HAS_IOMEM
4
5config NEW_LEDS
6 bool "LED Support" 2 bool "LED Support"
3 depends on HAS_IOMEM
7 help 4 help
8 Say Y to enable Linux LED support. This allows control of supported 5 Say Y to enable Linux LED support. This allows control of supported
9 LEDs from both userspace and optionally, by kernel events (triggers). 6 LEDs from both userspace and optionally, by kernel events (triggers).
@@ -11,9 +8,10 @@ config NEW_LEDS
11 This is not related to standard keyboard LEDs which are controlled 8 This is not related to standard keyboard LEDs which are controlled
12 via the input system. 9 via the input system.
13 10
11if NEW_LEDS
12
14config LEDS_CLASS 13config LEDS_CLASS
15 tristate "LED Class Support" 14 tristate "LED Class Support"
16 depends on NEW_LEDS
17 help 15 help
18 This option enables the led sysfs class in /sys/class/leds. You'll 16 This option enables the led sysfs class in /sys/class/leds. You'll
19 need this to do anything useful with LEDs. If unsure, say N. 17 need this to do anything useful with LEDs. If unsure, say N.
@@ -95,11 +93,18 @@ config LEDS_COBALT
95 help 93 help
96 This option enables support for the front LED on Cobalt Server 94 This option enables support for the front LED on Cobalt Server
97 95
96config LEDS_GPIO
97 tristate "LED Support for GPIO connected LEDs"
98 depends on LEDS_CLASS && GENERIC_GPIO
99 help
100 This option enables support for the LEDs connected to GPIO
101 outputs. To be useful the particular board must have LEDs
102 and they must be connected to the GPIO lines.
103
98comment "LED Triggers" 104comment "LED Triggers"
99 105
100config LEDS_TRIGGERS 106config LEDS_TRIGGERS
101 bool "LED Trigger support" 107 bool "LED Trigger support"
102 depends on NEW_LEDS
103 help 108 help
104 This option enables trigger support for the leds class. 109 This option enables trigger support for the leds class.
105 These triggers allow kernel events to drive the LEDs and can 110 These triggers allow kernel events to drive the LEDs and can
@@ -128,5 +133,4 @@ config LEDS_TRIGGER_HEARTBEAT
128 load average. 133 load average.
129 If unsure, say Y. 134 If unsure, say Y.
130 135
131endmenu 136endif # NEW_LEDS
132
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index aa2c18efa5b2..f8995c9bc2ea 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o
16obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o 16obj-$(CONFIG_LEDS_WRAP) += leds-wrap.o
17obj-$(CONFIG_LEDS_H1940) += leds-h1940.o 17obj-$(CONFIG_LEDS_H1940) += leds-h1940.o
18obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o 18obj-$(CONFIG_LEDS_COBALT) += leds-cobalt.o
19obj-$(CONFIG_LEDS_GPIO) += leds-gpio.o
19 20
20# LED Triggers 21# LED Triggers
21obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o 22obj-$(CONFIG_LEDS_TRIGGER_TIMER) += ledtrig-timer.o
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 3c1711210e38..4211293ce862 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -2,7 +2,7 @@
2 * LED Class Core 2 * LED Class Core
3 * 3 *
4 * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu> 4 * Copyright (C) 2005 John Lenz <lenz@cs.wisc.edu>
5 * Copyright (C) 2005-2006 Richard Purdie <rpurdie@openedhand.com> 5 * Copyright (C) 2005-2007 Richard Purdie <rpurdie@openedhand.com>
6 * 6 *
7 * This program is free software; you can redistribute it and/or modify 7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as 8 * it under the terms of the GNU General Public License version 2 as
@@ -24,9 +24,10 @@
24 24
25static struct class *leds_class; 25static struct class *leds_class;
26 26
27static ssize_t led_brightness_show(struct class_device *dev, char *buf) 27static ssize_t led_brightness_show(struct device *dev,
28 struct device_attribute *attr, char *buf)
28{ 29{
29 struct led_classdev *led_cdev = class_get_devdata(dev); 30 struct led_classdev *led_cdev = dev_get_drvdata(dev);
30 ssize_t ret = 0; 31 ssize_t ret = 0;
31 32
32 /* no lock needed for this */ 33 /* no lock needed for this */
@@ -36,10 +37,10 @@ static ssize_t led_brightness_show(struct class_device *dev, char *buf)
36 return ret; 37 return ret;
37} 38}
38 39
39static ssize_t led_brightness_store(struct class_device *dev, 40static ssize_t led_brightness_store(struct device *dev,
40 const char *buf, size_t size) 41 struct device_attribute *attr, const char *buf, size_t size)
41{ 42{
42 struct led_classdev *led_cdev = class_get_devdata(dev); 43 struct led_classdev *led_cdev = dev_get_drvdata(dev);
43 ssize_t ret = -EINVAL; 44 ssize_t ret = -EINVAL;
44 char *after; 45 char *after;
45 unsigned long state = simple_strtoul(buf, &after, 10); 46 unsigned long state = simple_strtoul(buf, &after, 10);
@@ -56,10 +57,9 @@ static ssize_t led_brightness_store(struct class_device *dev,
56 return ret; 57 return ret;
57} 58}
58 59
59static CLASS_DEVICE_ATTR(brightness, 0644, led_brightness_show, 60static DEVICE_ATTR(brightness, 0644, led_brightness_show, led_brightness_store);
60 led_brightness_store);
61#ifdef CONFIG_LEDS_TRIGGERS 61#ifdef CONFIG_LEDS_TRIGGERS
62static CLASS_DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store); 62static DEVICE_ATTR(trigger, 0644, led_trigger_show, led_trigger_store);
63#endif 63#endif
64 64
65/** 65/**
@@ -93,16 +93,15 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
93{ 93{
94 int rc; 94 int rc;
95 95
96 led_cdev->class_dev = class_device_create(leds_class, NULL, 0, 96 led_cdev->dev = device_create(leds_class, parent, 0, "%s",
97 parent, "%s", led_cdev->name); 97 led_cdev->name);
98 if (unlikely(IS_ERR(led_cdev->class_dev))) 98 if (unlikely(IS_ERR(led_cdev->dev)))
99 return PTR_ERR(led_cdev->class_dev); 99 return PTR_ERR(led_cdev->dev);
100 100
101 class_set_devdata(led_cdev->class_dev, led_cdev); 101 dev_set_drvdata(led_cdev->dev, led_cdev);
102 102
103 /* register the attributes */ 103 /* register the attributes */
104 rc = class_device_create_file(led_cdev->class_dev, 104 rc = device_create_file(led_cdev->dev, &dev_attr_brightness);
105 &class_device_attr_brightness);
106 if (rc) 105 if (rc)
107 goto err_out; 106 goto err_out;
108 107
@@ -114,8 +113,7 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
114#ifdef CONFIG_LEDS_TRIGGERS 113#ifdef CONFIG_LEDS_TRIGGERS
115 rwlock_init(&led_cdev->trigger_lock); 114 rwlock_init(&led_cdev->trigger_lock);
116 115
117 rc = class_device_create_file(led_cdev->class_dev, 116 rc = device_create_file(led_cdev->dev, &dev_attr_trigger);
118 &class_device_attr_trigger);
119 if (rc) 117 if (rc)
120 goto err_out_led_list; 118 goto err_out_led_list;
121 119
@@ -123,18 +121,17 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
123#endif 121#endif
124 122
125 printk(KERN_INFO "Registered led device: %s\n", 123 printk(KERN_INFO "Registered led device: %s\n",
126 led_cdev->class_dev->class_id); 124 led_cdev->name);
127 125
128 return 0; 126 return 0;
129 127
130#ifdef CONFIG_LEDS_TRIGGERS 128#ifdef CONFIG_LEDS_TRIGGERS
131err_out_led_list: 129err_out_led_list:
132 class_device_remove_file(led_cdev->class_dev, 130 device_remove_file(led_cdev->dev, &dev_attr_brightness);
133 &class_device_attr_brightness);
134 list_del(&led_cdev->node); 131 list_del(&led_cdev->node);
135#endif 132#endif
136err_out: 133err_out:
137 class_device_unregister(led_cdev->class_dev); 134 device_unregister(led_cdev->dev);
138 return rc; 135 return rc;
139} 136}
140EXPORT_SYMBOL_GPL(led_classdev_register); 137EXPORT_SYMBOL_GPL(led_classdev_register);
@@ -147,18 +144,16 @@ EXPORT_SYMBOL_GPL(led_classdev_register);
147 */ 144 */
148void led_classdev_unregister(struct led_classdev *led_cdev) 145void led_classdev_unregister(struct led_classdev *led_cdev)
149{ 146{
150 class_device_remove_file(led_cdev->class_dev, 147 device_remove_file(led_cdev->dev, &dev_attr_brightness);
151 &class_device_attr_brightness);
152#ifdef CONFIG_LEDS_TRIGGERS 148#ifdef CONFIG_LEDS_TRIGGERS
153 class_device_remove_file(led_cdev->class_dev, 149 device_remove_file(led_cdev->dev, &dev_attr_trigger);
154 &class_device_attr_trigger);
155 write_lock(&led_cdev->trigger_lock); 150 write_lock(&led_cdev->trigger_lock);
156 if (led_cdev->trigger) 151 if (led_cdev->trigger)
157 led_trigger_set(led_cdev, NULL); 152 led_trigger_set(led_cdev, NULL);
158 write_unlock(&led_cdev->trigger_lock); 153 write_unlock(&led_cdev->trigger_lock);
159#endif 154#endif
160 155
161 class_device_unregister(led_cdev->class_dev); 156 device_unregister(led_cdev->dev);
162 157
163 write_lock(&leds_list_lock); 158 write_lock(&leds_list_lock);
164 list_del(&led_cdev->node); 159 list_del(&led_cdev->node);
diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index 454fb0901f82..575368c2b100 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * LED Triggers Core 2 * LED Triggers Core
3 * 3 *
4 * Copyright 2005-2006 Openedhand Ltd. 4 * Copyright 2005-2007 Openedhand Ltd.
5 * 5 *
6 * Author: Richard Purdie <rpurdie@openedhand.com> 6 * Author: Richard Purdie <rpurdie@openedhand.com>
7 * 7 *
@@ -28,10 +28,10 @@
28static DEFINE_RWLOCK(triggers_list_lock); 28static DEFINE_RWLOCK(triggers_list_lock);
29static LIST_HEAD(trigger_list); 29static LIST_HEAD(trigger_list);
30 30
31ssize_t led_trigger_store(struct class_device *dev, const char *buf, 31ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
32 size_t count) 32 const char *buf, size_t count)
33{ 33{
34 struct led_classdev *led_cdev = class_get_devdata(dev); 34 struct led_classdev *led_cdev = dev_get_drvdata(dev);
35 char trigger_name[TRIG_NAME_MAX]; 35 char trigger_name[TRIG_NAME_MAX];
36 struct led_trigger *trig; 36 struct led_trigger *trig;
37 size_t len; 37 size_t len;
@@ -67,9 +67,10 @@ ssize_t led_trigger_store(struct class_device *dev, const char *buf,
67} 67}
68 68
69 69
70ssize_t led_trigger_show(struct class_device *dev, char *buf) 70ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
71 char *buf)
71{ 72{
72 struct led_classdev *led_cdev = class_get_devdata(dev); 73 struct led_classdev *led_cdev = dev_get_drvdata(dev);
73 struct led_trigger *trig; 74 struct led_trigger *trig;
74 int len = 0; 75 int len = 0;
75 76
@@ -183,13 +184,20 @@ int led_trigger_register(struct led_trigger *trigger)
183void led_trigger_register_simple(const char *name, struct led_trigger **tp) 184void led_trigger_register_simple(const char *name, struct led_trigger **tp)
184{ 185{
185 struct led_trigger *trigger; 186 struct led_trigger *trigger;
187 int err;
186 188
187 trigger = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); 189 trigger = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
188 190
189 if (trigger) { 191 if (trigger) {
190 trigger->name = name; 192 trigger->name = name;
191 led_trigger_register(trigger); 193 err = led_trigger_register(trigger);
192 } 194 if (err < 0)
195 printk(KERN_WARNING "LED trigger %s failed to register"
196 " (%d)\n", name, err);
197 } else
198 printk(KERN_WARNING "LED trigger %s failed to register"
199 " (no memory)\n", name);
200
193 *tp = trigger; 201 *tp = trigger;
194} 202}
195 203
@@ -215,7 +223,8 @@ void led_trigger_unregister(struct led_trigger *trigger)
215 223
216void led_trigger_unregister_simple(struct led_trigger *trigger) 224void led_trigger_unregister_simple(struct led_trigger *trigger)
217{ 225{
218 led_trigger_unregister(trigger); 226 if (trigger)
227 led_trigger_unregister(trigger);
219 kfree(trigger); 228 kfree(trigger);
220} 229}
221 230
diff --git a/drivers/leds/leds-gpio.c b/drivers/leds/leds-gpio.c
new file mode 100644
index 000000000000..47d90db280ce
--- /dev/null
+++ b/drivers/leds/leds-gpio.c
@@ -0,0 +1,199 @@
1/*
2 * LEDs driver for GPIOs
3 *
4 * Copyright (C) 2007 8D Technologies inc.
5 * Raphael Assenat <raph@8d.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12#include <linux/kernel.h>
13#include <linux/init.h>
14#include <linux/platform_device.h>
15#include <linux/leds.h>
16#include <linux/workqueue.h>
17
18#include <asm/gpio.h>
19
20struct gpio_led_data {
21 struct led_classdev cdev;
22 unsigned gpio;
23 struct work_struct work;
24 u8 new_level;
25 u8 can_sleep;
26 u8 active_low;
27};
28
29static void gpio_led_work(struct work_struct *work)
30{
31 struct gpio_led_data *led_dat =
32 container_of(work, struct gpio_led_data, work);
33
34 gpio_set_value_cansleep(led_dat->gpio, led_dat->new_level);
35}
36
37static void gpio_led_set(struct led_classdev *led_cdev,
38 enum led_brightness value)
39{
40 struct gpio_led_data *led_dat =
41 container_of(led_cdev, struct gpio_led_data, cdev);
42 int level;
43
44 if (value == LED_OFF)
45 level = 0;
46 else
47 level = 1;
48
49 if (led_dat->active_low)
50 level = !level;
51
52 /* setting GPIOs with I2C/etc requires a preemptible task context */
53 if (led_dat->can_sleep) {
54 if (preempt_count()) {
55 led_dat->new_level = level;
56 schedule_work(&led_dat->work);
57 } else
58 gpio_set_value_cansleep(led_dat->gpio, level);
59 } else
60 gpio_set_value(led_dat->gpio, level);
61}
62
63static int __init gpio_led_probe(struct platform_device *pdev)
64{
65 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
66 struct gpio_led *cur_led;
67 struct gpio_led_data *leds_data, *led_dat;
68 int i, ret = 0;
69
70 if (!pdata)
71 return -EBUSY;
72
73 leds_data = kzalloc(sizeof(struct gpio_led_data) * pdata->num_leds,
74 GFP_KERNEL);
75 if (!leds_data)
76 return -ENOMEM;
77
78 for (i = 0; i < pdata->num_leds; i++) {
79 cur_led = &pdata->leds[i];
80 led_dat = &leds_data[i];
81
82 led_dat->cdev.name = cur_led->name;
83 led_dat->cdev.default_trigger = cur_led->default_trigger;
84 led_dat->gpio = cur_led->gpio;
85 led_dat->can_sleep = gpio_cansleep(cur_led->gpio);
86 led_dat->active_low = cur_led->active_low;
87 led_dat->cdev.brightness_set = gpio_led_set;
88 led_dat->cdev.brightness = cur_led->active_low ? LED_FULL : LED_OFF;
89
90 ret = gpio_request(led_dat->gpio, led_dat->cdev.name);
91 if (ret < 0)
92 goto err;
93
94 gpio_direction_output(led_dat->gpio, led_dat->active_low);
95
96 ret = led_classdev_register(&pdev->dev, &led_dat->cdev);
97 if (ret < 0) {
98 gpio_free(led_dat->gpio);
99 goto err;
100 }
101
102 INIT_WORK(&led_dat->work, gpio_led_work);
103 }
104
105 platform_set_drvdata(pdev, leds_data);
106
107 return 0;
108
109err:
110 if (i > 0) {
111 for (i = i - 1; i >= 0; i--) {
112 led_classdev_unregister(&leds_data[i].cdev);
113 gpio_free(leds_data[i].gpio);
114 }
115 }
116
117 flush_scheduled_work();
118 kfree(leds_data);
119
120 return ret;
121}
122
123static int __exit gpio_led_remove(struct platform_device *pdev)
124{
125 int i;
126 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
127 struct gpio_led_data *leds_data;
128
129 leds_data = platform_get_drvdata(pdev);
130
131 for (i = 0; i < pdata->num_leds; i++) {
132 led_classdev_unregister(&leds_data[i].cdev);
133 gpio_free(leds_data[i].gpio);
134 }
135
136 kfree(leds_data);
137
138 return 0;
139}
140
141#ifdef CONFIG_PM
142static int gpio_led_suspend(struct platform_device *pdev, pm_message_t state)
143{
144 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
145 struct gpio_led_data *leds_data;
146 int i;
147
148 leds_data = platform_get_drvdata(pdev);
149
150 for (i = 0; i < pdata->num_leds; i++)
151 led_classdev_suspend(&leds_data[i].cdev);
152
153 return 0;
154}
155
156static int gpio_led_resume(struct platform_device *pdev)
157{
158 struct gpio_led_platform_data *pdata = pdev->dev.platform_data;
159 struct gpio_led_data *leds_data;
160 int i;
161
162 leds_data = platform_get_drvdata(pdev);
163
164 for (i = 0; i < pdata->num_leds; i++)
165 led_classdev_resume(&leds_data[i].cdev);
166
167 return 0;
168}
169#else
170#define gpio_led_suspend NULL
171#define gpio_led_resume NULL
172#endif
173
174static struct platform_driver gpio_led_driver = {
175 .remove = __exit_p(gpio_led_remove),
176 .suspend = gpio_led_suspend,
177 .resume = gpio_led_resume,
178 .driver = {
179 .name = "leds-gpio",
180 .owner = THIS_MODULE,
181 },
182};
183
184static int __init gpio_led_init(void)
185{
186 return platform_driver_probe(&gpio_led_driver, gpio_led_probe);
187}
188
189static void __exit gpio_led_exit(void)
190{
191 platform_driver_unregister(&gpio_led_driver);
192}
193
194module_init(gpio_led_init);
195module_exit(gpio_led_exit);
196
197MODULE_AUTHOR("Raphael Assenat <raph@8d.com>");
198MODULE_DESCRIPTION("GPIO LED driver");
199MODULE_LICENSE("GPL");
diff --git a/drivers/leds/leds-locomo.c b/drivers/leds/leds-locomo.c
index 6f2d449ba983..bfac499f3258 100644
--- a/drivers/leds/leds-locomo.c
+++ b/drivers/leds/leds-locomo.c
@@ -19,7 +19,7 @@
19static void locomoled_brightness_set(struct led_classdev *led_cdev, 19static void locomoled_brightness_set(struct led_classdev *led_cdev,
20 enum led_brightness value, int offset) 20 enum led_brightness value, int offset)
21{ 21{
22 struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->class_dev->dev); 22 struct locomo_dev *locomo_dev = LOCOMO_DEV(led_cdev->dev);
23 unsigned long flags; 23 unsigned long flags;
24 24
25 local_irq_save(flags); 25 local_irq_save(flags);
diff --git a/drivers/leds/leds.h b/drivers/leds/leds.h
index a715c4ed93ff..f2f3884fe063 100644
--- a/drivers/leds/leds.h
+++ b/drivers/leds/leds.h
@@ -13,6 +13,7 @@
13#ifndef __LEDS_H_INCLUDED 13#ifndef __LEDS_H_INCLUDED
14#define __LEDS_H_INCLUDED 14#define __LEDS_H_INCLUDED
15 15
16#include <linux/device.h>
16#include <linux/leds.h> 17#include <linux/leds.h>
17 18
18static inline void led_set_brightness(struct led_classdev *led_cdev, 19static inline void led_set_brightness(struct led_classdev *led_cdev,
@@ -37,8 +38,9 @@ void led_trigger_set(struct led_classdev *led_cdev,
37#define led_trigger_set(x, y) do {} while(0) 38#define led_trigger_set(x, y) do {} while(0)
38#endif 39#endif
39 40
40ssize_t led_trigger_store(struct class_device *dev, const char *buf, 41ssize_t led_trigger_store(struct device *dev, struct device_attribute *attr,
41 size_t count); 42 const char *buf, size_t count);
42ssize_t led_trigger_show(struct class_device *dev, char *buf); 43ssize_t led_trigger_show(struct device *dev, struct device_attribute *attr,
44 char *buf);
43 45
44#endif /* __LEDS_H_INCLUDED */ 46#endif /* __LEDS_H_INCLUDED */
diff --git a/drivers/leds/ledtrig-timer.c b/drivers/leds/ledtrig-timer.c
index d756bdb01c59..ed9ff02c77ea 100644
--- a/drivers/leds/ledtrig-timer.c
+++ b/drivers/leds/ledtrig-timer.c
@@ -52,9 +52,10 @@ static void led_timer_function(unsigned long data)
52 mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay)); 52 mod_timer(&timer_data->timer, jiffies + msecs_to_jiffies(delay));
53} 53}
54 54
55static ssize_t led_delay_on_show(struct class_device *dev, char *buf) 55static ssize_t led_delay_on_show(struct device *dev,
56 struct device_attribute *attr, char *buf)
56{ 57{
57 struct led_classdev *led_cdev = class_get_devdata(dev); 58 struct led_classdev *led_cdev = dev_get_drvdata(dev);
58 struct timer_trig_data *timer_data = led_cdev->trigger_data; 59 struct timer_trig_data *timer_data = led_cdev->trigger_data;
59 60
60 sprintf(buf, "%lu\n", timer_data->delay_on); 61 sprintf(buf, "%lu\n", timer_data->delay_on);
@@ -62,10 +63,10 @@ static ssize_t led_delay_on_show(struct class_device *dev, char *buf)
62 return strlen(buf) + 1; 63 return strlen(buf) + 1;
63} 64}
64 65
65static ssize_t led_delay_on_store(struct class_device *dev, const char *buf, 66static ssize_t led_delay_on_store(struct device *dev,
66 size_t size) 67 struct device_attribute *attr, const char *buf, size_t size)
67{ 68{
68 struct led_classdev *led_cdev = class_get_devdata(dev); 69 struct led_classdev *led_cdev = dev_get_drvdata(dev);
69 struct timer_trig_data *timer_data = led_cdev->trigger_data; 70 struct timer_trig_data *timer_data = led_cdev->trigger_data;
70 int ret = -EINVAL; 71 int ret = -EINVAL;
71 char *after; 72 char *after;
@@ -84,9 +85,10 @@ static ssize_t led_delay_on_store(struct class_device *dev, const char *buf,
84 return ret; 85 return ret;
85} 86}
86 87
87static ssize_t led_delay_off_show(struct class_device *dev, char *buf) 88static ssize_t led_delay_off_show(struct device *dev,
89 struct device_attribute *attr, char *buf)
88{ 90{
89 struct led_classdev *led_cdev = class_get_devdata(dev); 91 struct led_classdev *led_cdev = dev_get_drvdata(dev);
90 struct timer_trig_data *timer_data = led_cdev->trigger_data; 92 struct timer_trig_data *timer_data = led_cdev->trigger_data;
91 93
92 sprintf(buf, "%lu\n", timer_data->delay_off); 94 sprintf(buf, "%lu\n", timer_data->delay_off);
@@ -94,10 +96,10 @@ static ssize_t led_delay_off_show(struct class_device *dev, char *buf)
94 return strlen(buf) + 1; 96 return strlen(buf) + 1;
95} 97}
96 98
97static ssize_t led_delay_off_store(struct class_device *dev, const char *buf, 99static ssize_t led_delay_off_store(struct device *dev,
98 size_t size) 100 struct device_attribute *attr, const char *buf, size_t size)
99{ 101{
100 struct led_classdev *led_cdev = class_get_devdata(dev); 102 struct led_classdev *led_cdev = dev_get_drvdata(dev);
101 struct timer_trig_data *timer_data = led_cdev->trigger_data; 103 struct timer_trig_data *timer_data = led_cdev->trigger_data;
102 int ret = -EINVAL; 104 int ret = -EINVAL;
103 char *after; 105 char *after;
@@ -116,10 +118,8 @@ static ssize_t led_delay_off_store(struct class_device *dev, const char *buf,
116 return ret; 118 return ret;
117} 119}
118 120
119static CLASS_DEVICE_ATTR(delay_on, 0644, led_delay_on_show, 121static DEVICE_ATTR(delay_on, 0644, led_delay_on_show, led_delay_on_store);
120 led_delay_on_store); 122static DEVICE_ATTR(delay_off, 0644, led_delay_off_show, led_delay_off_store);
121static CLASS_DEVICE_ATTR(delay_off, 0644, led_delay_off_show,
122 led_delay_off_store);
123 123
124static void timer_trig_activate(struct led_classdev *led_cdev) 124static void timer_trig_activate(struct led_classdev *led_cdev)
125{ 125{
@@ -136,18 +136,17 @@ static void timer_trig_activate(struct led_classdev *led_cdev)
136 timer_data->timer.function = led_timer_function; 136 timer_data->timer.function = led_timer_function;
137 timer_data->timer.data = (unsigned long) led_cdev; 137 timer_data->timer.data = (unsigned long) led_cdev;
138 138
139 rc = class_device_create_file(led_cdev->class_dev, 139 rc = device_create_file(led_cdev->dev, &dev_attr_delay_on);
140 &class_device_attr_delay_on); 140 if (rc)
141 if (rc) goto err_out; 141 goto err_out;
142 rc = class_device_create_file(led_cdev->class_dev, 142 rc = device_create_file(led_cdev->dev, &dev_attr_delay_off);
143 &class_device_attr_delay_off); 143 if (rc)
144 if (rc) goto err_out_delayon; 144 goto err_out_delayon;
145 145
146 return; 146 return;
147 147
148err_out_delayon: 148err_out_delayon:
149 class_device_remove_file(led_cdev->class_dev, 149 device_remove_file(led_cdev->dev, &dev_attr_delay_on);
150 &class_device_attr_delay_on);
151err_out: 150err_out:
152 led_cdev->trigger_data = NULL; 151 led_cdev->trigger_data = NULL;
153 kfree(timer_data); 152 kfree(timer_data);
@@ -158,10 +157,8 @@ static void timer_trig_deactivate(struct led_classdev *led_cdev)
158 struct timer_trig_data *timer_data = led_cdev->trigger_data; 157 struct timer_trig_data *timer_data = led_cdev->trigger_data;
159 158
160 if (timer_data) { 159 if (timer_data) {
161 class_device_remove_file(led_cdev->class_dev, 160 device_remove_file(led_cdev->dev, &dev_attr_delay_on);
162 &class_device_attr_delay_on); 161 device_remove_file(led_cdev->dev, &dev_attr_delay_off);
163 class_device_remove_file(led_cdev->class_dev,
164 &class_device_attr_delay_off);
165 del_timer_sync(&timer_data->timer); 162 del_timer_sync(&timer_data->timer);
166 kfree(timer_data); 163 kfree(timer_data);
167 } 164 }
diff --git a/drivers/lguest/lguest.c b/drivers/lguest/lguest.c
index 434fea1e82f7..18dade06d4a9 100644
--- a/drivers/lguest/lguest.c
+++ b/drivers/lguest/lguest.c
@@ -398,6 +398,8 @@ static void lguest_clockevent_set_mode(enum clock_event_mode mode,
398 break; 398 break;
399 case CLOCK_EVT_MODE_PERIODIC: 399 case CLOCK_EVT_MODE_PERIODIC:
400 BUG(); 400 BUG();
401 case CLOCK_EVT_MODE_RESUME:
402 break;
401 } 403 }
402} 404}
403 405
diff --git a/drivers/macintosh/rack-meter.c b/drivers/macintosh/rack-meter.c
index 4177ff004753..2c21d4f25cc8 100644
--- a/drivers/macintosh/rack-meter.c
+++ b/drivers/macintosh/rack-meter.c
@@ -30,7 +30,6 @@
30#include <asm/machdep.h> 30#include <asm/machdep.h>
31#include <asm/pmac_feature.h> 31#include <asm/pmac_feature.h>
32#include <asm/dbdma.h> 32#include <asm/dbdma.h>
33#include <asm/dbdma.h>
34#include <asm/macio.h> 33#include <asm/macio.h>
35#include <asm/keylargo.h> 34#include <asm/keylargo.h>
36 35
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index ba952a032598..bdc52d6922b7 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -920,6 +920,8 @@ static void crypt_dtr(struct dm_target *ti)
920{ 920{
921 struct crypt_config *cc = (struct crypt_config *) ti->private; 921 struct crypt_config *cc = (struct crypt_config *) ti->private;
922 922
923 flush_workqueue(_kcryptd_workqueue);
924
923 bioset_free(cc->bs); 925 bioset_free(cc->bs);
924 mempool_destroy(cc->page_pool); 926 mempool_destroy(cc->page_pool);
925 mempool_destroy(cc->io_pool); 927 mempool_destroy(cc->io_pool);
diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig
index c88cc75ab49b..4494e0fd36c6 100644
--- a/drivers/message/fusion/Kconfig
+++ b/drivers/message/fusion/Kconfig
@@ -37,6 +37,7 @@ config FUSION_FC
37 LSIFC929 37 LSIFC929
38 LSIFC929X 38 LSIFC929X
39 LSIFC929XL 39 LSIFC929XL
40 Brocade FC 410/420
40 41
41config FUSION_SAS 42config FUSION_SAS
42 tristate "Fusion MPT ScsiHost drivers for SAS" 43 tristate "Fusion MPT ScsiHost drivers for SAS"
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 5a10c87239c2..04f75e24dcec 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -161,6 +161,7 @@ static int mpt_readScsiDevicePageHeaders(MPT_ADAPTER *ioc, int portnum);
161static void mpt_read_ioc_pg_1(MPT_ADAPTER *ioc); 161static void mpt_read_ioc_pg_1(MPT_ADAPTER *ioc);
162static void mpt_read_ioc_pg_4(MPT_ADAPTER *ioc); 162static void mpt_read_ioc_pg_4(MPT_ADAPTER *ioc);
163static void mpt_timer_expired(unsigned long data); 163static void mpt_timer_expired(unsigned long data);
164static void mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc);
164static int SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch); 165static int SendEventNotification(MPT_ADAPTER *ioc, u8 EvSwitch);
165static int SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp); 166static int SendEventAck(MPT_ADAPTER *ioc, EventNotificationReply_t *evnp);
166static int mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag); 167static int mpt_host_page_access_control(MPT_ADAPTER *ioc, u8 access_control_value, int sleepFlag);
@@ -1131,6 +1132,248 @@ mpt_verify_adapter(int iocid, MPT_ADAPTER **iocpp)
1131 return -1; 1132 return -1;
1132} 1133}
1133 1134
1135/**
1136 * mpt_get_product_name - returns product string
1137 * @vendor: pci vendor id
1138 * @device: pci device id
1139 * @revision: pci revision id
1140 * @prod_name: string returned
1141 *
1142 * Returns product string displayed when driver loads,
1143 * in /proc/mpt/summary and /sysfs/class/scsi_host/host<X>/version_product
1144 *
1145 **/
1146static void
1147mpt_get_product_name(u16 vendor, u16 device, u8 revision, char *prod_name)
1148{
1149 char *product_str = NULL;
1150
1151 if (vendor == PCI_VENDOR_ID_BROCADE) {
1152 switch (device)
1153 {
1154 case MPI_MANUFACTPAGE_DEVICEID_FC949E:
1155 switch (revision)
1156 {
1157 case 0x00:
1158 product_str = "BRE040 A0";
1159 break;
1160 case 0x01:
1161 product_str = "BRE040 A1";
1162 break;
1163 default:
1164 product_str = "BRE040";
1165 break;
1166 }
1167 break;
1168 }
1169 goto out;
1170 }
1171
1172 switch (device)
1173 {
1174 case MPI_MANUFACTPAGE_DEVICEID_FC909:
1175 product_str = "LSIFC909 B1";
1176 break;
1177 case MPI_MANUFACTPAGE_DEVICEID_FC919:
1178 product_str = "LSIFC919 B0";
1179 break;
1180 case MPI_MANUFACTPAGE_DEVICEID_FC929:
1181 product_str = "LSIFC929 B0";
1182 break;
1183 case MPI_MANUFACTPAGE_DEVICEID_FC919X:
1184 if (revision < 0x80)
1185 product_str = "LSIFC919X A0";
1186 else
1187 product_str = "LSIFC919XL A1";
1188 break;
1189 case MPI_MANUFACTPAGE_DEVICEID_FC929X:
1190 if (revision < 0x80)
1191 product_str = "LSIFC929X A0";
1192 else
1193 product_str = "LSIFC929XL A1";
1194 break;
1195 case MPI_MANUFACTPAGE_DEVICEID_FC939X:
1196 product_str = "LSIFC939X A1";
1197 break;
1198 case MPI_MANUFACTPAGE_DEVICEID_FC949X:
1199 product_str = "LSIFC949X A1";
1200 break;
1201 case MPI_MANUFACTPAGE_DEVICEID_FC949E:
1202 switch (revision)
1203 {
1204 case 0x00:
1205 product_str = "LSIFC949E A0";
1206 break;
1207 case 0x01:
1208 product_str = "LSIFC949E A1";
1209 break;
1210 default:
1211 product_str = "LSIFC949E";
1212 break;
1213 }
1214 break;
1215 case MPI_MANUFACTPAGE_DEVID_53C1030:
1216 switch (revision)
1217 {
1218 case 0x00:
1219 product_str = "LSI53C1030 A0";
1220 break;
1221 case 0x01:
1222 product_str = "LSI53C1030 B0";
1223 break;
1224 case 0x03:
1225 product_str = "LSI53C1030 B1";
1226 break;
1227 case 0x07:
1228 product_str = "LSI53C1030 B2";
1229 break;
1230 case 0x08:
1231 product_str = "LSI53C1030 C0";
1232 break;
1233 case 0x80:
1234 product_str = "LSI53C1030T A0";
1235 break;
1236 case 0x83:
1237 product_str = "LSI53C1030T A2";
1238 break;
1239 case 0x87:
1240 product_str = "LSI53C1030T A3";
1241 break;
1242 case 0xc1:
1243 product_str = "LSI53C1020A A1";
1244 break;
1245 default:
1246 product_str = "LSI53C1030";
1247 break;
1248 }
1249 break;
1250 case MPI_MANUFACTPAGE_DEVID_1030_53C1035:
1251 switch (revision)
1252 {
1253 case 0x03:
1254 product_str = "LSI53C1035 A2";
1255 break;
1256 case 0x04:
1257 product_str = "LSI53C1035 B0";
1258 break;
1259 default:
1260 product_str = "LSI53C1035";
1261 break;
1262 }
1263 break;
1264 case MPI_MANUFACTPAGE_DEVID_SAS1064:
1265 switch (revision)
1266 {
1267 case 0x00:
1268 product_str = "LSISAS1064 A1";
1269 break;
1270 case 0x01:
1271 product_str = "LSISAS1064 A2";
1272 break;
1273 case 0x02:
1274 product_str = "LSISAS1064 A3";
1275 break;
1276 case 0x03:
1277 product_str = "LSISAS1064 A4";
1278 break;
1279 default:
1280 product_str = "LSISAS1064";
1281 break;
1282 }
1283 break;
1284 case MPI_MANUFACTPAGE_DEVID_SAS1064E:
1285 switch (revision)
1286 {
1287 case 0x00:
1288 product_str = "LSISAS1064E A0";
1289 break;
1290 case 0x01:
1291 product_str = "LSISAS1064E B0";
1292 break;
1293 case 0x02:
1294 product_str = "LSISAS1064E B1";
1295 break;
1296 case 0x04:
1297 product_str = "LSISAS1064E B2";
1298 break;
1299 case 0x08:
1300 product_str = "LSISAS1064E B3";
1301 break;
1302 default:
1303 product_str = "LSISAS1064E";
1304 break;
1305 }
1306 break;
1307 case MPI_MANUFACTPAGE_DEVID_SAS1068:
1308 switch (revision)
1309 {
1310 case 0x00:
1311 product_str = "LSISAS1068 A0";
1312 break;
1313 case 0x01:
1314 product_str = "LSISAS1068 B0";
1315 break;
1316 case 0x02:
1317 product_str = "LSISAS1068 B1";
1318 break;
1319 default:
1320 product_str = "LSISAS1068";
1321 break;
1322 }
1323 break;
1324 case MPI_MANUFACTPAGE_DEVID_SAS1068E:
1325 switch (revision)
1326 {
1327 case 0x00:
1328 product_str = "LSISAS1068E A0";
1329 break;
1330 case 0x01:
1331 product_str = "LSISAS1068E B0";
1332 break;
1333 case 0x02:
1334 product_str = "LSISAS1068E B1";
1335 break;
1336 case 0x04:
1337 product_str = "LSISAS1068E B2";
1338 break;
1339 case 0x08:
1340 product_str = "LSISAS1068E B3";
1341 break;
1342 default:
1343 product_str = "LSISAS1068E";
1344 break;
1345 }
1346 break;
1347 case MPI_MANUFACTPAGE_DEVID_SAS1078:
1348 switch (revision)
1349 {
1350 case 0x00:
1351 product_str = "LSISAS1078 A0";
1352 break;
1353 case 0x01:
1354 product_str = "LSISAS1078 B0";
1355 break;
1356 case 0x02:
1357 product_str = "LSISAS1078 C0";
1358 break;
1359 case 0x03:
1360 product_str = "LSISAS1078 C1";
1361 break;
1362 case 0x04:
1363 product_str = "LSISAS1078 C2";
1364 break;
1365 default:
1366 product_str = "LSISAS1078";
1367 break;
1368 }
1369 break;
1370 }
1371
1372 out:
1373 if (product_str)
1374 sprintf(prod_name, "%s", product_str);
1375}
1376
1134/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1377/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
1135/** 1378/**
1136 * mpt_attach - Install a PCI intelligent MPT adapter. 1379 * mpt_attach - Install a PCI intelligent MPT adapter.
@@ -1274,23 +1517,23 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1274 ioc->pio_chip = (SYSIF_REGS __iomem *)pmem; 1517 ioc->pio_chip = (SYSIF_REGS __iomem *)pmem;
1275 } 1518 }
1276 1519
1277 if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC909) { 1520 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1278 ioc->prod_name = "LSIFC909"; 1521 mpt_get_product_name(pdev->vendor, pdev->device, revision, ioc->prod_name);
1279 ioc->bus_type = FC; 1522
1280 } 1523 switch (pdev->device)
1281 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC929) { 1524 {
1282 ioc->prod_name = "LSIFC929"; 1525 case MPI_MANUFACTPAGE_DEVICEID_FC939X:
1283 ioc->bus_type = FC; 1526 case MPI_MANUFACTPAGE_DEVICEID_FC949X:
1284 } 1527 ioc->errata_flag_1064 = 1;
1285 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC919) { 1528 case MPI_MANUFACTPAGE_DEVICEID_FC909:
1286 ioc->prod_name = "LSIFC919"; 1529 case MPI_MANUFACTPAGE_DEVICEID_FC929:
1287 ioc->bus_type = FC; 1530 case MPI_MANUFACTPAGE_DEVICEID_FC919:
1288 } 1531 case MPI_MANUFACTPAGE_DEVICEID_FC949E:
1289 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC929X) {
1290 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1291 ioc->bus_type = FC; 1532 ioc->bus_type = FC;
1533 break;
1534
1535 case MPI_MANUFACTPAGE_DEVICEID_FC929X:
1292 if (revision < XL_929) { 1536 if (revision < XL_929) {
1293 ioc->prod_name = "LSIFC929X";
1294 /* 929X Chip Fix. Set Split transactions level 1537 /* 929X Chip Fix. Set Split transactions level
1295 * for PCIX. Set MOST bits to zero. 1538 * for PCIX. Set MOST bits to zero.
1296 */ 1539 */
@@ -1298,75 +1541,46 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
1298 pcixcmd &= 0x8F; 1541 pcixcmd &= 0x8F;
1299 pci_write_config_byte(pdev, 0x6a, pcixcmd); 1542 pci_write_config_byte(pdev, 0x6a, pcixcmd);
1300 } else { 1543 } else {
1301 ioc->prod_name = "LSIFC929XL";
1302 /* 929XL Chip Fix. Set MMRBC to 0x08. 1544 /* 929XL Chip Fix. Set MMRBC to 0x08.
1303 */ 1545 */
1304 pci_read_config_byte(pdev, 0x6a, &pcixcmd); 1546 pci_read_config_byte(pdev, 0x6a, &pcixcmd);
1305 pcixcmd |= 0x08; 1547 pcixcmd |= 0x08;
1306 pci_write_config_byte(pdev, 0x6a, pcixcmd); 1548 pci_write_config_byte(pdev, 0x6a, pcixcmd);
1307 } 1549 }
1308 }
1309 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC919X) {
1310 ioc->prod_name = "LSIFC919X";
1311 ioc->bus_type = FC; 1550 ioc->bus_type = FC;
1551 break;
1552
1553 case MPI_MANUFACTPAGE_DEVICEID_FC919X:
1312 /* 919X Chip Fix. Set Split transactions level 1554 /* 919X Chip Fix. Set Split transactions level
1313 * for PCIX. Set MOST bits to zero. 1555 * for PCIX. Set MOST bits to zero.
1314 */ 1556 */
1315 pci_read_config_byte(pdev, 0x6a, &pcixcmd); 1557 pci_read_config_byte(pdev, 0x6a, &pcixcmd);
1316 pcixcmd &= 0x8F; 1558 pcixcmd &= 0x8F;
1317 pci_write_config_byte(pdev, 0x6a, pcixcmd); 1559 pci_write_config_byte(pdev, 0x6a, pcixcmd);
1318 }
1319 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC939X) {
1320 ioc->prod_name = "LSIFC939X";
1321 ioc->bus_type = FC;
1322 ioc->errata_flag_1064 = 1;
1323 }
1324 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC949X) {
1325 ioc->prod_name = "LSIFC949X";
1326 ioc->bus_type = FC; 1560 ioc->bus_type = FC;
1327 ioc->errata_flag_1064 = 1; 1561 break;
1328 } 1562
1329 else if (pdev->device == MPI_MANUFACTPAGE_DEVICEID_FC949E) { 1563 case MPI_MANUFACTPAGE_DEVID_53C1030:
1330 ioc->prod_name = "LSIFC949E";
1331 ioc->bus_type = FC;
1332 }
1333 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_53C1030) {
1334 ioc->prod_name = "LSI53C1030";
1335 ioc->bus_type = SPI;
1336 /* 1030 Chip Fix. Disable Split transactions 1564 /* 1030 Chip Fix. Disable Split transactions
1337 * for PCIX. Set MOST bits to zero if Rev < C0( = 8). 1565 * for PCIX. Set MOST bits to zero if Rev < C0( = 8).
1338 */ 1566 */
1339 pci_read_config_byte(pdev, PCI_CLASS_REVISION, &revision);
1340 if (revision < C0_1030) { 1567 if (revision < C0_1030) {
1341 pci_read_config_byte(pdev, 0x6a, &pcixcmd); 1568 pci_read_config_byte(pdev, 0x6a, &pcixcmd);
1342 pcixcmd &= 0x8F; 1569 pcixcmd &= 0x8F;
1343 pci_write_config_byte(pdev, 0x6a, pcixcmd); 1570 pci_write_config_byte(pdev, 0x6a, pcixcmd);
1344 } 1571 }
1345 } 1572
1346 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_1030_53C1035) { 1573 case MPI_MANUFACTPAGE_DEVID_1030_53C1035:
1347 ioc->prod_name = "LSI53C1035";
1348 ioc->bus_type = SPI; 1574 ioc->bus_type = SPI;
1349 } 1575 break;
1350 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064) { 1576
1351 ioc->prod_name = "LSISAS1064"; 1577 case MPI_MANUFACTPAGE_DEVID_SAS1064:
1352 ioc->bus_type = SAS; 1578 case MPI_MANUFACTPAGE_DEVID_SAS1068:
1353 ioc->errata_flag_1064 = 1;
1354 }
1355 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068) {
1356 ioc->prod_name = "LSISAS1068";
1357 ioc->bus_type = SAS;
1358 ioc->errata_flag_1064 = 1; 1579 ioc->errata_flag_1064 = 1;
1359 } 1580
1360 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1064E) { 1581 case MPI_MANUFACTPAGE_DEVID_SAS1064E:
1361 ioc->prod_name = "LSISAS1064E"; 1582 case MPI_MANUFACTPAGE_DEVID_SAS1068E:
1362 ioc->bus_type = SAS; 1583 case MPI_MANUFACTPAGE_DEVID_SAS1078:
1363 }
1364 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1068E) {
1365 ioc->prod_name = "LSISAS1068E";
1366 ioc->bus_type = SAS;
1367 }
1368 else if (pdev->device == MPI_MANUFACTPAGE_DEVID_SAS1078) {
1369 ioc->prod_name = "LSISAS1078";
1370 ioc->bus_type = SAS; 1584 ioc->bus_type = SAS;
1371 } 1585 }
1372 1586
@@ -1880,6 +2094,7 @@ mpt_do_ioc_recovery(MPT_ADAPTER *ioc, u32 reason, int sleepFlag)
1880 } 2094 }
1881 2095
1882 GetIoUnitPage2(ioc); 2096 GetIoUnitPage2(ioc);
2097 mpt_get_manufacturing_pg_0(ioc);
1883 } 2098 }
1884 2099
1885 /* 2100 /*
@@ -2138,8 +2353,8 @@ MptDisplayIocCapabilities(MPT_ADAPTER *ioc)
2138 int i = 0; 2353 int i = 0;
2139 2354
2140 printk(KERN_INFO "%s: ", ioc->name); 2355 printk(KERN_INFO "%s: ", ioc->name);
2141 if (ioc->prod_name && strlen(ioc->prod_name) > 3) 2356 if (ioc->prod_name)
2142 printk("%s: ", ioc->prod_name+3); 2357 printk("%s: ", ioc->prod_name);
2143 printk("Capabilities={"); 2358 printk("Capabilities={");
2144 2359
2145 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) { 2360 if (ioc->pfacts[0].ProtocolFlags & MPI_PORTFACTS_PROTOCOL_INITIATOR) {
@@ -5190,6 +5405,49 @@ mpt_read_ioc_pg_1(MPT_ADAPTER *ioc)
5190 return; 5405 return;
5191} 5406}
5192 5407
5408static void
5409mpt_get_manufacturing_pg_0(MPT_ADAPTER *ioc)
5410{
5411 CONFIGPARMS cfg;
5412 ConfigPageHeader_t hdr;
5413 dma_addr_t buf_dma;
5414 ManufacturingPage0_t *pbuf = NULL;
5415
5416 memset(&cfg, 0 , sizeof(CONFIGPARMS));
5417 memset(&hdr, 0 , sizeof(ConfigPageHeader_t));
5418
5419 hdr.PageType = MPI_CONFIG_PAGETYPE_MANUFACTURING;
5420 cfg.cfghdr.hdr = &hdr;
5421 cfg.physAddr = -1;
5422 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
5423 cfg.timeout = 10;
5424
5425 if (mpt_config(ioc, &cfg) != 0)
5426 goto out;
5427
5428 if (!cfg.cfghdr.hdr->PageLength)
5429 goto out;
5430
5431 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
5432 pbuf = pci_alloc_consistent(ioc->pcidev, hdr.PageLength * 4, &buf_dma);
5433 if (!pbuf)
5434 goto out;
5435
5436 cfg.physAddr = buf_dma;
5437
5438 if (mpt_config(ioc, &cfg) != 0)
5439 goto out;
5440
5441 memcpy(ioc->board_name, pbuf->BoardName, sizeof(ioc->board_name));
5442 memcpy(ioc->board_assembly, pbuf->BoardAssembly, sizeof(ioc->board_assembly));
5443 memcpy(ioc->board_tracer, pbuf->BoardTracerNumber, sizeof(ioc->board_tracer));
5444
5445 out:
5446
5447 if (pbuf)
5448 pci_free_consistent(ioc->pcidev, hdr.PageLength * 4, pbuf, buf_dma);
5449}
5450
5193/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 5451/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
5194/** 5452/**
5195 * SendEventNotification - Send EventNotification (on or off) request to adapter 5453 * SendEventNotification - Send EventNotification (on or off) request to adapter
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 05eb6e528753..98eb9c688e17 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -537,7 +537,14 @@ typedef struct _MPT_ADAPTER
537 int id; /* Unique adapter id N {0,1,2,...} */ 537 int id; /* Unique adapter id N {0,1,2,...} */
538 int pci_irq; /* This irq */ 538 int pci_irq; /* This irq */
539 char name[MPT_NAME_LENGTH]; /* "iocN" */ 539 char name[MPT_NAME_LENGTH]; /* "iocN" */
540 char *prod_name; /* "LSIFC9x9" */ 540 char prod_name[MPT_NAME_LENGTH]; /* "LSIFC9x9" */
541 char board_name[16];
542 char board_assembly[16];
543 char board_tracer[16];
544 u16 nvdata_version_persistent;
545 u16 nvdata_version_default;
546 u8 io_missing_delay;
547 u8 device_missing_delay;
541 SYSIF_REGS __iomem *chip; /* == c8817000 (mmap) */ 548 SYSIF_REGS __iomem *chip; /* == c8817000 (mmap) */
542 SYSIF_REGS __iomem *pio_chip; /* Programmed IO (downloadboot) */ 549 SYSIF_REGS __iomem *pio_chip; /* Programmed IO (downloadboot) */
543 u8 bus_type; 550 u8 bus_type;
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index b766445f19aa..f2ebaa9992fe 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -130,6 +130,7 @@ static struct scsi_host_template mptfc_driver_template = {
130 .max_sectors = 8192, 130 .max_sectors = 8192,
131 .cmd_per_lun = 7, 131 .cmd_per_lun = 7,
132 .use_clustering = ENABLE_CLUSTERING, 132 .use_clustering = ENABLE_CLUSTERING,
133 .shost_attrs = mptscsih_host_attrs,
133}; 134};
134 135
135/**************************************************************************** 136/****************************************************************************
@@ -153,6 +154,8 @@ static struct pci_device_id mptfc_pci_table[] = {
153 PCI_ANY_ID, PCI_ANY_ID }, 154 PCI_ANY_ID, PCI_ANY_ID },
154 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC949E, 155 { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVICEID_FC949E,
155 PCI_ANY_ID, PCI_ANY_ID }, 156 PCI_ANY_ID, PCI_ANY_ID },
157 { PCI_VENDOR_ID_BROCADE, MPI_MANUFACTPAGE_DEVICEID_FC949E,
158 PCI_ANY_ID, PCI_ANY_ID },
156 {0} /* Terminating entry */ 159 {0} /* Terminating entry */
157}; 160};
158MODULE_DEVICE_TABLE(pci, mptfc_pci_table); 161MODULE_DEVICE_TABLE(pci, mptfc_pci_table);
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 9e5424e1871f..d50664640512 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1119,6 +1119,7 @@ static struct scsi_host_template mptsas_driver_template = {
1119 .max_sectors = 8192, 1119 .max_sectors = 8192,
1120 .cmd_per_lun = 7, 1120 .cmd_per_lun = 7,
1121 .use_clustering = ENABLE_CLUSTERING, 1121 .use_clustering = ENABLE_CLUSTERING,
1122 .shost_attrs = mptscsih_host_attrs,
1122}; 1123};
1123 1124
1124static int mptsas_get_linkerrors(struct sas_phy *phy) 1125static int mptsas_get_linkerrors(struct sas_phy *phy)
@@ -1390,6 +1391,11 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
1390 goto out_free_consistent; 1391 goto out_free_consistent;
1391 } 1392 }
1392 1393
1394 ioc->nvdata_version_persistent =
1395 le16_to_cpu(buffer->NvdataVersionPersistent);
1396 ioc->nvdata_version_default =
1397 le16_to_cpu(buffer->NvdataVersionDefault);
1398
1393 for (i = 0; i < port_info->num_phys; i++) { 1399 for (i = 0; i < port_info->num_phys; i++) {
1394 mptsas_print_phy_data(&buffer->PhyData[i]); 1400 mptsas_print_phy_data(&buffer->PhyData[i]);
1395 port_info->phy_info[i].phy_id = i; 1401 port_info->phy_info[i].phy_id = i;
@@ -1410,6 +1416,63 @@ mptsas_sas_io_unit_pg0(MPT_ADAPTER *ioc, struct mptsas_portinfo *port_info)
1410} 1416}
1411 1417
1412static int 1418static int
1419mptsas_sas_io_unit_pg1(MPT_ADAPTER *ioc)
1420{
1421 ConfigExtendedPageHeader_t hdr;
1422 CONFIGPARMS cfg;
1423 SasIOUnitPage1_t *buffer;
1424 dma_addr_t dma_handle;
1425 int error;
1426 u16 device_missing_delay;
1427
1428 memset(&hdr, 0, sizeof(ConfigExtendedPageHeader_t));
1429 memset(&cfg, 0, sizeof(CONFIGPARMS));
1430
1431 cfg.cfghdr.ehdr = &hdr;
1432 cfg.action = MPI_CONFIG_ACTION_PAGE_HEADER;
1433 cfg.timeout = 10;
1434 cfg.cfghdr.ehdr->PageType = MPI_CONFIG_PAGETYPE_EXTENDED;
1435 cfg.cfghdr.ehdr->ExtPageType = MPI_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
1436 cfg.cfghdr.ehdr->PageVersion = MPI_SASIOUNITPAGE1_PAGEVERSION;
1437 cfg.cfghdr.ehdr->PageNumber = 1;
1438
1439 error = mpt_config(ioc, &cfg);
1440 if (error)
1441 goto out;
1442 if (!hdr.ExtPageLength) {
1443 error = -ENXIO;
1444 goto out;
1445 }
1446
1447 buffer = pci_alloc_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
1448 &dma_handle);
1449 if (!buffer) {
1450 error = -ENOMEM;
1451 goto out;
1452 }
1453
1454 cfg.physAddr = dma_handle;
1455 cfg.action = MPI_CONFIG_ACTION_PAGE_READ_CURRENT;
1456
1457 error = mpt_config(ioc, &cfg);
1458 if (error)
1459 goto out_free_consistent;
1460
1461 ioc->io_missing_delay =
1462 le16_to_cpu(buffer->IODeviceMissingDelay);
1463 device_missing_delay = le16_to_cpu(buffer->ReportDeviceMissingDelay);
1464 ioc->device_missing_delay = (device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_UNIT_16) ?
1465 (device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_TIMEOUT_MASK) * 16 :
1466 device_missing_delay & MPI_SAS_IOUNIT1_REPORT_MISSING_TIMEOUT_MASK;
1467
1468 out_free_consistent:
1469 pci_free_consistent(ioc->pcidev, hdr.ExtPageLength * 4,
1470 buffer, dma_handle);
1471 out:
1472 return error;
1473}
1474
1475static int
1413mptsas_sas_phy_pg0(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, 1476mptsas_sas_phy_pg0(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info,
1414 u32 form, u32 form_specific) 1477 u32 form, u32 form_specific)
1415{ 1478{
@@ -1990,6 +2053,7 @@ mptsas_probe_hba_phys(MPT_ADAPTER *ioc)
1990 if (error) 2053 if (error)
1991 goto out_free_port_info; 2054 goto out_free_port_info;
1992 2055
2056 mptsas_sas_io_unit_pg1(ioc);
1993 mutex_lock(&ioc->sas_topology_mutex); 2057 mutex_lock(&ioc->sas_topology_mutex);
1994 ioc->handle = hba->phy_info[0].handle; 2058 ioc->handle = hba->phy_info[0].handle;
1995 port_info = mptsas_find_portinfo_by_handle(ioc, ioc->handle); 2059 port_info = mptsas_find_portinfo_by_handle(ioc, ioc->handle);
@@ -3237,6 +3301,8 @@ static struct pci_driver mptsas_driver = {
3237static int __init 3301static int __init
3238mptsas_init(void) 3302mptsas_init(void)
3239{ 3303{
3304 int error;
3305
3240 show_mptmod_ver(my_NAME, my_VERSION); 3306 show_mptmod_ver(my_NAME, my_VERSION);
3241 3307
3242 mptsas_transport_template = 3308 mptsas_transport_template =
@@ -3260,7 +3326,11 @@ mptsas_init(void)
3260 ": Registered for IOC reset notifications\n")); 3326 ": Registered for IOC reset notifications\n"));
3261 } 3327 }
3262 3328
3263 return pci_register_driver(&mptsas_driver); 3329 error = pci_register_driver(&mptsas_driver);
3330 if (error)
3331 sas_release_transport(mptsas_transport_template);
3332
3333 return error;
3264} 3334}
3265 3335
3266static void __exit 3336static void __exit
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index d35617376f87..fd3aa2619f42 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -3187,6 +3187,159 @@ mptscsih_synchronize_cache(MPT_SCSI_HOST *hd, VirtDevice *vdevice)
3187 mptscsih_do_cmd(hd, &iocmd); 3187 mptscsih_do_cmd(hd, &iocmd);
3188} 3188}
3189 3189
3190static ssize_t
3191mptscsih_version_fw_show(struct class_device *cdev, char *buf)
3192{
3193 struct Scsi_Host *host = class_to_shost(cdev);
3194 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3195 MPT_ADAPTER *ioc = hd->ioc;
3196
3197 return snprintf(buf, PAGE_SIZE, "%02d.%02d.%02d.%02d\n",
3198 (ioc->facts.FWVersion.Word & 0xFF000000) >> 24,
3199 (ioc->facts.FWVersion.Word & 0x00FF0000) >> 16,
3200 (ioc->facts.FWVersion.Word & 0x0000FF00) >> 8,
3201 ioc->facts.FWVersion.Word & 0x000000FF);
3202}
3203static CLASS_DEVICE_ATTR(version_fw, S_IRUGO, mptscsih_version_fw_show, NULL);
3204
3205static ssize_t
3206mptscsih_version_bios_show(struct class_device *cdev, char *buf)
3207{
3208 struct Scsi_Host *host = class_to_shost(cdev);
3209 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3210 MPT_ADAPTER *ioc = hd->ioc;
3211
3212 return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n",
3213 (ioc->biosVersion & 0xFF000000) >> 24,
3214 (ioc->biosVersion & 0x00FF0000) >> 16,
3215 (ioc->biosVersion & 0x0000FF00) >> 8,
3216 ioc->biosVersion & 0x000000FF);
3217}
3218static CLASS_DEVICE_ATTR(version_bios, S_IRUGO, mptscsih_version_bios_show, NULL);
3219
3220static ssize_t
3221mptscsih_version_mpi_show(struct class_device *cdev, char *buf)
3222{
3223 struct Scsi_Host *host = class_to_shost(cdev);
3224 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3225 MPT_ADAPTER *ioc = hd->ioc;
3226
3227 return snprintf(buf, PAGE_SIZE, "%03x\n", ioc->facts.MsgVersion);
3228}
3229static CLASS_DEVICE_ATTR(version_mpi, S_IRUGO, mptscsih_version_mpi_show, NULL);
3230
3231static ssize_t
3232mptscsih_version_product_show(struct class_device *cdev, char *buf)
3233{
3234 struct Scsi_Host *host = class_to_shost(cdev);
3235 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3236 MPT_ADAPTER *ioc = hd->ioc;
3237
3238 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->prod_name);
3239}
3240static CLASS_DEVICE_ATTR(version_product, S_IRUGO,
3241 mptscsih_version_product_show, NULL);
3242
3243static ssize_t
3244mptscsih_version_nvdata_persistent_show(struct class_device *cdev, char *buf)
3245{
3246 struct Scsi_Host *host = class_to_shost(cdev);
3247 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3248 MPT_ADAPTER *ioc = hd->ioc;
3249
3250 return snprintf(buf, PAGE_SIZE, "%02xh\n",
3251 ioc->nvdata_version_persistent);
3252}
3253static CLASS_DEVICE_ATTR(version_nvdata_persistent, S_IRUGO,
3254 mptscsih_version_nvdata_persistent_show, NULL);
3255
3256static ssize_t
3257mptscsih_version_nvdata_default_show(struct class_device *cdev, char *buf)
3258{
3259 struct Scsi_Host *host = class_to_shost(cdev);
3260 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3261 MPT_ADAPTER *ioc = hd->ioc;
3262
3263 return snprintf(buf, PAGE_SIZE, "%02xh\n",ioc->nvdata_version_default);
3264}
3265static CLASS_DEVICE_ATTR(version_nvdata_default, S_IRUGO,
3266 mptscsih_version_nvdata_default_show, NULL);
3267
3268static ssize_t
3269mptscsih_board_name_show(struct class_device *cdev, char *buf)
3270{
3271 struct Scsi_Host *host = class_to_shost(cdev);
3272 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3273 MPT_ADAPTER *ioc = hd->ioc;
3274
3275 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_name);
3276}
3277static CLASS_DEVICE_ATTR(board_name, S_IRUGO, mptscsih_board_name_show, NULL);
3278
3279static ssize_t
3280mptscsih_board_assembly_show(struct class_device *cdev, char *buf)
3281{
3282 struct Scsi_Host *host = class_to_shost(cdev);
3283 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3284 MPT_ADAPTER *ioc = hd->ioc;
3285
3286 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_assembly);
3287}
3288static CLASS_DEVICE_ATTR(board_assembly, S_IRUGO,
3289 mptscsih_board_assembly_show, NULL);
3290
3291static ssize_t
3292mptscsih_board_tracer_show(struct class_device *cdev, char *buf)
3293{
3294 struct Scsi_Host *host = class_to_shost(cdev);
3295 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3296 MPT_ADAPTER *ioc = hd->ioc;
3297
3298 return snprintf(buf, PAGE_SIZE, "%s\n", ioc->board_tracer);
3299}
3300static CLASS_DEVICE_ATTR(board_tracer, S_IRUGO,
3301 mptscsih_board_tracer_show, NULL);
3302
3303static ssize_t
3304mptscsih_io_delay_show(struct class_device *cdev, char *buf)
3305{
3306 struct Scsi_Host *host = class_to_shost(cdev);
3307 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3308 MPT_ADAPTER *ioc = hd->ioc;
3309
3310 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->io_missing_delay);
3311}
3312static CLASS_DEVICE_ATTR(io_delay, S_IRUGO,
3313 mptscsih_io_delay_show, NULL);
3314
3315static ssize_t
3316mptscsih_device_delay_show(struct class_device *cdev, char *buf)
3317{
3318 struct Scsi_Host *host = class_to_shost(cdev);
3319 MPT_SCSI_HOST *hd = (MPT_SCSI_HOST *)host->hostdata;
3320 MPT_ADAPTER *ioc = hd->ioc;
3321
3322 return snprintf(buf, PAGE_SIZE, "%02d\n", ioc->device_missing_delay);
3323}
3324static CLASS_DEVICE_ATTR(device_delay, S_IRUGO,
3325 mptscsih_device_delay_show, NULL);
3326
3327struct class_device_attribute *mptscsih_host_attrs[] = {
3328 &class_device_attr_version_fw,
3329 &class_device_attr_version_bios,
3330 &class_device_attr_version_mpi,
3331 &class_device_attr_version_product,
3332 &class_device_attr_version_nvdata_persistent,
3333 &class_device_attr_version_nvdata_default,
3334 &class_device_attr_board_name,
3335 &class_device_attr_board_assembly,
3336 &class_device_attr_board_tracer,
3337 &class_device_attr_io_delay,
3338 &class_device_attr_device_delay,
3339 NULL,
3340};
3341EXPORT_SYMBOL(mptscsih_host_attrs);
3342
3190EXPORT_SYMBOL(mptscsih_remove); 3343EXPORT_SYMBOL(mptscsih_remove);
3191EXPORT_SYMBOL(mptscsih_shutdown); 3344EXPORT_SYMBOL(mptscsih_shutdown);
3192#ifdef CONFIG_PM 3345#ifdef CONFIG_PM
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 8eccdfe5701a..67b088db2f10 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -129,3 +129,4 @@ extern void mptscsih_timer_expired(unsigned long data);
129extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout); 129extern int mptscsih_TMHandler(MPT_SCSI_HOST *hd, u8 type, u8 channel, u8 id, int lun, int ctx2abort, ulong timeout);
130extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id); 130extern u8 mptscsih_raid_id_to_num(MPT_ADAPTER *ioc, u8 channel, u8 id);
131extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id); 131extern int mptscsih_is_phys_disk(MPT_ADAPTER *ioc, u8 channel, u8 id);
132extern struct class_device_attribute *mptscsih_host_attrs[];
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 6b3e0c00952b..947fe2901800 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -821,6 +821,7 @@ static struct scsi_host_template mptspi_driver_template = {
821 .max_sectors = 8192, 821 .max_sectors = 8192,
822 .cmd_per_lun = 7, 822 .cmd_per_lun = 7,
823 .use_clustering = ENABLE_CLUSTERING, 823 .use_clustering = ENABLE_CLUSTERING,
824 .shost_attrs = mptscsih_host_attrs,
824}; 825};
825 826
826static int mptspi_write_spi_device_pg1(struct scsi_target *starget, 827static int mptspi_write_spi_device_pg1(struct scsi_target *starget,
@@ -1523,6 +1524,8 @@ static struct pci_driver mptspi_driver = {
1523static int __init 1524static int __init
1524mptspi_init(void) 1525mptspi_init(void)
1525{ 1526{
1527 int error;
1528
1526 show_mptmod_ver(my_NAME, my_VERSION); 1529 show_mptmod_ver(my_NAME, my_VERSION);
1527 1530
1528 mptspi_transport_template = spi_attach_transport(&mptspi_transport_functions); 1531 mptspi_transport_template = spi_attach_transport(&mptspi_transport_functions);
@@ -1543,7 +1546,11 @@ mptspi_init(void)
1543 ": Registered for IOC reset notifications\n")); 1546 ": Registered for IOC reset notifications\n"));
1544 } 1547 }
1545 1548
1546 return pci_register_driver(&mptspi_driver); 1549 error = pci_register_driver(&mptspi_driver);
1550 if (error)
1551 spi_release_transport(mptspi_transport_template);
1552
1553 return error;
1547} 1554}
1548 1555
1549/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ 1556/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 1d516f24ba53..aaaa61ea4217 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -150,6 +150,7 @@ config THINKPAD_ACPI
150 depends on X86 && ACPI 150 depends on X86 && ACPI
151 select BACKLIGHT_CLASS_DEVICE 151 select BACKLIGHT_CLASS_DEVICE
152 select HWMON 152 select HWMON
153 select NVRAM
153 ---help--- 154 ---help---
154 This is a driver for the IBM and Lenovo ThinkPad laptops. It adds 155 This is a driver for the IBM and Lenovo ThinkPad laptops. It adds
155 support for Fn-Fx key combinations, Bluetooth control, video 156 support for Fn-Fx key combinations, Bluetooth control, video
@@ -196,4 +197,17 @@ config THINKPAD_ACPI_BAY
196 197
197 If you are not sure, say Y here. 198 If you are not sure, say Y here.
198 199
200config THINKPAD_ACPI_INPUT_ENABLED
201 bool "Enable input layer support by default"
202 depends on THINKPAD_ACPI
203 default y
204 ---help---
205 Enables hot key handling over the input layer by default. If unset,
206 the driver does not enable any hot key handling by default, and also
207 starts up with a mostly empty keymap.
208
209 If you are not sure, say Y here. Say N to retain the deprecated
210 behavior of ibm-acpi, and thinkpad-acpi for kernels up to 2.6.21.
211
212
199endif # MISC_DEVICES 213endif # MISC_DEVICES
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c
index 9623eaf4f89f..303e48ca0e8a 100644
--- a/drivers/misc/sony-laptop.c
+++ b/drivers/misc/sony-laptop.c
@@ -142,43 +142,124 @@ struct sony_laptop_keypress {
142 int key; 142 int key;
143}; 143};
144 144
145/* Correspondance table between sonypi events and input layer events */ 145/* Correspondance table between sonypi events
146static struct { 146 * and input layer indexes in the keymap
147 int sonypiev; 147 */
148 int inputev; 148static int sony_laptop_input_index[] = {
149} sony_laptop_inputkeys[] = { 149 -1, /* no event */
150 { SONYPI_EVENT_CAPTURE_PRESSED, KEY_CAMERA }, 150 -1, /* SONYPI_EVENT_JOGDIAL_DOWN */
151 { SONYPI_EVENT_FNKEY_ONLY, KEY_FN }, 151 -1, /* SONYPI_EVENT_JOGDIAL_UP */
152 { SONYPI_EVENT_FNKEY_ESC, KEY_FN_ESC }, 152 -1, /* SONYPI_EVENT_JOGDIAL_DOWN_PRESSED */
153 { SONYPI_EVENT_FNKEY_F1, KEY_FN_F1 }, 153 -1, /* SONYPI_EVENT_JOGDIAL_UP_PRESSED */
154 { SONYPI_EVENT_FNKEY_F2, KEY_FN_F2 }, 154 -1, /* SONYPI_EVENT_JOGDIAL_PRESSED */
155 { SONYPI_EVENT_FNKEY_F3, KEY_FN_F3 }, 155 -1, /* SONYPI_EVENT_JOGDIAL_RELEASED */
156 { SONYPI_EVENT_FNKEY_F4, KEY_FN_F4 }, 156 0, /* SONYPI_EVENT_CAPTURE_PRESSED */
157 { SONYPI_EVENT_FNKEY_F5, KEY_FN_F5 }, 157 1, /* SONYPI_EVENT_CAPTURE_RELEASED */
158 { SONYPI_EVENT_FNKEY_F6, KEY_FN_F6 }, 158 2, /* SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
159 { SONYPI_EVENT_FNKEY_F7, KEY_FN_F7 }, 159 3, /* SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
160 { SONYPI_EVENT_FNKEY_F8, KEY_FN_F8 }, 160 4, /* SONYPI_EVENT_FNKEY_ESC */
161 { SONYPI_EVENT_FNKEY_F9, KEY_FN_F9 }, 161 5, /* SONYPI_EVENT_FNKEY_F1 */
162 { SONYPI_EVENT_FNKEY_F10, KEY_FN_F10 }, 162 6, /* SONYPI_EVENT_FNKEY_F2 */
163 { SONYPI_EVENT_FNKEY_F11, KEY_FN_F11 }, 163 7, /* SONYPI_EVENT_FNKEY_F3 */
164 { SONYPI_EVENT_FNKEY_F12, KEY_FN_F12 }, 164 8, /* SONYPI_EVENT_FNKEY_F4 */
165 { SONYPI_EVENT_FNKEY_1, KEY_FN_1 }, 165 9, /* SONYPI_EVENT_FNKEY_F5 */
166 { SONYPI_EVENT_FNKEY_2, KEY_FN_2 }, 166 10, /* SONYPI_EVENT_FNKEY_F6 */
167 { SONYPI_EVENT_FNKEY_D, KEY_FN_D }, 167 11, /* SONYPI_EVENT_FNKEY_F7 */
168 { SONYPI_EVENT_FNKEY_E, KEY_FN_E }, 168 12, /* SONYPI_EVENT_FNKEY_F8 */
169 { SONYPI_EVENT_FNKEY_F, KEY_FN_F }, 169 13, /* SONYPI_EVENT_FNKEY_F9 */
170 { SONYPI_EVENT_FNKEY_S, KEY_FN_S }, 170 14, /* SONYPI_EVENT_FNKEY_F10 */
171 { SONYPI_EVENT_FNKEY_B, KEY_FN_B }, 171 15, /* SONYPI_EVENT_FNKEY_F11 */
172 { SONYPI_EVENT_BLUETOOTH_PRESSED, KEY_BLUE }, 172 16, /* SONYPI_EVENT_FNKEY_F12 */
173 { SONYPI_EVENT_BLUETOOTH_ON, KEY_BLUE }, 173 17, /* SONYPI_EVENT_FNKEY_1 */
174 { SONYPI_EVENT_PKEY_P1, KEY_PROG1 }, 174 18, /* SONYPI_EVENT_FNKEY_2 */
175 { SONYPI_EVENT_PKEY_P2, KEY_PROG2 }, 175 19, /* SONYPI_EVENT_FNKEY_D */
176 { SONYPI_EVENT_PKEY_P3, KEY_PROG3 }, 176 20, /* SONYPI_EVENT_FNKEY_E */
177 { SONYPI_EVENT_BACK_PRESSED, KEY_BACK }, 177 21, /* SONYPI_EVENT_FNKEY_F */
178 { SONYPI_EVENT_HELP_PRESSED, KEY_HELP }, 178 22, /* SONYPI_EVENT_FNKEY_S */
179 { SONYPI_EVENT_ZOOM_PRESSED, KEY_ZOOM }, 179 23, /* SONYPI_EVENT_FNKEY_B */
180 { SONYPI_EVENT_THUMBPHRASE_PRESSED, BTN_THUMB }, 180 24, /* SONYPI_EVENT_BLUETOOTH_PRESSED */
181 { 0, 0 }, 181 25, /* SONYPI_EVENT_PKEY_P1 */
182 26, /* SONYPI_EVENT_PKEY_P2 */
183 27, /* SONYPI_EVENT_PKEY_P3 */
184 28, /* SONYPI_EVENT_BACK_PRESSED */
185 -1, /* SONYPI_EVENT_LID_CLOSED */
186 -1, /* SONYPI_EVENT_LID_OPENED */
187 29, /* SONYPI_EVENT_BLUETOOTH_ON */
188 30, /* SONYPI_EVENT_BLUETOOTH_OFF */
189 31, /* SONYPI_EVENT_HELP_PRESSED */
190 32, /* SONYPI_EVENT_FNKEY_ONLY */
191 33, /* SONYPI_EVENT_JOGDIAL_FAST_DOWN */
192 34, /* SONYPI_EVENT_JOGDIAL_FAST_UP */
193 35, /* SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
194 36, /* SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
195 37, /* SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
196 38, /* SONYPI_EVENT_JOGDIAL_VFAST_UP */
197 39, /* SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
198 40, /* SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
199 41, /* SONYPI_EVENT_ZOOM_PRESSED */
200 42, /* SONYPI_EVENT_THUMBPHRASE_PRESSED */
201 43, /* SONYPI_EVENT_MEYE_FACE */
202 44, /* SONYPI_EVENT_MEYE_OPPOSITE */
203 45, /* SONYPI_EVENT_MEMORYSTICK_INSERT */
204 46, /* SONYPI_EVENT_MEMORYSTICK_EJECT */
205 -1, /* SONYPI_EVENT_ANYBUTTON_RELEASED */
206 -1, /* SONYPI_EVENT_BATTERY_INSERT */
207 -1, /* SONYPI_EVENT_BATTERY_REMOVE */
208 -1, /* SONYPI_EVENT_FNKEY_RELEASED */
209 47, /* SONYPI_EVENT_WIRELESS_ON */
210 48, /* SONYPI_EVENT_WIRELESS_OFF */
211};
212
213static int sony_laptop_input_keycode_map[] = {
214 KEY_CAMERA, /* 0 SONYPI_EVENT_CAPTURE_PRESSED */
215 KEY_RESERVED, /* 1 SONYPI_EVENT_CAPTURE_RELEASED */
216 KEY_RESERVED, /* 2 SONYPI_EVENT_CAPTURE_PARTIALPRESSED */
217 KEY_RESERVED, /* 3 SONYPI_EVENT_CAPTURE_PARTIALRELEASED */
218 KEY_FN_ESC, /* 4 SONYPI_EVENT_FNKEY_ESC */
219 KEY_FN_F1, /* 5 SONYPI_EVENT_FNKEY_F1 */
220 KEY_FN_F2, /* 6 SONYPI_EVENT_FNKEY_F2 */
221 KEY_FN_F3, /* 7 SONYPI_EVENT_FNKEY_F3 */
222 KEY_FN_F4, /* 8 SONYPI_EVENT_FNKEY_F4 */
223 KEY_FN_F5, /* 9 SONYPI_EVENT_FNKEY_F5 */
224 KEY_FN_F6, /* 10 SONYPI_EVENT_FNKEY_F6 */
225 KEY_FN_F7, /* 11 SONYPI_EVENT_FNKEY_F7 */
226 KEY_FN_F8, /* 12 SONYPI_EVENT_FNKEY_F8 */
227 KEY_FN_F9, /* 13 SONYPI_EVENT_FNKEY_F9 */
228 KEY_FN_F10, /* 14 SONYPI_EVENT_FNKEY_F10 */
229 KEY_FN_F11, /* 15 SONYPI_EVENT_FNKEY_F11 */
230 KEY_FN_F12, /* 16 SONYPI_EVENT_FNKEY_F12 */
231 KEY_FN_F1, /* 17 SONYPI_EVENT_FNKEY_1 */
232 KEY_FN_F2, /* 18 SONYPI_EVENT_FNKEY_2 */
233 KEY_FN_D, /* 19 SONYPI_EVENT_FNKEY_D */
234 KEY_FN_E, /* 20 SONYPI_EVENT_FNKEY_E */
235 KEY_FN_F, /* 21 SONYPI_EVENT_FNKEY_F */
236 KEY_FN_S, /* 22 SONYPI_EVENT_FNKEY_S */
237 KEY_FN_B, /* 23 SONYPI_EVENT_FNKEY_B */
238 KEY_BLUETOOTH, /* 24 SONYPI_EVENT_BLUETOOTH_PRESSED */
239 KEY_PROG1, /* 25 SONYPI_EVENT_PKEY_P1 */
240 KEY_PROG2, /* 26 SONYPI_EVENT_PKEY_P2 */
241 KEY_PROG3, /* 27 SONYPI_EVENT_PKEY_P3 */
242 KEY_BACK, /* 28 SONYPI_EVENT_BACK_PRESSED */
243 KEY_BLUETOOTH, /* 29 SONYPI_EVENT_BLUETOOTH_ON */
244 KEY_BLUETOOTH, /* 30 SONYPI_EVENT_BLUETOOTH_OFF */
245 KEY_HELP, /* 31 SONYPI_EVENT_HELP_PRESSED */
246 KEY_FN, /* 32 SONYPI_EVENT_FNKEY_ONLY */
247 KEY_RESERVED, /* 33 SONYPI_EVENT_JOGDIAL_FAST_DOWN */
248 KEY_RESERVED, /* 34 SONYPI_EVENT_JOGDIAL_FAST_UP */
249 KEY_RESERVED, /* 35 SONYPI_EVENT_JOGDIAL_FAST_DOWN_PRESSED */
250 KEY_RESERVED, /* 36 SONYPI_EVENT_JOGDIAL_FAST_UP_PRESSED */
251 KEY_RESERVED, /* 37 SONYPI_EVENT_JOGDIAL_VFAST_DOWN */
252 KEY_RESERVED, /* 38 SONYPI_EVENT_JOGDIAL_VFAST_UP */
253 KEY_RESERVED, /* 39 SONYPI_EVENT_JOGDIAL_VFAST_DOWN_PRESSED */
254 KEY_RESERVED, /* 40 SONYPI_EVENT_JOGDIAL_VFAST_UP_PRESSED */
255 KEY_ZOOM, /* 41 SONYPI_EVENT_ZOOM_PRESSED */
256 BTN_THUMB, /* 42 SONYPI_EVENT_THUMBPHRASE_PRESSED */
257 KEY_RESERVED, /* 43 SONYPI_EVENT_MEYE_FACE */
258 KEY_RESERVED, /* 44 SONYPI_EVENT_MEYE_OPPOSITE */
259 KEY_RESERVED, /* 45 SONYPI_EVENT_MEMORYSTICK_INSERT */
260 KEY_RESERVED, /* 46 SONYPI_EVENT_MEMORYSTICK_EJECT */
261 KEY_WLAN, /* 47 SONYPI_EVENT_WIRELESS_ON */
262 KEY_WLAN, /* 48 SONYPI_EVENT_WIRELESS_OFF */
182}; 263};
183 264
184/* release buttons after a short delay if pressed */ 265/* release buttons after a short delay if pressed */
@@ -202,7 +283,6 @@ static void sony_laptop_report_input_event(u8 event)
202 struct input_dev *jog_dev = sony_laptop_input.jog_dev; 283 struct input_dev *jog_dev = sony_laptop_input.jog_dev;
203 struct input_dev *key_dev = sony_laptop_input.key_dev; 284 struct input_dev *key_dev = sony_laptop_input.key_dev;
204 struct sony_laptop_keypress kp = { NULL }; 285 struct sony_laptop_keypress kp = { NULL };
205 int i;
206 286
207 if (event == SONYPI_EVENT_FNKEY_RELEASED) { 287 if (event == SONYPI_EVENT_FNKEY_RELEASED) {
208 /* Nothing, not all VAIOs generate this event */ 288 /* Nothing, not all VAIOs generate this event */
@@ -231,17 +311,22 @@ static void sony_laptop_report_input_event(u8 event)
231 break; 311 break;
232 312
233 default: 313 default:
234 for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++) 314 if (event > ARRAY_SIZE (sony_laptop_input_keycode_map)) {
235 if (event == sony_laptop_inputkeys[i].sonypiev) { 315 dprintk("sony_laptop_report_input_event, event not known: %d\n", event);
316 break;
317 }
318 if (sony_laptop_input_index[event] != -1) {
319 kp.key = sony_laptop_input_keycode_map[sony_laptop_input_index[event]];
320 if (kp.key != KEY_UNKNOWN)
236 kp.dev = key_dev; 321 kp.dev = key_dev;
237 kp.key = sony_laptop_inputkeys[i].inputev; 322 }
238 break;
239 }
240 break; 323 break;
241 } 324 }
242 325
243 if (kp.dev) { 326 if (kp.dev) {
244 input_report_key(kp.dev, kp.key, 1); 327 input_report_key(kp.dev, kp.key, 1);
328 /* we emit the scancode so we can always remap the key */
329 input_event(kp.dev, EV_MSC, MSC_SCAN, event);
245 input_sync(kp.dev); 330 input_sync(kp.dev);
246 kfifo_put(sony_laptop_input.fifo, 331 kfifo_put(sony_laptop_input.fifo,
247 (unsigned char *)&kp, sizeof(kp)); 332 (unsigned char *)&kp, sizeof(kp));
@@ -296,11 +381,18 @@ static int sony_laptop_setup_input(void)
296 key_dev->id.vendor = PCI_VENDOR_ID_SONY; 381 key_dev->id.vendor = PCI_VENDOR_ID_SONY;
297 382
298 /* Initialize the Input Drivers: special keys */ 383 /* Initialize the Input Drivers: special keys */
299 key_dev->evbit[0] = BIT(EV_KEY); 384 set_bit(EV_KEY, key_dev->evbit);
300 for (i = 0; sony_laptop_inputkeys[i].sonypiev; i++) 385 set_bit(EV_MSC, key_dev->evbit);
301 if (sony_laptop_inputkeys[i].inputev) 386 set_bit(MSC_SCAN, key_dev->mscbit);
302 set_bit(sony_laptop_inputkeys[i].inputev, 387 key_dev->keycodesize = sizeof(sony_laptop_input_keycode_map[0]);
303 key_dev->keybit); 388 key_dev->keycodemax = ARRAY_SIZE(sony_laptop_input_keycode_map);
389 key_dev->keycode = &sony_laptop_input_keycode_map;
390 for (i = 0; i < ARRAY_SIZE(sony_laptop_input_keycode_map); i++) {
391 if (sony_laptop_input_keycode_map[i] != KEY_RESERVED) {
392 set_bit(sony_laptop_input_keycode_map[i],
393 key_dev->keybit);
394 }
395 }
304 396
305 error = input_register_device(key_dev); 397 error = input_register_device(key_dev);
306 if (error) 398 if (error)
@@ -487,6 +579,14 @@ SNC_HANDLE_NAMES(audiopower_set, "AZPW");
487SNC_HANDLE_NAMES(lanpower_get, "GLNP"); 579SNC_HANDLE_NAMES(lanpower_get, "GLNP");
488SNC_HANDLE_NAMES(lanpower_set, "LNPW"); 580SNC_HANDLE_NAMES(lanpower_set, "LNPW");
489 581
582SNC_HANDLE_NAMES(lidstate_get, "GLID");
583
584SNC_HANDLE_NAMES(indicatorlamp_get, "GILS");
585SNC_HANDLE_NAMES(indicatorlamp_set, "SILS");
586
587SNC_HANDLE_NAMES(gainbass_get, "GMGB");
588SNC_HANDLE_NAMES(gainbass_set, "CMGB");
589
490SNC_HANDLE_NAMES(PID_get, "GPID"); 590SNC_HANDLE_NAMES(PID_get, "GPID");
491 591
492SNC_HANDLE_NAMES(CTR_get, "GCTR"); 592SNC_HANDLE_NAMES(CTR_get, "GCTR");
@@ -507,6 +607,12 @@ static struct sony_nc_value sony_nc_values[] = {
507 boolean_validate, 0), 607 boolean_validate, 0),
508 SNC_HANDLE(lanpower, snc_lanpower_get, snc_lanpower_set, 608 SNC_HANDLE(lanpower, snc_lanpower_get, snc_lanpower_set,
509 boolean_validate, 1), 609 boolean_validate, 1),
610 SNC_HANDLE(lidstate, snc_lidstate_get, NULL,
611 boolean_validate, 0),
612 SNC_HANDLE(indicatorlamp, snc_indicatorlamp_get, snc_indicatorlamp_set,
613 boolean_validate, 0),
614 SNC_HANDLE(gainbass, snc_gainbass_get, snc_gainbass_set,
615 boolean_validate, 0),
510 /* unknown methods */ 616 /* unknown methods */
511 SNC_HANDLE(PID, snc_PID_get, NULL, NULL, 1), 617 SNC_HANDLE(PID, snc_PID_get, NULL, NULL, 1),
512 SNC_HANDLE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1), 618 SNC_HANDLE(CTR, snc_CTR_get, snc_CTR_set, NULL, 1),
@@ -689,13 +795,116 @@ static struct backlight_ops sony_backlight_ops = {
689}; 795};
690 796
691/* 797/*
798 * New SNC-only Vaios event mapping to driver known keys
799 */
800struct sony_nc_event {
801 u8 data;
802 u8 event;
803};
804
805static struct sony_nc_event *sony_nc_events;
806
807/* Vaio C* --maybe also FE*, N* and AR* ?-- special init sequence
808 * for Fn keys
809 */
810static int sony_nc_C_enable(struct dmi_system_id *id)
811{
812 int result = 0;
813
814 printk(KERN_NOTICE DRV_PFX "detected %s\n", id->ident);
815
816 sony_nc_events = id->driver_data;
817
818 if (acpi_callsetfunc(sony_nc_acpi_handle, "SN02", 0x4, &result) < 0
819 || acpi_callsetfunc(sony_nc_acpi_handle, "SN07", 0x2, &result) < 0
820 || acpi_callsetfunc(sony_nc_acpi_handle, "SN02", 0x10, &result) < 0
821 || acpi_callsetfunc(sony_nc_acpi_handle, "SN07", 0x0, &result) < 0
822 || acpi_callsetfunc(sony_nc_acpi_handle, "SN03", 0x2, &result) < 0
823 || acpi_callsetfunc(sony_nc_acpi_handle, "SN07", 0x101, &result) < 0) {
824 printk(KERN_WARNING DRV_PFX "failed to initialize SNC, some "
825 "functionalities may be missing\n");
826 return 1;
827 }
828 return 0;
829}
830
831static struct sony_nc_event sony_C_events[] = {
832 { 0x81, SONYPI_EVENT_FNKEY_F1 },
833 { 0x01, SONYPI_EVENT_FNKEY_RELEASED },
834 { 0x85, SONYPI_EVENT_FNKEY_F5 },
835 { 0x05, SONYPI_EVENT_FNKEY_RELEASED },
836 { 0x86, SONYPI_EVENT_FNKEY_F6 },
837 { 0x06, SONYPI_EVENT_FNKEY_RELEASED },
838 { 0x87, SONYPI_EVENT_FNKEY_F7 },
839 { 0x07, SONYPI_EVENT_FNKEY_RELEASED },
840 { 0x8A, SONYPI_EVENT_FNKEY_F10 },
841 { 0x0A, SONYPI_EVENT_FNKEY_RELEASED },
842 { 0x8C, SONYPI_EVENT_FNKEY_F12 },
843 { 0x0C, SONYPI_EVENT_FNKEY_RELEASED },
844 { 0, 0 },
845};
846
847/* SNC-only model map */
848struct dmi_system_id sony_nc_ids[] = {
849 {
850 .ident = "Sony Vaio FE Series",
851 .callback = sony_nc_C_enable,
852 .driver_data = sony_C_events,
853 .matches = {
854 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
855 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-FE"),
856 },
857 },
858 {
859 .ident = "Sony Vaio C Series",
860 .callback = sony_nc_C_enable,
861 .driver_data = sony_C_events,
862 .matches = {
863 DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"),
864 DMI_MATCH(DMI_PRODUCT_NAME, "VGN-C"),
865 },
866 },
867 { }
868};
869
870/*
692 * ACPI callbacks 871 * ACPI callbacks
693 */ 872 */
694static void sony_acpi_notify(acpi_handle handle, u32 event, void *data) 873static void sony_acpi_notify(acpi_handle handle, u32 event, void *data)
695{ 874{
696 dprintk("sony_acpi_notify, event: %d\n", event); 875 struct sony_nc_event *evmap;
697 sony_laptop_report_input_event(event); 876 u32 ev = event;
698 acpi_bus_generate_event(sony_nc_acpi_device, 1, event); 877 int result;
878
879 if (ev == 0x92) {
880 /* read the key pressed from EC.GECR
881 * A call to SN07 with 0x0202 will do it as well respecting
882 * the current protocol on different OSes
883 *
884 * Note: the path for GECR may be
885 * \_SB.PCI0.LPCB.EC (C, FE, AR, N and friends)
886 * \_SB.PCI0.PIB.EC0 (VGN-FR notifications are sent directly, no GECR)
887 *
888 * TODO: we may want to do the same for the older GHKE -need
889 * dmi list- so this snippet may become one more callback.
890 */
891 if (acpi_callsetfunc(handle, "SN07", 0x0202, &result) < 0)
892 dprintk("sony_acpi_notify, unable to decode event 0x%.2x\n", ev);
893 else
894 ev = result & 0xFF;
895 }
896
897 if (sony_nc_events)
898 for (evmap = sony_nc_events; evmap->event; evmap++) {
899 if (evmap->data == ev) {
900 ev = evmap->event;
901 break;
902 }
903 }
904
905 dprintk("sony_acpi_notify, event: 0x%.2x\n", ev);
906 sony_laptop_report_input_event(ev);
907 acpi_bus_generate_event(sony_nc_acpi_device, 1, ev);
699} 908}
700 909
701static acpi_status sony_walk_callback(acpi_handle handle, u32 level, 910static acpi_status sony_walk_callback(acpi_handle handle, u32 level,
@@ -732,6 +941,10 @@ static int sony_nc_resume(struct acpi_device *device)
732 break; 941 break;
733 } 942 }
734 } 943 }
944
945 /* re-initialize models with specific requirements */
946 dmi_check_system(sony_nc_ids);
947
735 return 0; 948 return 0;
736} 949}
737 950
@@ -750,6 +963,15 @@ static int sony_nc_add(struct acpi_device *device)
750 963
751 sony_nc_acpi_handle = device->handle; 964 sony_nc_acpi_handle = device->handle;
752 965
966 /* read device status */
967 result = acpi_bus_get_status(device);
968 /* bail IFF the above call was successful and the device is not present */
969 if (!result && !device->status.present) {
970 dprintk("Device not present\n");
971 result = -ENODEV;
972 goto outwalk;
973 }
974
753 if (debug) { 975 if (debug) {
754 status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_nc_acpi_handle, 976 status = acpi_walk_namespace(ACPI_TYPE_METHOD, sony_nc_acpi_handle,
755 1, sony_walk_callback, NULL, NULL); 977 1, sony_walk_callback, NULL, NULL);
@@ -760,6 +982,15 @@ static int sony_nc_add(struct acpi_device *device)
760 } 982 }
761 } 983 }
762 984
985 /* try to _INI the device if such method exists (ACPI spec 3.0-6.5.1
986 * should be respected as we already checked for the device presence above */
987 if (ACPI_SUCCESS(acpi_get_handle(sony_nc_acpi_handle, METHOD_NAME__INI, &handle))) {
988 dprintk("Invoking _INI\n");
989 if (ACPI_FAILURE(acpi_evaluate_object(sony_nc_acpi_handle, METHOD_NAME__INI,
990 NULL, NULL)))
991 dprintk("_INI Method failed\n");
992 }
993
763 /* setup input devices and helper fifo */ 994 /* setup input devices and helper fifo */
764 result = sony_laptop_setup_input(); 995 result = sony_laptop_setup_input();
765 if (result) { 996 if (result) {
@@ -772,7 +1003,7 @@ static int sony_nc_add(struct acpi_device *device)
772 ACPI_DEVICE_NOTIFY, 1003 ACPI_DEVICE_NOTIFY,
773 sony_acpi_notify, NULL); 1004 sony_acpi_notify, NULL);
774 if (ACPI_FAILURE(status)) { 1005 if (ACPI_FAILURE(status)) {
775 printk(KERN_WARNING DRV_PFX "unable to install notify handler\n"); 1006 printk(KERN_WARNING DRV_PFX "unable to install notify handler (%u)\n", status);
776 result = -ENODEV; 1007 result = -ENODEV;
777 goto outinput; 1008 goto outinput;
778 } 1009 }
@@ -795,6 +1026,9 @@ static int sony_nc_add(struct acpi_device *device)
795 1026
796 } 1027 }
797 1028
1029 /* initialize models with specific requirements */
1030 dmi_check_system(sony_nc_ids);
1031
798 result = sony_pf_add(); 1032 result = sony_pf_add();
799 if (result) 1033 if (result)
800 goto outbacklight; 1034 goto outbacklight;
@@ -908,7 +1142,9 @@ static struct acpi_driver sony_nc_driver = {
908#define SONYPI_DEVICE_TYPE2 0x00000002 1142#define SONYPI_DEVICE_TYPE2 0x00000002
909#define SONYPI_DEVICE_TYPE3 0x00000004 1143#define SONYPI_DEVICE_TYPE3 0x00000004
910 1144
911#define SONY_PIC_EV_MASK 0xff 1145#define SONYPI_TYPE1_OFFSET 0x04
1146#define SONYPI_TYPE2_OFFSET 0x12
1147#define SONYPI_TYPE3_OFFSET 0x12
912 1148
913struct sony_pic_ioport { 1149struct sony_pic_ioport {
914 struct acpi_resource_io io; 1150 struct acpi_resource_io io;
@@ -922,6 +1158,7 @@ struct sony_pic_irq {
922 1158
923struct sony_pic_dev { 1159struct sony_pic_dev {
924 int model; 1160 int model;
1161 u16 evport_offset;
925 u8 camera_power; 1162 u8 camera_power;
926 u8 bluetooth_power; 1163 u8 bluetooth_power;
927 u8 wwan_power; 1164 u8 wwan_power;
@@ -1999,20 +2236,17 @@ end:
1999static irqreturn_t sony_pic_irq(int irq, void *dev_id) 2236static irqreturn_t sony_pic_irq(int irq, void *dev_id)
2000{ 2237{
2001 int i, j; 2238 int i, j;
2002 u32 port_val = 0;
2003 u8 ev = 0; 2239 u8 ev = 0;
2004 u8 data_mask = 0; 2240 u8 data_mask = 0;
2005 u8 device_event = 0; 2241 u8 device_event = 0;
2006 2242
2007 struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id; 2243 struct sony_pic_dev *dev = (struct sony_pic_dev *) dev_id;
2008 2244
2009 acpi_os_read_port(dev->cur_ioport->io.minimum, &port_val, 2245 ev = inb_p(dev->cur_ioport->io.minimum);
2010 dev->cur_ioport->io.address_length); 2246 data_mask = inb_p(dev->cur_ioport->io.minimum + dev->evport_offset);
2011 ev = port_val & SONY_PIC_EV_MASK;
2012 data_mask = 0xff & (port_val >> (dev->cur_ioport->io.address_length - 8));
2013 2247
2014 dprintk("event (0x%.8x [%.2x] [%.2x]) at port 0x%.4x\n", 2248 dprintk("event ([%.2x] [%.2x]) at port 0x%.4x(+0x%.2x)\n",
2015 port_val, ev, data_mask, dev->cur_ioport->io.minimum); 2249 ev, data_mask, dev->cur_ioport->io.minimum, dev->evport_offset);
2016 2250
2017 if (ev == 0x00 || ev == 0xff) 2251 if (ev == 0x00 || ev == 0xff)
2018 return IRQ_HANDLED; 2252 return IRQ_HANDLED;
@@ -2103,6 +2337,20 @@ static int sony_pic_add(struct acpi_device *device)
2103 spic_dev.model = sony_pic_detect_device_type(); 2337 spic_dev.model = sony_pic_detect_device_type();
2104 mutex_init(&spic_dev.lock); 2338 mutex_init(&spic_dev.lock);
2105 2339
2340 /* model specific characteristics */
2341 switch(spic_dev.model) {
2342 case SONYPI_DEVICE_TYPE1:
2343 spic_dev.evport_offset = SONYPI_TYPE1_OFFSET;
2344 break;
2345 case SONYPI_DEVICE_TYPE3:
2346 spic_dev.evport_offset = SONYPI_TYPE3_OFFSET;
2347 break;
2348 case SONYPI_DEVICE_TYPE2:
2349 default:
2350 spic_dev.evport_offset = SONYPI_TYPE2_OFFSET;
2351 break;
2352 }
2353
2106 /* read _PRS resources */ 2354 /* read _PRS resources */
2107 result = sony_pic_possible_resources(device); 2355 result = sony_pic_possible_resources(device);
2108 if (result) { 2356 if (result) {
diff --git a/drivers/misc/thinkpad_acpi.c b/drivers/misc/thinkpad_acpi.c
index 95c0b96e83f2..f15a58f7403f 100644
--- a/drivers/misc/thinkpad_acpi.c
+++ b/drivers/misc/thinkpad_acpi.c
@@ -21,8 +21,8 @@
21 * 02110-1301, USA. 21 * 02110-1301, USA.
22 */ 22 */
23 23
24#define IBM_VERSION "0.14" 24#define IBM_VERSION "0.15"
25#define TPACPI_SYSFS_VERSION 0x000100 25#define TPACPI_SYSFS_VERSION 0x010000
26 26
27/* 27/*
28 * Changelog: 28 * Changelog:
@@ -92,6 +92,29 @@ MODULE_LICENSE("GPL");
92/* Please remove this in year 2009 */ 92/* Please remove this in year 2009 */
93MODULE_ALIAS("ibm_acpi"); 93MODULE_ALIAS("ibm_acpi");
94 94
95/*
96 * DMI matching for module autoloading
97 *
98 * See http://thinkwiki.org/wiki/List_of_DMI_IDs
99 * See http://thinkwiki.org/wiki/BIOS_Upgrade_Downloads
100 *
101 * Only models listed in thinkwiki will be supported, so add yours
102 * if it is not there yet.
103 */
104#define IBM_BIOS_MODULE_ALIAS(__type) \
105 MODULE_ALIAS("dmi:bvnIBM:bvr" __type "ET??WW")
106
107/* Non-ancient thinkpads */
108MODULE_ALIAS("dmi:bvnIBM:*:svnIBM:*:pvrThinkPad*:rvnIBM:*");
109MODULE_ALIAS("dmi:bvnLENOVO:*:svnLENOVO:*:pvrThinkPad*:rvnLENOVO:*");
110
111/* Ancient thinkpad BIOSes have to be identified by
112 * BIOS type or model number, and there are far less
113 * BIOS types than model numbers... */
114IBM_BIOS_MODULE_ALIAS("I[B,D,H,I,M,N,O,T,W,V,Y,Z]");
115IBM_BIOS_MODULE_ALIAS("1[0,3,6,8,A-G,I,K,M-P,S,T]");
116IBM_BIOS_MODULE_ALIAS("K[U,X-Z]");
117
95#define __unused __attribute__ ((unused)) 118#define __unused __attribute__ ((unused))
96 119
97/**************************************************************************** 120/****************************************************************************
@@ -106,7 +129,7 @@ MODULE_ALIAS("ibm_acpi");
106 * ACPI basic handles 129 * ACPI basic handles
107 */ 130 */
108 131
109static acpi_handle root_handle = NULL; 132static acpi_handle root_handle;
110 133
111#define IBM_HANDLE(object, parent, paths...) \ 134#define IBM_HANDLE(object, parent, paths...) \
112 static acpi_handle object##_handle; \ 135 static acpi_handle object##_handle; \
@@ -487,19 +510,36 @@ static char *next_cmd(char **cmds)
487/**************************************************************************** 510/****************************************************************************
488 **************************************************************************** 511 ****************************************************************************
489 * 512 *
490 * Device model: hwmon and platform 513 * Device model: input, hwmon and platform
491 * 514 *
492 **************************************************************************** 515 ****************************************************************************
493 ****************************************************************************/ 516 ****************************************************************************/
494 517
495static struct platform_device *tpacpi_pdev = NULL; 518static struct platform_device *tpacpi_pdev;
496static struct class_device *tpacpi_hwmon = NULL; 519static struct class_device *tpacpi_hwmon;
520static struct input_dev *tpacpi_inputdev;
521
522
523static int tpacpi_resume_handler(struct platform_device *pdev)
524{
525 struct ibm_struct *ibm, *itmp;
526
527 list_for_each_entry_safe(ibm, itmp,
528 &tpacpi_all_drivers,
529 all_drivers) {
530 if (ibm->resume)
531 (ibm->resume)();
532 }
533
534 return 0;
535}
497 536
498static struct platform_driver tpacpi_pdriver = { 537static struct platform_driver tpacpi_pdriver = {
499 .driver = { 538 .driver = {
500 .name = IBM_DRVR_NAME, 539 .name = IBM_DRVR_NAME,
501 .owner = THIS_MODULE, 540 .owner = THIS_MODULE,
502 }, 541 },
542 .resume = tpacpi_resume_handler,
503}; 543};
504 544
505 545
@@ -677,9 +717,19 @@ static int __init thinkpad_acpi_driver_init(struct ibm_init_struct *iibm)
677 printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION); 717 printk(IBM_INFO "%s v%s\n", IBM_DESC, IBM_VERSION);
678 printk(IBM_INFO "%s\n", IBM_URL); 718 printk(IBM_INFO "%s\n", IBM_URL);
679 719
680 if (ibm_thinkpad_ec_found) 720 printk(IBM_INFO "ThinkPad BIOS %s, EC %s\n",
681 printk(IBM_INFO "ThinkPad EC firmware %s\n", 721 (thinkpad_id.bios_version_str) ?
682 ibm_thinkpad_ec_found); 722 thinkpad_id.bios_version_str : "unknown",
723 (thinkpad_id.ec_version_str) ?
724 thinkpad_id.ec_version_str : "unknown");
725
726 if (thinkpad_id.vendor && thinkpad_id.model_str)
727 printk(IBM_INFO "%s %s\n",
728 (thinkpad_id.vendor == PCI_VENDOR_ID_IBM) ?
729 "IBM" : ((thinkpad_id.vendor ==
730 PCI_VENDOR_ID_LENOVO) ?
731 "Lenovo" : "Unknown vendor"),
732 thinkpad_id.model_str);
683 733
684 return 0; 734 return 0;
685} 735}
@@ -704,16 +754,28 @@ static struct ibm_struct thinkpad_acpi_driver_data = {
704 */ 754 */
705 755
706static int hotkey_orig_status; 756static int hotkey_orig_status;
707static int hotkey_orig_mask; 757static u32 hotkey_orig_mask;
758static u32 hotkey_all_mask;
759static u32 hotkey_reserved_mask;
760
761static u16 *hotkey_keycode_map;
708 762
709static struct attribute_set *hotkey_dev_attributes = NULL; 763static struct attribute_set *hotkey_dev_attributes;
764
765static int hotkey_get_wlsw(int *status)
766{
767 if (!acpi_evalf(hkey_handle, status, "WLSW", "d"))
768 return -EIO;
769 return 0;
770}
710 771
711/* sysfs hotkey enable ------------------------------------------------- */ 772/* sysfs hotkey enable ------------------------------------------------- */
712static ssize_t hotkey_enable_show(struct device *dev, 773static ssize_t hotkey_enable_show(struct device *dev,
713 struct device_attribute *attr, 774 struct device_attribute *attr,
714 char *buf) 775 char *buf)
715{ 776{
716 int res, status, mask; 777 int res, status;
778 u32 mask;
717 779
718 res = hotkey_get(&status, &mask); 780 res = hotkey_get(&status, &mask);
719 if (res) 781 if (res)
@@ -727,7 +789,8 @@ static ssize_t hotkey_enable_store(struct device *dev,
727 const char *buf, size_t count) 789 const char *buf, size_t count)
728{ 790{
729 unsigned long t; 791 unsigned long t;
730 int res, status, mask; 792 int res, status;
793 u32 mask;
731 794
732 if (parse_strtoul(buf, 1, &t)) 795 if (parse_strtoul(buf, 1, &t))
733 return -EINVAL; 796 return -EINVAL;
@@ -748,13 +811,14 @@ static ssize_t hotkey_mask_show(struct device *dev,
748 struct device_attribute *attr, 811 struct device_attribute *attr,
749 char *buf) 812 char *buf)
750{ 813{
751 int res, status, mask; 814 int res, status;
815 u32 mask;
752 816
753 res = hotkey_get(&status, &mask); 817 res = hotkey_get(&status, &mask);
754 if (res) 818 if (res)
755 return res; 819 return res;
756 820
757 return snprintf(buf, PAGE_SIZE, "0x%04x\n", mask); 821 return snprintf(buf, PAGE_SIZE, "0x%08x\n", mask);
758} 822}
759 823
760static ssize_t hotkey_mask_store(struct device *dev, 824static ssize_t hotkey_mask_store(struct device *dev,
@@ -762,9 +826,10 @@ static ssize_t hotkey_mask_store(struct device *dev,
762 const char *buf, size_t count) 826 const char *buf, size_t count)
763{ 827{
764 unsigned long t; 828 unsigned long t;
765 int res, status, mask; 829 int res, status;
830 u32 mask;
766 831
767 if (parse_strtoul(buf, 0xffff, &t)) 832 if (parse_strtoul(buf, 0xffffffffUL, &t))
768 return -EINVAL; 833 return -EINVAL;
769 834
770 res = hotkey_get(&status, &mask); 835 res = hotkey_get(&status, &mask);
@@ -794,26 +859,123 @@ static ssize_t hotkey_bios_mask_show(struct device *dev,
794 struct device_attribute *attr, 859 struct device_attribute *attr,
795 char *buf) 860 char *buf)
796{ 861{
797 return snprintf(buf, PAGE_SIZE, "0x%04x\n", hotkey_orig_mask); 862 return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_orig_mask);
798} 863}
799 864
800static struct device_attribute dev_attr_hotkey_bios_mask = 865static struct device_attribute dev_attr_hotkey_bios_mask =
801 __ATTR(hotkey_bios_mask, S_IRUGO, hotkey_bios_mask_show, NULL); 866 __ATTR(hotkey_bios_mask, S_IRUGO, hotkey_bios_mask_show, NULL);
802 867
868/* sysfs hotkey all_mask ----------------------------------------------- */
869static ssize_t hotkey_all_mask_show(struct device *dev,
870 struct device_attribute *attr,
871 char *buf)
872{
873 return snprintf(buf, PAGE_SIZE, "0x%08x\n", hotkey_all_mask);
874}
875
876static struct device_attribute dev_attr_hotkey_all_mask =
877 __ATTR(hotkey_all_mask, S_IRUGO, hotkey_all_mask_show, NULL);
878
879/* sysfs hotkey recommended_mask --------------------------------------- */
880static ssize_t hotkey_recommended_mask_show(struct device *dev,
881 struct device_attribute *attr,
882 char *buf)
883{
884 return snprintf(buf, PAGE_SIZE, "0x%08x\n",
885 hotkey_all_mask & ~hotkey_reserved_mask);
886}
887
888static struct device_attribute dev_attr_hotkey_recommended_mask =
889 __ATTR(hotkey_recommended_mask, S_IRUGO,
890 hotkey_recommended_mask_show, NULL);
891
892/* sysfs hotkey radio_sw ----------------------------------------------- */
893static ssize_t hotkey_radio_sw_show(struct device *dev,
894 struct device_attribute *attr,
895 char *buf)
896{
897 int res, s;
898 res = hotkey_get_wlsw(&s);
899 if (res < 0)
900 return res;
901
902 return snprintf(buf, PAGE_SIZE, "%d\n", !!s);
903}
904
905static struct device_attribute dev_attr_hotkey_radio_sw =
906 __ATTR(hotkey_radio_sw, S_IRUGO, hotkey_radio_sw_show, NULL);
907
803/* --------------------------------------------------------------------- */ 908/* --------------------------------------------------------------------- */
804 909
805static struct attribute *hotkey_mask_attributes[] = { 910static struct attribute *hotkey_mask_attributes[] = {
806 &dev_attr_hotkey_mask.attr, 911 &dev_attr_hotkey_mask.attr,
807 &dev_attr_hotkey_bios_enabled.attr, 912 &dev_attr_hotkey_bios_enabled.attr,
808 &dev_attr_hotkey_bios_mask.attr, 913 &dev_attr_hotkey_bios_mask.attr,
914 &dev_attr_hotkey_all_mask.attr,
915 &dev_attr_hotkey_recommended_mask.attr,
809}; 916};
810 917
811static int __init hotkey_init(struct ibm_init_struct *iibm) 918static int __init hotkey_init(struct ibm_init_struct *iibm)
812{ 919{
813 int res; 920
921 static u16 ibm_keycode_map[] __initdata = {
922 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */
923 KEY_FN_F1, KEY_FN_F2, KEY_COFFEE, KEY_SLEEP,
924 KEY_WLAN, KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8,
925 KEY_FN_F9, KEY_FN_F10, KEY_FN_F11, KEY_SUSPEND,
926 /* Scan codes 0x0C to 0x0F: Other ACPI HKEY hot keys */
927 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */
928 KEY_UNKNOWN, /* 0x0D: FN+INSERT */
929 KEY_UNKNOWN, /* 0x0E: FN+DELETE */
930 KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */
931 /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */
932 KEY_RESERVED, /* 0x10: FN+END (brightness down) */
933 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
934 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
935 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
936 KEY_RESERVED, /* 0x14: VOLUME UP */
937 KEY_RESERVED, /* 0x15: VOLUME DOWN */
938 KEY_RESERVED, /* 0x16: MUTE */
939 KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
940 /* (assignments unknown, please report if found) */
941 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
942 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
943 };
944 static u16 lenovo_keycode_map[] __initdata = {
945 /* Scan Codes 0x00 to 0x0B: ACPI HKEY FN+F1..F12 */
946 KEY_FN_F1, KEY_COFFEE, KEY_BATTERY, KEY_SLEEP,
947 KEY_WLAN, KEY_FN_F6, KEY_SWITCHVIDEOMODE, KEY_FN_F8,
948 KEY_FN_F9, KEY_FN_F10, KEY_FN_F11, KEY_SUSPEND,
949 /* Scan codes 0x0C to 0x0F: Other ACPI HKEY hot keys */
950 KEY_UNKNOWN, /* 0x0C: FN+BACKSPACE */
951 KEY_UNKNOWN, /* 0x0D: FN+INSERT */
952 KEY_UNKNOWN, /* 0x0E: FN+DELETE */
953 KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */
954 /* Scan codes 0x10 to 0x1F: Extended ACPI HKEY hot keys */
955 KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */
956 KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
957 KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
958 KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
959 KEY_RESERVED, /* 0x14: VOLUME UP */
960 KEY_RESERVED, /* 0x15: VOLUME DOWN */
961 KEY_RESERVED, /* 0x16: MUTE */
962 KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
963 /* (assignments unknown, please report if found) */
964 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
965 KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN, KEY_UNKNOWN,
966 };
967
968#define TPACPI_HOTKEY_MAP_LEN ARRAY_SIZE(ibm_keycode_map)
969#define TPACPI_HOTKEY_MAP_SIZE sizeof(ibm_keycode_map)
970#define TPACPI_HOTKEY_MAP_TYPESIZE sizeof(ibm_keycode_map[0])
971
972 int res, i;
973 int status;
814 974
815 vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n"); 975 vdbg_printk(TPACPI_DBG_INIT, "initializing hotkey subdriver\n");
816 976
977 BUG_ON(!tpacpi_inputdev);
978
817 IBM_ACPIHANDLE_INIT(hkey); 979 IBM_ACPIHANDLE_INIT(hkey);
818 mutex_init(&hotkey_mutex); 980 mutex_init(&hotkey_mutex);
819 981
@@ -824,7 +986,7 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
824 str_supported(tp_features.hotkey)); 986 str_supported(tp_features.hotkey));
825 987
826 if (tp_features.hotkey) { 988 if (tp_features.hotkey) {
827 hotkey_dev_attributes = create_attr_set(4, NULL); 989 hotkey_dev_attributes = create_attr_set(7, NULL);
828 if (!hotkey_dev_attributes) 990 if (!hotkey_dev_attributes)
829 return -ENOMEM; 991 return -ENOMEM;
830 res = add_to_attr_set(hotkey_dev_attributes, 992 res = add_to_attr_set(hotkey_dev_attributes,
@@ -840,19 +1002,92 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
840 vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n", 1002 vdbg_printk(TPACPI_DBG_INIT, "hotkey masks are %s\n",
841 str_supported(tp_features.hotkey_mask)); 1003 str_supported(tp_features.hotkey_mask));
842 1004
1005 if (tp_features.hotkey_mask) {
1006 /* MHKA available in A31, R40, R40e, T4x, X31, and later */
1007 if (!acpi_evalf(hkey_handle, &hotkey_all_mask,
1008 "MHKA", "qd"))
1009 hotkey_all_mask = 0x080cU; /* FN+F12, FN+F4, FN+F3 */
1010 }
1011
843 res = hotkey_get(&hotkey_orig_status, &hotkey_orig_mask); 1012 res = hotkey_get(&hotkey_orig_status, &hotkey_orig_mask);
844 if (!res && tp_features.hotkey_mask) { 1013 if (!res && tp_features.hotkey_mask) {
845 res = add_many_to_attr_set(hotkey_dev_attributes, 1014 res = add_many_to_attr_set(hotkey_dev_attributes,
846 hotkey_mask_attributes, 1015 hotkey_mask_attributes,
847 ARRAY_SIZE(hotkey_mask_attributes)); 1016 ARRAY_SIZE(hotkey_mask_attributes));
848 } 1017 }
1018
1019 /* Not all thinkpads have a hardware radio switch */
1020 if (!res && acpi_evalf(hkey_handle, &status, "WLSW", "qd")) {
1021 tp_features.hotkey_wlsw = 1;
1022 printk(IBM_INFO
1023 "radio switch found; radios are %s\n",
1024 enabled(status, 0));
1025 res = add_to_attr_set(hotkey_dev_attributes,
1026 &dev_attr_hotkey_radio_sw.attr);
1027 }
1028
849 if (!res) 1029 if (!res)
850 res = register_attr_set_with_sysfs( 1030 res = register_attr_set_with_sysfs(
851 hotkey_dev_attributes, 1031 hotkey_dev_attributes,
852 &tpacpi_pdev->dev.kobj); 1032 &tpacpi_pdev->dev.kobj);
1033 if (res)
1034 return res;
1035
1036 /* Set up key map */
1037
1038 hotkey_keycode_map = kmalloc(TPACPI_HOTKEY_MAP_SIZE,
1039 GFP_KERNEL);
1040 if (!hotkey_keycode_map) {
1041 printk(IBM_ERR "failed to allocate memory for key map\n");
1042 return -ENOMEM;
1043 }
1044
1045 if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO) {
1046 dbg_printk(TPACPI_DBG_INIT,
1047 "using Lenovo default hot key map\n");
1048 memcpy(hotkey_keycode_map, &lenovo_keycode_map,
1049 TPACPI_HOTKEY_MAP_SIZE);
1050 } else {
1051 dbg_printk(TPACPI_DBG_INIT,
1052 "using IBM default hot key map\n");
1053 memcpy(hotkey_keycode_map, &ibm_keycode_map,
1054 TPACPI_HOTKEY_MAP_SIZE);
1055 }
853 1056
1057#ifndef CONFIG_THINKPAD_ACPI_INPUT_ENABLED
1058 for (i = 0; i < 12; i++)
1059 hotkey_keycode_map[i] = KEY_UNKNOWN;
1060#endif /* ! CONFIG_THINKPAD_ACPI_INPUT_ENABLED */
1061
1062 set_bit(EV_KEY, tpacpi_inputdev->evbit);
1063 set_bit(EV_MSC, tpacpi_inputdev->evbit);
1064 set_bit(MSC_SCAN, tpacpi_inputdev->mscbit);
1065 tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE;
1066 tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN;
1067 tpacpi_inputdev->keycode = hotkey_keycode_map;
1068 for (i = 0; i < TPACPI_HOTKEY_MAP_LEN; i++) {
1069 if (hotkey_keycode_map[i] != KEY_RESERVED) {
1070 set_bit(hotkey_keycode_map[i],
1071 tpacpi_inputdev->keybit);
1072 } else {
1073 if (i < sizeof(hotkey_reserved_mask)*8)
1074 hotkey_reserved_mask |= 1 << i;
1075 }
1076 }
1077
1078 if (tp_features.hotkey_wlsw) {
1079 set_bit(EV_SW, tpacpi_inputdev->evbit);
1080 set_bit(SW_RADIO, tpacpi_inputdev->swbit);
1081 }
1082
1083#ifdef CONFIG_THINKPAD_ACPI_INPUT_ENABLED
1084 dbg_printk(TPACPI_DBG_INIT,
1085 "enabling hot key handling\n");
1086 res = hotkey_set(1, (hotkey_all_mask & ~hotkey_reserved_mask)
1087 | hotkey_orig_mask);
854 if (res) 1088 if (res)
855 return res; 1089 return res;
1090#endif /* CONFIG_THINKPAD_ACPI_INPUT_ENABLED */
856 } 1091 }
857 1092
858 return (tp_features.hotkey)? 0 : 1; 1093 return (tp_features.hotkey)? 0 : 1;
@@ -875,22 +1110,101 @@ static void hotkey_exit(void)
875 } 1110 }
876} 1111}
877 1112
1113static void tpacpi_input_send_key(unsigned int scancode,
1114 unsigned int keycode)
1115{
1116 if (keycode != KEY_RESERVED) {
1117 input_report_key(tpacpi_inputdev, keycode, 1);
1118 if (keycode == KEY_UNKNOWN)
1119 input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
1120 scancode);
1121 input_sync(tpacpi_inputdev);
1122
1123 input_report_key(tpacpi_inputdev, keycode, 0);
1124 if (keycode == KEY_UNKNOWN)
1125 input_event(tpacpi_inputdev, EV_MSC, MSC_SCAN,
1126 scancode);
1127 input_sync(tpacpi_inputdev);
1128 }
1129}
1130
1131static void tpacpi_input_send_radiosw(void)
1132{
1133 int wlsw;
1134
1135 if (tp_features.hotkey_wlsw && !hotkey_get_wlsw(&wlsw))
1136 input_report_switch(tpacpi_inputdev,
1137 SW_RADIO, !!wlsw);
1138}
1139
878static void hotkey_notify(struct ibm_struct *ibm, u32 event) 1140static void hotkey_notify(struct ibm_struct *ibm, u32 event)
879{ 1141{
880 int hkey; 1142 u32 hkey;
1143 unsigned int keycode, scancode;
1144 int sendacpi = 1;
1145
1146 if (event == 0x80 && acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) {
1147 if (tpacpi_inputdev->users > 0) {
1148 switch (hkey >> 12) {
1149 case 1:
1150 /* 0x1000-0x1FFF: key presses */
1151 scancode = hkey & 0xfff;
1152 if (scancode > 0 && scancode < 0x21) {
1153 scancode--;
1154 keycode = hotkey_keycode_map[scancode];
1155 tpacpi_input_send_key(scancode, keycode);
1156 sendacpi = (keycode == KEY_RESERVED
1157 || keycode == KEY_UNKNOWN);
1158 } else {
1159 printk(IBM_ERR
1160 "hotkey 0x%04x out of range for keyboard map\n",
1161 hkey);
1162 }
1163 break;
1164 case 5:
1165 /* 0x5000-0x5FFF: LID */
1166 /* we don't handle it through this path, just
1167 * eat up known LID events */
1168 if (hkey != 0x5001 && hkey != 0x5002) {
1169 printk(IBM_ERR
1170 "unknown LID-related hotkey event: 0x%04x\n",
1171 hkey);
1172 }
1173 break;
1174 case 7:
1175 /* 0x7000-0x7FFF: misc */
1176 if (tp_features.hotkey_wlsw && hkey == 0x7000) {
1177 tpacpi_input_send_radiosw();
1178 sendacpi = 0;
1179 break;
1180 }
1181 /* fallthrough to default */
1182 default:
1183 /* case 2: dock-related */
1184 /* 0x2305 - T43 waking up due to bay lever eject while aslept */
1185 /* case 3: ultra-bay related. maybe bay in dock? */
1186 /* 0x3003 - T43 after wake up by bay lever eject (0x2305) */
1187 printk(IBM_NOTICE "unhandled hotkey event 0x%04x\n", hkey);
1188 }
1189 }
881 1190
882 if (acpi_evalf(hkey_handle, &hkey, "MHKP", "d")) 1191 if (sendacpi)
883 acpi_bus_generate_event(ibm->acpi->device, event, hkey); 1192 acpi_bus_generate_event(ibm->acpi->device, event, hkey);
884 else { 1193 } else {
885 printk(IBM_ERR "unknown hotkey event %d\n", event); 1194 printk(IBM_ERR "unknown hotkey notification event %d\n", event);
886 acpi_bus_generate_event(ibm->acpi->device, event, 0); 1195 acpi_bus_generate_event(ibm->acpi->device, event, 0);
887 } 1196 }
888} 1197}
889 1198
1199static void hotkey_resume(void)
1200{
1201 tpacpi_input_send_radiosw();
1202}
1203
890/* 1204/*
891 * Call with hotkey_mutex held 1205 * Call with hotkey_mutex held
892 */ 1206 */
893static int hotkey_get(int *status, int *mask) 1207static int hotkey_get(int *status, u32 *mask)
894{ 1208{
895 if (!acpi_evalf(hkey_handle, status, "DHKC", "d")) 1209 if (!acpi_evalf(hkey_handle, status, "DHKC", "d"))
896 return -EIO; 1210 return -EIO;
@@ -905,7 +1219,7 @@ static int hotkey_get(int *status, int *mask)
905/* 1219/*
906 * Call with hotkey_mutex held 1220 * Call with hotkey_mutex held
907 */ 1221 */
908static int hotkey_set(int status, int mask) 1222static int hotkey_set(int status, u32 mask)
909{ 1223{
910 int i; 1224 int i;
911 1225
@@ -926,7 +1240,8 @@ static int hotkey_set(int status, int mask)
926/* procfs -------------------------------------------------------------- */ 1240/* procfs -------------------------------------------------------------- */
927static int hotkey_read(char *p) 1241static int hotkey_read(char *p)
928{ 1242{
929 int res, status, mask; 1243 int res, status;
1244 u32 mask;
930 int len = 0; 1245 int len = 0;
931 1246
932 if (!tp_features.hotkey) { 1247 if (!tp_features.hotkey) {
@@ -944,7 +1259,7 @@ static int hotkey_read(char *p)
944 1259
945 len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0)); 1260 len += sprintf(p + len, "status:\t\t%s\n", enabled(status, 0));
946 if (tp_features.hotkey_mask) { 1261 if (tp_features.hotkey_mask) {
947 len += sprintf(p + len, "mask:\t\t0x%04x\n", mask); 1262 len += sprintf(p + len, "mask:\t\t0x%08x\n", mask);
948 len += sprintf(p + len, 1263 len += sprintf(p + len,
949 "commands:\tenable, disable, reset, <mask>\n"); 1264 "commands:\tenable, disable, reset, <mask>\n");
950 } else { 1265 } else {
@@ -957,7 +1272,8 @@ static int hotkey_read(char *p)
957 1272
958static int hotkey_write(char *buf) 1273static int hotkey_write(char *buf)
959{ 1274{
960 int res, status, mask; 1275 int res, status;
1276 u32 mask;
961 char *cmd; 1277 char *cmd;
962 int do_cmd = 0; 1278 int do_cmd = 0;
963 1279
@@ -1012,6 +1328,7 @@ static struct ibm_struct hotkey_driver_data = {
1012 .read = hotkey_read, 1328 .read = hotkey_read,
1013 .write = hotkey_write, 1329 .write = hotkey_write,
1014 .exit = hotkey_exit, 1330 .exit = hotkey_exit,
1331 .resume = hotkey_resume,
1015 .acpi = &ibm_hotkey_acpidriver, 1332 .acpi = &ibm_hotkey_acpidriver,
1016}; 1333};
1017 1334
@@ -1770,7 +2087,10 @@ static struct tp_acpi_drv_struct ibm_dock_acpidriver[2] = {
1770 .type = ACPI_SYSTEM_NOTIFY, 2087 .type = ACPI_SYSTEM_NOTIFY,
1771 }, 2088 },
1772 { 2089 {
1773 .hid = IBM_PCI_HID, 2090 /* THIS ONE MUST NEVER BE USED FOR DRIVER AUTOLOADING.
2091 * We just use it to get notifications of dock hotplug
2092 * in very old thinkpads */
2093 .hid = PCI_ROOT_HID_STRING,
1774 .notify = dock_notify, 2094 .notify = dock_notify,
1775 .handle = &pci_handle, 2095 .handle = &pci_handle,
1776 .type = ACPI_SYSTEM_NOTIFY, 2096 .type = ACPI_SYSTEM_NOTIFY,
@@ -1829,7 +2149,7 @@ static int __init dock_init2(struct ibm_init_struct *iibm)
1829static void dock_notify(struct ibm_struct *ibm, u32 event) 2149static void dock_notify(struct ibm_struct *ibm, u32 event)
1830{ 2150{
1831 int docked = dock_docked(); 2151 int docked = dock_docked();
1832 int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, IBM_PCI_HID); 2152 int pci = ibm->acpi->hid && strstr(ibm->acpi->hid, PCI_ROOT_HID_STRING);
1833 2153
1834 if (event == 1 && !pci) /* 570 */ 2154 if (event == 1 && !pci) /* 570 */
1835 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */ 2155 acpi_bus_generate_event(ibm->acpi->device, event, 1); /* button */
@@ -2389,7 +2709,7 @@ static int __init thermal_init(struct ibm_init_struct *iibm)
2389 2709
2390 acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv"); 2710 acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
2391 2711
2392 if (ibm_thinkpad_ec_found && experimental) { 2712 if (thinkpad_id.ec_model) {
2393 /* 2713 /*
2394 * Direct EC access mode: sensors at registers 2714 * Direct EC access mode: sensors at registers
2395 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for 2715 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for
@@ -2533,6 +2853,8 @@ static int thermal_get_sensor(int idx, s32 *value)
2533 snprintf(tmpi, sizeof(tmpi), "TMP%c", '0' + idx); 2853 snprintf(tmpi, sizeof(tmpi), "TMP%c", '0' + idx);
2534 if (!acpi_evalf(ec_handle, &t, tmpi, "d")) 2854 if (!acpi_evalf(ec_handle, &t, tmpi, "d"))
2535 return -EIO; 2855 return -EIO;
2856 if (t > 127 || t < -127)
2857 t = TP_EC_THERMAL_TMP_NA;
2536 *value = t * 1000; 2858 *value = t * 1000;
2537 return 0; 2859 return 0;
2538 } 2860 }
@@ -2671,22 +2993,39 @@ static struct ibm_struct ecdump_driver_data = {
2671 * Backlight/brightness subdriver 2993 * Backlight/brightness subdriver
2672 */ 2994 */
2673 2995
2674static struct backlight_device *ibm_backlight_device = NULL; 2996static struct backlight_device *ibm_backlight_device;
2675 2997
2676static struct backlight_ops ibm_backlight_data = { 2998static struct backlight_ops ibm_backlight_data = {
2677 .get_brightness = brightness_get, 2999 .get_brightness = brightness_get,
2678 .update_status = brightness_update_status, 3000 .update_status = brightness_update_status,
2679}; 3001};
2680 3002
3003static struct mutex brightness_mutex;
3004
2681static int __init brightness_init(struct ibm_init_struct *iibm) 3005static int __init brightness_init(struct ibm_init_struct *iibm)
2682{ 3006{
2683 int b; 3007 int b;
2684 3008
2685 vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n"); 3009 vdbg_printk(TPACPI_DBG_INIT, "initializing brightness subdriver\n");
2686 3010
3011 mutex_init(&brightness_mutex);
3012
3013 if (!brightness_mode) {
3014 if (thinkpad_id.vendor == PCI_VENDOR_ID_LENOVO)
3015 brightness_mode = 2;
3016 else
3017 brightness_mode = 3;
3018
3019 dbg_printk(TPACPI_DBG_INIT, "selected brightness_mode=%d\n",
3020 brightness_mode);
3021 }
3022
3023 if (brightness_mode > 3)
3024 return -EINVAL;
3025
2687 b = brightness_get(NULL); 3026 b = brightness_get(NULL);
2688 if (b < 0) 3027 if (b < 0)
2689 return b; 3028 return 1;
2690 3029
2691 ibm_backlight_device = backlight_device_register( 3030 ibm_backlight_device = backlight_device_register(
2692 TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL, 3031 TPACPI_BACKLIGHT_DEV_NAME, NULL, NULL,
@@ -2722,34 +3061,79 @@ static int brightness_update_status(struct backlight_device *bd)
2722 bd->props.brightness : 0); 3061 bd->props.brightness : 0);
2723} 3062}
2724 3063
3064/*
3065 * ThinkPads can read brightness from two places: EC 0x31, or
3066 * CMOS NVRAM byte 0x5E, bits 0-3.
3067 */
2725static int brightness_get(struct backlight_device *bd) 3068static int brightness_get(struct backlight_device *bd)
2726{ 3069{
2727 u8 level; 3070 u8 lec = 0, lcmos = 0, level = 0;
2728 if (!acpi_ec_read(brightness_offset, &level))
2729 return -EIO;
2730 3071
2731 level &= 0x7; 3072 if (brightness_mode & 1) {
3073 if (!acpi_ec_read(brightness_offset, &lec))
3074 return -EIO;
3075 lec &= 7;
3076 level = lec;
3077 };
3078 if (brightness_mode & 2) {
3079 lcmos = (nvram_read_byte(TP_NVRAM_ADDR_BRIGHTNESS)
3080 & TP_NVRAM_MASK_LEVEL_BRIGHTNESS)
3081 >> TP_NVRAM_POS_LEVEL_BRIGHTNESS;
3082 level = lcmos;
3083 }
3084
3085 if (brightness_mode == 3 && lec != lcmos) {
3086 printk(IBM_ERR
3087 "CMOS NVRAM (%u) and EC (%u) do not agree "
3088 "on display brightness level\n",
3089 (unsigned int) lcmos,
3090 (unsigned int) lec);
3091 return -EIO;
3092 }
2732 3093
2733 return level; 3094 return level;
2734} 3095}
2735 3096
2736static int brightness_set(int value) 3097static int brightness_set(int value)
2737{ 3098{
2738 int cmos_cmd, inc, i; 3099 int cmos_cmd, inc, i, res;
2739 int current_value = brightness_get(NULL); 3100 int current_value;
3101
3102 if (value > 7)
3103 return -EINVAL;
2740 3104
2741 value &= 7; 3105 res = mutex_lock_interruptible(&brightness_mutex);
3106 if (res < 0)
3107 return res;
3108
3109 current_value = brightness_get(NULL);
3110 if (current_value < 0) {
3111 res = current_value;
3112 goto errout;
3113 }
2742 3114
2743 cmos_cmd = value > current_value ? TP_CMOS_BRIGHTNESS_UP : TP_CMOS_BRIGHTNESS_DOWN; 3115 cmos_cmd = value > current_value ?
3116 TP_CMOS_BRIGHTNESS_UP :
3117 TP_CMOS_BRIGHTNESS_DOWN;
2744 inc = value > current_value ? 1 : -1; 3118 inc = value > current_value ? 1 : -1;
3119
3120 res = 0;
2745 for (i = current_value; i != value; i += inc) { 3121 for (i = current_value; i != value; i += inc) {
2746 if (issue_thinkpad_cmos_command(cmos_cmd)) 3122 if ((brightness_mode & 2) &&
2747 return -EIO; 3123 issue_thinkpad_cmos_command(cmos_cmd)) {
2748 if (!acpi_ec_write(brightness_offset, i + inc)) 3124 res = -EIO;
2749 return -EIO; 3125 goto errout;
3126 }
3127 if ((brightness_mode & 1) &&
3128 !acpi_ec_write(brightness_offset, i + inc)) {
3129 res = -EIO;
3130 goto errout;;
3131 }
2750 } 3132 }
2751 3133
2752 return 0; 3134errout:
3135 mutex_unlock(&brightness_mutex);
3136 return res;
2753} 3137}
2754 3138
2755static int brightness_read(char *p) 3139static int brightness_read(char *p)
@@ -3273,20 +3657,19 @@ static int __init fan_init(struct ibm_init_struct *iibm)
3273 * Enable for TP-1Y (T43), TP-78 (R51e), 3657 * Enable for TP-1Y (T43), TP-78 (R51e),
3274 * TP-76 (R52), TP-70 (T43, R52), which are known 3658 * TP-76 (R52), TP-70 (T43, R52), which are known
3275 * to be buggy. */ 3659 * to be buggy. */
3276 if (fan_control_initial_status == 0x07 && 3660 if (fan_control_initial_status == 0x07) {
3277 ibm_thinkpad_ec_found && 3661 switch (thinkpad_id.ec_model) {
3278 ((ibm_thinkpad_ec_found[0] == '1' && 3662 case 0x5931: /* TP-1Y */
3279 ibm_thinkpad_ec_found[1] == 'Y') || 3663 case 0x3837: /* TP-78 */
3280 (ibm_thinkpad_ec_found[0] == '7' && 3664 case 0x3637: /* TP-76 */
3281 (ibm_thinkpad_ec_found[1] == '6' || 3665 case 0x3037: /* TP-70 */
3282 ibm_thinkpad_ec_found[1] == '8' || 3666 printk(IBM_NOTICE
3283 ibm_thinkpad_ec_found[1] == '0')) 3667 "fan_init: initial fan status is "
3284 )) { 3668 "unknown, assuming it is in auto "
3285 printk(IBM_NOTICE 3669 "mode\n");
3286 "fan_init: initial fan status is " 3670 tp_features.fan_ctrl_status_undef = 1;
3287 "unknown, assuming it is in auto " 3671 ;;
3288 "mode\n"); 3672 }
3289 tp_features.fan_ctrl_status_undef = 1;
3290 } 3673 }
3291 } else { 3674 } else {
3292 printk(IBM_ERR 3675 printk(IBM_ERR
@@ -3474,7 +3857,7 @@ static void fan_watchdog_fire(struct work_struct *ignored)
3474 3857
3475static void fan_watchdog_reset(void) 3858static void fan_watchdog_reset(void)
3476{ 3859{
3477 static int fan_watchdog_active = 0; 3860 static int fan_watchdog_active;
3478 3861
3479 if (fan_control_access_mode == TPACPI_FAN_WR_NONE) 3862 if (fan_control_access_mode == TPACPI_FAN_WR_NONE)
3480 return; 3863 return;
@@ -3877,7 +4260,7 @@ static struct ibm_struct fan_driver_data = {
3877 ****************************************************************************/ 4260 ****************************************************************************/
3878 4261
3879/* /proc support */ 4262/* /proc support */
3880static struct proc_dir_entry *proc_dir = NULL; 4263static struct proc_dir_entry *proc_dir;
3881 4264
3882/* Subdriver registry */ 4265/* Subdriver registry */
3883static LIST_HEAD(tpacpi_all_drivers); 4266static LIST_HEAD(tpacpi_all_drivers);
@@ -4020,13 +4403,30 @@ static void ibm_exit(struct ibm_struct *ibm)
4020 4403
4021/* Probing */ 4404/* Probing */
4022 4405
4023static char *ibm_thinkpad_ec_found = NULL; 4406static void __init get_thinkpad_model_data(struct thinkpad_id_data *tp)
4024
4025static char* __init check_dmi_for_ec(void)
4026{ 4407{
4027 struct dmi_device *dev = NULL; 4408 struct dmi_device *dev = NULL;
4028 char ec_fw_string[18]; 4409 char ec_fw_string[18];
4029 4410
4411 if (!tp)
4412 return;
4413
4414 memset(tp, 0, sizeof(*tp));
4415
4416 if (dmi_name_in_vendors("IBM"))
4417 tp->vendor = PCI_VENDOR_ID_IBM;
4418 else if (dmi_name_in_vendors("LENOVO"))
4419 tp->vendor = PCI_VENDOR_ID_LENOVO;
4420 else
4421 return;
4422
4423 tp->bios_version_str = kstrdup(dmi_get_system_info(DMI_BIOS_VERSION),
4424 GFP_KERNEL);
4425 if (!tp->bios_version_str)
4426 return;
4427 tp->bios_model = tp->bios_version_str[0]
4428 | (tp->bios_version_str[1] << 8);
4429
4030 /* 4430 /*
4031 * ThinkPad T23 or newer, A31 or newer, R50e or newer, 4431 * ThinkPad T23 or newer, A31 or newer, R50e or newer,
4032 * X32 or newer, all Z series; Some models must have an 4432 * X32 or newer, all Z series; Some models must have an
@@ -4040,10 +4440,20 @@ static char* __init check_dmi_for_ec(void)
4040 ec_fw_string) == 1) { 4440 ec_fw_string) == 1) {
4041 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; 4441 ec_fw_string[sizeof(ec_fw_string) - 1] = 0;
4042 ec_fw_string[strcspn(ec_fw_string, " ]")] = 0; 4442 ec_fw_string[strcspn(ec_fw_string, " ]")] = 0;
4043 return kstrdup(ec_fw_string, GFP_KERNEL); 4443
4444 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL);
4445 tp->ec_model = ec_fw_string[0]
4446 | (ec_fw_string[1] << 8);
4447 break;
4044 } 4448 }
4045 } 4449 }
4046 return NULL; 4450
4451 tp->model_str = kstrdup(dmi_get_system_info(DMI_PRODUCT_VERSION),
4452 GFP_KERNEL);
4453 if (strnicmp(tp->model_str, "ThinkPad", 8) != 0) {
4454 kfree(tp->model_str);
4455 tp->model_str = NULL;
4456 }
4047} 4457}
4048 4458
4049static int __init probe_for_thinkpad(void) 4459static int __init probe_for_thinkpad(void)
@@ -4057,7 +4467,7 @@ static int __init probe_for_thinkpad(void)
4057 * Non-ancient models have better DMI tagging, but very old models 4467 * Non-ancient models have better DMI tagging, but very old models
4058 * don't. 4468 * don't.
4059 */ 4469 */
4060 is_thinkpad = dmi_name_in_vendors("ThinkPad"); 4470 is_thinkpad = (thinkpad_id.model_str != NULL);
4061 4471
4062 /* ec is required because many other handles are relative to it */ 4472 /* ec is required because many other handles are relative to it */
4063 IBM_ACPIHANDLE_INIT(ec); 4473 IBM_ACPIHANDLE_INIT(ec);
@@ -4073,7 +4483,7 @@ static int __init probe_for_thinkpad(void)
4073 * false positives a damn great deal 4483 * false positives a damn great deal
4074 */ 4484 */
4075 if (!is_thinkpad) 4485 if (!is_thinkpad)
4076 is_thinkpad = dmi_name_in_vendors("IBM"); 4486 is_thinkpad = (thinkpad_id.vendor == PCI_VENDOR_ID_IBM);
4077 4487
4078 if (!is_thinkpad && !force_load) 4488 if (!is_thinkpad && !force_load)
4079 return -ENODEV; 4489 return -ENODEV;
@@ -4185,10 +4595,13 @@ static u32 dbg_level;
4185module_param_named(debug, dbg_level, uint, 0); 4595module_param_named(debug, dbg_level, uint, 0);
4186 4596
4187static int force_load; 4597static int force_load;
4188module_param(force_load, int, 0); 4598module_param(force_load, bool, 0);
4189 4599
4190static int fan_control_allowed; 4600static int fan_control_allowed;
4191module_param_named(fan_control, fan_control_allowed, int, 0); 4601module_param_named(fan_control, fan_control_allowed, bool, 0);
4602
4603static int brightness_mode;
4604module_param_named(brightness_mode, brightness_mode, int, 0);
4192 4605
4193#define IBM_PARAM(feature) \ 4606#define IBM_PARAM(feature) \
4194 module_param_call(feature, set_ibm_param, NULL, NULL, 0) 4607 module_param_call(feature, set_ibm_param, NULL, NULL, 0)
@@ -4216,12 +4629,16 @@ static int __init thinkpad_acpi_module_init(void)
4216 int ret, i; 4629 int ret, i;
4217 4630
4218 /* Driver-level probe */ 4631 /* Driver-level probe */
4632
4633 get_thinkpad_model_data(&thinkpad_id);
4219 ret = probe_for_thinkpad(); 4634 ret = probe_for_thinkpad();
4220 if (ret) 4635 if (ret) {
4636 thinkpad_acpi_module_exit();
4221 return ret; 4637 return ret;
4638 }
4222 4639
4223 /* Driver initialization */ 4640 /* Driver initialization */
4224 ibm_thinkpad_ec_found = check_dmi_for_ec(); 4641
4225 IBM_ACPIHANDLE_INIT(ecrd); 4642 IBM_ACPIHANDLE_INIT(ecrd);
4226 IBM_ACPIHANDLE_INIT(ecwr); 4643 IBM_ACPIHANDLE_INIT(ecwr);
4227 4644
@@ -4265,6 +4682,22 @@ static int __init thinkpad_acpi_module_init(void)
4265 thinkpad_acpi_module_exit(); 4682 thinkpad_acpi_module_exit();
4266 return ret; 4683 return ret;
4267 } 4684 }
4685 tpacpi_inputdev = input_allocate_device();
4686 if (!tpacpi_inputdev) {
4687 printk(IBM_ERR "unable to allocate input device\n");
4688 thinkpad_acpi_module_exit();
4689 return -ENOMEM;
4690 } else {
4691 /* Prepare input device, but don't register */
4692 tpacpi_inputdev->name = "ThinkPad Extra Buttons";
4693 tpacpi_inputdev->phys = IBM_DRVR_NAME "/input0";
4694 tpacpi_inputdev->id.bustype = BUS_HOST;
4695 tpacpi_inputdev->id.vendor = (thinkpad_id.vendor) ?
4696 thinkpad_id.vendor :
4697 PCI_VENDOR_ID_IBM;
4698 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT;
4699 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION;
4700 }
4268 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) { 4701 for (i = 0; i < ARRAY_SIZE(ibms_init); i++) {
4269 ret = ibm_init(&ibms_init[i]); 4702 ret = ibm_init(&ibms_init[i]);
4270 if (ret >= 0 && *ibms_init[i].param) 4703 if (ret >= 0 && *ibms_init[i].param)
@@ -4274,6 +4707,14 @@ static int __init thinkpad_acpi_module_init(void)
4274 return ret; 4707 return ret;
4275 } 4708 }
4276 } 4709 }
4710 ret = input_register_device(tpacpi_inputdev);
4711 if (ret < 0) {
4712 printk(IBM_ERR "unable to register input device\n");
4713 thinkpad_acpi_module_exit();
4714 return ret;
4715 } else {
4716 tp_features.input_device_registered = 1;
4717 }
4277 4718
4278 return 0; 4719 return 0;
4279} 4720}
@@ -4290,6 +4731,13 @@ static void thinkpad_acpi_module_exit(void)
4290 4731
4291 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n"); 4732 dbg_printk(TPACPI_DBG_INIT, "finished subdriver exit path...\n");
4292 4733
4734 if (tpacpi_inputdev) {
4735 if (tp_features.input_device_registered)
4736 input_unregister_device(tpacpi_inputdev);
4737 else
4738 input_free_device(tpacpi_inputdev);
4739 }
4740
4293 if (tpacpi_hwmon) 4741 if (tpacpi_hwmon)
4294 hwmon_device_unregister(tpacpi_hwmon); 4742 hwmon_device_unregister(tpacpi_hwmon);
4295 4743
@@ -4302,7 +4750,9 @@ static void thinkpad_acpi_module_exit(void)
4302 if (proc_dir) 4750 if (proc_dir)
4303 remove_proc_entry(IBM_PROC_DIR, acpi_root_dir); 4751 remove_proc_entry(IBM_PROC_DIR, acpi_root_dir);
4304 4752
4305 kfree(ibm_thinkpad_ec_found); 4753 kfree(thinkpad_id.bios_version_str);
4754 kfree(thinkpad_id.ec_version_str);
4755 kfree(thinkpad_id.model_str);
4306} 4756}
4307 4757
4308module_init(thinkpad_acpi_module_init); 4758module_init(thinkpad_acpi_module_init);
diff --git a/drivers/misc/thinkpad_acpi.h b/drivers/misc/thinkpad_acpi.h
index 72d62f2dabb9..b7a4a888cc8b 100644
--- a/drivers/misc/thinkpad_acpi.h
+++ b/drivers/misc/thinkpad_acpi.h
@@ -32,6 +32,7 @@
32#include <linux/list.h> 32#include <linux/list.h>
33#include <linux/mutex.h> 33#include <linux/mutex.h>
34 34
35#include <linux/nvram.h>
35#include <linux/proc_fs.h> 36#include <linux/proc_fs.h>
36#include <linux/sysfs.h> 37#include <linux/sysfs.h>
37#include <linux/backlight.h> 38#include <linux/backlight.h>
@@ -39,6 +40,7 @@
39#include <linux/platform_device.h> 40#include <linux/platform_device.h>
40#include <linux/hwmon.h> 41#include <linux/hwmon.h>
41#include <linux/hwmon-sysfs.h> 42#include <linux/hwmon-sysfs.h>
43#include <linux/input.h>
42#include <asm/uaccess.h> 44#include <asm/uaccess.h>
43 45
44#include <linux/dmi.h> 46#include <linux/dmi.h>
@@ -48,6 +50,7 @@
48#include <acpi/acpi_drivers.h> 50#include <acpi/acpi_drivers.h>
49#include <acpi/acnamesp.h> 51#include <acpi/acnamesp.h>
50 52
53#include <linux/pci_ids.h>
51 54
52/**************************************************************************** 55/****************************************************************************
53 * Main driver 56 * Main driver
@@ -78,6 +81,11 @@
78#define TP_CMOS_BRIGHTNESS_UP 4 81#define TP_CMOS_BRIGHTNESS_UP 4
79#define TP_CMOS_BRIGHTNESS_DOWN 5 82#define TP_CMOS_BRIGHTNESS_DOWN 5
80 83
84/* ThinkPad CMOS NVRAM constants */
85#define TP_NVRAM_ADDR_BRIGHTNESS 0x5e
86#define TP_NVRAM_MASK_LEVEL_BRIGHTNESS 0x07
87#define TP_NVRAM_POS_LEVEL_BRIGHTNESS 0
88
81#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") 89#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
82#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled") 90#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
83#define strlencmp(a,b) (strncmp((a), (b), strlen(b))) 91#define strlencmp(a,b) (strncmp((a), (b), strlen(b)))
@@ -98,9 +106,13 @@ static const char *str_supported(int is_supported);
98#define vdbg_printk(a_dbg_level, format, arg...) 106#define vdbg_printk(a_dbg_level, format, arg...)
99#endif 107#endif
100 108
109/* Input IDs */
110#define TPACPI_HKEY_INPUT_VENDOR PCI_VENDOR_ID_IBM
111#define TPACPI_HKEY_INPUT_PRODUCT 0x5054 /* "TP" */
112#define TPACPI_HKEY_INPUT_VERSION 0x4101
113
101/* ACPI HIDs */ 114/* ACPI HIDs */
102#define IBM_HKEY_HID "IBM0068" 115#define IBM_HKEY_HID "IBM0068"
103#define IBM_PCI_HID "PNP0A03"
104 116
105/* ACPI helpers */ 117/* ACPI helpers */
106static int __must_check acpi_evalf(acpi_handle handle, 118static int __must_check acpi_evalf(acpi_handle handle,
@@ -161,6 +173,7 @@ static int parse_strtoul(const char *buf, unsigned long max,
161static struct platform_device *tpacpi_pdev; 173static struct platform_device *tpacpi_pdev;
162static struct class_device *tpacpi_hwmon; 174static struct class_device *tpacpi_hwmon;
163static struct platform_driver tpacpi_pdriver; 175static struct platform_driver tpacpi_pdriver;
176static struct input_dev *tpacpi_inputdev;
164static int tpacpi_create_driver_attributes(struct device_driver *drv); 177static int tpacpi_create_driver_attributes(struct device_driver *drv);
165static void tpacpi_remove_driver_attributes(struct device_driver *drv); 178static void tpacpi_remove_driver_attributes(struct device_driver *drv);
166 179
@@ -168,9 +181,7 @@ static void tpacpi_remove_driver_attributes(struct device_driver *drv);
168static int experimental; 181static int experimental;
169static u32 dbg_level; 182static u32 dbg_level;
170static int force_load; 183static int force_load;
171static char *ibm_thinkpad_ec_found;
172 184
173static char* check_dmi_for_ec(void);
174static int thinkpad_acpi_module_init(void); 185static int thinkpad_acpi_module_init(void);
175static void thinkpad_acpi_module_exit(void); 186static void thinkpad_acpi_module_exit(void);
176 187
@@ -197,6 +208,7 @@ struct ibm_struct {
197 int (*read) (char *); 208 int (*read) (char *);
198 int (*write) (char *); 209 int (*write) (char *);
199 void (*exit) (void); 210 void (*exit) (void);
211 void (*resume) (void);
200 212
201 struct list_head all_drivers; 213 struct list_head all_drivers;
202 214
@@ -228,12 +240,29 @@ static struct {
228 u16 bluetooth:1; 240 u16 bluetooth:1;
229 u16 hotkey:1; 241 u16 hotkey:1;
230 u16 hotkey_mask:1; 242 u16 hotkey_mask:1;
243 u16 hotkey_wlsw:1;
231 u16 light:1; 244 u16 light:1;
232 u16 light_status:1; 245 u16 light_status:1;
233 u16 wan:1; 246 u16 wan:1;
234 u16 fan_ctrl_status_undef:1; 247 u16 fan_ctrl_status_undef:1;
248 u16 input_device_registered:1;
235} tp_features; 249} tp_features;
236 250
251struct thinkpad_id_data {
252 unsigned int vendor; /* ThinkPad vendor:
253 * PCI_VENDOR_ID_IBM/PCI_VENDOR_ID_LENOVO */
254
255 char *bios_version_str; /* Something like 1ZET51WW (1.03z) */
256 char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
257
258 u16 bios_model; /* Big Endian, TP-1Y = 0x5931, 0 = unknown */
259 u16 ec_model;
260
261 char *model_str;
262};
263
264static struct thinkpad_id_data thinkpad_id;
265
237static struct list_head tpacpi_all_drivers; 266static struct list_head tpacpi_all_drivers;
238 267
239static struct ibm_init_struct ibms_init[]; 268static struct ibm_init_struct ibms_init[];
@@ -300,6 +329,7 @@ static int bluetooth_write(char *buf);
300 329
301static struct backlight_device *ibm_backlight_device; 330static struct backlight_device *ibm_backlight_device;
302static int brightness_offset = 0x31; 331static int brightness_offset = 0x31;
332static int brightness_mode;
303 333
304static int brightness_init(struct ibm_init_struct *iibm); 334static int brightness_init(struct ibm_init_struct *iibm);
305static void brightness_exit(void); 335static void brightness_exit(void);
@@ -415,14 +445,14 @@ static int fan_write_cmd_watchdog(const char *cmd, int *rc);
415 */ 445 */
416 446
417static int hotkey_orig_status; 447static int hotkey_orig_status;
418static int hotkey_orig_mask; 448static u32 hotkey_orig_mask;
419 449
420static struct mutex hotkey_mutex; 450static struct mutex hotkey_mutex;
421 451
422static int hotkey_init(struct ibm_init_struct *iibm); 452static int hotkey_init(struct ibm_init_struct *iibm);
423static void hotkey_exit(void); 453static void hotkey_exit(void);
424static int hotkey_get(int *status, int *mask); 454static int hotkey_get(int *status, u32 *mask);
425static int hotkey_set(int status, int mask); 455static int hotkey_set(int status, u32 mask);
426static void hotkey_notify(struct ibm_struct *ibm, u32 event); 456static void hotkey_notify(struct ibm_struct *ibm, u32 event);
427static int hotkey_read(char *p); 457static int hotkey_read(char *p);
428static int hotkey_write(char *buf); 458static int hotkey_write(char *buf);
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c
index 28c881895ab7..15aab374127e 100644
--- a/drivers/mmc/host/at91_mci.c
+++ b/drivers/mmc/host/at91_mci.c
@@ -903,8 +903,10 @@ static int __init at91_mci_probe(struct platform_device *pdev)
903 /* 903 /*
904 * Add host to MMC layer 904 * Add host to MMC layer
905 */ 905 */
906 if (host->board->det_pin) 906 if (host->board->det_pin) {
907 host->present = !at91_get_gpio_value(host->board->det_pin); 907 host->present = !at91_get_gpio_value(host->board->det_pin);
908 device_init_wakeup(&pdev->dev, 1);
909 }
908 else 910 else
909 host->present = -1; 911 host->present = -1;
910 912
@@ -940,6 +942,7 @@ static int __exit at91_mci_remove(struct platform_device *pdev)
940 host = mmc_priv(mmc); 942 host = mmc_priv(mmc);
941 943
942 if (host->present != -1) { 944 if (host->present != -1) {
945 device_init_wakeup(&pdev->dev, 0);
943 free_irq(host->board->det_pin, host); 946 free_irq(host->board->det_pin, host);
944 cancel_delayed_work(&host->mmc->detect); 947 cancel_delayed_work(&host->mmc->detect);
945 } 948 }
@@ -966,8 +969,12 @@ static int __exit at91_mci_remove(struct platform_device *pdev)
966static int at91_mci_suspend(struct platform_device *pdev, pm_message_t state) 969static int at91_mci_suspend(struct platform_device *pdev, pm_message_t state)
967{ 970{
968 struct mmc_host *mmc = platform_get_drvdata(pdev); 971 struct mmc_host *mmc = platform_get_drvdata(pdev);
972 struct at91mci_host *host = mmc_priv(mmc);
969 int ret = 0; 973 int ret = 0;
970 974
975 if (device_may_wakeup(&pdev->dev))
976 enable_irq_wake(host->board->det_pin);
977
971 if (mmc) 978 if (mmc)
972 ret = mmc_suspend_host(mmc, state); 979 ret = mmc_suspend_host(mmc, state);
973 980
@@ -977,8 +984,12 @@ static int at91_mci_suspend(struct platform_device *pdev, pm_message_t state)
977static int at91_mci_resume(struct platform_device *pdev) 984static int at91_mci_resume(struct platform_device *pdev)
978{ 985{
979 struct mmc_host *mmc = platform_get_drvdata(pdev); 986 struct mmc_host *mmc = platform_get_drvdata(pdev);
987 struct at91mci_host *host = mmc_priv(mmc);
980 int ret = 0; 988 int ret = 0;
981 989
990 if (device_may_wakeup(&pdev->dev))
991 disable_irq_wake(host->board->det_pin);
992
982 if (mmc) 993 if (mmc)
983 ret = mmc_resume_host(mmc); 994 ret = mmc_resume_host(mmc);
984 995
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 10d15c39d003..4a24db028d87 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1024,6 +1024,8 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id)
1024 1024
1025 intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK); 1025 intmask &= ~(SDHCI_INT_CMD_MASK | SDHCI_INT_DATA_MASK);
1026 1026
1027 intmask &= ~SDHCI_INT_ERROR;
1028
1027 if (intmask & SDHCI_INT_BUS_POWER) { 1029 if (intmask & SDHCI_INT_BUS_POWER) {
1028 printk(KERN_ERR "%s: Card is consuming too much power!\n", 1030 printk(KERN_ERR "%s: Card is consuming too much power!\n",
1029 mmc_hostname(host->mmc)); 1031 mmc_hostname(host->mmc));
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 7400f4bc114f..a6c870480b8a 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -107,6 +107,7 @@
107#define SDHCI_INT_CARD_INSERT 0x00000040 107#define SDHCI_INT_CARD_INSERT 0x00000040
108#define SDHCI_INT_CARD_REMOVE 0x00000080 108#define SDHCI_INT_CARD_REMOVE 0x00000080
109#define SDHCI_INT_CARD_INT 0x00000100 109#define SDHCI_INT_CARD_INT 0x00000100
110#define SDHCI_INT_ERROR 0x00008000
110#define SDHCI_INT_TIMEOUT 0x00010000 111#define SDHCI_INT_TIMEOUT 0x00010000
111#define SDHCI_INT_CRC 0x00020000 112#define SDHCI_INT_CRC 0x00020000
112#define SDHCI_INT_END_BIT 0x00040000 113#define SDHCI_INT_END_BIT 0x00040000
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 3073f679584b..f8a602caabcb 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -5,6 +5,7 @@
5 5
6menuconfig NETDEVICES 6menuconfig NETDEVICES
7 default y if UML 7 default y if UML
8 depends on NET
8 bool "Network device support" 9 bool "Network device support"
9 ---help--- 10 ---help---
10 You can say N here if you don't intend to connect your Linux box to 11 You can say N here if you don't intend to connect your Linux box to
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c
index f21148e7b579..80f33b6d5713 100644
--- a/drivers/net/arm/ether1.c
+++ b/drivers/net/arm/ether1.c
@@ -36,7 +36,6 @@
36#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/fcntl.h> 37#include <linux/fcntl.h>
38#include <linux/interrupt.h> 38#include <linux/interrupt.h>
39#include <linux/ptrace.h>
40#include <linux/ioport.h> 39#include <linux/ioport.h>
41#include <linux/in.h> 40#include <linux/in.h>
42#include <linux/slab.h> 41#include <linux/slab.h>
@@ -75,7 +74,7 @@ static void ether1_timeout(struct net_device *dev);
75 74
76/* ------------------------------------------------------------------------- */ 75/* ------------------------------------------------------------------------- */
77 76
78static char version[] __initdata = "ether1 ethernet driver (c) 2000 Russell King v1.07\n"; 77static char version[] __devinitdata = "ether1 ethernet driver (c) 2000 Russell King v1.07\n";
79 78
80#define BUS_16 16 79#define BUS_16 16
81#define BUS_8 8 80#define BUS_8 8
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c
index a7cac695a9bd..3805506a3ab8 100644
--- a/drivers/net/arm/ether3.c
+++ b/drivers/net/arm/ether3.c
@@ -51,7 +51,6 @@
51#include <linux/types.h> 51#include <linux/types.h>
52#include <linux/fcntl.h> 52#include <linux/fcntl.h>
53#include <linux/interrupt.h> 53#include <linux/interrupt.h>
54#include <linux/ptrace.h>
55#include <linux/ioport.h> 54#include <linux/ioport.h>
56#include <linux/in.h> 55#include <linux/in.h>
57#include <linux/slab.h> 56#include <linux/slab.h>
@@ -69,7 +68,7 @@
69#include <asm/ecard.h> 68#include <asm/ecard.h>
70#include <asm/io.h> 69#include <asm/io.h>
71 70
72static char version[] __initdata = "ether3 ethernet driver (c) 1995-2000 R.M.King v1.17\n"; 71static char version[] __devinitdata = "ether3 ethernet driver (c) 1995-2000 R.M.King v1.17\n";
73 72
74#include "ether3.h" 73#include "ether3.h"
75 74
diff --git a/drivers/net/arm/etherh.c b/drivers/net/arm/etherh.c
index 769ba69451f4..0d37d9d1fd78 100644
--- a/drivers/net/arm/etherh.c
+++ b/drivers/net/arm/etherh.c
@@ -31,7 +31,6 @@
31#include <linux/types.h> 31#include <linux/types.h>
32#include <linux/fcntl.h> 32#include <linux/fcntl.h>
33#include <linux/interrupt.h> 33#include <linux/interrupt.h>
34#include <linux/ptrace.h>
35#include <linux/ioport.h> 34#include <linux/ioport.h>
36#include <linux/in.h> 35#include <linux/in.h>
37#include <linux/slab.h> 36#include <linux/slab.h>
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 829da9a1d113..2098d0af8ff5 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -155,6 +155,15 @@ config KINGSUN_DONGLE
155 To compile it as a module, choose M here: the module will be called 155 To compile it as a module, choose M here: the module will be called
156 kingsun-sir. 156 kingsun-sir.
157 157
158config EP7211_DONGLE
159 tristate "EP7211 I/R support"
160 depends on IRTTY_SIR && ARCH_EP7211 && IRDA && EXPERIMENTAL
161 help
162 Say Y here if you want to build support for the Cirrus logic
163 EP7211 chipset's infrared module.
164
165
166
158comment "Old SIR device drivers" 167comment "Old SIR device drivers"
159 168
160config IRPORT_SIR 169config IRPORT_SIR
@@ -355,7 +364,7 @@ config WINBOND_FIR
355 364
356config TOSHIBA_FIR 365config TOSHIBA_FIR
357 tristate "Toshiba Type-O IR Port" 366 tristate "Toshiba Type-O IR Port"
358 depends on IRDA && PCI && !64BIT 367 depends on IRDA && PCI && !64BIT && VIRT_TO_BUS
359 help 368 help
360 Say Y here if you want to build support for the Toshiba Type-O IR 369 Say Y here if you want to build support for the Toshiba Type-O IR
361 and Donau oboe chipsets. These chipsets are used by the Toshiba 370 and Donau oboe chipsets. These chipsets are used by the Toshiba
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index 233a2f923730..2808ef5c7b79 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -45,6 +45,7 @@ obj-$(CONFIG_MCP2120_DONGLE) += mcp2120-sir.o
45obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o 45obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o
46obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o 46obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o
47obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o 47obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o
48obj-$(CONFIG_EP7211_DONGLE) += ep7211-sir.o
48obj-$(CONFIG_KINGSUN_DONGLE) += kingsun-sir.o 49obj-$(CONFIG_KINGSUN_DONGLE) += kingsun-sir.o
49 50
50# The SIR helper module 51# The SIR helper module
diff --git a/drivers/net/irda/ep7211-sir.c b/drivers/net/irda/ep7211-sir.c
new file mode 100644
index 000000000000..831572429bb9
--- /dev/null
+++ b/drivers/net/irda/ep7211-sir.c
@@ -0,0 +1,89 @@
1/*
2 * IR port driver for the Cirrus Logic EP7211 processor.
3 *
4 * Copyright 2001, Blue Mug Inc. All rights reserved.
5 * Copyright 2007, Samuel Ortiz <samuel@sortiz.org>
6 */
7#include <linux/module.h>
8#include <linux/delay.h>
9#include <linux/tty.h>
10#include <linux/init.h>
11#include <linux/spinlock.h>
12
13#include <net/irda/irda.h>
14#include <net/irda/irda_device.h>
15
16#include <asm/io.h>
17#include <asm/hardware.h>
18
19#include "sir-dev.h"
20
21#define MIN_DELAY 25 /* 15 us, but wait a little more to be sure */
22#define MAX_DELAY 10000 /* 1 ms */
23
24static int ep7211_open(struct sir_dev *dev);
25static int ep7211_close(struct sir_dev *dev);
26static int ep7211_change_speed(struct sir_dev *dev, unsigned speed);
27static int ep7211_reset(struct sir_dev *dev);
28
29static struct dongle_driver ep7211 = {
30 .owner = THIS_MODULE,
31 .driver_name = "EP7211 IR driver",
32 .type = IRDA_EP7211_DONGLE,
33 .open = ep7211_open,
34 .close = ep7211_close,
35 .reset = ep7211_reset,
36 .set_speed = ep7211_change_speed,
37};
38
39static int __init ep7211_sir_init(void)
40{
41 return irda_register_dongle(&ep7211);
42}
43
44static void __exit ep7211_sir_cleanup(void)
45{
46 irda_unregister_dongle(&ep7211);
47}
48
49static int ep7211_open(struct sir_dev *dev)
50{
51 unsigned int syscon;
52
53 /* Turn on the SIR encoder. */
54 syscon = clps_readl(SYSCON1);
55 syscon |= SYSCON1_SIREN;
56 clps_writel(syscon, SYSCON1);
57
58 return 0;
59}
60
61static int ep7211_close(struct sir_dev *dev)
62{
63 unsigned int syscon;
64
65 /* Turn off the SIR encoder. */
66 syscon = clps_readl(SYSCON1);
67 syscon &= ~SYSCON1_SIREN;
68 clps_writel(syscon, SYSCON1);
69
70 return 0;
71}
72
73static int ep7211_change_speed(struct sir_dev *dev, unsigned speed)
74{
75 return 0;
76}
77
78static int ep7211_reset(struct sir_dev *dev)
79{
80 return 0;
81}
82
83MODULE_AUTHOR("Samuel Ortiz <samuel@sortiz.org>");
84MODULE_DESCRIPTION("EP7211 IR dongle driver");
85MODULE_LICENSE("GPL");
86MODULE_ALIAS("irda-dongle-13"); /* IRDA_EP7211_DONGLE */
87
88module_init(ep7211_sir_init);
89module_exit(ep7211_sir_cleanup);
diff --git a/drivers/pcmcia/m8xx_pcmcia.c b/drivers/pcmcia/m8xx_pcmcia.c
index 3c45142c40b2..b01985498460 100644
--- a/drivers/pcmcia/m8xx_pcmcia.c
+++ b/drivers/pcmcia/m8xx_pcmcia.c
@@ -1316,7 +1316,7 @@ static struct of_device_id m8xx_pcmcia_match[] = {
1316MODULE_DEVICE_TABLE(of, m8xx_pcmcia_match); 1316MODULE_DEVICE_TABLE(of, m8xx_pcmcia_match);
1317 1317
1318static struct of_platform_driver m8xx_pcmcia_driver = { 1318static struct of_platform_driver m8xx_pcmcia_driver = {
1319 .name = (char *)driver_name, 1319 .name = driver_name,
1320 .match_table = m8xx_pcmcia_match, 1320 .match_table = m8xx_pcmcia_match,
1321 .probe = m8xx_probe, 1321 .probe = m8xx_probe,
1322 .remove = m8xx_remove, 1322 .remove = m8xx_remove,
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 35f34665e3c4..9d8d40d5c8f7 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -38,6 +38,9 @@ config RTC_HCTOSYS_DEVICE
38 clock, usually rtc0. Initialization is done when the system 38 clock, usually rtc0. Initialization is done when the system
39 starts up, and when it resumes from a low power state. 39 starts up, and when it resumes from a low power state.
40 40
41 The driver for this RTC device must be loaded before late_initcall
42 functions run, so it must usually be statically linked.
43
41 This clock should be battery-backed, so that it reads the correct 44 This clock should be battery-backed, so that it reads the correct
42 time when the system boots from a power-off state. Otherwise, your 45 time when the system boots from a power-off state. Otherwise, your
43 system will need an external clock source (like an NTP server). 46 system will need an external clock source (like an NTP server).
@@ -305,6 +308,16 @@ config RTC_DRV_DS1553
305 This driver can also be built as a module. If so, the module 308 This driver can also be built as a module. If so, the module
306 will be called rtc-ds1553. 309 will be called rtc-ds1553.
307 310
311config RTC_DRV_STK17TA8
312 tristate "Simtek STK17TA8"
313 depends on RTC_CLASS
314 help
315 If you say yes here you get support for the
316 Simtek STK17TA8 timekeeping chip.
317
318 This driver can also be built as a module. If so, the module
319 will be called rtc-stk17ta8.
320
308config RTC_DRV_DS1742 321config RTC_DRV_DS1742
309 tristate "Dallas DS1742/1743" 322 tristate "Dallas DS1742/1743"
310 depends on RTC_CLASS 323 depends on RTC_CLASS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 3109af9a1651..7ede9e725360 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -32,6 +32,7 @@ obj-$(CONFIG_RTC_DRV_RS5C348) += rtc-rs5c348.o
32obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o 32obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o
33obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o 33obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o
34obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o 34obj-$(CONFIG_RTC_DRV_DS1553) += rtc-ds1553.o
35obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o
35obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o 36obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
36obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o 37obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o
37obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o 38obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c
index f98a83a11aae..46da5714932c 100644
--- a/drivers/rtc/rtc-ds1553.c
+++ b/drivers/rtc/rtc-ds1553.c
@@ -407,7 +407,7 @@ static __init int ds1553_init(void)
407 407
408static __exit void ds1553_exit(void) 408static __exit void ds1553_exit(void)
409{ 409{
410 return platform_driver_unregister(&ds1553_rtc_driver); 410 platform_driver_unregister(&ds1553_rtc_driver);
411} 411}
412 412
413module_init(ds1553_init); 413module_init(ds1553_init);
diff --git a/drivers/rtc/rtc-ds1742.c b/drivers/rtc/rtc-ds1742.c
index d1778ae8bca5..b2e5481ba3b6 100644
--- a/drivers/rtc/rtc-ds1742.c
+++ b/drivers/rtc/rtc-ds1742.c
@@ -263,7 +263,7 @@ static __init int ds1742_init(void)
263 263
264static __exit void ds1742_exit(void) 264static __exit void ds1742_exit(void)
265{ 265{
266 return platform_driver_unregister(&ds1742_rtc_driver); 266 platform_driver_unregister(&ds1742_rtc_driver);
267} 267}
268 268
269module_init(ds1742_init); 269module_init(ds1742_init);
diff --git a/drivers/rtc/rtc-max6900.c b/drivers/rtc/rtc-max6900.c
index eee4ee5bb75a..a1cd448639c9 100644
--- a/drivers/rtc/rtc-max6900.c
+++ b/drivers/rtc/rtc-max6900.c
@@ -31,17 +31,24 @@
31#define MAX6900_REG_DW 5 /* day of week 1-7 */ 31#define MAX6900_REG_DW 5 /* day of week 1-7 */
32#define MAX6900_REG_YR 6 /* year 00-99 */ 32#define MAX6900_REG_YR 6 /* year 00-99 */
33#define MAX6900_REG_CT 7 /* control */ 33#define MAX6900_REG_CT 7 /* control */
34#define MAX6900_REG_LEN 8 34 /* register 8 is undocumented */
35#define MAX6900_REG_CENTURY 9 /* century */
36#define MAX6900_REG_LEN 10
37
38#define MAX6900_BURST_LEN 8 /* can burst r/w first 8 regs */
35 39
36#define MAX6900_REG_CT_WP (1 << 7) /* Write Protect */ 40#define MAX6900_REG_CT_WP (1 << 7) /* Write Protect */
37 41
42
38/* 43/*
39 * register read/write commands 44 * register read/write commands
40 */ 45 */
41#define MAX6900_REG_CONTROL_WRITE 0x8e 46#define MAX6900_REG_CONTROL_WRITE 0x8e
42#define MAX6900_REG_BURST_READ 0xbf 47#define MAX6900_REG_CENTURY_WRITE 0x92
43#define MAX6900_REG_BURST_WRITE 0xbe 48#define MAX6900_REG_CENTURY_READ 0x93
44#define MAX6900_REG_RESERVED_READ 0x96 49#define MAX6900_REG_RESERVED_READ 0x96
50#define MAX6900_REG_BURST_WRITE 0xbe
51#define MAX6900_REG_BURST_READ 0xbf
45 52
46#define MAX6900_IDLE_TIME_AFTER_WRITE 3 /* specification says 2.5 mS */ 53#define MAX6900_IDLE_TIME_AFTER_WRITE 3 /* specification says 2.5 mS */
47 54
@@ -58,19 +65,32 @@ static int max6900_probe(struct i2c_adapter *adapter, int addr, int kind);
58 65
59static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf) 66static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
60{ 67{
61 u8 reg_addr[1] = { MAX6900_REG_BURST_READ }; 68 u8 reg_burst_read[1] = { MAX6900_REG_BURST_READ };
62 struct i2c_msg msgs[2] = { 69 u8 reg_century_read[1] = { MAX6900_REG_CENTURY_READ };
70 struct i2c_msg msgs[4] = {
63 { 71 {
64 .addr = client->addr, 72 .addr = client->addr,
65 .flags = 0, /* write */ 73 .flags = 0, /* write */
66 .len = sizeof(reg_addr), 74 .len = sizeof(reg_burst_read),
67 .buf = reg_addr 75 .buf = reg_burst_read
68 }, 76 },
69 { 77 {
70 .addr = client->addr, 78 .addr = client->addr,
71 .flags = I2C_M_RD, 79 .flags = I2C_M_RD,
72 .len = MAX6900_REG_LEN, 80 .len = MAX6900_BURST_LEN,
73 .buf = buf 81 .buf = buf
82 },
83 {
84 .addr = client->addr,
85 .flags = 0, /* write */
86 .len = sizeof(reg_century_read),
87 .buf = reg_century_read
88 },
89 {
90 .addr = client->addr,
91 .flags = I2C_M_RD,
92 .len = sizeof(buf[MAX6900_REG_CENTURY]),
93 .buf = &buf[MAX6900_REG_CENTURY]
74 } 94 }
75 }; 95 };
76 int rc; 96 int rc;
@@ -86,33 +106,58 @@ static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
86 106
87static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf) 107static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf)
88{ 108{
89 u8 i2c_buf[MAX6900_REG_LEN + 1] = { MAX6900_REG_BURST_WRITE }; 109 u8 i2c_century_buf[1 + 1] = { MAX6900_REG_CENTURY_WRITE };
90 struct i2c_msg msgs[1] = { 110 struct i2c_msg century_msgs[1] = {
91 { 111 {
92 .addr = client->addr, 112 .addr = client->addr,
93 .flags = 0, /* write */ 113 .flags = 0, /* write */
94 .len = MAX6900_REG_LEN + 1, 114 .len = sizeof(i2c_century_buf),
95 .buf = i2c_buf 115 .buf = i2c_century_buf
116 }
117 };
118 u8 i2c_burst_buf[MAX6900_BURST_LEN + 1] = { MAX6900_REG_BURST_WRITE };
119 struct i2c_msg burst_msgs[1] = {
120 {
121 .addr = client->addr,
122 .flags = 0, /* write */
123 .len = sizeof(i2c_burst_buf),
124 .buf = i2c_burst_buf
96 } 125 }
97 }; 126 };
98 int rc; 127 int rc;
99 128
100 memcpy(&i2c_buf[1], buf, MAX6900_REG_LEN); 129 /*
130 * We have to make separate calls to i2c_transfer because of
131 * the need to delay after each write to the chip. Also,
132 * we write the century byte first, since we set the write-protect
133 * bit as part of the burst write.
134 */
135 i2c_century_buf[1] = buf[MAX6900_REG_CENTURY];
136 rc = i2c_transfer(client->adapter, century_msgs,
137 ARRAY_SIZE(century_msgs));
138 if (rc != ARRAY_SIZE(century_msgs))
139 goto write_failed;
140 msleep(MAX6900_IDLE_TIME_AFTER_WRITE);
101 141
102 rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); 142 memcpy(&i2c_burst_buf[1], buf, MAX6900_BURST_LEN);
103 if (rc != ARRAY_SIZE(msgs)) { 143
104 dev_err(&client->dev, "%s: register write failed\n", 144 rc = i2c_transfer(client->adapter, burst_msgs, ARRAY_SIZE(burst_msgs));
105 __FUNCTION__); 145 if (rc != ARRAY_SIZE(burst_msgs))
106 return -EIO; 146 goto write_failed;
107 }
108 msleep(MAX6900_IDLE_TIME_AFTER_WRITE); 147 msleep(MAX6900_IDLE_TIME_AFTER_WRITE);
148
109 return 0; 149 return 0;
150
151write_failed:
152 dev_err(&client->dev, "%s: register write failed\n",
153 __FUNCTION__);
154 return -EIO;
110} 155}
111 156
112static int max6900_i2c_validate_client(struct i2c_client *client) 157static int max6900_i2c_validate_client(struct i2c_client *client)
113{ 158{
114 u8 regs[MAX6900_REG_LEN]; 159 u8 regs[MAX6900_REG_LEN];
115 u8 zero_mask[MAX6900_REG_LEN] = { 160 u8 zero_mask[] = {
116 0x80, /* seconds */ 161 0x80, /* seconds */
117 0x80, /* minutes */ 162 0x80, /* minutes */
118 0x40, /* hours */ 163 0x40, /* hours */
@@ -134,7 +179,7 @@ static int max6900_i2c_validate_client(struct i2c_client *client)
134 if (rc < 0) 179 if (rc < 0)
135 return rc; 180 return rc;
136 181
137 for (i = 0; i < MAX6900_REG_LEN; ++i) { 182 for (i = 0; i < ARRAY_SIZE(zero_mask); ++i) {
138 if (regs[i] & zero_mask[i]) 183 if (regs[i] & zero_mask[i])
139 return -ENODEV; 184 return -ENODEV;
140 } 185 }
@@ -156,7 +201,8 @@ static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
156 tm->tm_hour = BCD2BIN(regs[MAX6900_REG_HR] & 0x3f); 201 tm->tm_hour = BCD2BIN(regs[MAX6900_REG_HR] & 0x3f);
157 tm->tm_mday = BCD2BIN(regs[MAX6900_REG_DT]); 202 tm->tm_mday = BCD2BIN(regs[MAX6900_REG_DT]);
158 tm->tm_mon = BCD2BIN(regs[MAX6900_REG_MO]) - 1; 203 tm->tm_mon = BCD2BIN(regs[MAX6900_REG_MO]) - 1;
159 tm->tm_year = BCD2BIN(regs[MAX6900_REG_YR]) + 100; 204 tm->tm_year = BCD2BIN(regs[MAX6900_REG_YR]) +
205 BCD2BIN(regs[MAX6900_REG_CENTURY]) * 100 - 1900;
160 tm->tm_wday = BCD2BIN(regs[MAX6900_REG_DW]); 206 tm->tm_wday = BCD2BIN(regs[MAX6900_REG_DW]);
161 207
162 return 0; 208 return 0;
@@ -189,9 +235,11 @@ static int max6900_i2c_set_time(struct i2c_client *client,
189 regs[MAX6900_REG_HR] = BIN2BCD(tm->tm_hour); 235 regs[MAX6900_REG_HR] = BIN2BCD(tm->tm_hour);
190 regs[MAX6900_REG_DT] = BIN2BCD(tm->tm_mday); 236 regs[MAX6900_REG_DT] = BIN2BCD(tm->tm_mday);
191 regs[MAX6900_REG_MO] = BIN2BCD(tm->tm_mon + 1); 237 regs[MAX6900_REG_MO] = BIN2BCD(tm->tm_mon + 1);
192 regs[MAX6900_REG_YR] = BIN2BCD(tm->tm_year - 100);
193 regs[MAX6900_REG_DW] = BIN2BCD(tm->tm_wday); 238 regs[MAX6900_REG_DW] = BIN2BCD(tm->tm_wday);
194 regs[MAX6900_REG_CT] = MAX6900_REG_CT_WP; /* set write protect */ 239 regs[MAX6900_REG_YR] = BIN2BCD(tm->tm_year % 100);
240 regs[MAX6900_REG_CENTURY] = BIN2BCD((tm->tm_year + 1900) / 100);
241 /* set write protect */
242 regs[MAX6900_REG_CT] = MAX6900_REG_CT_WP;
195 243
196 rc = max6900_i2c_write_regs(client, regs); 244 rc = max6900_i2c_write_regs(client, regs);
197 if (rc < 0) 245 if (rc < 0)
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
new file mode 100644
index 000000000000..f10d3facecbe
--- /dev/null
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -0,0 +1,420 @@
1/*
2 * A RTC driver for the Simtek STK17TA8
3 *
4 * By Thomas Hommel <thomas.hommel@gefanuc.com>
5 *
6 * Based on the DS1553 driver from
7 * Atsushi Nemoto <anemo@mba.ocn.ne.jp>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13
14#include <linux/bcd.h>
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/delay.h>
18#include <linux/jiffies.h>
19#include <linux/interrupt.h>
20#include <linux/rtc.h>
21#include <linux/platform_device.h>
22#include <linux/io.h>
23
24#define DRV_VERSION "0.1"
25
26#define RTC_REG_SIZE 0x20000
27#define RTC_OFFSET 0x1fff0
28
29#define RTC_FLAGS (RTC_OFFSET + 0)
30#define RTC_CENTURY (RTC_OFFSET + 1)
31#define RTC_SECONDS_ALARM (RTC_OFFSET + 2)
32#define RTC_MINUTES_ALARM (RTC_OFFSET + 3)
33#define RTC_HOURS_ALARM (RTC_OFFSET + 4)
34#define RTC_DATE_ALARM (RTC_OFFSET + 5)
35#define RTC_INTERRUPTS (RTC_OFFSET + 6)
36#define RTC_WATCHDOG (RTC_OFFSET + 7)
37#define RTC_CALIBRATION (RTC_OFFSET + 8)
38#define RTC_SECONDS (RTC_OFFSET + 9)
39#define RTC_MINUTES (RTC_OFFSET + 10)
40#define RTC_HOURS (RTC_OFFSET + 11)
41#define RTC_DAY (RTC_OFFSET + 12)
42#define RTC_DATE (RTC_OFFSET + 13)
43#define RTC_MONTH (RTC_OFFSET + 14)
44#define RTC_YEAR (RTC_OFFSET + 15)
45
46#define RTC_SECONDS_MASK 0x7f
47#define RTC_DAY_MASK 0x07
48#define RTC_CAL_MASK 0x3f
49
50/* Bits in the Calibration register */
51#define RTC_STOP 0x80
52
53/* Bits in the Flags register */
54#define RTC_FLAGS_AF 0x40
55#define RTC_FLAGS_PF 0x20
56#define RTC_WRITE 0x02
57#define RTC_READ 0x01
58
59/* Bits in the Interrupts register */
60#define RTC_INTS_AIE 0x40
61
62struct rtc_plat_data {
63 struct rtc_device *rtc;
64 void __iomem *ioaddr;
65 unsigned long baseaddr;
66 unsigned long last_jiffies;
67 int irq;
68 unsigned int irqen;
69 int alrm_sec;
70 int alrm_min;
71 int alrm_hour;
72 int alrm_mday;
73};
74
75static int stk17ta8_rtc_set_time(struct device *dev, struct rtc_time *tm)
76{
77 struct platform_device *pdev = to_platform_device(dev);
78 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
79 void __iomem *ioaddr = pdata->ioaddr;
80 u8 flags;
81
82 flags = readb(pdata->ioaddr + RTC_FLAGS);
83 writeb(flags | RTC_WRITE, pdata->ioaddr + RTC_FLAGS);
84
85 writeb(BIN2BCD(tm->tm_year % 100), ioaddr + RTC_YEAR);
86 writeb(BIN2BCD(tm->tm_mon + 1), ioaddr + RTC_MONTH);
87 writeb(BIN2BCD(tm->tm_wday) & RTC_DAY_MASK, ioaddr + RTC_DAY);
88 writeb(BIN2BCD(tm->tm_mday), ioaddr + RTC_DATE);
89 writeb(BIN2BCD(tm->tm_hour), ioaddr + RTC_HOURS);
90 writeb(BIN2BCD(tm->tm_min), ioaddr + RTC_MINUTES);
91 writeb(BIN2BCD(tm->tm_sec) & RTC_SECONDS_MASK, ioaddr + RTC_SECONDS);
92 writeb(BIN2BCD((tm->tm_year + 1900) / 100), ioaddr + RTC_CENTURY);
93
94 writeb(flags & ~RTC_WRITE, pdata->ioaddr + RTC_FLAGS);
95 return 0;
96}
97
98static int stk17ta8_rtc_read_time(struct device *dev, struct rtc_time *tm)
99{
100 struct platform_device *pdev = to_platform_device(dev);
101 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
102 void __iomem *ioaddr = pdata->ioaddr;
103 unsigned int year, month, day, hour, minute, second, week;
104 unsigned int century;
105 u8 flags;
106
107 /* give enough time to update RTC in case of continuous read */
108 if (pdata->last_jiffies == jiffies)
109 msleep(1);
110 pdata->last_jiffies = jiffies;
111
112 flags = readb(pdata->ioaddr + RTC_FLAGS);
113 writeb(flags | RTC_READ, ioaddr + RTC_FLAGS);
114 second = readb(ioaddr + RTC_SECONDS) & RTC_SECONDS_MASK;
115 minute = readb(ioaddr + RTC_MINUTES);
116 hour = readb(ioaddr + RTC_HOURS);
117 day = readb(ioaddr + RTC_DATE);
118 week = readb(ioaddr + RTC_DAY) & RTC_DAY_MASK;
119 month = readb(ioaddr + RTC_MONTH);
120 year = readb(ioaddr + RTC_YEAR);
121 century = readb(ioaddr + RTC_CENTURY);
122 writeb(flags & ~RTC_READ, ioaddr + RTC_FLAGS);
123 tm->tm_sec = BCD2BIN(second);
124 tm->tm_min = BCD2BIN(minute);
125 tm->tm_hour = BCD2BIN(hour);
126 tm->tm_mday = BCD2BIN(day);
127 tm->tm_wday = BCD2BIN(week);
128 tm->tm_mon = BCD2BIN(month) - 1;
129 /* year is 1900 + tm->tm_year */
130 tm->tm_year = BCD2BIN(year) + BCD2BIN(century) * 100 - 1900;
131
132 if (rtc_valid_tm(tm) < 0) {
133 dev_err(dev, "retrieved date/time is not valid.\n");
134 rtc_time_to_tm(0, tm);
135 }
136 return 0;
137}
138
139static void stk17ta8_rtc_update_alarm(struct rtc_plat_data *pdata)
140{
141 void __iomem *ioaddr = pdata->ioaddr;
142 unsigned long irqflags;
143 u8 flags;
144
145 spin_lock_irqsave(&pdata->rtc->irq_lock, irqflags);
146
147 flags = readb(ioaddr + RTC_FLAGS);
148 writeb(flags | RTC_WRITE, ioaddr + RTC_FLAGS);
149
150 writeb(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ?
151 0x80 : BIN2BCD(pdata->alrm_mday),
152 ioaddr + RTC_DATE_ALARM);
153 writeb(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ?
154 0x80 : BIN2BCD(pdata->alrm_hour),
155 ioaddr + RTC_HOURS_ALARM);
156 writeb(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ?
157 0x80 : BIN2BCD(pdata->alrm_min),
158 ioaddr + RTC_MINUTES_ALARM);
159 writeb(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ?
160 0x80 : BIN2BCD(pdata->alrm_sec),
161 ioaddr + RTC_SECONDS_ALARM);
162 writeb(pdata->irqen ? RTC_INTS_AIE : 0, ioaddr + RTC_INTERRUPTS);
163 readb(ioaddr + RTC_FLAGS); /* clear interrupts */
164 writeb(flags & ~RTC_WRITE, ioaddr + RTC_FLAGS);
165 spin_unlock_irqrestore(&pdata->rtc->irq_lock, irqflags);
166}
167
168static int stk17ta8_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
169{
170 struct platform_device *pdev = to_platform_device(dev);
171 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
172
173 if (pdata->irq < 0)
174 return -EINVAL;
175 pdata->alrm_mday = alrm->time.tm_mday;
176 pdata->alrm_hour = alrm->time.tm_hour;
177 pdata->alrm_min = alrm->time.tm_min;
178 pdata->alrm_sec = alrm->time.tm_sec;
179 if (alrm->enabled)
180 pdata->irqen |= RTC_AF;
181 stk17ta8_rtc_update_alarm(pdata);
182 return 0;
183}
184
185static int stk17ta8_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
186{
187 struct platform_device *pdev = to_platform_device(dev);
188 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
189
190 if (pdata->irq < 0)
191 return -EINVAL;
192 alrm->time.tm_mday = pdata->alrm_mday < 0 ? 0 : pdata->alrm_mday;
193 alrm->time.tm_hour = pdata->alrm_hour < 0 ? 0 : pdata->alrm_hour;
194 alrm->time.tm_min = pdata->alrm_min < 0 ? 0 : pdata->alrm_min;
195 alrm->time.tm_sec = pdata->alrm_sec < 0 ? 0 : pdata->alrm_sec;
196 alrm->enabled = (pdata->irqen & RTC_AF) ? 1 : 0;
197 return 0;
198}
199
200static irqreturn_t stk17ta8_rtc_interrupt(int irq, void *dev_id)
201{
202 struct platform_device *pdev = dev_id;
203 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
204 void __iomem *ioaddr = pdata->ioaddr;
205 unsigned long events = RTC_IRQF;
206
207 /* read and clear interrupt */
208 if (!(readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_AF))
209 return IRQ_NONE;
210 if (readb(ioaddr + RTC_SECONDS_ALARM) & 0x80)
211 events |= RTC_UF;
212 else
213 events |= RTC_AF;
214 rtc_update_irq(pdata->rtc, 1, events);
215 return IRQ_HANDLED;
216}
217
218static void stk17ta8_rtc_release(struct device *dev)
219{
220 struct platform_device *pdev = to_platform_device(dev);
221 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
222
223 if (pdata->irq >= 0) {
224 pdata->irqen = 0;
225 stk17ta8_rtc_update_alarm(pdata);
226 }
227}
228
229static int stk17ta8_rtc_ioctl(struct device *dev, unsigned int cmd,
230 unsigned long arg)
231{
232 struct platform_device *pdev = to_platform_device(dev);
233 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
234
235 if (pdata->irq < 0)
236 return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */
237 switch (cmd) {
238 case RTC_AIE_OFF:
239 pdata->irqen &= ~RTC_AF;
240 stk17ta8_rtc_update_alarm(pdata);
241 break;
242 case RTC_AIE_ON:
243 pdata->irqen |= RTC_AF;
244 stk17ta8_rtc_update_alarm(pdata);
245 break;
246 default:
247 return -ENOIOCTLCMD;
248 }
249 return 0;
250}
251
252static const struct rtc_class_ops stk17ta8_rtc_ops = {
253 .read_time = stk17ta8_rtc_read_time,
254 .set_time = stk17ta8_rtc_set_time,
255 .read_alarm = stk17ta8_rtc_read_alarm,
256 .set_alarm = stk17ta8_rtc_set_alarm,
257 .release = stk17ta8_rtc_release,
258 .ioctl = stk17ta8_rtc_ioctl,
259};
260
261static ssize_t stk17ta8_nvram_read(struct kobject *kobj, char *buf,
262 loff_t pos, size_t size)
263{
264 struct platform_device *pdev =
265 to_platform_device(container_of(kobj, struct device, kobj));
266 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
267 void __iomem *ioaddr = pdata->ioaddr;
268 ssize_t count;
269
270 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--)
271 *buf++ = readb(ioaddr + pos++);
272 return count;
273}
274
275static ssize_t stk17ta8_nvram_write(struct kobject *kobj, char *buf,
276 loff_t pos, size_t size)
277{
278 struct platform_device *pdev =
279 to_platform_device(container_of(kobj, struct device, kobj));
280 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
281 void __iomem *ioaddr = pdata->ioaddr;
282 ssize_t count;
283
284 for (count = 0; size > 0 && pos < RTC_OFFSET; count++, size--)
285 writeb(*buf++, ioaddr + pos++);
286 return count;
287}
288
289static struct bin_attribute stk17ta8_nvram_attr = {
290 .attr = {
291 .name = "nvram",
292 .mode = S_IRUGO | S_IWUGO,
293 .owner = THIS_MODULE,
294 },
295 .size = RTC_OFFSET,
296 .read = stk17ta8_nvram_read,
297 .write = stk17ta8_nvram_write,
298};
299
300static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
301{
302 struct rtc_device *rtc;
303 struct resource *res;
304 unsigned int cal;
305 unsigned int flags;
306 struct rtc_plat_data *pdata;
307 void __iomem *ioaddr = NULL;
308 int ret = 0;
309
310 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
311 if (!res)
312 return -ENODEV;
313
314 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
315 if (!pdata)
316 return -ENOMEM;
317 pdata->irq = -1;
318 if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) {
319 ret = -EBUSY;
320 goto out;
321 }
322 pdata->baseaddr = res->start;
323 ioaddr = ioremap(pdata->baseaddr, RTC_REG_SIZE);
324 if (!ioaddr) {
325 ret = -ENOMEM;
326 goto out;
327 }
328 pdata->ioaddr = ioaddr;
329 pdata->irq = platform_get_irq(pdev, 0);
330
331 /* turn RTC on if it was not on */
332 cal = readb(ioaddr + RTC_CALIBRATION);
333 if (cal & RTC_STOP) {
334 cal &= RTC_CAL_MASK;
335 flags = readb(ioaddr + RTC_FLAGS);
336 writeb(flags | RTC_WRITE, ioaddr + RTC_FLAGS);
337 writeb(cal, ioaddr + RTC_CALIBRATION);
338 writeb(flags & ~RTC_WRITE, ioaddr + RTC_FLAGS);
339 }
340 if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_PF)
341 dev_warn(&pdev->dev, "voltage-low detected.\n");
342
343 if (pdata->irq >= 0) {
344 writeb(0, ioaddr + RTC_INTERRUPTS);
345 if (request_irq(pdata->irq, stk17ta8_rtc_interrupt,
346 IRQF_DISABLED | IRQF_SHARED,
347 pdev->name, pdev) < 0) {
348 dev_warn(&pdev->dev, "interrupt not available.\n");
349 pdata->irq = -1;
350 }
351 }
352
353 rtc = rtc_device_register(pdev->name, &pdev->dev,
354 &stk17ta8_rtc_ops, THIS_MODULE);
355 if (IS_ERR(rtc)) {
356 ret = PTR_ERR(rtc);
357 goto out;
358 }
359 pdata->rtc = rtc;
360 pdata->last_jiffies = jiffies;
361 platform_set_drvdata(pdev, pdata);
362 ret = sysfs_create_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr);
363 if (ret)
364 goto out;
365 return 0;
366 out:
367 if (pdata->rtc)
368 rtc_device_unregister(pdata->rtc);
369 if (pdata->irq >= 0)
370 free_irq(pdata->irq, pdev);
371 if (ioaddr)
372 iounmap(ioaddr);
373 if (pdata->baseaddr)
374 release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
375 kfree(pdata);
376 return ret;
377}
378
379static int __devexit stk17ta8_rtc_remove(struct platform_device *pdev)
380{
381 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
382
383 sysfs_remove_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr);
384 rtc_device_unregister(pdata->rtc);
385 if (pdata->irq >= 0) {
386 writeb(0, pdata->ioaddr + RTC_INTERRUPTS);
387 free_irq(pdata->irq, pdev);
388 }
389 iounmap(pdata->ioaddr);
390 release_mem_region(pdata->baseaddr, RTC_REG_SIZE);
391 kfree(pdata);
392 return 0;
393}
394
395static struct platform_driver stk17ta8_rtc_driver = {
396 .probe = stk17ta8_rtc_probe,
397 .remove = __devexit_p(stk17ta8_rtc_remove),
398 .driver = {
399 .name = "stk17ta8",
400 .owner = THIS_MODULE,
401 },
402};
403
404static __init int stk17ta8_init(void)
405{
406 return platform_driver_register(&stk17ta8_rtc_driver);
407}
408
409static __exit void stk17ta8_exit(void)
410{
411 return platform_driver_unregister(&stk17ta8_rtc_driver);
412}
413
414module_init(stk17ta8_init);
415module_exit(stk17ta8_exit);
416
417MODULE_AUTHOR("Thomas Hommel <thomas.hommel@gefanuc.com>");
418MODULE_DESCRIPTION("Simtek STK17TA8 RTC driver");
419MODULE_LICENSE("GPL");
420MODULE_VERSION(DRV_VERSION);
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index 9726261c367d..ab5ec1feaf4e 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -1526,15 +1526,12 @@ zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool)
1526 * zfcp_gid_pn_buffers_free - free buffers for GID_PN nameserver request 1526 * zfcp_gid_pn_buffers_free - free buffers for GID_PN nameserver request
1527 * @gid_pn: pointer to struct zfcp_gid_pn_data which has to be freed 1527 * @gid_pn: pointer to struct zfcp_gid_pn_data which has to be freed
1528 */ 1528 */
1529static void 1529static void zfcp_gid_pn_buffers_free(struct zfcp_gid_pn_data *gid_pn)
1530zfcp_gid_pn_buffers_free(struct zfcp_gid_pn_data *gid_pn)
1531{ 1530{
1532 if ((gid_pn->ct.pool != 0)) 1531 if (gid_pn->ct.pool)
1533 mempool_free(gid_pn, gid_pn->ct.pool); 1532 mempool_free(gid_pn, gid_pn->ct.pool);
1534 else 1533 else
1535 kfree(gid_pn); 1534 kfree(gid_pn);
1536
1537 return;
1538} 1535}
1539 1536
1540/** 1537/**
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 22649639230b..b36dfc40d9fa 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -126,6 +126,7 @@ zfcp_address_to_sg(void *address, struct scatterlist *list)
126#define ZFCP_MIN_OUTPUT_THRESHOLD 1 /* ignored by QDIO layer */ 126#define ZFCP_MIN_OUTPUT_THRESHOLD 1 /* ignored by QDIO layer */
127 127
128#define QDIO_SCSI_QFMT 1 /* 1 for FSF */ 128#define QDIO_SCSI_QFMT 1 /* 1 for FSF */
129#define QBUFF_PER_PAGE (PAGE_SIZE / sizeof(struct qdio_buffer))
129 130
130/********************* FSF SPECIFIC DEFINES *********************************/ 131/********************* FSF SPECIFIC DEFINES *********************************/
131 132
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 4e7cb6dc4d34..d8cd75ce2d9a 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -1626,7 +1626,7 @@ zfcp_erp_schedule_work(struct zfcp_unit *unit)
1626{ 1626{
1627 struct zfcp_erp_add_work *p; 1627 struct zfcp_erp_add_work *p;
1628 1628
1629 p = kmalloc(sizeof(*p), GFP_KERNEL); 1629 p = kzalloc(sizeof(*p), GFP_KERNEL);
1630 if (!p) { 1630 if (!p) {
1631 ZFCP_LOG_NORMAL("error: Out of resources. Could not register " 1631 ZFCP_LOG_NORMAL("error: Out of resources. Could not register "
1632 "the FCP-LUN 0x%Lx connected to " 1632 "the FCP-LUN 0x%Lx connected to "
@@ -1639,7 +1639,6 @@ zfcp_erp_schedule_work(struct zfcp_unit *unit)
1639 } 1639 }
1640 1640
1641 zfcp_unit_get(unit); 1641 zfcp_unit_get(unit);
1642 memset(p, 0, sizeof(*p));
1643 atomic_set_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status); 1642 atomic_set_mask(ZFCP_STATUS_UNIT_SCSI_WORK_PENDING, &unit->status);
1644 INIT_WORK(&p->work, zfcp_erp_scsi_scan); 1643 INIT_WORK(&p->work, zfcp_erp_scsi_scan);
1645 p->unit = unit; 1644 p->unit = unit;
diff --git a/drivers/s390/scsi/zfcp_fsf.c b/drivers/s390/scsi/zfcp_fsf.c
index 0eb31e162b15..b240800b78d7 100644
--- a/drivers/s390/scsi/zfcp_fsf.c
+++ b/drivers/s390/scsi/zfcp_fsf.c
@@ -1930,7 +1930,7 @@ static int zfcp_fsf_send_els_handler(struct zfcp_fsf_req *fsf_req)
1930skip_fsfstatus: 1930skip_fsfstatus:
1931 send_els->status = retval; 1931 send_els->status = retval;
1932 1932
1933 if (send_els->handler != 0) 1933 if (send_els->handler)
1934 send_els->handler(send_els->handler_data); 1934 send_els->handler(send_els->handler_data);
1935 1935
1936 return retval; 1936 return retval;
diff --git a/drivers/s390/scsi/zfcp_qdio.c b/drivers/s390/scsi/zfcp_qdio.c
index bdf5782b8a7a..c408badd2ae9 100644
--- a/drivers/s390/scsi/zfcp_qdio.c
+++ b/drivers/s390/scsi/zfcp_qdio.c
@@ -47,103 +47,56 @@ static int zfcp_qdio_handler_error_check(struct zfcp_adapter *,
47#define ZFCP_LOG_AREA ZFCP_LOG_AREA_QDIO 47#define ZFCP_LOG_AREA ZFCP_LOG_AREA_QDIO
48 48
49/* 49/*
50 * Allocates BUFFER memory to each of the pointers of the qdio_buffer_t 50 * Frees BUFFER memory for each of the pointers of the struct qdio_buffer array
51 * array in the adapter struct. 51 * in the adapter struct sbuf is the pointer array.
52 * Cur_buf is the pointer array and count can be any number of required
53 * buffers, the page-fitting arithmetic is done entirely within this funciton.
54 * 52 *
55 * returns: number of buffers allocated
56 * locks: must only be called with zfcp_data.config_sema taken 53 * locks: must only be called with zfcp_data.config_sema taken
57 */ 54 */
58static int 55static void
59zfcp_qdio_buffers_enqueue(struct qdio_buffer **cur_buf, int count) 56zfcp_qdio_buffers_dequeue(struct qdio_buffer **sbuf)
60{ 57{
61 int buf_pos; 58 int pos;
62 int qdio_buffers_per_page;
63 int page_pos = 0;
64 struct qdio_buffer *first_in_page = NULL;
65
66 qdio_buffers_per_page = PAGE_SIZE / sizeof (struct qdio_buffer);
67 ZFCP_LOG_TRACE("buffers_per_page=%d\n", qdio_buffers_per_page);
68
69 for (buf_pos = 0; buf_pos < count; buf_pos++) {
70 if (page_pos == 0) {
71 cur_buf[buf_pos] = (struct qdio_buffer *)
72 get_zeroed_page(GFP_KERNEL);
73 if (cur_buf[buf_pos] == NULL) {
74 ZFCP_LOG_INFO("error: allocation of "
75 "QDIO buffer failed \n");
76 goto out;
77 }
78 first_in_page = cur_buf[buf_pos];
79 } else {
80 cur_buf[buf_pos] = first_in_page + page_pos;
81 59
82 } 60 for (pos = 0; pos < QDIO_MAX_BUFFERS_PER_Q; pos += QBUFF_PER_PAGE)
83 /* was initialised to zero */ 61 free_page((unsigned long) sbuf[pos]);
84 page_pos++;
85 page_pos %= qdio_buffers_per_page;
86 }
87 out:
88 return buf_pos;
89} 62}
90 63
91/* 64/*
92 * Frees BUFFER memory for each of the pointers of the struct qdio_buffer array 65 * Allocates BUFFER memory to each of the pointers of the qdio_buffer_t
93 * in the adapter struct cur_buf is the pointer array and count can be any 66 * array in the adapter struct.
94 * number of buffers in the array that should be freed starting from buffer 0 67 * Cur_buf is the pointer array
95 * 68 *
69 * returns: zero on success else -ENOMEM
96 * locks: must only be called with zfcp_data.config_sema taken 70 * locks: must only be called with zfcp_data.config_sema taken
97 */ 71 */
98static void 72static int
99zfcp_qdio_buffers_dequeue(struct qdio_buffer **cur_buf, int count) 73zfcp_qdio_buffers_enqueue(struct qdio_buffer **sbuf)
100{ 74{
101 int buf_pos; 75 int pos;
102 int qdio_buffers_per_page;
103
104 qdio_buffers_per_page = PAGE_SIZE / sizeof (struct qdio_buffer);
105 ZFCP_LOG_TRACE("buffers_per_page=%d\n", qdio_buffers_per_page);
106 76
107 for (buf_pos = 0; buf_pos < count; buf_pos += qdio_buffers_per_page) 77 for (pos = 0; pos < QDIO_MAX_BUFFERS_PER_Q; pos += QBUFF_PER_PAGE) {
108 free_page((unsigned long) cur_buf[buf_pos]); 78 sbuf[pos] = (struct qdio_buffer *) get_zeroed_page(GFP_KERNEL);
109 return; 79 if (!sbuf[pos]) {
80 zfcp_qdio_buffers_dequeue(sbuf);
81 return -ENOMEM;
82 }
83 }
84 for (pos = 0; pos < QDIO_MAX_BUFFERS_PER_Q; pos++)
85 if (pos % QBUFF_PER_PAGE)
86 sbuf[pos] = sbuf[pos - 1] + 1;
87 return 0;
110} 88}
111 89
112/* locks: must only be called with zfcp_data.config_sema taken */ 90/* locks: must only be called with zfcp_data.config_sema taken */
113int 91int
114zfcp_qdio_allocate_queues(struct zfcp_adapter *adapter) 92zfcp_qdio_allocate_queues(struct zfcp_adapter *adapter)
115{ 93{
116 int buffer_count; 94 int ret;
117 int retval = 0;
118 95
119 buffer_count = 96 ret = zfcp_qdio_buffers_enqueue(adapter->request_queue.buffer);
120 zfcp_qdio_buffers_enqueue(&(adapter->request_queue.buffer[0]), 97 if (ret)
121 QDIO_MAX_BUFFERS_PER_Q); 98 return ret;
122 if (buffer_count < QDIO_MAX_BUFFERS_PER_Q) { 99 return zfcp_qdio_buffers_enqueue(adapter->response_queue.buffer);
123 ZFCP_LOG_DEBUG("only %d QDIO buffers allocated for request "
124 "queue\n", buffer_count);
125 zfcp_qdio_buffers_dequeue(&(adapter->request_queue.buffer[0]),
126 buffer_count);
127 retval = -ENOMEM;
128 goto out;
129 }
130
131 buffer_count =
132 zfcp_qdio_buffers_enqueue(&(adapter->response_queue.buffer[0]),
133 QDIO_MAX_BUFFERS_PER_Q);
134 if (buffer_count < QDIO_MAX_BUFFERS_PER_Q) {
135 ZFCP_LOG_DEBUG("only %d QDIO buffers allocated for response "
136 "queue", buffer_count);
137 zfcp_qdio_buffers_dequeue(&(adapter->response_queue.buffer[0]),
138 buffer_count);
139 ZFCP_LOG_TRACE("freeing request_queue buffers\n");
140 zfcp_qdio_buffers_dequeue(&(adapter->request_queue.buffer[0]),
141 QDIO_MAX_BUFFERS_PER_Q);
142 retval = -ENOMEM;
143 goto out;
144 }
145 out:
146 return retval;
147} 100}
148 101
149/* locks: must only be called with zfcp_data.config_sema taken */ 102/* locks: must only be called with zfcp_data.config_sema taken */
@@ -151,12 +104,10 @@ void
151zfcp_qdio_free_queues(struct zfcp_adapter *adapter) 104zfcp_qdio_free_queues(struct zfcp_adapter *adapter)
152{ 105{
153 ZFCP_LOG_TRACE("freeing request_queue buffers\n"); 106 ZFCP_LOG_TRACE("freeing request_queue buffers\n");
154 zfcp_qdio_buffers_dequeue(&(adapter->request_queue.buffer[0]), 107 zfcp_qdio_buffers_dequeue(adapter->request_queue.buffer);
155 QDIO_MAX_BUFFERS_PER_Q);
156 108
157 ZFCP_LOG_TRACE("freeing response_queue buffers\n"); 109 ZFCP_LOG_TRACE("freeing response_queue buffers\n");
158 zfcp_qdio_buffers_dequeue(&(adapter->response_queue.buffer[0]), 110 zfcp_qdio_buffers_dequeue(adapter->response_queue.buffer);
159 QDIO_MAX_BUFFERS_PER_Q);
160} 111}
161 112
162int 113int
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index 6b49f6a2524d..efd9d8d3a890 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -4,7 +4,7 @@
4 Written By: Adam Radford <linuxraid@amcc.com> 4 Written By: Adam Radford <linuxraid@amcc.com>
5 Modifications By: Tom Couch <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com>
6 6
7 Copyright (C) 2004-2006 Applied Micro Circuits Corporation. 7 Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
@@ -69,6 +69,8 @@
69 2.26.02.008 - Free irq handler in __twa_shutdown(). 69 2.26.02.008 - Free irq handler in __twa_shutdown().
70 Serialize reset code. 70 Serialize reset code.
71 Add support for 9650SE controllers. 71 Add support for 9650SE controllers.
72 2.26.02.009 - Fix dma mask setting to fallback to 32-bit if 64-bit fails.
73 2.26.02.010 - Add support for 9690SA controllers.
72*/ 74*/
73 75
74#include <linux/module.h> 76#include <linux/module.h>
@@ -92,7 +94,7 @@
92#include "3w-9xxx.h" 94#include "3w-9xxx.h"
93 95
94/* Globals */ 96/* Globals */
95#define TW_DRIVER_VERSION "2.26.02.008" 97#define TW_DRIVER_VERSION "2.26.02.010"
96static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT]; 98static TW_Device_Extension *twa_device_extension_list[TW_MAX_SLOT];
97static unsigned int twa_device_extension_count; 99static unsigned int twa_device_extension_count;
98static int twa_major = -1; 100static int twa_major = -1;
@@ -124,11 +126,11 @@ static int twa_initconnection(TW_Device_Extension *tw_dev, int message_credits,
124 unsigned short *fw_on_ctlr_branch, 126 unsigned short *fw_on_ctlr_branch,
125 unsigned short *fw_on_ctlr_build, 127 unsigned short *fw_on_ctlr_build,
126 u32 *init_connect_result); 128 u32 *init_connect_result);
127static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length); 129static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length);
128static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds); 130static int twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds);
129static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds); 131static int twa_poll_status_gone(TW_Device_Extension *tw_dev, u32 flag, int seconds);
130static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal); 132static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id, char internal);
131static int twa_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset); 133static int twa_reset_device_extension(TW_Device_Extension *tw_dev);
132static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset); 134static int twa_reset_sequence(TW_Device_Extension *tw_dev, int soft_reset);
133static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg); 135static int twa_scsiop_execute_scsi(TW_Device_Extension *tw_dev, int request_id, char *cdb, int use_sg, TW_SG_Entry *sglistarg);
134static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id); 136static void twa_scsiop_execute_scsi_complete(TW_Device_Extension *tw_dev, int request_id);
@@ -683,7 +685,7 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
683 full_command_packet = &tw_ioctl->firmware_command; 685 full_command_packet = &tw_ioctl->firmware_command;
684 686
685 /* Load request id and sglist for both command types */ 687 /* Load request id and sglist for both command types */
686 twa_load_sgl(full_command_packet, request_id, dma_handle, data_buffer_length_adjusted); 688 twa_load_sgl(tw_dev, full_command_packet, request_id, dma_handle, data_buffer_length_adjusted);
687 689
688 memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_Full)); 690 memcpy(tw_dev->command_packet_virt[request_id], &(tw_ioctl->firmware_command), sizeof(TW_Command_Full));
689 691
@@ -700,10 +702,10 @@ static int twa_chrdev_ioctl(struct inode *inode, struct file *file, unsigned int
700 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) { 702 if (tw_dev->chrdev_request_id != TW_IOCTL_CHRDEV_FREE) {
701 /* Now we need to reset the board */ 703 /* Now we need to reset the board */
702 printk(KERN_WARNING "3w-9xxx: scsi%d: WARNING: (0x%02X:0x%04X): Character ioctl (0x%x) timed out, resetting card.\n", 704 printk(KERN_WARNING "3w-9xxx: scsi%d: WARNING: (0x%02X:0x%04X): Character ioctl (0x%x) timed out, resetting card.\n",
703 tw_dev->host->host_no, TW_DRIVER, 0xc, 705 tw_dev->host->host_no, TW_DRIVER, 0x37,
704 cmd); 706 cmd);
705 retval = TW_IOCTL_ERROR_OS_EIO; 707 retval = TW_IOCTL_ERROR_OS_EIO;
706 twa_reset_device_extension(tw_dev, 1); 708 twa_reset_device_extension(tw_dev);
707 goto out3; 709 goto out3;
708 } 710 }
709 711
@@ -890,7 +892,9 @@ static int twa_decode_bits(TW_Device_Extension *tw_dev, u32 status_reg_value)
890 } 892 }
891 893
892 if (status_reg_value & TW_STATUS_QUEUE_ERROR) { 894 if (status_reg_value & TW_STATUS_QUEUE_ERROR) {
893 if ((tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9650SE) || (!test_bit(TW_IN_RESET, &tw_dev->flags))) 895 if (((tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9650SE) &&
896 (tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9690SA)) ||
897 (!test_bit(TW_IN_RESET, &tw_dev->flags)))
894 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing"); 898 TW_PRINTK(tw_dev->host, TW_DRIVER, 0xe, "Controller Queue Error: clearing");
895 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev)); 899 writel(TW_CONTROL_CLEAR_QUEUE_ERROR, TW_CONTROL_REG_ADDR(tw_dev));
896 } 900 }
@@ -935,8 +939,7 @@ static int twa_empty_response_queue_large(TW_Device_Extension *tw_dev)
935 unsigned long before; 939 unsigned long before;
936 int retval = 1; 940 int retval = 1;
937 941
938 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9550SX) || 942 if (tw_dev->tw_pci_dev->device != PCI_DEVICE_ID_3WARE_9000) {
939 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE)) {
940 before = jiffies; 943 before = jiffies;
941 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) { 944 while ((response_que_value & TW_9550SX_DRAIN_COMPLETED) != TW_9550SX_DRAIN_COMPLETED) {
942 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev)); 945 response_que_value = readl(TW_RESPONSE_QUEUE_REG_ADDR_LARGE(tw_dev));
@@ -1195,7 +1198,6 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1195 u32 status_reg_value; 1198 u32 status_reg_value;
1196 TW_Response_Queue response_que; 1199 TW_Response_Queue response_que;
1197 TW_Command_Full *full_command_packet; 1200 TW_Command_Full *full_command_packet;
1198 TW_Command *command_packet;
1199 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance; 1201 TW_Device_Extension *tw_dev = (TW_Device_Extension *)dev_instance;
1200 int handled = 0; 1202 int handled = 0;
1201 1203
@@ -1273,7 +1275,6 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance)
1273 request_id = TW_RESID_OUT(response_que.response_id); 1275 request_id = TW_RESID_OUT(response_que.response_id);
1274 full_command_packet = tw_dev->command_packet_virt[request_id]; 1276 full_command_packet = tw_dev->command_packet_virt[request_id];
1275 error = 0; 1277 error = 0;
1276 command_packet = &full_command_packet->command.oldcommand;
1277 /* Check for command packet errors */ 1278 /* Check for command packet errors */
1278 if (full_command_packet->command.newcommand.status != 0) { 1279 if (full_command_packet->command.newcommand.status != 0) {
1279 if (tw_dev->srb[request_id] != 0) { 1280 if (tw_dev->srb[request_id] != 0) {
@@ -1352,11 +1353,15 @@ twa_interrupt_bail:
1352} /* End twa_interrupt() */ 1353} /* End twa_interrupt() */
1353 1354
1354/* This function will load the request id and various sgls for ioctls */ 1355/* This function will load the request id and various sgls for ioctls */
1355static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length) 1356static void twa_load_sgl(TW_Device_Extension *tw_dev, TW_Command_Full *full_command_packet, int request_id, dma_addr_t dma_handle, int length)
1356{ 1357{
1357 TW_Command *oldcommand; 1358 TW_Command *oldcommand;
1358 TW_Command_Apache *newcommand; 1359 TW_Command_Apache *newcommand;
1359 TW_SG_Entry *sgl; 1360 TW_SG_Entry *sgl;
1361 unsigned int pae = 0;
1362
1363 if ((sizeof(long) < 8) && (sizeof(dma_addr_t) > 4))
1364 pae = 1;
1360 1365
1361 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) { 1366 if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) {
1362 newcommand = &full_command_packet->command.newcommand; 1367 newcommand = &full_command_packet->command.newcommand;
@@ -1372,12 +1377,14 @@ static void twa_load_sgl(TW_Command_Full *full_command_packet, int request_id, d
1372 1377
1373 if (TW_SGL_OUT(oldcommand->opcode__sgloffset)) { 1378 if (TW_SGL_OUT(oldcommand->opcode__sgloffset)) {
1374 /* Load the sg list */ 1379 /* Load the sg list */
1375 sgl = (TW_SG_Entry *)((u32 *)oldcommand+TW_SGL_OUT(oldcommand->opcode__sgloffset)); 1380 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA)
1381 sgl = (TW_SG_Entry *)((u32 *)oldcommand+oldcommand->size - (sizeof(TW_SG_Entry)/4) + pae);
1382 else
1383 sgl = (TW_SG_Entry *)((u32 *)oldcommand+TW_SGL_OUT(oldcommand->opcode__sgloffset));
1376 sgl->address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1); 1384 sgl->address = TW_CPU_TO_SGL(dma_handle + sizeof(TW_Ioctl_Buf_Apache) - 1);
1377 sgl->length = cpu_to_le32(length); 1385 sgl->length = cpu_to_le32(length);
1378 1386
1379 if ((sizeof(long) < 8) && (sizeof(dma_addr_t) > 4)) 1387 oldcommand->size += pae;
1380 oldcommand->size += 1;
1381 } 1388 }
1382 } 1389 }
1383} /* End twa_load_sgl() */ 1390} /* End twa_load_sgl() */
@@ -1506,7 +1513,8 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1506 command_que_value = tw_dev->command_packet_phys[request_id]; 1513 command_que_value = tw_dev->command_packet_phys[request_id];
1507 1514
1508 /* For 9650SE write low 4 bytes first */ 1515 /* For 9650SE write low 4 bytes first */
1509 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) { 1516 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) ||
1517 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA)) {
1510 command_que_value += TW_COMMAND_OFFSET; 1518 command_que_value += TW_COMMAND_OFFSET;
1511 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev)); 1519 writel((u32)command_que_value, TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev));
1512 } 1520 }
@@ -1537,7 +1545,8 @@ static int twa_post_command_packet(TW_Device_Extension *tw_dev, int request_id,
1537 TW_UNMASK_COMMAND_INTERRUPT(tw_dev); 1545 TW_UNMASK_COMMAND_INTERRUPT(tw_dev);
1538 goto out; 1546 goto out;
1539 } else { 1547 } else {
1540 if (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) { 1548 if ((tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9650SE) ||
1549 (tw_dev->tw_pci_dev->device == PCI_DEVICE_ID_3WARE_9690SA)) {
1541 /* Now write upper 4 bytes */ 1550 /* Now write upper 4 bytes */
1542 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev) + 0x4); 1551 writel((u32)((u64)command_que_value >> 32), TW_COMMAND_QUEUE_REG_ADDR_LARGE(tw_dev) + 0x4);
1543 } else { 1552 } else {
@@ -1561,7 +1570,7 @@ out:
1561} /* End twa_post_command_packet() */ 1570} /* End twa_post_command_packet() */
1562 1571
1563/* This function will reset a device extension */ 1572/* This function will reset a device extension */
1564static int twa_reset_device_extension(TW_Device_Extension *tw_dev, int ioctl_reset) 1573static int twa_reset_device_extension(TW_Device_Extension *tw_dev)
1565{ 1574{
1566 int i = 0; 1575 int i = 0;
1567 int retval = 1; 1576 int retval = 1;
@@ -1719,7 +1728,7 @@ static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
1719 mutex_lock(&tw_dev->ioctl_lock); 1728 mutex_lock(&tw_dev->ioctl_lock);
1720 1729
1721 /* Now reset the card and some of the device extension data */ 1730 /* Now reset the card and some of the device extension data */
1722 if (twa_reset_device_extension(tw_dev, 0)) { 1731 if (twa_reset_device_extension(tw_dev)) {
1723 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset"); 1732 TW_PRINTK(tw_dev->host, TW_DRIVER, 0x2b, "Controller reset failed during scsi host reset");
1724 goto out; 1733 goto out;
1725 } 1734 }
@@ -2001,11 +2010,14 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2001 2010
2002 pci_set_master(pdev); 2011 pci_set_master(pdev);
2003 2012
2004 retval = pci_set_dma_mask(pdev, sizeof(dma_addr_t) > 4 ? DMA_64BIT_MASK : DMA_32BIT_MASK); 2013 if (pci_set_dma_mask(pdev, DMA_64BIT_MASK)
2005 if (retval) { 2014 || pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK))
2006 TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask"); 2015 if (pci_set_dma_mask(pdev, DMA_32BIT_MASK)
2007 goto out_disable_device; 2016 || pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK)) {
2008 } 2017 TW_PRINTK(host, TW_DRIVER, 0x23, "Failed to set dma mask");
2018 retval = -ENODEV;
2019 goto out_disable_device;
2020 }
2009 2021
2010 host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension)); 2022 host = scsi_host_alloc(&driver_template, sizeof(TW_Device_Extension));
2011 if (!host) { 2023 if (!host) {
@@ -2053,7 +2065,8 @@ static int __devinit twa_probe(struct pci_dev *pdev, const struct pci_device_id
2053 goto out_iounmap; 2065 goto out_iounmap;
2054 2066
2055 /* Set host specific parameters */ 2067 /* Set host specific parameters */
2056 if (pdev->device == PCI_DEVICE_ID_3WARE_9650SE) 2068 if ((pdev->device == PCI_DEVICE_ID_3WARE_9650SE) ||
2069 (pdev->device == PCI_DEVICE_ID_3WARE_9690SA))
2057 host->max_id = TW_MAX_UNITS_9650SE; 2070 host->max_id = TW_MAX_UNITS_9650SE;
2058 else 2071 else
2059 host->max_id = TW_MAX_UNITS; 2072 host->max_id = TW_MAX_UNITS;
@@ -2160,6 +2173,8 @@ static struct pci_device_id twa_pci_tbl[] __devinitdata = {
2160 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2173 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2161 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9650SE, 2174 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9650SE,
2162 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 2175 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2176 { PCI_VENDOR_ID_3WARE, PCI_DEVICE_ID_3WARE_9690SA,
2177 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
2163 { } 2178 { }
2164}; 2179};
2165MODULE_DEVICE_TABLE(pci, twa_pci_tbl); 2180MODULE_DEVICE_TABLE(pci, twa_pci_tbl);
diff --git a/drivers/scsi/3w-9xxx.h b/drivers/scsi/3w-9xxx.h
index 7901517d4513..d14a9479e389 100644
--- a/drivers/scsi/3w-9xxx.h
+++ b/drivers/scsi/3w-9xxx.h
@@ -4,7 +4,7 @@
4 Written By: Adam Radford <linuxraid@amcc.com> 4 Written By: Adam Radford <linuxraid@amcc.com>
5 Modifications By: Tom Couch <linuxraid@amcc.com> 5 Modifications By: Tom Couch <linuxraid@amcc.com>
6 6
7 Copyright (C) 2004-2006 Applied Micro Circuits Corporation. 7 Copyright (C) 2004-2007 Applied Micro Circuits Corporation.
8 8
9 This program is free software; you can redistribute it and/or modify 9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 10 it under the terms of the GNU General Public License as published by
@@ -419,6 +419,9 @@ static twa_message_type twa_error_table[] = {
419#ifndef PCI_DEVICE_ID_3WARE_9650SE 419#ifndef PCI_DEVICE_ID_3WARE_9650SE
420#define PCI_DEVICE_ID_3WARE_9650SE 0x1004 420#define PCI_DEVICE_ID_3WARE_9650SE 0x1004
421#endif 421#endif
422#ifndef PCI_DEVICE_ID_3WARE_9690SA
423#define PCI_DEVICE_ID_3WARE_9690SA 0x1005
424#endif
422 425
423/* Bitmask macros to eliminate bitfields */ 426/* Bitmask macros to eliminate bitfields */
424 427
diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig
index a947257b8964..d2b3898b750a 100644
--- a/drivers/scsi/Kconfig
+++ b/drivers/scsi/Kconfig
@@ -282,7 +282,7 @@ config SCSI_ISCSI_ATTRS
282 282
283config SCSI_SAS_ATTRS 283config SCSI_SAS_ATTRS
284 tristate "SAS Transport Attributes" 284 tristate "SAS Transport Attributes"
285 depends on SCSI 285 depends on SCSI && BLK_DEV_BSG
286 help 286 help
287 If you wish to export transport-specific information about 287 If you wish to export transport-specific information about
288 each attached SAS device to sysfs, say Y. 288 each attached SAS device to sysfs, say Y.
@@ -291,8 +291,12 @@ source "drivers/scsi/libsas/Kconfig"
291 291
292endmenu 292endmenu
293 293
294menu "SCSI low-level drivers" 294menuconfig SCSI_LOWLEVEL
295 bool "SCSI low-level drivers"
295 depends on SCSI!=n 296 depends on SCSI!=n
297 default y
298
299if SCSI_LOWLEVEL
296 300
297config ISCSI_TCP 301config ISCSI_TCP
298 tristate "iSCSI Initiator over TCP/IP" 302 tristate "iSCSI Initiator over TCP/IP"
@@ -1800,7 +1804,7 @@ config SCSI_SRP
1800 To compile this driver as a module, choose M here: the 1804 To compile this driver as a module, choose M here: the
1801 module will be called libsrp. 1805 module will be called libsrp.
1802 1806
1803endmenu 1807endif # SCSI_LOWLEVEL
1804 1808
1805source "drivers/scsi/pcmcia/Kconfig" 1809source "drivers/scsi/pcmcia/Kconfig"
1806 1810
diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile
index 0f8689557158..86a7ba7bad63 100644
--- a/drivers/scsi/Makefile
+++ b/drivers/scsi/Makefile
@@ -132,6 +132,7 @@ obj-$(CONFIG_SCSI_IBMVSCSI) += ibmvscsi/
132obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/ 132obj-$(CONFIG_SCSI_IBMVSCSIS) += ibmvscsi/
133obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o 133obj-$(CONFIG_SCSI_HPTIOP) += hptiop.o
134obj-$(CONFIG_SCSI_STEX) += stex.o 134obj-$(CONFIG_SCSI_STEX) += stex.o
135obj-$(CONFIG_PS3_ROM) += ps3rom.o
135 136
136obj-$(CONFIG_ARM) += arm/ 137obj-$(CONFIG_ARM) += arm/
137 138
diff --git a/drivers/scsi/a4000t.c b/drivers/scsi/a4000t.c
index 6a5784683ed3..0c758d1452ba 100644
--- a/drivers/scsi/a4000t.c
+++ b/drivers/scsi/a4000t.c
@@ -79,6 +79,7 @@ static int __devinit a4000t_probe(struct device *dev)
79 goto out_put_host; 79 goto out_put_host;
80 } 80 }
81 81
82 dev_set_drvdata(dev, host);
82 scsi_scan_host(host); 83 scsi_scan_host(host);
83 84
84 return 0; 85 return 0;
@@ -95,7 +96,7 @@ static int __devinit a4000t_probe(struct device *dev)
95 96
96static __devexit int a4000t_device_remove(struct device *dev) 97static __devexit int a4000t_device_remove(struct device *dev)
97{ 98{
98 struct Scsi_Host *host = dev_to_shost(dev); 99 struct Scsi_Host *host = dev_get_drvdata(dev);
99 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 100 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
100 101
101 scsi_remove_host(host); 102 scsi_remove_host(host);
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 0b6fd0b654d2..a26baab09dbf 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -751,6 +751,101 @@ static void setinqstr(struct aac_dev *dev, void *data, int tindex)
751 inqstrcpy ("V1.0", str->prl); 751 inqstrcpy ("V1.0", str->prl);
752} 752}
753 753
754static void get_container_serial_callback(void *context, struct fib * fibptr)
755{
756 struct aac_get_serial_resp * get_serial_reply;
757 struct scsi_cmnd * scsicmd;
758
759 BUG_ON(fibptr == NULL);
760
761 scsicmd = (struct scsi_cmnd *) context;
762 if (!aac_valid_context(scsicmd, fibptr))
763 return;
764
765 get_serial_reply = (struct aac_get_serial_resp *) fib_data(fibptr);
766 /* Failure is irrelevant, using default value instead */
767 if (le32_to_cpu(get_serial_reply->status) == CT_OK) {
768 char sp[13];
769 /* EVPD bit set */
770 sp[0] = INQD_PDT_DA;
771 sp[1] = scsicmd->cmnd[2];
772 sp[2] = 0;
773 sp[3] = snprintf(sp+4, sizeof(sp)-4, "%08X",
774 le32_to_cpu(get_serial_reply->uid));
775 aac_internal_transfer(scsicmd, sp, 0, sizeof(sp));
776 }
777
778 scsicmd->result = DID_OK << 16 | COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
779
780 aac_fib_complete(fibptr);
781 aac_fib_free(fibptr);
782 scsicmd->scsi_done(scsicmd);
783}
784
785/**
786 * aac_get_container_serial - get container serial, none blocking.
787 */
788static int aac_get_container_serial(struct scsi_cmnd * scsicmd)
789{
790 int status;
791 struct aac_get_serial *dinfo;
792 struct fib * cmd_fibcontext;
793 struct aac_dev * dev;
794
795 dev = (struct aac_dev *)scsicmd->device->host->hostdata;
796
797 if (!(cmd_fibcontext = aac_fib_alloc(dev)))
798 return -ENOMEM;
799
800 aac_fib_init(cmd_fibcontext);
801 dinfo = (struct aac_get_serial *) fib_data(cmd_fibcontext);
802
803 dinfo->command = cpu_to_le32(VM_ContainerConfig);
804 dinfo->type = cpu_to_le32(CT_CID_TO_32BITS_UID);
805 dinfo->cid = cpu_to_le32(scmd_id(scsicmd));
806
807 status = aac_fib_send(ContainerCommand,
808 cmd_fibcontext,
809 sizeof (struct aac_get_serial),
810 FsaNormal,
811 0, 1,
812 (fib_callback) get_container_serial_callback,
813 (void *) scsicmd);
814
815 /*
816 * Check that the command queued to the controller
817 */
818 if (status == -EINPROGRESS) {
819 scsicmd->SCp.phase = AAC_OWNER_FIRMWARE;
820 return 0;
821 }
822
823 printk(KERN_WARNING "aac_get_container_serial: aac_fib_send failed with status: %d.\n", status);
824 aac_fib_complete(cmd_fibcontext);
825 aac_fib_free(cmd_fibcontext);
826 return -1;
827}
828
829/* Function: setinqserial
830 *
831 * Arguments: [1] pointer to void [1] int
832 *
833 * Purpose: Sets SCSI Unit Serial number.
834 * This is a fake. We should read a proper
835 * serial number from the container. <SuSE>But
836 * without docs it's quite hard to do it :-)
837 * So this will have to do in the meantime.</SuSE>
838 */
839
840static int setinqserial(struct aac_dev *dev, void *data, int cid)
841{
842 /*
843 * This breaks array migration.
844 */
845 return snprintf((char *)(data), sizeof(struct scsi_inq) - 4, "%08X%02X",
846 le32_to_cpu(dev->adapter_info.serial[0]), cid);
847}
848
754static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code, 849static void set_sense(u8 *sense_buf, u8 sense_key, u8 sense_code,
755 u8 a_sense_code, u8 incorrect_length, 850 u8 a_sense_code, u8 incorrect_length,
756 u8 bit_pointer, u16 field_pointer, 851 u8 bit_pointer, u16 field_pointer,
@@ -1798,6 +1893,49 @@ int aac_scsi_cmd(struct scsi_cmnd * scsicmd)
1798 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid)); 1893 dprintk((KERN_DEBUG "INQUIRY command, ID: %d.\n", cid));
1799 memset(&inq_data, 0, sizeof (struct inquiry_data)); 1894 memset(&inq_data, 0, sizeof (struct inquiry_data));
1800 1895
1896 if (scsicmd->cmnd[1] & 0x1 ) {
1897 char *arr = (char *)&inq_data;
1898
1899 /* EVPD bit set */
1900 arr[0] = (scmd_id(scsicmd) == host->this_id) ?
1901 INQD_PDT_PROC : INQD_PDT_DA;
1902 if (scsicmd->cmnd[2] == 0) {
1903 /* supported vital product data pages */
1904 arr[3] = 2;
1905 arr[4] = 0x0;
1906 arr[5] = 0x80;
1907 arr[1] = scsicmd->cmnd[2];
1908 aac_internal_transfer(scsicmd, &inq_data, 0,
1909 sizeof(inq_data));
1910 scsicmd->result = DID_OK << 16 |
1911 COMMAND_COMPLETE << 8 | SAM_STAT_GOOD;
1912 } else if (scsicmd->cmnd[2] == 0x80) {
1913 /* unit serial number page */
1914 arr[3] = setinqserial(dev, &arr[4],
1915 scmd_id(scsicmd));
1916 arr[1] = scsicmd->cmnd[2];
1917 aac_internal_transfer(scsicmd, &inq_data, 0,
1918 sizeof(inq_data));
1919 return aac_get_container_serial(scsicmd);
1920 } else {
1921 /* vpd page not implemented */
1922 scsicmd->result = DID_OK << 16 |
1923 COMMAND_COMPLETE << 8 |
1924 SAM_STAT_CHECK_CONDITION;
1925 set_sense((u8 *) &dev->fsa_dev[cid].sense_data,
1926 ILLEGAL_REQUEST,
1927 SENCODE_INVALID_CDB_FIELD,
1928 ASENCODE_NO_SENSE, 0, 7, 2, 0);
1929 memcpy(scsicmd->sense_buffer,
1930 &dev->fsa_dev[cid].sense_data,
1931 (sizeof(dev->fsa_dev[cid].sense_data) >
1932 sizeof(scsicmd->sense_buffer))
1933 ? sizeof(scsicmd->sense_buffer)
1934 : sizeof(dev->fsa_dev[cid].sense_data));
1935 }
1936 scsicmd->scsi_done(scsicmd);
1937 return 0;
1938 }
1801 inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */ 1939 inq_data.inqd_ver = 2; /* claim compliance to SCSI-2 */
1802 inq_data.inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */ 1940 inq_data.inqd_rdf = 2; /* A response data format value of two indicates that the data shall be in the format specified in SCSI-2 */
1803 inq_data.inqd_len = 31; 1941 inq_data.inqd_len = 31;
@@ -2070,7 +2208,7 @@ static int query_disk(struct aac_dev *dev, void __user *arg)
2070 } 2208 }
2071 else return -EINVAL; 2209 else return -EINVAL;
2072 2210
2073 qd.valid = fsa_dev_ptr[qd.cnum].valid; 2211 qd.valid = fsa_dev_ptr[qd.cnum].valid != 0;
2074 qd.locked = fsa_dev_ptr[qd.cnum].locked; 2212 qd.locked = fsa_dev_ptr[qd.cnum].locked;
2075 qd.deleted = fsa_dev_ptr[qd.cnum].deleted; 2213 qd.deleted = fsa_dev_ptr[qd.cnum].deleted;
2076 2214
diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h
index f1d3b66af879..400d03403cd5 100644
--- a/drivers/scsi/aacraid/aacraid.h
+++ b/drivers/scsi/aacraid/aacraid.h
@@ -1567,6 +1567,20 @@ struct aac_get_name_resp {
1567 u8 data[16]; 1567 u8 data[16];
1568}; 1568};
1569 1569
1570#define CT_CID_TO_32BITS_UID 165
1571struct aac_get_serial {
1572 __le32 command; /* VM_ContainerConfig */
1573 __le32 type; /* CT_CID_TO_32BITS_UID */
1574 __le32 cid;
1575};
1576
1577struct aac_get_serial_resp {
1578 __le32 dummy0;
1579 __le32 dummy1;
1580 __le32 status; /* CT_OK */
1581 __le32 uid;
1582};
1583
1570/* 1584/*
1571 * The following command is sent to shut down each container. 1585 * The following command is sent to shut down each container.
1572 */ 1586 */
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index d510839c0bb2..bb870906b4cf 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -80,7 +80,11 @@ static int fib_map_alloc(struct aac_dev *dev)
80 80
81void aac_fib_map_free(struct aac_dev *dev) 81void aac_fib_map_free(struct aac_dev *dev)
82{ 82{
83 pci_free_consistent(dev->pdev, dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB), dev->hw_fib_va, dev->hw_fib_pa); 83 pci_free_consistent(dev->pdev,
84 dev->max_fib_size * (dev->scsi_host_ptr->can_queue + AAC_NUM_MGT_FIB),
85 dev->hw_fib_va, dev->hw_fib_pa);
86 dev->hw_fib_va = NULL;
87 dev->hw_fib_pa = 0;
84} 88}
85 89
86/** 90/**
@@ -1087,8 +1091,6 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced)
1087 * case. 1091 * case.
1088 */ 1092 */
1089 aac_fib_map_free(aac); 1093 aac_fib_map_free(aac);
1090 aac->hw_fib_va = NULL;
1091 aac->hw_fib_pa = 0;
1092 pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys); 1094 pci_free_consistent(aac->pdev, aac->comm_size, aac->comm_addr, aac->comm_phys);
1093 aac->comm_addr = NULL; 1095 aac->comm_addr = NULL;
1094 aac->comm_phys = 0; 1096 aac->comm_phys = 0;
@@ -1098,12 +1100,12 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced)
1098 kfree(aac->fsa_dev); 1100 kfree(aac->fsa_dev);
1099 aac->fsa_dev = NULL; 1101 aac->fsa_dev = NULL;
1100 if (aac_get_driver_ident(index)->quirks & AAC_QUIRK_31BIT) { 1102 if (aac_get_driver_ident(index)->quirks & AAC_QUIRK_31BIT) {
1101 if (((retval = pci_set_dma_mask(aac->pdev, DMA_32BIT_MASK))) || 1103 if (((retval = pci_set_dma_mask(aac->pdev, DMA_31BIT_MASK))) ||
1102 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_32BIT_MASK)))) 1104 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_31BIT_MASK))))
1103 goto out; 1105 goto out;
1104 } else { 1106 } else {
1105 if (((retval = pci_set_dma_mask(aac->pdev, 0x7FFFFFFFULL))) || 1107 if (((retval = pci_set_dma_mask(aac->pdev, DMA_32BIT_MASK))) ||
1106 ((retval = pci_set_consistent_dma_mask(aac->pdev, 0x7FFFFFFFULL)))) 1108 ((retval = pci_set_consistent_dma_mask(aac->pdev, DMA_32BIT_MASK))))
1107 goto out; 1109 goto out;
1108 } 1110 }
1109 if ((retval = (*(aac_get_driver_ident(index)->init))(aac))) 1111 if ((retval = (*(aac_get_driver_ident(index)->init))(aac)))
diff --git a/drivers/scsi/aic94xx/aic94xx_dev.c b/drivers/scsi/aic94xx/aic94xx_dev.c
index c520e5b41fb5..3dce618bf414 100644
--- a/drivers/scsi/aic94xx/aic94xx_dev.c
+++ b/drivers/scsi/aic94xx/aic94xx_dev.c
@@ -126,7 +126,7 @@ static inline int asd_init_sata(struct domain_device *dev)
126 if (w76 & 0x100) /* NCQ? */ 126 if (w76 & 0x100) /* NCQ? */
127 qdepth = (w75 & 0x1F) + 1; 127 qdepth = (w75 & 0x1F) + 1;
128 asd_ddbsite_write_dword(asd_ha, ddb, SATA_TAG_ALLOC_MASK, 128 asd_ddbsite_write_dword(asd_ha, ddb, SATA_TAG_ALLOC_MASK,
129 (1<<qdepth)-1); 129 (1ULL<<qdepth)-1);
130 asd_ddbsite_write_byte(asd_ha, ddb, NUM_SATA_TAGS, qdepth); 130 asd_ddbsite_write_byte(asd_ha, ddb, NUM_SATA_TAGS, qdepth);
131 } 131 }
132 if (dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM || 132 if (dev->dev_type == SATA_DEV || dev->dev_type == SATA_PM ||
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c
index b8c6810090d5..ab00aecc5466 100644
--- a/drivers/scsi/aic94xx/aic94xx_init.c
+++ b/drivers/scsi/aic94xx/aic94xx_init.c
@@ -81,6 +81,9 @@ static struct scsi_host_template aic94xx_sht = {
81 .use_clustering = ENABLE_CLUSTERING, 81 .use_clustering = ENABLE_CLUSTERING,
82 .eh_device_reset_handler = sas_eh_device_reset_handler, 82 .eh_device_reset_handler = sas_eh_device_reset_handler,
83 .eh_bus_reset_handler = sas_eh_bus_reset_handler, 83 .eh_bus_reset_handler = sas_eh_bus_reset_handler,
84 .slave_alloc = sas_slave_alloc,
85 .target_destroy = sas_target_destroy,
86 .ioctl = sas_ioctl,
84}; 87};
85 88
86static int __devinit asd_map_memio(struct asd_ha_struct *asd_ha) 89static int __devinit asd_map_memio(struct asd_ha_struct *asd_ha)
diff --git a/drivers/scsi/aic94xx/aic94xx_task.c b/drivers/scsi/aic94xx/aic94xx_task.c
index e2ad5bed9403..d5d8caba3560 100644
--- a/drivers/scsi/aic94xx/aic94xx_task.c
+++ b/drivers/scsi/aic94xx/aic94xx_task.c
@@ -74,8 +74,13 @@ static inline int asd_map_scatterlist(struct sas_task *task,
74 return 0; 74 return 0;
75 } 75 }
76 76
77 num_sg = pci_map_sg(asd_ha->pcidev, task->scatter, task->num_scatter, 77 /* STP tasks come from libata which has already mapped
78 task->data_dir); 78 * the SG list */
79 if (sas_protocol_ata(task->task_proto))
80 num_sg = task->num_scatter;
81 else
82 num_sg = pci_map_sg(asd_ha->pcidev, task->scatter,
83 task->num_scatter, task->data_dir);
79 if (num_sg == 0) 84 if (num_sg == 0)
80 return -ENOMEM; 85 return -ENOMEM;
81 86
@@ -120,8 +125,9 @@ static inline int asd_map_scatterlist(struct sas_task *task,
120 125
121 return 0; 126 return 0;
122err_unmap: 127err_unmap:
123 pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter, 128 if (sas_protocol_ata(task->task_proto))
124 task->data_dir); 129 pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
130 task->data_dir);
125 return res; 131 return res;
126} 132}
127 133
@@ -142,8 +148,9 @@ static inline void asd_unmap_scatterlist(struct asd_ascb *ascb)
142 } 148 }
143 149
144 asd_free_coherent(asd_ha, ascb->sg_arr); 150 asd_free_coherent(asd_ha, ascb->sg_arr);
145 pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter, 151 if (task->task_proto != SAS_PROTOCOL_STP)
146 task->data_dir); 152 pci_unmap_sg(asd_ha->pcidev, task->scatter, task->num_scatter,
153 task->data_dir);
147} 154}
148 155
149/* ---------- Task complete tasklet ---------- */ 156/* ---------- Task complete tasklet ---------- */
@@ -391,7 +398,6 @@ static int asd_build_ata_ascb(struct asd_ascb *ascb, struct sas_task *task,
391 398
392 scb->ata_task.total_xfer_len = cpu_to_le32(task->total_xfer_len); 399 scb->ata_task.total_xfer_len = cpu_to_le32(task->total_xfer_len);
393 scb->ata_task.fis = task->ata_task.fis; 400 scb->ata_task.fis = task->ata_task.fis;
394 scb->ata_task.fis.fis_type = 0x27;
395 if (likely(!task->ata_task.device_control_reg_update)) 401 if (likely(!task->ata_task.device_control_reg_update))
396 scb->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */ 402 scb->ata_task.fis.flags |= 0x80; /* C=1: update ATA cmd reg */
397 scb->ata_task.fis.flags &= 0xF0; /* PM_PORT field shall be 0 */ 403 scb->ata_task.fis.flags &= 0xF0; /* PM_PORT field shall be 0 */
diff --git a/drivers/scsi/arm/cumana_1.c b/drivers/scsi/arm/cumana_1.c
index cf9a21cea6d9..49d838e90a24 100644
--- a/drivers/scsi/arm/cumana_1.c
+++ b/drivers/scsi/arm/cumana_1.c
@@ -24,7 +24,7 @@
24 24
25#define CUMANASCSI_PUBLIC_RELEASE 1 25#define CUMANASCSI_PUBLIC_RELEASE 1
26 26
27#define NCR5380_implementation_fields int port, ctrl 27#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
28#define NCR5380_local_declare() struct Scsi_Host *_instance 28#define NCR5380_local_declare() struct Scsi_Host *_instance
29#define NCR5380_setup(instance) _instance = instance 29#define NCR5380_setup(instance) _instance = instance
30#define NCR5380_read(reg) cumanascsi_read(_instance, reg) 30#define NCR5380_read(reg) cumanascsi_read(_instance, reg)
@@ -33,6 +33,11 @@
33#define NCR5380_queue_command cumanascsi_queue_command 33#define NCR5380_queue_command cumanascsi_queue_command
34#define NCR5380_proc_info cumanascsi_proc_info 34#define NCR5380_proc_info cumanascsi_proc_info
35 35
36#define NCR5380_implementation_fields \
37 unsigned ctrl; \
38 void __iomem *base; \
39 void __iomem *dma
40
36#define BOARD_NORMAL 0 41#define BOARD_NORMAL 0
37#define BOARD_NCR53C400 1 42#define BOARD_NCR53C400 1
38 43
@@ -47,192 +52,162 @@ const char *cumanascsi_info(struct Scsi_Host *spnt)
47 return ""; 52 return "";
48} 53}
49 54
50#ifdef NOT_EFFICIENT 55#define CTRL 0x16fc
51#define CTRL(p,v) outb(*ctrl = (v), (p) - 577) 56#define STAT 0x2004
52#define STAT(p) inb((p)+1) 57#define L(v) (((v)<<16)|((v) & 0x0000ffff))
53#define IN(p) inb((p)) 58#define H(v) (((v)>>16)|((v) & 0xffff0000))
54#define OUT(v,p) outb((v), (p))
55#else
56#define CTRL(p,v) (p[-2308] = (*ctrl = (v)))
57#define STAT(p) (p[4])
58#define IN(p) (*(p))
59#define IN2(p) ((unsigned short)(*(volatile unsigned long *)(p)))
60#define OUT(v,p) (*(p) = (v))
61#define OUT2(v,p) (*((volatile unsigned long *)(p)) = (v))
62#endif
63#define L(v) (((v)<<16)|((v) & 0x0000ffff))
64#define H(v) (((v)>>16)|((v) & 0xffff0000))
65 59
66static inline int 60static inline int
67NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, int len) 61NCR5380_pwrite(struct Scsi_Host *host, unsigned char *addr, int len)
68{ 62{
69 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
70 int oldctrl = *ctrl;
71 unsigned long *laddr; 63 unsigned long *laddr;
72#ifdef NOT_EFFICIENT 64 void __iomem *dma = priv(host)->dma + 0x2000;
73 int iobase = instance->io_port;
74 int dma_io = iobase & ~(0x3C0000>>2);
75#else
76 volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port);
77 volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000);
78#endif
79 65
80 if(!len) return 0; 66 if(!len) return 0;
81 67
82 CTRL(iobase, 0x02); 68 writeb(0x02, priv(host)->base + CTRL);
83 laddr = (unsigned long *)addr; 69 laddr = (unsigned long *)addr;
84 while(len >= 32) 70 while(len >= 32)
85 { 71 {
86 int status; 72 unsigned int status;
87 unsigned long v; 73 unsigned long v;
88 status = STAT(iobase); 74 status = readb(priv(host)->base + STAT);
89 if(status & 0x80) 75 if(status & 0x80)
90 goto end; 76 goto end;
91 if(!(status & 0x40)) 77 if(!(status & 0x40))
92 continue; 78 continue;
93 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 79 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
94 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 80 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
95 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 81 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
96 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 82 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
97 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 83 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
98 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 84 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
99 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 85 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
100 v=*laddr++; OUT2(L(v),dma_io); OUT2(H(v),dma_io); 86 v=*laddr++; writew(L(v), dma); writew(H(v), dma);
101 len -= 32; 87 len -= 32;
102 if(len == 0) 88 if(len == 0)
103 break; 89 break;
104 } 90 }
105 91
106 addr = (unsigned char *)laddr; 92 addr = (unsigned char *)laddr;
107 CTRL(iobase, 0x12); 93 writeb(0x12, priv(host)->base + CTRL);
94
108 while(len > 0) 95 while(len > 0)
109 { 96 {
110 int status; 97 unsigned int status;
111 status = STAT(iobase); 98 status = readb(priv(host)->base + STAT);
112 if(status & 0x80) 99 if(status & 0x80)
113 goto end; 100 goto end;
114 if(status & 0x40) 101 if(status & 0x40)
115 { 102 {
116 OUT(*addr++, dma_io); 103 writeb(*addr++, dma);
117 if(--len == 0) 104 if(--len == 0)
118 break; 105 break;
119 } 106 }
120 107
121 status = STAT(iobase); 108 status = readb(priv(host)->base + STAT);
122 if(status & 0x80) 109 if(status & 0x80)
123 goto end; 110 goto end;
124 if(status & 0x40) 111 if(status & 0x40)
125 { 112 {
126 OUT(*addr++, dma_io); 113 writeb(*addr++, dma);
127 if(--len == 0) 114 if(--len == 0)
128 break; 115 break;
129 } 116 }
130 } 117 }
131end: 118end:
132 CTRL(iobase, oldctrl|0x40); 119 writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
133 return len; 120 return len;
134} 121}
135 122
136static inline int 123static inline int
137NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, int len) 124NCR5380_pread(struct Scsi_Host *host, unsigned char *addr, int len)
138{ 125{
139 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
140 int oldctrl = *ctrl;
141 unsigned long *laddr; 126 unsigned long *laddr;
142#ifdef NOT_EFFICIENT 127 void __iomem *dma = priv(host)->dma + 0x2000;
143 int iobase = instance->io_port;
144 int dma_io = iobase & ~(0x3C0000>>2);
145#else
146 volatile unsigned char *iobase = (unsigned char *)ioaddr(instance->io_port);
147 volatile unsigned char *dma_io = (unsigned char *)((int)iobase & ~0x3C0000);
148#endif
149 128
150 if(!len) return 0; 129 if(!len) return 0;
151 130
152 CTRL(iobase, 0x00); 131 writeb(0x00, priv(host)->base + CTRL);
153 laddr = (unsigned long *)addr; 132 laddr = (unsigned long *)addr;
154 while(len >= 32) 133 while(len >= 32)
155 { 134 {
156 int status; 135 unsigned int status;
157 status = STAT(iobase); 136 status = readb(priv(host)->base + STAT);
158 if(status & 0x80) 137 if(status & 0x80)
159 goto end; 138 goto end;
160 if(!(status & 0x40)) 139 if(!(status & 0x40))
161 continue; 140 continue;
162 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 141 *laddr++ = readw(dma) | (readw(dma) << 16);
163 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 142 *laddr++ = readw(dma) | (readw(dma) << 16);
164 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 143 *laddr++ = readw(dma) | (readw(dma) << 16);
165 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 144 *laddr++ = readw(dma) | (readw(dma) << 16);
166 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 145 *laddr++ = readw(dma) | (readw(dma) << 16);
167 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 146 *laddr++ = readw(dma) | (readw(dma) << 16);
168 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 147 *laddr++ = readw(dma) | (readw(dma) << 16);
169 *laddr++ = IN2(dma_io)|(IN2(dma_io)<<16); 148 *laddr++ = readw(dma) | (readw(dma) << 16);
170 len -= 32; 149 len -= 32;
171 if(len == 0) 150 if(len == 0)
172 break; 151 break;
173 } 152 }
174 153
175 addr = (unsigned char *)laddr; 154 addr = (unsigned char *)laddr;
176 CTRL(iobase, 0x10); 155 writeb(0x10, priv(host)->base + CTRL);
156
177 while(len > 0) 157 while(len > 0)
178 { 158 {
179 int status; 159 unsigned int status;
180 status = STAT(iobase); 160 status = readb(priv(host)->base + STAT);
181 if(status & 0x80) 161 if(status & 0x80)
182 goto end; 162 goto end;
183 if(status & 0x40) 163 if(status & 0x40)
184 { 164 {
185 *addr++ = IN(dma_io); 165 *addr++ = readb(dma);
186 if(--len == 0) 166 if(--len == 0)
187 break; 167 break;
188 } 168 }
189 169
190 status = STAT(iobase); 170 status = readb(priv(host)->base + STAT);
191 if(status & 0x80) 171 if(status & 0x80)
192 goto end; 172 goto end;
193 if(status & 0x40) 173 if(status & 0x40)
194 { 174 {
195 *addr++ = IN(dma_io); 175 *addr++ = readb(dma);
196 if(--len == 0) 176 if(--len == 0)
197 break; 177 break;
198 } 178 }
199 } 179 }
200end: 180end:
201 CTRL(iobase, oldctrl|0x40); 181 writeb(priv(host)->ctrl | 0x40, priv(host)->base + CTRL);
202 return len; 182 return len;
203} 183}
204 184
205#undef STAT 185static unsigned char cumanascsi_read(struct Scsi_Host *host, unsigned int reg)
206#undef CTRL 186{
207#undef IN 187 void __iomem *base = priv(host)->base;
208#undef OUT 188 unsigned char val;
209 189
210#define CTRL(p,v) outb(*ctrl = (v), (p) - 577) 190 writeb(0, base + CTRL);
211 191
212static char cumanascsi_read(struct Scsi_Host *instance, int reg) 192 val = readb(base + 0x2100 + (reg << 2));
213{
214 unsigned int iobase = instance->io_port;
215 int i;
216 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
217 193
218 CTRL(iobase, 0); 194 priv(host)->ctrl = 0x40;
219 i = inb(iobase + 64 + reg); 195 writeb(0x40, base + CTRL);
220 CTRL(iobase, 0x40);
221 196
222 return i; 197 return val;
223} 198}
224 199
225static void cumanascsi_write(struct Scsi_Host *instance, int reg, int value) 200static void cumanascsi_write(struct Scsi_Host *host, unsigned int reg, unsigned int value)
226{ 201{
227 int iobase = instance->io_port; 202 void __iomem *base = priv(host)->base;
228 int *ctrl = &((struct NCR5380_hostdata *)instance->hostdata)->ctrl;
229 203
230 CTRL(iobase, 0); 204 writeb(0, base + CTRL);
231 outb(value, iobase + 64 + reg);
232 CTRL(iobase, 0x40);
233}
234 205
235#undef CTRL 206 writeb(value, base + 0x2100 + (reg << 2));
207
208 priv(host)->ctrl = 0x40;
209 writeb(0x40, base + CTRL);
210}
236 211
237#include "../NCR5380.c" 212#include "../NCR5380.c"
238 213
@@ -256,32 +231,46 @@ static int __devinit
256cumanascsi1_probe(struct expansion_card *ec, const struct ecard_id *id) 231cumanascsi1_probe(struct expansion_card *ec, const struct ecard_id *id)
257{ 232{
258 struct Scsi_Host *host; 233 struct Scsi_Host *host;
259 int ret = -ENOMEM; 234 int ret;
260 235
261 host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata)); 236 ret = ecard_request_resources(ec);
262 if (!host) 237 if (ret)
263 goto out; 238 goto out;
264 239
265 host->io_port = ecard_address(ec, ECARD_IOC, ECARD_SLOW) + 0x800; 240 host = scsi_host_alloc(&cumanascsi_template, sizeof(struct NCR5380_hostdata));
241 if (!host) {
242 ret = -ENOMEM;
243 goto out_release;
244 }
245
246 priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_IOCSLOW),
247 ecard_resource_len(ec, ECARD_RES_IOCSLOW));
248 priv(host)->dma = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
249 ecard_resource_len(ec, ECARD_RES_MEMC));
250 if (!priv(host)->base || !priv(host)->dma) {
251 ret = -ENOMEM;
252 goto out_unmap;
253 }
254
266 host->irq = ec->irq; 255 host->irq = ec->irq;
267 256
268 NCR5380_init(host, 0); 257 NCR5380_init(host, 0);
269 258
259 priv(host)->ctrl = 0;
260 writeb(0, priv(host)->base + CTRL);
261
270 host->n_io_port = 255; 262 host->n_io_port = 255;
271 if (!(request_region(host->io_port, host->n_io_port, "CumanaSCSI-1"))) { 263 if (!(request_region(host->io_port, host->n_io_port, "CumanaSCSI-1"))) {
272 ret = -EBUSY; 264 ret = -EBUSY;
273 goto out_free; 265 goto out_unmap;
274 } 266 }
275 267
276 ((struct NCR5380_hostdata *)host->hostdata)->ctrl = 0;
277 outb(0x00, host->io_port - 577);
278
279 ret = request_irq(host->irq, cumanascsi_intr, IRQF_DISABLED, 268 ret = request_irq(host->irq, cumanascsi_intr, IRQF_DISABLED,
280 "CumanaSCSI-1", host); 269 "CumanaSCSI-1", host);
281 if (ret) { 270 if (ret) {
282 printk("scsi%d: IRQ%d not free: %d\n", 271 printk("scsi%d: IRQ%d not free: %d\n",
283 host->host_no, host->irq, ret); 272 host->host_no, host->irq, ret);
284 goto out_release; 273 goto out_unmap;
285 } 274 }
286 275
287 printk("scsi%d: at port 0x%08lx irq %d", 276 printk("scsi%d: at port 0x%08lx irq %d",
@@ -301,10 +290,12 @@ cumanascsi1_probe(struct expansion_card *ec, const struct ecard_id *id)
301 290
302 out_free_irq: 291 out_free_irq:
303 free_irq(host->irq, host); 292 free_irq(host->irq, host);
304 out_release: 293 out_unmap:
305 release_region(host->io_port, host->n_io_port); 294 iounmap(priv(host)->base);
306 out_free: 295 iounmap(priv(host)->dma);
307 scsi_host_put(host); 296 scsi_host_put(host);
297 out_release:
298 ecard_release_resources(ec);
308 out: 299 out:
309 return ret; 300 return ret;
310} 301}
@@ -318,8 +309,10 @@ static void __devexit cumanascsi1_remove(struct expansion_card *ec)
318 scsi_remove_host(host); 309 scsi_remove_host(host);
319 free_irq(host->irq, host); 310 free_irq(host->irq, host);
320 NCR5380_exit(host); 311 NCR5380_exit(host);
321 release_region(host->io_port, host->n_io_port); 312 iounmap(priv(host)->base);
313 iounmap(priv(host)->dma);
322 scsi_host_put(host); 314 scsi_host_put(host);
315 ecard_release_resources(ec);
323} 316}
324 317
325static const struct ecard_id cumanascsi1_cids[] = { 318static const struct ecard_id cumanascsi1_cids[] = {
diff --git a/drivers/scsi/arm/ecoscsi.c b/drivers/scsi/arm/ecoscsi.c
index 378e7af0c5d6..5265a9884338 100644
--- a/drivers/scsi/arm/ecoscsi.c
+++ b/drivers/scsi/arm/ecoscsi.c
@@ -34,35 +34,25 @@
34#include "../scsi.h" 34#include "../scsi.h"
35#include <scsi/scsi_host.h> 35#include <scsi/scsi_host.h>
36 36
37#define NCR5380_implementation_fields int port, ctrl 37#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
38#define NCR5380_local_declare() struct Scsi_Host *_instance
39#define NCR5380_setup(instance) _instance = instance
40 38
41#define NCR5380_read(reg) ecoscsi_read(_instance, reg) 39#define NCR5380_local_declare() void __iomem *_base
42#define NCR5380_write(reg, value) ecoscsi_write(_instance, reg, value) 40#define NCR5380_setup(host) _base = priv(host)->base
41
42#define NCR5380_read(reg) ({ writeb(reg | 8, _base); readb(_base + 4); })
43#define NCR5380_write(reg, value) ({ writeb(reg | 8, _base); writeb(value, _base + 4); })
43 44
44#define NCR5380_intr ecoscsi_intr 45#define NCR5380_intr ecoscsi_intr
45#define NCR5380_queue_command ecoscsi_queue_command 46#define NCR5380_queue_command ecoscsi_queue_command
46#define NCR5380_proc_info ecoscsi_proc_info 47#define NCR5380_proc_info ecoscsi_proc_info
47 48
49#define NCR5380_implementation_fields \
50 void __iomem *base
51
48#include "../NCR5380.h" 52#include "../NCR5380.h"
49 53
50#define ECOSCSI_PUBLIC_RELEASE 1 54#define ECOSCSI_PUBLIC_RELEASE 1
51 55
52static char ecoscsi_read(struct Scsi_Host *instance, int reg)
53{
54 int iobase = instance->io_port;
55 outb(reg | 8, iobase);
56 return inb(iobase + 1);
57}
58
59static void ecoscsi_write(struct Scsi_Host *instance, int reg, int value)
60{
61 int iobase = instance->io_port;
62 outb(reg | 8, iobase);
63 outb(value, iobase + 1);
64}
65
66/* 56/*
67 * Function : ecoscsi_setup(char *str, int *ints) 57 * Function : ecoscsi_setup(char *str, int *ints)
68 * 58 *
@@ -82,73 +72,6 @@ const char * ecoscsi_info (struct Scsi_Host *spnt)
82 return ""; 72 return "";
83} 73}
84 74
85#if 0
86#define STAT(p) inw(p + 144)
87
88static inline int NCR5380_pwrite(struct Scsi_Host *host, unsigned char *addr,
89 int len)
90{
91 int iobase = host->io_port;
92printk("writing %p len %d\n",addr, len);
93 if(!len) return -1;
94
95 while(1)
96 {
97 int status;
98 while(((status = STAT(iobase)) & 0x100)==0);
99 }
100}
101
102static inline int NCR5380_pread(struct Scsi_Host *host, unsigned char *addr,
103 int len)
104{
105 int iobase = host->io_port;
106 int iobase2= host->io_port + 0x100;
107 unsigned char *start = addr;
108 int s;
109printk("reading %p len %d\n",addr, len);
110 outb(inb(iobase + 128), iobase + 135);
111 while(len > 0)
112 {
113 int status,b,i, timeout;
114 timeout = 0x07FFFFFF;
115 while(((status = STAT(iobase)) & 0x100)==0)
116 {
117 timeout--;
118 if(status & 0x200 || !timeout)
119 {
120 printk("status = %p\n",status);
121 outb(0, iobase + 135);
122 return 1;
123 }
124 }
125 if(len >= 128)
126 {
127 for(i=0; i<64; i++)
128 {
129 b = inw(iobase + 136);
130 *addr++ = b;
131 *addr++ = b>>8;
132 }
133 len -= 128;
134 }
135 else
136 {
137 b = inw(iobase + 136);
138 *addr ++ = b;
139 len -= 1;
140 if(len)
141 *addr ++ = b>>8;
142 len -= 1;
143 }
144 }
145 outb(0, iobase + 135);
146 printk("first bytes = %02X %02X %02X %20X %02X %02X %02X\n",*start, start[1], start[2], start[3], start[4], start[5], start[6]);
147 return 1;
148}
149#endif
150#undef STAT
151
152#define BOARD_NORMAL 0 75#define BOARD_NORMAL 0
153#define BOARD_NCR53C400 1 76#define BOARD_NCR53C400 1
154 77
@@ -173,25 +96,36 @@ static struct Scsi_Host *host;
173 96
174static int __init ecoscsi_init(void) 97static int __init ecoscsi_init(void)
175{ 98{
99 void __iomem *_base;
100 int ret;
176 101
177 host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata)); 102 if (!request_mem_region(0x33a0000, 4096, "ecoscsi")) {
178 if (!host) 103 ret = -EBUSY;
179 return 0; 104 goto out;
105 }
180 106
181 host->io_port = 0x80ce8000; 107 _base = ioremap(0x33a0000, 4096);
182 host->n_io_port = 144; 108 if (!_base) {
183 host->irq = IRQ_NONE; 109 ret = -ENOMEM;
110 goto out_release;
111 }
184 112
185 if (!(request_region(host->io_port, host->n_io_port, "ecoscsi")) ) 113 NCR5380_write(MODE_REG, 0x20); /* Is it really SCSI? */
186 goto unregister_scsi; 114 if (NCR5380_read(MODE_REG) != 0x20) /* Write to a reg. */
115 goto out_unmap;
187 116
188 ecoscsi_write(host, MODE_REG, 0x20); /* Is it really SCSI? */ 117 NCR5380_write(MODE_REG, 0x00); /* it back. */
189 if (ecoscsi_read(host, MODE_REG) != 0x20) /* Write to a reg. */ 118 if (NCR5380_read(MODE_REG) != 0x00)
190 goto release_reg; 119 goto out_unmap;
191 120
192 ecoscsi_write(host, MODE_REG, 0x00 ); /* it back. */ 121 host = scsi_host_alloc(tpnt, sizeof(struct NCR5380_hostdata));
193 if (ecoscsi_read(host, MODE_REG) != 0x00) 122 if (!host) {
194 goto release_reg; 123 ret = -ENOMEM;
124 goto out_unmap;
125 }
126
127 priv(host)->base = _base;
128 host->irq = IRQ_NONE;
195 129
196 NCR5380_init(host, 0); 130 NCR5380_init(host, 0);
197 131
@@ -206,24 +140,20 @@ static int __init ecoscsi_init(void)
206 scsi_scan_host(host); 140 scsi_scan_host(host);
207 return 0; 141 return 0;
208 142
209release_reg: 143 out_unmap:
210 release_region(host->io_port, host->n_io_port); 144 iounmap(_base);
211unregister_scsi: 145 out_release:
212 scsi_host_put(host); 146 release_mem_region(0x33a0000, 4096);
213 return -ENODEV; 147 out:
148 return ret;
214} 149}
215 150
216static void __exit ecoscsi_exit(void) 151static void __exit ecoscsi_exit(void)
217{ 152{
218 scsi_remove_host(host); 153 scsi_remove_host(host);
219
220 if (shpnt->irq != IRQ_NONE)
221 free_irq(shpnt->irq, NULL);
222 NCR5380_exit(host); 154 NCR5380_exit(host);
223 if (shpnt->io_port)
224 release_region(shpnt->io_port, shpnt->n_io_port);
225
226 scsi_host_put(host); 155 scsi_host_put(host);
156 release_mem_region(0x33a0000, 4096);
227 return 0; 157 return 0;
228} 158}
229 159
diff --git a/drivers/scsi/arm/oak.c b/drivers/scsi/arm/oak.c
index c21b8392c928..849cdf89f7bb 100644
--- a/drivers/scsi/arm/oak.c
+++ b/drivers/scsi/arm/oak.c
@@ -23,15 +23,18 @@
23 23
24#define OAKSCSI_PUBLIC_RELEASE 1 24#define OAKSCSI_PUBLIC_RELEASE 1
25 25
26#define NCR5380_read(reg) oakscsi_read(_instance, reg) 26#define priv(host) ((struct NCR5380_hostdata *)(host)->hostdata)
27#define NCR5380_write(reg, value) oakscsi_write(_instance, reg, value) 27#define NCR5380_local_declare() void __iomem *_base
28#define NCR5380_setup(host) _base = priv(host)->base
29
30#define NCR5380_read(reg) readb(_base + ((reg) << 2))
31#define NCR5380_write(reg, value) writeb(value, _base + ((reg) << 2))
28#define NCR5380_intr oakscsi_intr 32#define NCR5380_intr oakscsi_intr
29#define NCR5380_queue_command oakscsi_queue_command 33#define NCR5380_queue_command oakscsi_queue_command
30#define NCR5380_proc_info oakscsi_proc_info 34#define NCR5380_proc_info oakscsi_proc_info
31 35
32#define NCR5380_implementation_fields int port, ctrl 36#define NCR5380_implementation_fields \
33#define NCR5380_local_declare() struct Scsi_Host *_instance 37 void __iomem *base
34#define NCR5380_setup(instance) _instance = instance
35 38
36#define BOARD_NORMAL 0 39#define BOARD_NORMAL 0
37#define BOARD_NCR53C400 1 40#define BOARD_NCR53C400 1
@@ -39,60 +42,62 @@
39#include "../NCR5380.h" 42#include "../NCR5380.h"
40 43
41#undef START_DMA_INITIATOR_RECEIVE_REG 44#undef START_DMA_INITIATOR_RECEIVE_REG
42#define START_DMA_INITIATOR_RECEIVE_REG (7 + 128) 45#define START_DMA_INITIATOR_RECEIVE_REG (128 + 7)
43 46
44const char * oakscsi_info (struct Scsi_Host *spnt) 47const char * oakscsi_info (struct Scsi_Host *spnt)
45{ 48{
46 return ""; 49 return "";
47} 50}
48 51
49#define STAT(p) inw(p + 144) 52#define STAT ((128 + 16) << 2)
50extern void inswb(int from, void *to, int len); 53#define DATA ((128 + 8) << 2)
51 54
52static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr, 55static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr,
53 int len) 56 int len)
54{ 57{
55 int iobase = instance->io_port; 58 void __iomem *base = priv(instance)->base;
59
56printk("writing %p len %d\n",addr, len); 60printk("writing %p len %d\n",addr, len);
57 if(!len) return -1; 61 if(!len) return -1;
58 62
59 while(1) 63 while(1)
60 { 64 {
61 int status; 65 int status;
62 while(((status = STAT(iobase)) & 0x100)==0); 66 while (((status = readw(base + STAT)) & 0x100)==0);
63 } 67 }
64} 68}
65 69
66static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr, 70static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
67 int len) 71 int len)
68{ 72{
69 int iobase = instance->io_port; 73 void __iomem *base = priv(instance)->base;
70printk("reading %p len %d\n", addr, len); 74printk("reading %p len %d\n", addr, len);
71 while(len > 0) 75 while(len > 0)
72 { 76 {
73 int status, timeout; 77 unsigned int status, timeout;
74 unsigned long b; 78 unsigned long b;
75 79
76 timeout = 0x01FFFFFF; 80 timeout = 0x01FFFFFF;
77 81
78 while(((status = STAT(iobase)) & 0x100)==0) 82 while (((status = readw(base + STAT)) & 0x100)==0)
79 { 83 {
80 timeout--; 84 timeout--;
81 if(status & 0x200 || !timeout) 85 if(status & 0x200 || !timeout)
82 { 86 {
83 printk("status = %08X\n",status); 87 printk("status = %08X\n", status);
84 return 1; 88 return 1;
85 } 89 }
86 } 90 }
91
87 if(len >= 128) 92 if(len >= 128)
88 { 93 {
89 inswb(iobase + 136, addr, 128); 94 readsw(base + DATA, addr, 128);
90 addr += 128; 95 addr += 128;
91 len -= 128; 96 len -= 128;
92 } 97 }
93 else 98 else
94 { 99 {
95 b = (unsigned long) inw(iobase + 136); 100 b = (unsigned long) readw(base + DATA);
96 *addr ++ = b; 101 *addr ++ = b;
97 len -= 1; 102 len -= 1;
98 if(len) 103 if(len)
@@ -103,10 +108,8 @@ printk("reading %p len %d\n", addr, len);
103 return 0; 108 return 0;
104} 109}
105 110
106#define oakscsi_read(instance,reg) (inb((instance)->io_port + (reg)))
107#define oakscsi_write(instance,reg,val) (outb((val), (instance)->io_port + (reg)))
108
109#undef STAT 111#undef STAT
112#undef DATA
110 113
111#include "../NCR5380.c" 114#include "../NCR5380.c"
112 115
@@ -132,18 +135,26 @@ oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
132 struct Scsi_Host *host; 135 struct Scsi_Host *host;
133 int ret = -ENOMEM; 136 int ret = -ENOMEM;
134 137
135 host = scsi_host_alloc(&oakscsi_template, sizeof(struct NCR5380_hostdata)); 138 ret = ecard_request_resources(ec);
136 if (!host) 139 if (ret)
137 goto out; 140 goto out;
138 141
139 host->io_port = ecard_address(ec, ECARD_MEMC, 0); 142 host = scsi_host_alloc(&oakscsi_template, sizeof(struct NCR5380_hostdata));
143 if (!host) {
144 ret = -ENOMEM;
145 goto release;
146 }
147
148 priv(host)->base = ioremap(ecard_resource_start(ec, ECARD_RES_MEMC),
149 ecard_resource_len(ec, ECARD_RES_MEMC));
150 if (!priv(host)->base) {
151 ret = -ENOMEM;
152 goto unreg;
153 }
154
140 host->irq = IRQ_NONE; 155 host->irq = IRQ_NONE;
141 host->n_io_port = 255; 156 host->n_io_port = 255;
142 157
143 ret = -EBUSY;
144 if (!request_region (host->io_port, host->n_io_port, "Oak SCSI"))
145 goto unreg;
146
147 NCR5380_init(host, 0); 158 NCR5380_init(host, 0);
148 159
149 printk("scsi%d: at port 0x%08lx irqs disabled", 160 printk("scsi%d: at port 0x%08lx irqs disabled",
@@ -156,15 +167,17 @@ oakscsi_probe(struct expansion_card *ec, const struct ecard_id *id)
156 167
157 ret = scsi_add_host(host, &ec->dev); 168 ret = scsi_add_host(host, &ec->dev);
158 if (ret) 169 if (ret)
159 goto out_release; 170 goto out_unmap;
160 171
161 scsi_scan_host(host); 172 scsi_scan_host(host);
162 goto out; 173 goto out;
163 174
164 out_release: 175 out_unmap:
165 release_region(host->io_port, host->n_io_port); 176 iounmap(priv(host)->base);
166 unreg: 177 unreg:
167 scsi_host_put(host); 178 scsi_host_put(host);
179 release:
180 ecard_release_resources(ec);
168 out: 181 out:
169 return ret; 182 return ret;
170} 183}
@@ -177,8 +190,9 @@ static void __devexit oakscsi_remove(struct expansion_card *ec)
177 scsi_remove_host(host); 190 scsi_remove_host(host);
178 191
179 NCR5380_exit(host); 192 NCR5380_exit(host);
180 release_region(host->io_port, host->n_io_port); 193 iounmap(priv(host)->base);
181 scsi_host_put(host); 194 scsi_host_put(host);
195 ecard_release_resources(ec);
182} 196}
183 197
184static const struct ecard_id oakscsi_cids[] = { 198static const struct ecard_id oakscsi_cids[] = {
diff --git a/drivers/scsi/bvme6000_scsi.c b/drivers/scsi/bvme6000_scsi.c
index 012cdea7946d..cac354086737 100644
--- a/drivers/scsi/bvme6000_scsi.c
+++ b/drivers/scsi/bvme6000_scsi.c
@@ -74,6 +74,7 @@ bvme6000_probe(struct device *dev)
74 goto out_put_host; 74 goto out_put_host;
75 } 75 }
76 76
77 dev_set_drvdata(dev, host);
77 scsi_scan_host(host); 78 scsi_scan_host(host);
78 79
79 return 0; 80 return 0;
@@ -89,7 +90,7 @@ bvme6000_probe(struct device *dev)
89static __devexit int 90static __devexit int
90bvme6000_device_remove(struct device *dev) 91bvme6000_device_remove(struct device *dev)
91{ 92{
92 struct Scsi_Host *host = dev_to_shost(dev); 93 struct Scsi_Host *host = dev_get_drvdata(dev);
93 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 94 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
94 95
95 scsi_remove_host(host); 96 scsi_remove_host(host);
diff --git a/drivers/scsi/esp_scsi.h b/drivers/scsi/esp_scsi.h
index d5576d54ce76..856e38b14861 100644
--- a/drivers/scsi/esp_scsi.h
+++ b/drivers/scsi/esp_scsi.h
@@ -220,7 +220,7 @@
220#define ESP_BUSID_RESELID 0x10 220#define ESP_BUSID_RESELID 0x10
221#define ESP_BUSID_CTR32BIT 0x40 221#define ESP_BUSID_CTR32BIT 0x40
222 222
223#define ESP_BUS_TIMEOUT 250 /* In milli-seconds */ 223#define ESP_BUS_TIMEOUT 275 /* In milli-seconds */
224#define ESP_TIMEO_CONST 8192 224#define ESP_TIMEO_CONST 8192
225#define ESP_NEG_DEFP(mhz, cfact) \ 225#define ESP_NEG_DEFP(mhz, cfact) \
226 ((ESP_BUS_TIMEOUT * ((mhz) / 1000)) / (8192 * (cfact))) 226 ((ESP_BUS_TIMEOUT * ((mhz) / 1000)) / (8192 * (cfact)))
diff --git a/drivers/scsi/libsas/Kconfig b/drivers/scsi/libsas/Kconfig
index aafdc92f8312..3a3c1ac9c6cd 100644
--- a/drivers/scsi/libsas/Kconfig
+++ b/drivers/scsi/libsas/Kconfig
@@ -30,6 +30,13 @@ config SCSI_SAS_LIBSAS
30 This provides transport specific helpers for SAS drivers which 30 This provides transport specific helpers for SAS drivers which
31 use the domain device construct (like the aic94xxx). 31 use the domain device construct (like the aic94xxx).
32 32
33config SCSI_SAS_ATA
34 bool "ATA support for libsas (requires libata)"
35 depends on SCSI_SAS_LIBSAS && ATA
36 help
37 Builds in ATA support into libsas. Will necessitate
38 the loading of libata along with libsas.
39
33config SCSI_SAS_LIBSAS_DEBUG 40config SCSI_SAS_LIBSAS_DEBUG
34 bool "Compile the SAS Domain Transport Attributes in debug mode" 41 bool "Compile the SAS Domain Transport Attributes in debug mode"
35 default y 42 default y
diff --git a/drivers/scsi/libsas/Makefile b/drivers/scsi/libsas/Makefile
index 44d972a3b4bd..fd387b91856e 100644
--- a/drivers/scsi/libsas/Makefile
+++ b/drivers/scsi/libsas/Makefile
@@ -34,3 +34,4 @@ libsas-y += sas_init.o \
34 sas_discover.o \ 34 sas_discover.o \
35 sas_expander.o \ 35 sas_expander.o \
36 sas_scsi_host.o 36 sas_scsi_host.o
37libsas-$(CONFIG_SCSI_SAS_ATA) += sas_ata.o
diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
new file mode 100644
index 000000000000..ced2de32c511
--- /dev/null
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -0,0 +1,817 @@
1/*
2 * Support for SATA devices on Serial Attached SCSI (SAS) controllers
3 *
4 * Copyright (C) 2006 IBM Corporation
5 *
6 * Written by: Darrick J. Wong <djwong@us.ibm.com>, IBM Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
22 */
23
24#include <linux/scatterlist.h>
25
26#include <scsi/sas_ata.h>
27#include "sas_internal.h"
28#include <scsi/scsi_host.h>
29#include <scsi/scsi_device.h>
30#include <scsi/scsi_tcq.h>
31#include <scsi/scsi.h>
32#include <scsi/scsi_transport.h>
33#include <scsi/scsi_transport_sas.h>
34#include "../scsi_sas_internal.h"
35#include "../scsi_transport_api.h"
36#include <scsi/scsi_eh.h>
37
38static enum ata_completion_errors sas_to_ata_err(struct task_status_struct *ts)
39{
40 /* Cheesy attempt to translate SAS errors into ATA. Hah! */
41
42 /* transport error */
43 if (ts->resp == SAS_TASK_UNDELIVERED)
44 return AC_ERR_ATA_BUS;
45
46 /* ts->resp == SAS_TASK_COMPLETE */
47 /* task delivered, what happened afterwards? */
48 switch (ts->stat) {
49 case SAS_DEV_NO_RESPONSE:
50 return AC_ERR_TIMEOUT;
51
52 case SAS_INTERRUPTED:
53 case SAS_PHY_DOWN:
54 case SAS_NAK_R_ERR:
55 return AC_ERR_ATA_BUS;
56
57
58 case SAS_DATA_UNDERRUN:
59 /*
60 * Some programs that use the taskfile interface
61 * (smartctl in particular) can cause underrun
62 * problems. Ignore these errors, perhaps at our
63 * peril.
64 */
65 return 0;
66
67 case SAS_DATA_OVERRUN:
68 case SAS_QUEUE_FULL:
69 case SAS_DEVICE_UNKNOWN:
70 case SAS_SG_ERR:
71 return AC_ERR_INVALID;
72
73 case SAM_CHECK_COND:
74 case SAS_OPEN_TO:
75 case SAS_OPEN_REJECT:
76 SAS_DPRINTK("%s: Saw error %d. What to do?\n",
77 __FUNCTION__, ts->stat);
78 return AC_ERR_OTHER;
79
80 case SAS_ABORTED_TASK:
81 return AC_ERR_DEV;
82
83 case SAS_PROTO_RESPONSE:
84 /* This means the ending_fis has the error
85 * value; return 0 here to collect it */
86 return 0;
87 default:
88 return 0;
89 }
90}
91
92static void sas_ata_task_done(struct sas_task *task)
93{
94 struct ata_queued_cmd *qc = task->uldd_task;
95 struct domain_device *dev;
96 struct task_status_struct *stat = &task->task_status;
97 struct ata_task_resp *resp = (struct ata_task_resp *)stat->buf;
98 struct sas_ha_struct *sas_ha;
99 enum ata_completion_errors ac;
100 unsigned long flags;
101
102 if (!qc)
103 goto qc_already_gone;
104
105 dev = qc->ap->private_data;
106 sas_ha = dev->port->ha;
107
108 spin_lock_irqsave(dev->sata_dev.ap->lock, flags);
109 if (stat->stat == SAS_PROTO_RESPONSE || stat->stat == SAM_GOOD) {
110 ata_tf_from_fis(resp->ending_fis, &dev->sata_dev.tf);
111 qc->err_mask |= ac_err_mask(dev->sata_dev.tf.command);
112 dev->sata_dev.sstatus = resp->sstatus;
113 dev->sata_dev.serror = resp->serror;
114 dev->sata_dev.scontrol = resp->scontrol;
115 } else if (stat->stat != SAM_STAT_GOOD) {
116 ac = sas_to_ata_err(stat);
117 if (ac) {
118 SAS_DPRINTK("%s: SAS error %x\n", __FUNCTION__,
119 stat->stat);
120 /* We saw a SAS error. Send a vague error. */
121 qc->err_mask = ac;
122 dev->sata_dev.tf.feature = 0x04; /* status err */
123 dev->sata_dev.tf.command = ATA_ERR;
124 }
125 }
126
127 qc->lldd_task = NULL;
128 if (qc->scsicmd)
129 ASSIGN_SAS_TASK(qc->scsicmd, NULL);
130 ata_qc_complete(qc);
131 spin_unlock_irqrestore(dev->sata_dev.ap->lock, flags);
132
133 /*
134 * If the sas_task has an ata qc, a scsi_cmnd and the aborted
135 * flag is set, then we must have come in via the libsas EH
136 * functions. When we exit this function, we need to put the
137 * scsi_cmnd on the list of finished errors. The ata_qc_complete
138 * call cleans up the libata side of things but we're protected
139 * from the scsi_cmnd going away because the scsi_cmnd is owned
140 * by the EH, making libata's call to scsi_done a NOP.
141 */
142 spin_lock_irqsave(&task->task_state_lock, flags);
143 if (qc->scsicmd && task->task_state_flags & SAS_TASK_STATE_ABORTED)
144 scsi_eh_finish_cmd(qc->scsicmd, &sas_ha->eh_done_q);
145 spin_unlock_irqrestore(&task->task_state_lock, flags);
146
147qc_already_gone:
148 list_del_init(&task->list);
149 sas_free_task(task);
150}
151
152static unsigned int sas_ata_qc_issue(struct ata_queued_cmd *qc)
153{
154 int res;
155 struct sas_task *task;
156 struct domain_device *dev = qc->ap->private_data;
157 struct sas_ha_struct *sas_ha = dev->port->ha;
158 struct Scsi_Host *host = sas_ha->core.shost;
159 struct sas_internal *i = to_sas_internal(host->transportt);
160 struct scatterlist *sg;
161 unsigned int num = 0;
162 unsigned int xfer = 0;
163
164 task = sas_alloc_task(GFP_ATOMIC);
165 if (!task)
166 return AC_ERR_SYSTEM;
167 task->dev = dev;
168 task->task_proto = SAS_PROTOCOL_STP;
169 task->task_done = sas_ata_task_done;
170
171 if (qc->tf.command == ATA_CMD_FPDMA_WRITE ||
172 qc->tf.command == ATA_CMD_FPDMA_READ) {
173 /* Need to zero out the tag libata assigned us */
174 qc->tf.nsect = 0;
175 }
176
177 ata_tf_to_fis(&qc->tf, 1, 0, (u8*)&task->ata_task.fis);
178 task->uldd_task = qc;
179 if (is_atapi_taskfile(&qc->tf)) {
180 memcpy(task->ata_task.atapi_packet, qc->cdb, qc->dev->cdb_len);
181 task->total_xfer_len = qc->nbytes + qc->pad_len;
182 task->num_scatter = qc->pad_len ? qc->n_elem + 1 : qc->n_elem;
183 } else {
184 ata_for_each_sg(sg, qc) {
185 num++;
186 xfer += sg->length;
187 }
188
189 task->total_xfer_len = xfer;
190 task->num_scatter = num;
191 }
192
193 task->data_dir = qc->dma_dir;
194 task->scatter = qc->__sg;
195 task->ata_task.retry_count = 1;
196 task->task_state_flags = SAS_TASK_STATE_PENDING;
197 qc->lldd_task = task;
198
199 switch (qc->tf.protocol) {
200 case ATA_PROT_NCQ:
201 task->ata_task.use_ncq = 1;
202 /* fall through */
203 case ATA_PROT_ATAPI_DMA:
204 case ATA_PROT_DMA:
205 task->ata_task.dma_xfer = 1;
206 break;
207 }
208
209 if (qc->scsicmd)
210 ASSIGN_SAS_TASK(qc->scsicmd, task);
211
212 if (sas_ha->lldd_max_execute_num < 2)
213 res = i->dft->lldd_execute_task(task, 1, GFP_ATOMIC);
214 else
215 res = sas_queue_up(task);
216
217 /* Examine */
218 if (res) {
219 SAS_DPRINTK("lldd_execute_task returned: %d\n", res);
220
221 if (qc->scsicmd)
222 ASSIGN_SAS_TASK(qc->scsicmd, NULL);
223 sas_free_task(task);
224 return AC_ERR_SYSTEM;
225 }
226
227 return 0;
228}
229
230static u8 sas_ata_check_status(struct ata_port *ap)
231{
232 struct domain_device *dev = ap->private_data;
233 return dev->sata_dev.tf.command;
234}
235
236static void sas_ata_phy_reset(struct ata_port *ap)
237{
238 struct domain_device *dev = ap->private_data;
239 struct sas_internal *i =
240 to_sas_internal(dev->port->ha->core.shost->transportt);
241 int res = 0;
242
243 if (i->dft->lldd_I_T_nexus_reset)
244 res = i->dft->lldd_I_T_nexus_reset(dev);
245
246 if (res)
247 SAS_DPRINTK("%s: Unable to reset I T nexus?\n", __FUNCTION__);
248
249 switch (dev->sata_dev.command_set) {
250 case ATA_COMMAND_SET:
251 SAS_DPRINTK("%s: Found ATA device.\n", __FUNCTION__);
252 ap->device[0].class = ATA_DEV_ATA;
253 break;
254 case ATAPI_COMMAND_SET:
255 SAS_DPRINTK("%s: Found ATAPI device.\n", __FUNCTION__);
256 ap->device[0].class = ATA_DEV_ATAPI;
257 break;
258 default:
259 SAS_DPRINTK("%s: Unknown SATA command set: %d.\n",
260 __FUNCTION__,
261 dev->sata_dev.command_set);
262 ap->device[0].class = ATA_DEV_UNKNOWN;
263 break;
264 }
265
266 ap->cbl = ATA_CBL_SATA;
267}
268
269static void sas_ata_post_internal(struct ata_queued_cmd *qc)
270{
271 if (qc->flags & ATA_QCFLAG_FAILED)
272 qc->err_mask |= AC_ERR_OTHER;
273
274 if (qc->err_mask) {
275 /*
276 * Find the sas_task and kill it. By this point,
277 * libata has decided to kill the qc, so we needn't
278 * bother with sas_ata_task_done. But we still
279 * ought to abort the task.
280 */
281 struct sas_task *task = qc->lldd_task;
282 unsigned long flags;
283
284 qc->lldd_task = NULL;
285 if (task) {
286 /* Should this be a AT(API) device reset? */
287 spin_lock_irqsave(&task->task_state_lock, flags);
288 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
289 spin_unlock_irqrestore(&task->task_state_lock, flags);
290
291 task->uldd_task = NULL;
292 __sas_task_abort(task);
293 }
294 }
295}
296
297static void sas_ata_tf_read(struct ata_port *ap, struct ata_taskfile *tf)
298{
299 struct domain_device *dev = ap->private_data;
300 memcpy(tf, &dev->sata_dev.tf, sizeof (*tf));
301}
302
303static int sas_ata_scr_write(struct ata_port *ap, unsigned int sc_reg_in,
304 u32 val)
305{
306 struct domain_device *dev = ap->private_data;
307
308 SAS_DPRINTK("STUB %s\n", __FUNCTION__);
309 switch (sc_reg_in) {
310 case SCR_STATUS:
311 dev->sata_dev.sstatus = val;
312 break;
313 case SCR_CONTROL:
314 dev->sata_dev.scontrol = val;
315 break;
316 case SCR_ERROR:
317 dev->sata_dev.serror = val;
318 break;
319 case SCR_ACTIVE:
320 dev->sata_dev.ap->sactive = val;
321 break;
322 default:
323 return -EINVAL;
324 }
325 return 0;
326}
327
328static int sas_ata_scr_read(struct ata_port *ap, unsigned int sc_reg_in,
329 u32 *val)
330{
331 struct domain_device *dev = ap->private_data;
332
333 SAS_DPRINTK("STUB %s\n", __FUNCTION__);
334 switch (sc_reg_in) {
335 case SCR_STATUS:
336 *val = dev->sata_dev.sstatus;
337 return 0;
338 case SCR_CONTROL:
339 *val = dev->sata_dev.scontrol;
340 return 0;
341 case SCR_ERROR:
342 *val = dev->sata_dev.serror;
343 return 0;
344 case SCR_ACTIVE:
345 *val = dev->sata_dev.ap->sactive;
346 return 0;
347 default:
348 return -EINVAL;
349 }
350}
351
352static struct ata_port_operations sas_sata_ops = {
353 .port_disable = ata_port_disable,
354 .check_status = sas_ata_check_status,
355 .check_altstatus = sas_ata_check_status,
356 .dev_select = ata_noop_dev_select,
357 .phy_reset = sas_ata_phy_reset,
358 .post_internal_cmd = sas_ata_post_internal,
359 .tf_read = sas_ata_tf_read,
360 .qc_prep = ata_noop_qc_prep,
361 .qc_issue = sas_ata_qc_issue,
362 .port_start = ata_sas_port_start,
363 .port_stop = ata_sas_port_stop,
364 .scr_read = sas_ata_scr_read,
365 .scr_write = sas_ata_scr_write
366};
367
368static struct ata_port_info sata_port_info = {
369 .flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | ATA_FLAG_SATA_RESET |
370 ATA_FLAG_MMIO | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ,
371 .pio_mask = 0x1f, /* PIO0-4 */
372 .mwdma_mask = 0x07, /* MWDMA0-2 */
373 .udma_mask = ATA_UDMA6,
374 .port_ops = &sas_sata_ops
375};
376
377int sas_ata_init_host_and_port(struct domain_device *found_dev,
378 struct scsi_target *starget)
379{
380 struct Scsi_Host *shost = dev_to_shost(&starget->dev);
381 struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
382 struct ata_port *ap;
383
384 ata_host_init(&found_dev->sata_dev.ata_host,
385 &ha->pcidev->dev,
386 sata_port_info.flags,
387 &sas_sata_ops);
388 ap = ata_sas_port_alloc(&found_dev->sata_dev.ata_host,
389 &sata_port_info,
390 shost);
391 if (!ap) {
392 SAS_DPRINTK("ata_sas_port_alloc failed.\n");
393 return -ENODEV;
394 }
395
396 ap->private_data = found_dev;
397 ap->cbl = ATA_CBL_SATA;
398 ap->scsi_host = shost;
399 found_dev->sata_dev.ap = ap;
400
401 return 0;
402}
403
404void sas_ata_task_abort(struct sas_task *task)
405{
406 struct ata_queued_cmd *qc = task->uldd_task;
407 struct completion *waiting;
408
409 /* Bounce SCSI-initiated commands to the SCSI EH */
410 if (qc->scsicmd) {
411 scsi_req_abort_cmd(qc->scsicmd);
412 scsi_schedule_eh(qc->scsicmd->device->host);
413 return;
414 }
415
416 /* Internal command, fake a timeout and complete. */
417 qc->flags &= ~ATA_QCFLAG_ACTIVE;
418 qc->flags |= ATA_QCFLAG_FAILED;
419 qc->err_mask |= AC_ERR_TIMEOUT;
420 waiting = qc->private_data;
421 complete(waiting);
422}
423
424static void sas_task_timedout(unsigned long _task)
425{
426 struct sas_task *task = (void *) _task;
427 unsigned long flags;
428
429 spin_lock_irqsave(&task->task_state_lock, flags);
430 if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
431 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
432 spin_unlock_irqrestore(&task->task_state_lock, flags);
433
434 complete(&task->completion);
435}
436
437static void sas_disc_task_done(struct sas_task *task)
438{
439 if (!del_timer(&task->timer))
440 return;
441 complete(&task->completion);
442}
443
444#define SAS_DEV_TIMEOUT 10
445
446/**
447 * sas_execute_task -- Basic task processing for discovery
448 * @task: the task to be executed
449 * @buffer: pointer to buffer to do I/O
450 * @size: size of @buffer
451 * @pci_dma_dir: PCI_DMA_...
452 */
453static int sas_execute_task(struct sas_task *task, void *buffer, int size,
454 int pci_dma_dir)
455{
456 int res = 0;
457 struct scatterlist *scatter = NULL;
458 struct task_status_struct *ts = &task->task_status;
459 int num_scatter = 0;
460 int retries = 0;
461 struct sas_internal *i =
462 to_sas_internal(task->dev->port->ha->core.shost->transportt);
463
464 if (pci_dma_dir != PCI_DMA_NONE) {
465 scatter = kzalloc(sizeof(*scatter), GFP_KERNEL);
466 if (!scatter)
467 goto out;
468
469 sg_init_one(scatter, buffer, size);
470 num_scatter = 1;
471 }
472
473 task->task_proto = task->dev->tproto;
474 task->scatter = scatter;
475 task->num_scatter = num_scatter;
476 task->total_xfer_len = size;
477 task->data_dir = pci_dma_dir;
478 task->task_done = sas_disc_task_done;
479 if (pci_dma_dir != PCI_DMA_NONE &&
480 sas_protocol_ata(task->task_proto)) {
481 task->num_scatter = pci_map_sg(task->dev->port->ha->pcidev,
482 task->scatter,
483 task->num_scatter,
484 task->data_dir);
485 }
486
487 for (retries = 0; retries < 5; retries++) {
488 task->task_state_flags = SAS_TASK_STATE_PENDING;
489 init_completion(&task->completion);
490
491 task->timer.data = (unsigned long) task;
492 task->timer.function = sas_task_timedout;
493 task->timer.expires = jiffies + SAS_DEV_TIMEOUT*HZ;
494 add_timer(&task->timer);
495
496 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL);
497 if (res) {
498 del_timer(&task->timer);
499 SAS_DPRINTK("executing SAS discovery task failed:%d\n",
500 res);
501 goto ex_err;
502 }
503 wait_for_completion(&task->completion);
504 res = -ETASK;
505 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
506 int res2;
507 SAS_DPRINTK("task aborted, flags:0x%x\n",
508 task->task_state_flags);
509 res2 = i->dft->lldd_abort_task(task);
510 SAS_DPRINTK("came back from abort task\n");
511 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
512 if (res2 == TMF_RESP_FUNC_COMPLETE)
513 continue; /* Retry the task */
514 else
515 goto ex_err;
516 }
517 }
518 if (task->task_status.stat == SAM_BUSY ||
519 task->task_status.stat == SAM_TASK_SET_FULL ||
520 task->task_status.stat == SAS_QUEUE_FULL) {
521 SAS_DPRINTK("task: q busy, sleeping...\n");
522 schedule_timeout_interruptible(HZ);
523 } else if (task->task_status.stat == SAM_CHECK_COND) {
524 struct scsi_sense_hdr shdr;
525
526 if (!scsi_normalize_sense(ts->buf, ts->buf_valid_size,
527 &shdr)) {
528 SAS_DPRINTK("couldn't normalize sense\n");
529 continue;
530 }
531 if ((shdr.sense_key == 6 && shdr.asc == 0x29) ||
532 (shdr.sense_key == 2 && shdr.asc == 4 &&
533 shdr.ascq == 1)) {
534 SAS_DPRINTK("device %016llx LUN: %016llx "
535 "powering up or not ready yet, "
536 "sleeping...\n",
537 SAS_ADDR(task->dev->sas_addr),
538 SAS_ADDR(task->ssp_task.LUN));
539
540 schedule_timeout_interruptible(5*HZ);
541 } else if (shdr.sense_key == 1) {
542 res = 0;
543 break;
544 } else if (shdr.sense_key == 5) {
545 break;
546 } else {
547 SAS_DPRINTK("dev %016llx LUN: %016llx "
548 "sense key:0x%x ASC:0x%x ASCQ:0x%x"
549 "\n",
550 SAS_ADDR(task->dev->sas_addr),
551 SAS_ADDR(task->ssp_task.LUN),
552 shdr.sense_key,
553 shdr.asc, shdr.ascq);
554 }
555 } else if (task->task_status.resp != SAS_TASK_COMPLETE ||
556 task->task_status.stat != SAM_GOOD) {
557 SAS_DPRINTK("task finished with resp:0x%x, "
558 "stat:0x%x\n",
559 task->task_status.resp,
560 task->task_status.stat);
561 goto ex_err;
562 } else {
563 res = 0;
564 break;
565 }
566 }
567ex_err:
568 if (pci_dma_dir != PCI_DMA_NONE) {
569 if (sas_protocol_ata(task->task_proto))
570 pci_unmap_sg(task->dev->port->ha->pcidev,
571 task->scatter, task->num_scatter,
572 task->data_dir);
573 kfree(scatter);
574 }
575out:
576 return res;
577}
578
579/* ---------- SATA ---------- */
580
581static void sas_get_ata_command_set(struct domain_device *dev)
582{
583 struct dev_to_host_fis *fis =
584 (struct dev_to_host_fis *) dev->frame_rcvd;
585
586 if ((fis->sector_count == 1 && /* ATA */
587 fis->lbal == 1 &&
588 fis->lbam == 0 &&
589 fis->lbah == 0 &&
590 fis->device == 0)
591 ||
592 (fis->sector_count == 0 && /* CE-ATA (mATA) */
593 fis->lbal == 0 &&
594 fis->lbam == 0xCE &&
595 fis->lbah == 0xAA &&
596 (fis->device & ~0x10) == 0))
597
598 dev->sata_dev.command_set = ATA_COMMAND_SET;
599
600 else if ((fis->interrupt_reason == 1 && /* ATAPI */
601 fis->lbal == 1 &&
602 fis->byte_count_low == 0x14 &&
603 fis->byte_count_high == 0xEB &&
604 (fis->device & ~0x10) == 0))
605
606 dev->sata_dev.command_set = ATAPI_COMMAND_SET;
607
608 else if ((fis->sector_count == 1 && /* SEMB */
609 fis->lbal == 1 &&
610 fis->lbam == 0x3C &&
611 fis->lbah == 0xC3 &&
612 fis->device == 0)
613 ||
614 (fis->interrupt_reason == 1 && /* SATA PM */
615 fis->lbal == 1 &&
616 fis->byte_count_low == 0x69 &&
617 fis->byte_count_high == 0x96 &&
618 (fis->device & ~0x10) == 0))
619
620 /* Treat it as a superset? */
621 dev->sata_dev.command_set = ATAPI_COMMAND_SET;
622}
623
624/**
625 * sas_issue_ata_cmd -- Basic SATA command processing for discovery
626 * @dev: the device to send the command to
627 * @command: the command register
628 * @features: the features register
629 * @buffer: pointer to buffer to do I/O
630 * @size: size of @buffer
631 * @pci_dma_dir: PCI_DMA_...
632 */
633static int sas_issue_ata_cmd(struct domain_device *dev, u8 command,
634 u8 features, void *buffer, int size,
635 int pci_dma_dir)
636{
637 int res = 0;
638 struct sas_task *task;
639 struct dev_to_host_fis *d2h_fis = (struct dev_to_host_fis *)
640 &dev->frame_rcvd[0];
641
642 res = -ENOMEM;
643 task = sas_alloc_task(GFP_KERNEL);
644 if (!task)
645 goto out;
646
647 task->dev = dev;
648
649 task->ata_task.fis.fis_type = 0x27;
650 task->ata_task.fis.command = command;
651 task->ata_task.fis.features = features;
652 task->ata_task.fis.device = d2h_fis->device;
653 task->ata_task.retry_count = 1;
654
655 res = sas_execute_task(task, buffer, size, pci_dma_dir);
656
657 sas_free_task(task);
658out:
659 return res;
660}
661
662static void sas_sata_propagate_sas_addr(struct domain_device *dev)
663{
664 unsigned long flags;
665 struct asd_sas_port *port = dev->port;
666 struct asd_sas_phy *phy;
667
668 BUG_ON(dev->parent);
669
670 memcpy(port->attached_sas_addr, dev->sas_addr, SAS_ADDR_SIZE);
671 spin_lock_irqsave(&port->phy_list_lock, flags);
672 list_for_each_entry(phy, &port->phy_list, port_phy_el)
673 memcpy(phy->attached_sas_addr, dev->sas_addr, SAS_ADDR_SIZE);
674 spin_unlock_irqrestore(&port->phy_list_lock, flags);
675}
676
677#define ATA_IDENTIFY_DEV 0xEC
678#define ATA_IDENTIFY_PACKET_DEV 0xA1
679#define ATA_SET_FEATURES 0xEF
680#define ATA_FEATURE_PUP_STBY_SPIN_UP 0x07
681
682/**
683 * sas_discover_sata_dev -- discover a STP/SATA device (SATA_DEV)
684 * @dev: STP/SATA device of interest (ATA/ATAPI)
685 *
686 * The LLDD has already been notified of this device, so that we can
687 * send FISes to it. Here we try to get IDENTIFY DEVICE or IDENTIFY
688 * PACKET DEVICE, if ATAPI device, so that the LLDD can fine-tune its
689 * performance for this device.
690 */
691static int sas_discover_sata_dev(struct domain_device *dev)
692{
693 int res;
694 __le16 *identify_x;
695 u8 command;
696
697 identify_x = kzalloc(512, GFP_KERNEL);
698 if (!identify_x)
699 return -ENOMEM;
700
701 if (dev->sata_dev.command_set == ATA_COMMAND_SET) {
702 dev->sata_dev.identify_device = identify_x;
703 command = ATA_IDENTIFY_DEV;
704 } else {
705 dev->sata_dev.identify_packet_device = identify_x;
706 command = ATA_IDENTIFY_PACKET_DEV;
707 }
708
709 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512,
710 PCI_DMA_FROMDEVICE);
711 if (res)
712 goto out_err;
713
714 /* lives on the media? */
715 if (le16_to_cpu(identify_x[0]) & 4) {
716 /* incomplete response */
717 SAS_DPRINTK("sending SET FEATURE/PUP_STBY_SPIN_UP to "
718 "dev %llx\n", SAS_ADDR(dev->sas_addr));
719 if (!le16_to_cpu(identify_x[83] & (1<<6)))
720 goto cont1;
721 res = sas_issue_ata_cmd(dev, ATA_SET_FEATURES,
722 ATA_FEATURE_PUP_STBY_SPIN_UP,
723 NULL, 0, PCI_DMA_NONE);
724 if (res)
725 goto cont1;
726
727 schedule_timeout_interruptible(5*HZ); /* More time? */
728 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512,
729 PCI_DMA_FROMDEVICE);
730 if (res)
731 goto out_err;
732 }
733cont1:
734 /* Get WWN */
735 if (dev->port->oob_mode != SATA_OOB_MODE) {
736 memcpy(dev->sas_addr, dev->sata_dev.rps_resp.rps.stp_sas_addr,
737 SAS_ADDR_SIZE);
738 } else if (dev->sata_dev.command_set == ATA_COMMAND_SET &&
739 (le16_to_cpu(dev->sata_dev.identify_device[108]) & 0xF000)
740 == 0x5000) {
741 int i;
742
743 for (i = 0; i < 4; i++) {
744 dev->sas_addr[2*i] =
745 (le16_to_cpu(dev->sata_dev.identify_device[108+i]) & 0xFF00) >> 8;
746 dev->sas_addr[2*i+1] =
747 le16_to_cpu(dev->sata_dev.identify_device[108+i]) & 0x00FF;
748 }
749 }
750 sas_hash_addr(dev->hashed_sas_addr, dev->sas_addr);
751 if (!dev->parent)
752 sas_sata_propagate_sas_addr(dev);
753
754 /* XXX Hint: register this SATA device with SATL.
755 When this returns, dev->sata_dev->lu is alive and
756 present.
757 sas_satl_register_dev(dev);
758 */
759
760 sas_fill_in_rphy(dev, dev->rphy);
761
762 return 0;
763out_err:
764 dev->sata_dev.identify_packet_device = NULL;
765 dev->sata_dev.identify_device = NULL;
766 kfree(identify_x);
767 return res;
768}
769
770static int sas_discover_sata_pm(struct domain_device *dev)
771{
772 return -ENODEV;
773}
774
775/**
776 * sas_discover_sata -- discover an STP/SATA domain device
777 * @dev: pointer to struct domain_device of interest
778 *
779 * First we notify the LLDD of this device, so we can send frames to
780 * it. Then depending on the type of device we call the appropriate
781 * discover functions. Once device discover is done, we notify the
782 * LLDD so that it can fine-tune its parameters for the device, by
783 * removing it and then adding it. That is, the second time around,
784 * the driver would have certain fields, that it is looking at, set.
785 * Finally we initialize the kobj so that the device can be added to
786 * the system at registration time. Devices directly attached to a HA
787 * port, have no parents. All other devices do, and should have their
788 * "parent" pointer set appropriately before calling this function.
789 */
790int sas_discover_sata(struct domain_device *dev)
791{
792 int res;
793
794 sas_get_ata_command_set(dev);
795
796 res = sas_notify_lldd_dev_found(dev);
797 if (res)
798 return res;
799
800 switch (dev->dev_type) {
801 case SATA_DEV:
802 res = sas_discover_sata_dev(dev);
803 break;
804 case SATA_PM:
805 res = sas_discover_sata_pm(dev);
806 break;
807 default:
808 break;
809 }
810 sas_notify_lldd_dev_gone(dev);
811 if (!res) {
812 sas_notify_lldd_dev_found(dev);
813 res = sas_rphy_add(dev->rphy);
814 }
815
816 return res;
817}
diff --git a/drivers/scsi/libsas/sas_discover.c b/drivers/scsi/libsas/sas_discover.c
index a65598b1e536..6ac9f61d006a 100644
--- a/drivers/scsi/libsas/sas_discover.c
+++ b/drivers/scsi/libsas/sas_discover.c
@@ -55,149 +55,6 @@ void sas_init_dev(struct domain_device *dev)
55 } 55 }
56} 56}
57 57
58static void sas_task_timedout(unsigned long _task)
59{
60 struct sas_task *task = (void *) _task;
61 unsigned long flags;
62
63 spin_lock_irqsave(&task->task_state_lock, flags);
64 if (!(task->task_state_flags & SAS_TASK_STATE_DONE))
65 task->task_state_flags |= SAS_TASK_STATE_ABORTED;
66 spin_unlock_irqrestore(&task->task_state_lock, flags);
67
68 complete(&task->completion);
69}
70
71static void sas_disc_task_done(struct sas_task *task)
72{
73 if (!del_timer(&task->timer))
74 return;
75 complete(&task->completion);
76}
77
78#define SAS_DEV_TIMEOUT 10
79
80/**
81 * sas_execute_task -- Basic task processing for discovery
82 * @task: the task to be executed
83 * @buffer: pointer to buffer to do I/O
84 * @size: size of @buffer
85 * @pci_dma_dir: PCI_DMA_...
86 */
87static int sas_execute_task(struct sas_task *task, void *buffer, int size,
88 int pci_dma_dir)
89{
90 int res = 0;
91 struct scatterlist *scatter = NULL;
92 struct task_status_struct *ts = &task->task_status;
93 int num_scatter = 0;
94 int retries = 0;
95 struct sas_internal *i =
96 to_sas_internal(task->dev->port->ha->core.shost->transportt);
97
98 if (pci_dma_dir != PCI_DMA_NONE) {
99 scatter = kzalloc(sizeof(*scatter), GFP_KERNEL);
100 if (!scatter)
101 goto out;
102
103 sg_init_one(scatter, buffer, size);
104 num_scatter = 1;
105 }
106
107 task->task_proto = task->dev->tproto;
108 task->scatter = scatter;
109 task->num_scatter = num_scatter;
110 task->total_xfer_len = size;
111 task->data_dir = pci_dma_dir;
112 task->task_done = sas_disc_task_done;
113
114 for (retries = 0; retries < 5; retries++) {
115 task->task_state_flags = SAS_TASK_STATE_PENDING;
116 init_completion(&task->completion);
117
118 task->timer.data = (unsigned long) task;
119 task->timer.function = sas_task_timedout;
120 task->timer.expires = jiffies + SAS_DEV_TIMEOUT*HZ;
121 add_timer(&task->timer);
122
123 res = i->dft->lldd_execute_task(task, 1, GFP_KERNEL);
124 if (res) {
125 del_timer(&task->timer);
126 SAS_DPRINTK("executing SAS discovery task failed:%d\n",
127 res);
128 goto ex_err;
129 }
130 wait_for_completion(&task->completion);
131 res = -ETASK;
132 if (task->task_state_flags & SAS_TASK_STATE_ABORTED) {
133 int res2;
134 SAS_DPRINTK("task aborted, flags:0x%x\n",
135 task->task_state_flags);
136 res2 = i->dft->lldd_abort_task(task);
137 SAS_DPRINTK("came back from abort task\n");
138 if (!(task->task_state_flags & SAS_TASK_STATE_DONE)) {
139 if (res2 == TMF_RESP_FUNC_COMPLETE)
140 continue; /* Retry the task */
141 else
142 goto ex_err;
143 }
144 }
145 if (task->task_status.stat == SAM_BUSY ||
146 task->task_status.stat == SAM_TASK_SET_FULL ||
147 task->task_status.stat == SAS_QUEUE_FULL) {
148 SAS_DPRINTK("task: q busy, sleeping...\n");
149 schedule_timeout_interruptible(HZ);
150 } else if (task->task_status.stat == SAM_CHECK_COND) {
151 struct scsi_sense_hdr shdr;
152
153 if (!scsi_normalize_sense(ts->buf, ts->buf_valid_size,
154 &shdr)) {
155 SAS_DPRINTK("couldn't normalize sense\n");
156 continue;
157 }
158 if ((shdr.sense_key == 6 && shdr.asc == 0x29) ||
159 (shdr.sense_key == 2 && shdr.asc == 4 &&
160 shdr.ascq == 1)) {
161 SAS_DPRINTK("device %016llx LUN: %016llx "
162 "powering up or not ready yet, "
163 "sleeping...\n",
164 SAS_ADDR(task->dev->sas_addr),
165 SAS_ADDR(task->ssp_task.LUN));
166
167 schedule_timeout_interruptible(5*HZ);
168 } else if (shdr.sense_key == 1) {
169 res = 0;
170 break;
171 } else if (shdr.sense_key == 5) {
172 break;
173 } else {
174 SAS_DPRINTK("dev %016llx LUN: %016llx "
175 "sense key:0x%x ASC:0x%x ASCQ:0x%x"
176 "\n",
177 SAS_ADDR(task->dev->sas_addr),
178 SAS_ADDR(task->ssp_task.LUN),
179 shdr.sense_key,
180 shdr.asc, shdr.ascq);
181 }
182 } else if (task->task_status.resp != SAS_TASK_COMPLETE ||
183 task->task_status.stat != SAM_GOOD) {
184 SAS_DPRINTK("task finished with resp:0x%x, "
185 "stat:0x%x\n",
186 task->task_status.resp,
187 task->task_status.stat);
188 goto ex_err;
189 } else {
190 res = 0;
191 break;
192 }
193 }
194ex_err:
195 if (pci_dma_dir != PCI_DMA_NONE)
196 kfree(scatter);
197out:
198 return res;
199}
200
201/* ---------- Domain device discovery ---------- */ 58/* ---------- Domain device discovery ---------- */
202 59
203/** 60/**
@@ -255,6 +112,7 @@ static int sas_get_port_device(struct asd_sas_port *port)
255 112
256 switch (dev->dev_type) { 113 switch (dev->dev_type) {
257 case SAS_END_DEV: 114 case SAS_END_DEV:
115 case SATA_DEV:
258 rphy = sas_end_device_alloc(port->port); 116 rphy = sas_end_device_alloc(port->port);
259 break; 117 break;
260 case EDGE_DEV: 118 case EDGE_DEV:
@@ -265,7 +123,6 @@ static int sas_get_port_device(struct asd_sas_port *port)
265 rphy = sas_expander_alloc(port->port, 123 rphy = sas_expander_alloc(port->port,
266 SAS_FANOUT_EXPANDER_DEVICE); 124 SAS_FANOUT_EXPANDER_DEVICE);
267 break; 125 break;
268 case SATA_DEV:
269 default: 126 default:
270 printk("ERROR: Unidentified device type %d\n", dev->dev_type); 127 printk("ERROR: Unidentified device type %d\n", dev->dev_type);
271 rphy = NULL; 128 rphy = NULL;
@@ -292,207 +149,15 @@ static int sas_get_port_device(struct asd_sas_port *port)
292 port->disc.max_level = 0; 149 port->disc.max_level = 0;
293 150
294 dev->rphy = rphy; 151 dev->rphy = rphy;
295 spin_lock(&port->dev_list_lock); 152 spin_lock_irq(&port->dev_list_lock);
296 list_add_tail(&dev->dev_list_node, &port->dev_list); 153 list_add_tail(&dev->dev_list_node, &port->dev_list);
297 spin_unlock(&port->dev_list_lock); 154 spin_unlock_irq(&port->dev_list_lock);
298 155
299 return 0; 156 return 0;
300} 157}
301 158
302/* ---------- Discover and Revalidate ---------- */ 159/* ---------- Discover and Revalidate ---------- */
303 160
304/* ---------- SATA ---------- */
305
306static void sas_get_ata_command_set(struct domain_device *dev)
307{
308 struct dev_to_host_fis *fis =
309 (struct dev_to_host_fis *) dev->frame_rcvd;
310
311 if ((fis->sector_count == 1 && /* ATA */
312 fis->lbal == 1 &&
313 fis->lbam == 0 &&
314 fis->lbah == 0 &&
315 fis->device == 0)
316 ||
317 (fis->sector_count == 0 && /* CE-ATA (mATA) */
318 fis->lbal == 0 &&
319 fis->lbam == 0xCE &&
320 fis->lbah == 0xAA &&
321 (fis->device & ~0x10) == 0))
322
323 dev->sata_dev.command_set = ATA_COMMAND_SET;
324
325 else if ((fis->interrupt_reason == 1 && /* ATAPI */
326 fis->lbal == 1 &&
327 fis->byte_count_low == 0x14 &&
328 fis->byte_count_high == 0xEB &&
329 (fis->device & ~0x10) == 0))
330
331 dev->sata_dev.command_set = ATAPI_COMMAND_SET;
332
333 else if ((fis->sector_count == 1 && /* SEMB */
334 fis->lbal == 1 &&
335 fis->lbam == 0x3C &&
336 fis->lbah == 0xC3 &&
337 fis->device == 0)
338 ||
339 (fis->interrupt_reason == 1 && /* SATA PM */
340 fis->lbal == 1 &&
341 fis->byte_count_low == 0x69 &&
342 fis->byte_count_high == 0x96 &&
343 (fis->device & ~0x10) == 0))
344
345 /* Treat it as a superset? */
346 dev->sata_dev.command_set = ATAPI_COMMAND_SET;
347}
348
349/**
350 * sas_issue_ata_cmd -- Basic SATA command processing for discovery
351 * @dev: the device to send the command to
352 * @command: the command register
353 * @features: the features register
354 * @buffer: pointer to buffer to do I/O
355 * @size: size of @buffer
356 * @pci_dma_dir: PCI_DMA_...
357 */
358static int sas_issue_ata_cmd(struct domain_device *dev, u8 command,
359 u8 features, void *buffer, int size,
360 int pci_dma_dir)
361{
362 int res = 0;
363 struct sas_task *task;
364 struct dev_to_host_fis *d2h_fis = (struct dev_to_host_fis *)
365 &dev->frame_rcvd[0];
366
367 res = -ENOMEM;
368 task = sas_alloc_task(GFP_KERNEL);
369 if (!task)
370 goto out;
371
372 task->dev = dev;
373
374 task->ata_task.fis.command = command;
375 task->ata_task.fis.features = features;
376 task->ata_task.fis.device = d2h_fis->device;
377 task->ata_task.retry_count = 1;
378
379 res = sas_execute_task(task, buffer, size, pci_dma_dir);
380
381 sas_free_task(task);
382out:
383 return res;
384}
385
386static void sas_sata_propagate_sas_addr(struct domain_device *dev)
387{
388 unsigned long flags;
389 struct asd_sas_port *port = dev->port;
390 struct asd_sas_phy *phy;
391
392 BUG_ON(dev->parent);
393
394 memcpy(port->attached_sas_addr, dev->sas_addr, SAS_ADDR_SIZE);
395 spin_lock_irqsave(&port->phy_list_lock, flags);
396 list_for_each_entry(phy, &port->phy_list, port_phy_el)
397 memcpy(phy->attached_sas_addr, dev->sas_addr, SAS_ADDR_SIZE);
398 spin_unlock_irqrestore(&port->phy_list_lock, flags);
399}
400
401#define ATA_IDENTIFY_DEV 0xEC
402#define ATA_IDENTIFY_PACKET_DEV 0xA1
403#define ATA_SET_FEATURES 0xEF
404#define ATA_FEATURE_PUP_STBY_SPIN_UP 0x07
405
406/**
407 * sas_discover_sata_dev -- discover a STP/SATA device (SATA_DEV)
408 * @dev: STP/SATA device of interest (ATA/ATAPI)
409 *
410 * The LLDD has already been notified of this device, so that we can
411 * send FISes to it. Here we try to get IDENTIFY DEVICE or IDENTIFY
412 * PACKET DEVICE, if ATAPI device, so that the LLDD can fine-tune its
413 * performance for this device.
414 */
415static int sas_discover_sata_dev(struct domain_device *dev)
416{
417 int res;
418 __le16 *identify_x;
419 u8 command;
420
421 identify_x = kzalloc(512, GFP_KERNEL);
422 if (!identify_x)
423 return -ENOMEM;
424
425 if (dev->sata_dev.command_set == ATA_COMMAND_SET) {
426 dev->sata_dev.identify_device = identify_x;
427 command = ATA_IDENTIFY_DEV;
428 } else {
429 dev->sata_dev.identify_packet_device = identify_x;
430 command = ATA_IDENTIFY_PACKET_DEV;
431 }
432
433 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512,
434 PCI_DMA_FROMDEVICE);
435 if (res)
436 goto out_err;
437
438 /* lives on the media? */
439 if (le16_to_cpu(identify_x[0]) & 4) {
440 /* incomplete response */
441 SAS_DPRINTK("sending SET FEATURE/PUP_STBY_SPIN_UP to "
442 "dev %llx\n", SAS_ADDR(dev->sas_addr));
443 if (!le16_to_cpu(identify_x[83] & (1<<6)))
444 goto cont1;
445 res = sas_issue_ata_cmd(dev, ATA_SET_FEATURES,
446 ATA_FEATURE_PUP_STBY_SPIN_UP,
447 NULL, 0, PCI_DMA_NONE);
448 if (res)
449 goto cont1;
450
451 schedule_timeout_interruptible(5*HZ); /* More time? */
452 res = sas_issue_ata_cmd(dev, command, 0, identify_x, 512,
453 PCI_DMA_FROMDEVICE);
454 if (res)
455 goto out_err;
456 }
457cont1:
458 /* Get WWN */
459 if (dev->port->oob_mode != SATA_OOB_MODE) {
460 memcpy(dev->sas_addr, dev->sata_dev.rps_resp.rps.stp_sas_addr,
461 SAS_ADDR_SIZE);
462 } else if (dev->sata_dev.command_set == ATA_COMMAND_SET &&
463 (le16_to_cpu(dev->sata_dev.identify_device[108]) & 0xF000)
464 == 0x5000) {
465 int i;
466
467 for (i = 0; i < 4; i++) {
468 dev->sas_addr[2*i] =
469 (le16_to_cpu(dev->sata_dev.identify_device[108+i]) & 0xFF00) >> 8;
470 dev->sas_addr[2*i+1] =
471 le16_to_cpu(dev->sata_dev.identify_device[108+i]) & 0x00FF;
472 }
473 }
474 sas_hash_addr(dev->hashed_sas_addr, dev->sas_addr);
475 if (!dev->parent)
476 sas_sata_propagate_sas_addr(dev);
477
478 /* XXX Hint: register this SATA device with SATL.
479 When this returns, dev->sata_dev->lu is alive and
480 present.
481 sas_satl_register_dev(dev);
482 */
483 return 0;
484out_err:
485 dev->sata_dev.identify_packet_device = NULL;
486 dev->sata_dev.identify_device = NULL;
487 kfree(identify_x);
488 return res;
489}
490
491static int sas_discover_sata_pm(struct domain_device *dev)
492{
493 return -ENODEV;
494}
495
496int sas_notify_lldd_dev_found(struct domain_device *dev) 161int sas_notify_lldd_dev_found(struct domain_device *dev)
497{ 162{
498 int res = 0; 163 int res = 0;
@@ -525,60 +190,6 @@ void sas_notify_lldd_dev_gone(struct domain_device *dev)
525 190
526/* ---------- Common/dispatchers ---------- */ 191/* ---------- Common/dispatchers ---------- */
527 192
528/**
529 * sas_discover_sata -- discover an STP/SATA domain device
530 * @dev: pointer to struct domain_device of interest
531 *
532 * First we notify the LLDD of this device, so we can send frames to
533 * it. Then depending on the type of device we call the appropriate
534 * discover functions. Once device discover is done, we notify the
535 * LLDD so that it can fine-tune its parameters for the device, by
536 * removing it and then adding it. That is, the second time around,
537 * the driver would have certain fields, that it is looking at, set.
538 * Finally we initialize the kobj so that the device can be added to
539 * the system at registration time. Devices directly attached to a HA
540 * port, have no parents. All other devices do, and should have their
541 * "parent" pointer set appropriately before calling this function.
542 */
543int sas_discover_sata(struct domain_device *dev)
544{
545 int res;
546
547 sas_get_ata_command_set(dev);
548
549 res = sas_notify_lldd_dev_found(dev);
550 if (res)
551 goto out_err2;
552
553 switch (dev->dev_type) {
554 case SATA_DEV:
555 res = sas_discover_sata_dev(dev);
556 break;
557 case SATA_PM:
558 res = sas_discover_sata_pm(dev);
559 break;
560 default:
561 break;
562 }
563 if (res)
564 goto out_err;
565
566 sas_notify_lldd_dev_gone(dev);
567 res = sas_notify_lldd_dev_found(dev);
568 if (res)
569 goto out_err2;
570
571 res = sas_rphy_add(dev->rphy);
572 if (res)
573 goto out_err;
574
575 return res;
576
577out_err:
578 sas_notify_lldd_dev_gone(dev);
579out_err2:
580 return res;
581}
582 193
583/** 194/**
584 * sas_discover_end_dev -- discover an end device (SSP, etc) 195 * sas_discover_end_dev -- discover an end device (SSP, etc)
@@ -685,11 +296,14 @@ static void sas_discover_domain(struct work_struct *work)
685 case FANOUT_DEV: 296 case FANOUT_DEV:
686 error = sas_discover_root_expander(dev); 297 error = sas_discover_root_expander(dev);
687 break; 298 break;
299#ifdef CONFIG_SCSI_SAS_ATA
688 case SATA_DEV: 300 case SATA_DEV:
689 case SATA_PM: 301 case SATA_PM:
690 error = sas_discover_sata(dev); 302 error = sas_discover_sata(dev);
691 break; 303 break;
304#endif
692 default: 305 default:
306 error = -ENXIO;
693 SAS_DPRINTK("unhandled device %d\n", dev->dev_type); 307 SAS_DPRINTK("unhandled device %d\n", dev->dev_type);
694 break; 308 break;
695 } 309 }
@@ -698,9 +312,9 @@ static void sas_discover_domain(struct work_struct *work)
698 sas_rphy_free(dev->rphy); 312 sas_rphy_free(dev->rphy);
699 dev->rphy = NULL; 313 dev->rphy = NULL;
700 314
701 spin_lock(&port->dev_list_lock); 315 spin_lock_irq(&port->dev_list_lock);
702 list_del_init(&dev->dev_list_node); 316 list_del_init(&dev->dev_list_node);
703 spin_unlock(&port->dev_list_lock); 317 spin_unlock_irq(&port->dev_list_lock);
704 318
705 kfree(dev); /* not kobject_register-ed yet */ 319 kfree(dev); /* not kobject_register-ed yet */
706 port->port_dev = NULL; 320 port->port_dev = NULL;
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 23e90c5f8f35..b500f0c1449c 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/scatterlist.h> 25#include <linux/scatterlist.h>
26#include <linux/blkdev.h>
26 27
27#include "sas_internal.h" 28#include "sas_internal.h"
28 29
@@ -36,14 +37,6 @@ static int sas_configure_phy(struct domain_device *dev, int phy_id,
36 u8 *sas_addr, int include); 37 u8 *sas_addr, int include);
37static int sas_disable_routing(struct domain_device *dev, u8 *sas_addr); 38static int sas_disable_routing(struct domain_device *dev, u8 *sas_addr);
38 39
39#if 0
40/* FIXME: smp needs to migrate into the sas class */
41static ssize_t smp_portal_read(struct kobject *, struct bin_attribute *,
42 char *, loff_t, size_t);
43static ssize_t smp_portal_write(struct kobject *, struct bin_attribute *,
44 char *, loff_t, size_t);
45#endif
46
47/* ---------- SMP task management ---------- */ 40/* ---------- SMP task management ---------- */
48 41
49static void smp_task_timedout(unsigned long _task) 42static void smp_task_timedout(unsigned long _task)
@@ -220,6 +213,36 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id,
220#define DISCOVER_REQ_SIZE 16 213#define DISCOVER_REQ_SIZE 16
221#define DISCOVER_RESP_SIZE 56 214#define DISCOVER_RESP_SIZE 56
222 215
216static int sas_ex_phy_discover_helper(struct domain_device *dev, u8 *disc_req,
217 u8 *disc_resp, int single)
218{
219 int i, res;
220
221 disc_req[9] = single;
222 for (i = 1 ; i < 3; i++) {
223 struct discover_resp *dr;
224
225 res = smp_execute_task(dev, disc_req, DISCOVER_REQ_SIZE,
226 disc_resp, DISCOVER_RESP_SIZE);
227 if (res)
228 return res;
229 /* This is detecting a failure to transmit inital
230 * dev to host FIS as described in section G.5 of
231 * sas-2 r 04b */
232 dr = &((struct smp_resp *)disc_resp)->disc;
233 if (!(dr->attached_dev_type == 0 &&
234 dr->attached_sata_dev))
235 break;
236 /* In order to generate the dev to host FIS, we
237 * send a link reset to the expander port */
238 sas_smp_phy_control(dev, single, PHY_FUNC_LINK_RESET, NULL);
239 /* Wait for the reset to trigger the negotiation */
240 msleep(500);
241 }
242 sas_set_ex_phy(dev, single, disc_resp);
243 return 0;
244}
245
223static int sas_ex_phy_discover(struct domain_device *dev, int single) 246static int sas_ex_phy_discover(struct domain_device *dev, int single)
224{ 247{
225 struct expander_device *ex = &dev->ex_dev; 248 struct expander_device *ex = &dev->ex_dev;
@@ -240,23 +263,15 @@ static int sas_ex_phy_discover(struct domain_device *dev, int single)
240 disc_req[1] = SMP_DISCOVER; 263 disc_req[1] = SMP_DISCOVER;
241 264
242 if (0 <= single && single < ex->num_phys) { 265 if (0 <= single && single < ex->num_phys) {
243 disc_req[9] = single; 266 res = sas_ex_phy_discover_helper(dev, disc_req, disc_resp, single);
244 res = smp_execute_task(dev, disc_req, DISCOVER_REQ_SIZE,
245 disc_resp, DISCOVER_RESP_SIZE);
246 if (res)
247 goto out_err;
248 sas_set_ex_phy(dev, single, disc_resp);
249 } else { 267 } else {
250 int i; 268 int i;
251 269
252 for (i = 0; i < ex->num_phys; i++) { 270 for (i = 0; i < ex->num_phys; i++) {
253 disc_req[9] = i; 271 res = sas_ex_phy_discover_helper(dev, disc_req,
254 res = smp_execute_task(dev, disc_req, 272 disc_resp, i);
255 DISCOVER_REQ_SIZE, disc_resp,
256 DISCOVER_RESP_SIZE);
257 if (res) 273 if (res)
258 goto out_err; 274 goto out_err;
259 sas_set_ex_phy(dev, i, disc_resp);
260 } 275 }
261 } 276 }
262out_err: 277out_err:
@@ -520,6 +535,8 @@ int sas_smp_get_phy_events(struct sas_phy *phy)
520 535
521} 536}
522 537
538#ifdef CONFIG_SCSI_SAS_ATA
539
523#define RPS_REQ_SIZE 16 540#define RPS_REQ_SIZE 16
524#define RPS_RESP_SIZE 60 541#define RPS_RESP_SIZE 60
525 542
@@ -529,6 +546,7 @@ static int sas_get_report_phy_sata(struct domain_device *dev,
529{ 546{
530 int res; 547 int res;
531 u8 *rps_req = alloc_smp_req(RPS_REQ_SIZE); 548 u8 *rps_req = alloc_smp_req(RPS_REQ_SIZE);
549 u8 *resp = (u8 *)rps_resp;
532 550
533 if (!rps_req) 551 if (!rps_req)
534 return -ENOMEM; 552 return -ENOMEM;
@@ -539,9 +557,30 @@ static int sas_get_report_phy_sata(struct domain_device *dev,
539 res = smp_execute_task(dev, rps_req, RPS_REQ_SIZE, 557 res = smp_execute_task(dev, rps_req, RPS_REQ_SIZE,
540 rps_resp, RPS_RESP_SIZE); 558 rps_resp, RPS_RESP_SIZE);
541 559
560 /* 0x34 is the FIS type for the D2H fis. There's a potential
561 * standards cockup here. sas-2 explicitly specifies the FIS
562 * should be encoded so that FIS type is in resp[24].
563 * However, some expanders endian reverse this. Undo the
564 * reversal here */
565 if (!res && resp[27] == 0x34 && resp[24] != 0x34) {
566 int i;
567
568 for (i = 0; i < 5; i++) {
569 int j = 24 + (i*4);
570 u8 a, b;
571 a = resp[j + 0];
572 b = resp[j + 1];
573 resp[j + 0] = resp[j + 3];
574 resp[j + 1] = resp[j + 2];
575 resp[j + 2] = b;
576 resp[j + 3] = a;
577 }
578 }
579
542 kfree(rps_req); 580 kfree(rps_req);
543 return 0; 581 return res;
544} 582}
583#endif
545 584
546static void sas_ex_get_linkrate(struct domain_device *parent, 585static void sas_ex_get_linkrate(struct domain_device *parent,
547 struct domain_device *child, 586 struct domain_device *child,
@@ -609,6 +648,7 @@ static struct domain_device *sas_ex_discover_end_dev(
609 } 648 }
610 sas_ex_get_linkrate(parent, child, phy); 649 sas_ex_get_linkrate(parent, child, phy);
611 650
651#ifdef CONFIG_SCSI_SAS_ATA
612 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) { 652 if ((phy->attached_tproto & SAS_PROTO_STP) || phy->attached_sata_dev) {
613 child->dev_type = SATA_DEV; 653 child->dev_type = SATA_DEV;
614 if (phy->attached_tproto & SAS_PROTO_STP) 654 if (phy->attached_tproto & SAS_PROTO_STP)
@@ -625,16 +665,30 @@ static struct domain_device *sas_ex_discover_end_dev(
625 } 665 }
626 memcpy(child->frame_rcvd, &child->sata_dev.rps_resp.rps.fis, 666 memcpy(child->frame_rcvd, &child->sata_dev.rps_resp.rps.fis,
627 sizeof(struct dev_to_host_fis)); 667 sizeof(struct dev_to_host_fis));
668
669 rphy = sas_end_device_alloc(phy->port);
670 if (unlikely(!rphy))
671 goto out_free;
672
628 sas_init_dev(child); 673 sas_init_dev(child);
674
675 child->rphy = rphy;
676
677 spin_lock_irq(&parent->port->dev_list_lock);
678 list_add_tail(&child->dev_list_node, &parent->port->dev_list);
679 spin_unlock_irq(&parent->port->dev_list_lock);
680
629 res = sas_discover_sata(child); 681 res = sas_discover_sata(child);
630 if (res) { 682 if (res) {
631 SAS_DPRINTK("sas_discover_sata() for device %16llx at " 683 SAS_DPRINTK("sas_discover_sata() for device %16llx at "
632 "%016llx:0x%x returned 0x%x\n", 684 "%016llx:0x%x returned 0x%x\n",
633 SAS_ADDR(child->sas_addr), 685 SAS_ADDR(child->sas_addr),
634 SAS_ADDR(parent->sas_addr), phy_id, res); 686 SAS_ADDR(parent->sas_addr), phy_id, res);
635 goto out_free; 687 goto out_list_del;
636 } 688 }
637 } else if (phy->attached_tproto & SAS_PROTO_SSP) { 689 } else
690#endif
691 if (phy->attached_tproto & SAS_PROTO_SSP) {
638 child->dev_type = SAS_END_DEV; 692 child->dev_type = SAS_END_DEV;
639 rphy = sas_end_device_alloc(phy->port); 693 rphy = sas_end_device_alloc(phy->port);
640 /* FIXME: error handling */ 694 /* FIXME: error handling */
@@ -646,9 +700,9 @@ static struct domain_device *sas_ex_discover_end_dev(
646 child->rphy = rphy; 700 child->rphy = rphy;
647 sas_fill_in_rphy(child, rphy); 701 sas_fill_in_rphy(child, rphy);
648 702
649 spin_lock(&parent->port->dev_list_lock); 703 spin_lock_irq(&parent->port->dev_list_lock);
650 list_add_tail(&child->dev_list_node, &parent->port->dev_list); 704 list_add_tail(&child->dev_list_node, &parent->port->dev_list);
651 spin_unlock(&parent->port->dev_list_lock); 705 spin_unlock_irq(&parent->port->dev_list_lock);
652 706
653 res = sas_discover_end_dev(child); 707 res = sas_discover_end_dev(child);
654 if (res) { 708 if (res) {
@@ -662,6 +716,7 @@ static struct domain_device *sas_ex_discover_end_dev(
662 SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n", 716 SAS_DPRINTK("target proto 0x%x at %016llx:0x%x not handled\n",
663 phy->attached_tproto, SAS_ADDR(parent->sas_addr), 717 phy->attached_tproto, SAS_ADDR(parent->sas_addr),
664 phy_id); 718 phy_id);
719 goto out_free;
665 } 720 }
666 721
667 list_add_tail(&child->siblings, &parent_ex->children); 722 list_add_tail(&child->siblings, &parent_ex->children);
@@ -761,9 +816,9 @@ static struct domain_device *sas_ex_discover_expander(
761 sas_fill_in_rphy(child, rphy); 816 sas_fill_in_rphy(child, rphy);
762 sas_rphy_add(rphy); 817 sas_rphy_add(rphy);
763 818
764 spin_lock(&parent->port->dev_list_lock); 819 spin_lock_irq(&parent->port->dev_list_lock);
765 list_add_tail(&child->dev_list_node, &parent->port->dev_list); 820 list_add_tail(&child->dev_list_node, &parent->port->dev_list);
766 spin_unlock(&parent->port->dev_list_lock); 821 spin_unlock_irq(&parent->port->dev_list_lock);
767 822
768 res = sas_discover_expander(child); 823 res = sas_discover_expander(child);
769 if (res) { 824 if (res) {
@@ -1359,30 +1414,6 @@ static int sas_disable_routing(struct domain_device *dev, u8 *sas_addr)
1359 return 0; 1414 return 0;
1360} 1415}
1361 1416
1362#if 0
1363#define SMP_BIN_ATTR_NAME "smp_portal"
1364
1365static void sas_ex_smp_hook(struct domain_device *dev)
1366{
1367 struct expander_device *ex_dev = &dev->ex_dev;
1368 struct bin_attribute *bin_attr = &ex_dev->smp_bin_attr;
1369
1370 memset(bin_attr, 0, sizeof(*bin_attr));
1371
1372 bin_attr->attr.name = SMP_BIN_ATTR_NAME;
1373 bin_attr->attr.mode = 0600;
1374
1375 bin_attr->size = 0;
1376 bin_attr->private = NULL;
1377 bin_attr->read = smp_portal_read;
1378 bin_attr->write= smp_portal_write;
1379 bin_attr->mmap = NULL;
1380
1381 ex_dev->smp_portal_pid = -1;
1382 init_MUTEX(&ex_dev->smp_sema);
1383}
1384#endif
1385
1386/** 1417/**
1387 * sas_discover_expander -- expander discovery 1418 * sas_discover_expander -- expander discovery
1388 * @ex: pointer to expander domain device 1419 * @ex: pointer to expander domain device
@@ -1844,76 +1875,49 @@ out:
1844 return res; 1875 return res;
1845} 1876}
1846 1877
1847#if 0 1878int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
1848/* ---------- SMP portal ---------- */ 1879 struct request *req)
1849
1850static ssize_t smp_portal_write(struct kobject *kobj,
1851 struct bin_attribute *bin_attr,
1852 char *buf, loff_t offs, size_t size)
1853{ 1880{
1854 struct domain_device *dev = to_dom_device(kobj); 1881 struct domain_device *dev;
1855 struct expander_device *ex = &dev->ex_dev; 1882 int ret, type = rphy->identify.device_type;
1856 1883 struct request *rsp = req->next_rq;
1857 if (offs != 0)
1858 return -EFBIG;
1859 else if (size == 0)
1860 return 0;
1861 1884
1862 down_interruptible(&ex->smp_sema); 1885 if (!rsp) {
1863 if (ex->smp_req) 1886 printk("%s: space for a smp response is missing\n",
1864 kfree(ex->smp_req); 1887 __FUNCTION__);
1865 ex->smp_req = kzalloc(size, GFP_USER); 1888 return -EINVAL;
1866 if (!ex->smp_req) {
1867 up(&ex->smp_sema);
1868 return -ENOMEM;
1869 } 1889 }
1870 memcpy(ex->smp_req, buf, size);
1871 ex->smp_req_size = size;
1872 ex->smp_portal_pid = current->pid;
1873 up(&ex->smp_sema);
1874 1890
1875 return size; 1891 /* seems aic94xx doesn't support */
1876} 1892 if (!rphy) {
1877 1893 printk("%s: can we send a smp request to a host?\n",
1878static ssize_t smp_portal_read(struct kobject *kobj, 1894 __FUNCTION__);
1879 struct bin_attribute *bin_attr, 1895 return -EINVAL;
1880 char *buf, loff_t offs, size_t size) 1896 }
1881{
1882 struct domain_device *dev = to_dom_device(kobj);
1883 struct expander_device *ex = &dev->ex_dev;
1884 u8 *smp_resp;
1885 int res = -EINVAL;
1886
1887 /* XXX: sysfs gives us an offset of 0x10 or 0x8 while in fact
1888 * it should be 0.
1889 */
1890 1897
1891 down_interruptible(&ex->smp_sema); 1898 if (type != SAS_EDGE_EXPANDER_DEVICE &&
1892 if (!ex->smp_req || ex->smp_portal_pid != current->pid) 1899 type != SAS_FANOUT_EXPANDER_DEVICE) {
1893 goto out; 1900 printk("%s: can we send a smp request to a device?\n",
1901 __FUNCTION__);
1902 return -EINVAL;
1903 }
1894 1904
1895 res = 0; 1905 dev = sas_find_dev_by_rphy(rphy);
1896 if (size == 0) 1906 if (!dev) {
1897 goto out; 1907 printk("%s: fail to find a domain_device?\n", __FUNCTION__);
1908 return -EINVAL;
1909 }
1898 1910
1899 res = -ENOMEM; 1911 /* do we need to support multiple segments? */
1900 smp_resp = alloc_smp_resp(size); 1912 if (req->bio->bi_vcnt > 1 || rsp->bio->bi_vcnt > 1) {
1901 if (!smp_resp) 1913 printk("%s: multiple segments req %u %u, rsp %u %u\n",
1902 goto out; 1914 __FUNCTION__, req->bio->bi_vcnt, req->data_len,
1903 res = smp_execute_task(dev, ex->smp_req, ex->smp_req_size, 1915 rsp->bio->bi_vcnt, rsp->data_len);
1904 smp_resp, size); 1916 return -EINVAL;
1905 if (!res) {
1906 memcpy(buf, smp_resp, size);
1907 res = size;
1908 } 1917 }
1909 1918
1910 kfree(smp_resp); 1919 ret = smp_execute_task(dev, bio_data(req->bio), req->data_len,
1911out: 1920 bio_data(rsp->bio), rsp->data_len);
1912 kfree(ex->smp_req); 1921
1913 ex->smp_req = NULL; 1922 return ret;
1914 ex->smp_req_size = 0;
1915 ex->smp_portal_pid = -1;
1916 up(&ex->smp_sema);
1917 return res;
1918} 1923}
1919#endif
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index 1396c83b0c9c..9cd5abe9e714 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -259,6 +259,7 @@ static struct sas_function_template sft = {
259 .phy_reset = sas_phy_reset, 259 .phy_reset = sas_phy_reset,
260 .set_phy_speed = sas_set_phy_speed, 260 .set_phy_speed = sas_set_phy_speed,
261 .get_linkerrors = sas_get_linkerrors, 261 .get_linkerrors = sas_get_linkerrors,
262 .smp_handler = sas_smp_handler,
262}; 263};
263 264
264struct scsi_transport_template * 265struct scsi_transport_template *
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index a78638df2018..2b8213b1832d 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -39,6 +39,9 @@
39#define SAS_DPRINTK(fmt, ...) 39#define SAS_DPRINTK(fmt, ...)
40#endif 40#endif
41 41
42#define TO_SAS_TASK(_scsi_cmd) ((void *)(_scsi_cmd)->host_scribble)
43#define ASSIGN_SAS_TASK(_sc, _t) do { (_sc)->host_scribble = (void *) _t; } while (0)
44
42void sas_scsi_recover_host(struct Scsi_Host *shost); 45void sas_scsi_recover_host(struct Scsi_Host *shost);
43 46
44int sas_show_class(enum sas_class class, char *buf); 47int sas_show_class(enum sas_class class, char *buf);
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 9c5342e7a69c..7663841eb4cf 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -34,6 +34,7 @@
34#include <scsi/scsi_eh.h> 34#include <scsi/scsi_eh.h>
35#include <scsi/scsi_transport.h> 35#include <scsi/scsi_transport.h>
36#include <scsi/scsi_transport_sas.h> 36#include <scsi/scsi_transport_sas.h>
37#include <scsi/sas_ata.h>
37#include "../scsi_sas_internal.h" 38#include "../scsi_sas_internal.h"
38#include "../scsi_transport_api.h" 39#include "../scsi_transport_api.h"
39#include "../scsi_priv.h" 40#include "../scsi_priv.h"
@@ -42,12 +43,10 @@
42#include <linux/blkdev.h> 43#include <linux/blkdev.h>
43#include <linux/freezer.h> 44#include <linux/freezer.h>
44#include <linux/scatterlist.h> 45#include <linux/scatterlist.h>
46#include <linux/libata.h>
45 47
46/* ---------- SCSI Host glue ---------- */ 48/* ---------- SCSI Host glue ---------- */
47 49
48#define TO_SAS_TASK(_scsi_cmd) ((void *)(_scsi_cmd)->host_scribble)
49#define ASSIGN_SAS_TASK(_sc, _t) do { (_sc)->host_scribble = (void *) _t; } while (0)
50
51static void sas_scsi_task_done(struct sas_task *task) 50static void sas_scsi_task_done(struct sas_task *task)
52{ 51{
53 struct task_status_struct *ts = &task->task_status; 52 struct task_status_struct *ts = &task->task_status;
@@ -172,7 +171,7 @@ static struct sas_task *sas_create_task(struct scsi_cmnd *cmd,
172 return task; 171 return task;
173} 172}
174 173
175static int sas_queue_up(struct sas_task *task) 174int sas_queue_up(struct sas_task *task)
176{ 175{
177 struct sas_ha_struct *sas_ha = task->dev->port->ha; 176 struct sas_ha_struct *sas_ha = task->dev->port->ha;
178 struct scsi_core *core = &sas_ha->core; 177 struct scsi_core *core = &sas_ha->core;
@@ -213,6 +212,16 @@ int sas_queuecommand(struct scsi_cmnd *cmd,
213 struct sas_ha_struct *sas_ha = dev->port->ha; 212 struct sas_ha_struct *sas_ha = dev->port->ha;
214 struct sas_task *task; 213 struct sas_task *task;
215 214
215 if (dev_is_sata(dev)) {
216 unsigned long flags;
217
218 spin_lock_irqsave(dev->sata_dev.ap->lock, flags);
219 res = ata_sas_queuecmd(cmd, scsi_done,
220 dev->sata_dev.ap);
221 spin_unlock_irqrestore(dev->sata_dev.ap->lock, flags);
222 goto out;
223 }
224
216 res = -ENOMEM; 225 res = -ENOMEM;
217 task = sas_create_task(cmd, dev, GFP_ATOMIC); 226 task = sas_create_task(cmd, dev, GFP_ATOMIC);
218 if (!task) 227 if (!task)
@@ -684,6 +693,16 @@ enum scsi_eh_timer_return sas_scsi_timed_out(struct scsi_cmnd *cmd)
684 return EH_NOT_HANDLED; 693 return EH_NOT_HANDLED;
685} 694}
686 695
696int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg)
697{
698 struct domain_device *dev = sdev_to_domain_dev(sdev);
699
700 if (dev_is_sata(dev))
701 return ata_scsi_ioctl(sdev, cmd, arg);
702
703 return -EINVAL;
704}
705
687struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy) 706struct domain_device *sas_find_dev_by_rphy(struct sas_rphy *rphy)
688{ 707{
689 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent); 708 struct Scsi_Host *shost = dev_to_shost(rphy->dev.parent);
@@ -723,10 +742,17 @@ static inline struct domain_device *sas_find_target(struct scsi_target *starget)
723int sas_target_alloc(struct scsi_target *starget) 742int sas_target_alloc(struct scsi_target *starget)
724{ 743{
725 struct domain_device *found_dev = sas_find_target(starget); 744 struct domain_device *found_dev = sas_find_target(starget);
745 int res;
726 746
727 if (!found_dev) 747 if (!found_dev)
728 return -ENODEV; 748 return -ENODEV;
729 749
750 if (dev_is_sata(found_dev)) {
751 res = sas_ata_init_host_and_port(found_dev, starget);
752 if (res)
753 return res;
754 }
755
730 starget->hostdata = found_dev; 756 starget->hostdata = found_dev;
731 return 0; 757 return 0;
732} 758}
@@ -741,6 +767,11 @@ int sas_slave_configure(struct scsi_device *scsi_dev)
741 767
742 BUG_ON(dev->rphy->identify.device_type != SAS_END_DEVICE); 768 BUG_ON(dev->rphy->identify.device_type != SAS_END_DEVICE);
743 769
770 if (dev_is_sata(dev)) {
771 ata_sas_slave_configure(scsi_dev, dev->sata_dev.ap);
772 return 0;
773 }
774
744 sas_ha = dev->port->ha; 775 sas_ha = dev->port->ha;
745 776
746 sas_read_port_mode_page(scsi_dev); 777 sas_read_port_mode_page(scsi_dev);
@@ -764,6 +795,10 @@ int sas_slave_configure(struct scsi_device *scsi_dev)
764 795
765void sas_slave_destroy(struct scsi_device *scsi_dev) 796void sas_slave_destroy(struct scsi_device *scsi_dev)
766{ 797{
798 struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
799
800 if (dev_is_sata(dev))
801 ata_port_disable(dev->sata_dev.ap);
767} 802}
768 803
769int sas_change_queue_depth(struct scsi_device *scsi_dev, int new_depth) 804int sas_change_queue_depth(struct scsi_device *scsi_dev, int new_depth)
@@ -980,10 +1015,38 @@ void sas_task_abort(struct sas_task *task)
980 return; 1015 return;
981 } 1016 }
982 1017
1018 if (dev_is_sata(task->dev)) {
1019 sas_ata_task_abort(task);
1020 return;
1021 }
1022
983 scsi_req_abort_cmd(sc); 1023 scsi_req_abort_cmd(sc);
984 scsi_schedule_eh(sc->device->host); 1024 scsi_schedule_eh(sc->device->host);
985} 1025}
986 1026
1027int sas_slave_alloc(struct scsi_device *scsi_dev)
1028{
1029 struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
1030
1031 if (dev_is_sata(dev))
1032 return ata_sas_port_init(dev->sata_dev.ap);
1033
1034 return 0;
1035}
1036
1037void sas_target_destroy(struct scsi_target *starget)
1038{
1039 struct domain_device *found_dev = sas_find_target(starget);
1040
1041 if (!found_dev)
1042 return;
1043
1044 if (dev_is_sata(found_dev))
1045 ata_sas_port_destroy(found_dev->sata_dev.ap);
1046
1047 return;
1048}
1049
987EXPORT_SYMBOL_GPL(sas_queuecommand); 1050EXPORT_SYMBOL_GPL(sas_queuecommand);
988EXPORT_SYMBOL_GPL(sas_target_alloc); 1051EXPORT_SYMBOL_GPL(sas_target_alloc);
989EXPORT_SYMBOL_GPL(sas_slave_configure); 1052EXPORT_SYMBOL_GPL(sas_slave_configure);
@@ -997,3 +1060,6 @@ EXPORT_SYMBOL_GPL(sas_phy_reset);
997EXPORT_SYMBOL_GPL(sas_phy_enable); 1060EXPORT_SYMBOL_GPL(sas_phy_enable);
998EXPORT_SYMBOL_GPL(sas_eh_device_reset_handler); 1061EXPORT_SYMBOL_GPL(sas_eh_device_reset_handler);
999EXPORT_SYMBOL_GPL(sas_eh_bus_reset_handler); 1062EXPORT_SYMBOL_GPL(sas_eh_bus_reset_handler);
1063EXPORT_SYMBOL_GPL(sas_slave_alloc);
1064EXPORT_SYMBOL_GPL(sas_target_destroy);
1065EXPORT_SYMBOL_GPL(sas_ioctl);
diff --git a/drivers/scsi/mvme16x_scsi.c b/drivers/scsi/mvme16x_scsi.c
index d6ef22a941c4..1bdddad48571 100644
--- a/drivers/scsi/mvme16x_scsi.c
+++ b/drivers/scsi/mvme16x_scsi.c
@@ -89,6 +89,7 @@ mvme16x_probe(struct device *dev)
89 out_be32(0xfff4202c, v); 89 out_be32(0xfff4202c, v);
90 } 90 }
91 91
92 dev_set_drvdata(dev, host);
92 scsi_scan_host(host); 93 scsi_scan_host(host);
93 94
94 return 0; 95 return 0;
@@ -104,7 +105,7 @@ mvme16x_probe(struct device *dev)
104static __devexit int 105static __devexit int
105mvme16x_device_remove(struct device *dev) 106mvme16x_device_remove(struct device *dev)
106{ 107{
107 struct Scsi_Host *host = dev_to_shost(dev); 108 struct Scsi_Host *host = dev_get_drvdata(dev);
108 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 109 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
109 110
110 /* Disable scsi chip ints */ 111 /* Disable scsi chip ints */
diff --git a/drivers/scsi/pcmcia/Kconfig b/drivers/scsi/pcmcia/Kconfig
index 7dd787f6ab27..fa481b515ead 100644
--- a/drivers/scsi/pcmcia/Kconfig
+++ b/drivers/scsi/pcmcia/Kconfig
@@ -2,9 +2,12 @@
2# PCMCIA SCSI adapter configuration 2# PCMCIA SCSI adapter configuration
3# 3#
4 4
5menu "PCMCIA SCSI adapter support" 5menuconfig SCSI_LOWLEVEL_PCMCIA
6 bool "PCMCIA SCSI adapter support"
6 depends on SCSI!=n && PCMCIA!=n 7 depends on SCSI!=n && PCMCIA!=n
7 8
9if SCSI_LOWLEVEL_PCMCIA && SCSI && PCMCIA
10
8config PCMCIA_AHA152X 11config PCMCIA_AHA152X
9 tristate "Adaptec AHA152X PCMCIA support" 12 tristate "Adaptec AHA152X PCMCIA support"
10 depends on !64BIT 13 depends on !64BIT
@@ -77,4 +80,4 @@ config PCMCIA_SYM53C500
77 To compile this driver as a module, choose M here: the 80 To compile this driver as a module, choose M here: the
78 module will be called sym53c500_cs. 81 module will be called sym53c500_cs.
79 82
80endmenu 83endif # SCSI_LOWLEVEL_PCMCIA
diff --git a/drivers/scsi/ps3rom.c b/drivers/scsi/ps3rom.c
new file mode 100644
index 000000000000..b50f1e14f2a5
--- /dev/null
+++ b/drivers/scsi/ps3rom.c
@@ -0,0 +1,533 @@
1/*
2 * PS3 BD/DVD/CD-ROM Storage Driver
3 *
4 * Copyright (C) 2007 Sony Computer Entertainment Inc.
5 * Copyright 2007 Sony Corp.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <linux/cdrom.h>
22#include <linux/highmem.h>
23
24#include <scsi/scsi.h>
25#include <scsi/scsi_cmnd.h>
26#include <scsi/scsi_dbg.h>
27#include <scsi/scsi_device.h>
28#include <scsi/scsi_host.h>
29
30#include <asm/lv1call.h>
31#include <asm/ps3stor.h>
32
33
34#define DEVICE_NAME "ps3rom"
35
36#define BOUNCE_SIZE (64*1024)
37
38#define PS3ROM_MAX_SECTORS (BOUNCE_SIZE / CD_FRAMESIZE)
39
40
41struct ps3rom_private {
42 struct ps3_storage_device *dev;
43 struct scsi_cmnd *curr_cmd;
44};
45
46
47#define LV1_STORAGE_SEND_ATAPI_COMMAND (1)
48
49struct lv1_atapi_cmnd_block {
50 u8 pkt[32]; /* packet command block */
51 u32 pktlen; /* should be 12 for ATAPI 8020 */
52 u32 blocks;
53 u32 block_size;
54 u32 proto; /* transfer mode */
55 u32 in_out; /* transfer direction */
56 u64 buffer; /* parameter except command block */
57 u32 arglen; /* length above */
58};
59
60enum lv1_atapi_proto {
61 NON_DATA_PROTO = 0,
62 PIO_DATA_IN_PROTO = 1,
63 PIO_DATA_OUT_PROTO = 2,
64 DMA_PROTO = 3
65};
66
67enum lv1_atapi_in_out {
68 DIR_WRITE = 0, /* memory -> device */
69 DIR_READ = 1 /* device -> memory */
70};
71
72
73static int ps3rom_slave_configure(struct scsi_device *scsi_dev)
74{
75 struct ps3rom_private *priv = shost_priv(scsi_dev->host);
76 struct ps3_storage_device *dev = priv->dev;
77
78 dev_dbg(&dev->sbd.core, "%s:%u: id %u, lun %u, channel %u\n", __func__,
79 __LINE__, scsi_dev->id, scsi_dev->lun, scsi_dev->channel);
80
81 /*
82 * ATAPI SFF8020 devices use MODE_SENSE_10,
83 * so we can prohibit MODE_SENSE_6
84 */
85 scsi_dev->use_10_for_ms = 1;
86
87 /* we don't support {READ,WRITE}_6 */
88 scsi_dev->use_10_for_rw = 1;
89
90 return 0;
91}
92
93/*
94 * copy data from device into scatter/gather buffer
95 */
96static int fill_from_dev_buffer(struct scsi_cmnd *cmd, const void *buf)
97{
98 int k, req_len, act_len, len, active;
99 void *kaddr;
100 struct scatterlist *sgpnt;
101 unsigned int buflen;
102
103 buflen = cmd->request_bufflen;
104 if (!buflen)
105 return 0;
106
107 if (!cmd->request_buffer)
108 return -1;
109
110 sgpnt = cmd->request_buffer;
111 active = 1;
112 for (k = 0, req_len = 0, act_len = 0; k < cmd->use_sg; ++k, ++sgpnt) {
113 if (active) {
114 kaddr = kmap_atomic(sgpnt->page, KM_IRQ0);
115 len = sgpnt->length;
116 if ((req_len + len) > buflen) {
117 active = 0;
118 len = buflen - req_len;
119 }
120 memcpy(kaddr + sgpnt->offset, buf + req_len, len);
121 flush_kernel_dcache_page(sgpnt->page);
122 kunmap_atomic(kaddr, KM_IRQ0);
123 act_len += len;
124 }
125 req_len += sgpnt->length;
126 }
127 cmd->resid = req_len - act_len;
128 return 0;
129}
130
131/*
132 * copy data from scatter/gather into device's buffer
133 */
134static int fetch_to_dev_buffer(struct scsi_cmnd *cmd, void *buf)
135{
136 int k, req_len, len, fin;
137 void *kaddr;
138 struct scatterlist *sgpnt;
139 unsigned int buflen;
140
141 buflen = cmd->request_bufflen;
142 if (!buflen)
143 return 0;
144
145 if (!cmd->request_buffer)
146 return -1;
147
148 sgpnt = cmd->request_buffer;
149 for (k = 0, req_len = 0, fin = 0; k < cmd->use_sg; ++k, ++sgpnt) {
150 kaddr = kmap_atomic(sgpnt->page, KM_IRQ0);
151 len = sgpnt->length;
152 if ((req_len + len) > buflen) {
153 len = buflen - req_len;
154 fin = 1;
155 }
156 memcpy(buf + req_len, kaddr + sgpnt->offset, len);
157 kunmap_atomic(kaddr, KM_IRQ0);
158 if (fin)
159 return req_len + len;
160 req_len += sgpnt->length;
161 }
162 return req_len;
163}
164
165static int ps3rom_atapi_request(struct ps3_storage_device *dev,
166 struct scsi_cmnd *cmd)
167{
168 struct lv1_atapi_cmnd_block atapi_cmnd;
169 unsigned char opcode = cmd->cmnd[0];
170 int res;
171 u64 lpar;
172
173 dev_dbg(&dev->sbd.core, "%s:%u: send ATAPI command 0x%02x\n", __func__,
174 __LINE__, opcode);
175
176 memset(&atapi_cmnd, 0, sizeof(struct lv1_atapi_cmnd_block));
177 memcpy(&atapi_cmnd.pkt, cmd->cmnd, 12);
178 atapi_cmnd.pktlen = 12;
179 atapi_cmnd.block_size = 1; /* transfer size is block_size * blocks */
180 atapi_cmnd.blocks = atapi_cmnd.arglen = cmd->request_bufflen;
181 atapi_cmnd.buffer = dev->bounce_lpar;
182
183 switch (cmd->sc_data_direction) {
184 case DMA_FROM_DEVICE:
185 if (cmd->request_bufflen >= CD_FRAMESIZE)
186 atapi_cmnd.proto = DMA_PROTO;
187 else
188 atapi_cmnd.proto = PIO_DATA_IN_PROTO;
189 atapi_cmnd.in_out = DIR_READ;
190 break;
191
192 case DMA_TO_DEVICE:
193 if (cmd->request_bufflen >= CD_FRAMESIZE)
194 atapi_cmnd.proto = DMA_PROTO;
195 else
196 atapi_cmnd.proto = PIO_DATA_OUT_PROTO;
197 atapi_cmnd.in_out = DIR_WRITE;
198 res = fetch_to_dev_buffer(cmd, dev->bounce_buf);
199 if (res < 0)
200 return DID_ERROR << 16;
201 break;
202
203 default:
204 atapi_cmnd.proto = NON_DATA_PROTO;
205 break;
206 }
207
208 lpar = ps3_mm_phys_to_lpar(__pa(&atapi_cmnd));
209 res = lv1_storage_send_device_command(dev->sbd.dev_id,
210 LV1_STORAGE_SEND_ATAPI_COMMAND,
211 lpar, sizeof(atapi_cmnd),
212 atapi_cmnd.buffer,
213 atapi_cmnd.arglen, &dev->tag);
214 if (res == LV1_DENIED_BY_POLICY) {
215 dev_dbg(&dev->sbd.core,
216 "%s:%u: ATAPI command 0x%02x denied by policy\n",
217 __func__, __LINE__, opcode);
218 return DID_ERROR << 16;
219 }
220
221 if (res) {
222 dev_err(&dev->sbd.core,
223 "%s:%u: ATAPI command 0x%02x failed %d\n", __func__,
224 __LINE__, opcode, res);
225 return DID_ERROR << 16;
226 }
227
228 return 0;
229}
230
231static inline unsigned int srb10_lba(const struct scsi_cmnd *cmd)
232{
233 return cmd->cmnd[2] << 24 | cmd->cmnd[3] << 16 | cmd->cmnd[4] << 8 |
234 cmd->cmnd[5];
235}
236
237static inline unsigned int srb10_len(const struct scsi_cmnd *cmd)
238{
239 return cmd->cmnd[7] << 8 | cmd->cmnd[8];
240}
241
242static int ps3rom_read_request(struct ps3_storage_device *dev,
243 struct scsi_cmnd *cmd, u32 start_sector,
244 u32 sectors)
245{
246 int res;
247
248 dev_dbg(&dev->sbd.core, "%s:%u: read %u sectors starting at %u\n",
249 __func__, __LINE__, sectors, start_sector);
250
251 res = lv1_storage_read(dev->sbd.dev_id,
252 dev->regions[dev->region_idx].id, start_sector,
253 sectors, 0, dev->bounce_lpar, &dev->tag);
254 if (res) {
255 dev_err(&dev->sbd.core, "%s:%u: read failed %d\n", __func__,
256 __LINE__, res);
257 return DID_ERROR << 16;
258 }
259
260 return 0;
261}
262
263static int ps3rom_write_request(struct ps3_storage_device *dev,
264 struct scsi_cmnd *cmd, u32 start_sector,
265 u32 sectors)
266{
267 int res;
268
269 dev_dbg(&dev->sbd.core, "%s:%u: write %u sectors starting at %u\n",
270 __func__, __LINE__, sectors, start_sector);
271
272 res = fetch_to_dev_buffer(cmd, dev->bounce_buf);
273 if (res < 0)
274 return DID_ERROR << 16;
275
276 res = lv1_storage_write(dev->sbd.dev_id,
277 dev->regions[dev->region_idx].id, start_sector,
278 sectors, 0, dev->bounce_lpar, &dev->tag);
279 if (res) {
280 dev_err(&dev->sbd.core, "%s:%u: write failed %d\n", __func__,
281 __LINE__, res);
282 return DID_ERROR << 16;
283 }
284
285 return 0;
286}
287
288static int ps3rom_queuecommand(struct scsi_cmnd *cmd,
289 void (*done)(struct scsi_cmnd *))
290{
291 struct ps3rom_private *priv = shost_priv(cmd->device->host);
292 struct ps3_storage_device *dev = priv->dev;
293 unsigned char opcode;
294 int res;
295
296#ifdef DEBUG
297 scsi_print_command(cmd);
298#endif
299
300 priv->curr_cmd = cmd;
301 cmd->scsi_done = done;
302
303 opcode = cmd->cmnd[0];
304 /*
305 * While we can submit READ/WRITE SCSI commands as ATAPI commands,
306 * it's recommended for various reasons (performance, error handling,
307 * ...) to use lv1_storage_{read,write}() instead
308 */
309 switch (opcode) {
310 case READ_10:
311 res = ps3rom_read_request(dev, cmd, srb10_lba(cmd),
312 srb10_len(cmd));
313 break;
314
315 case WRITE_10:
316 res = ps3rom_write_request(dev, cmd, srb10_lba(cmd),
317 srb10_len(cmd));
318 break;
319
320 default:
321 res = ps3rom_atapi_request(dev, cmd);
322 break;
323 }
324
325 if (res) {
326 memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
327 cmd->result = res;
328 cmd->sense_buffer[0] = 0x70;
329 cmd->sense_buffer[2] = ILLEGAL_REQUEST;
330 priv->curr_cmd = NULL;
331 cmd->scsi_done(cmd);
332 }
333
334 return 0;
335}
336
337static int decode_lv1_status(u64 status, unsigned char *sense_key,
338 unsigned char *asc, unsigned char *ascq)
339{
340 if (((status >> 24) & 0xff) != SAM_STAT_CHECK_CONDITION)
341 return -1;
342
343 *sense_key = (status >> 16) & 0xff;
344 *asc = (status >> 8) & 0xff;
345 *ascq = status & 0xff;
346 return 0;
347}
348
349static irqreturn_t ps3rom_interrupt(int irq, void *data)
350{
351 struct ps3_storage_device *dev = data;
352 struct Scsi_Host *host;
353 struct ps3rom_private *priv;
354 struct scsi_cmnd *cmd;
355 int res;
356 u64 tag, status;
357 unsigned char sense_key, asc, ascq;
358
359 res = lv1_storage_get_async_status(dev->sbd.dev_id, &tag, &status);
360 /*
361 * status = -1 may mean that ATAPI transport completed OK, but
362 * ATAPI command itself resulted CHECK CONDITION
363 * so, upper layer should issue REQUEST_SENSE to check the sense data
364 */
365
366 if (tag != dev->tag)
367 dev_err(&dev->sbd.core,
368 "%s:%u: tag mismatch, got %lx, expected %lx\n",
369 __func__, __LINE__, tag, dev->tag);
370
371 if (res) {
372 dev_err(&dev->sbd.core, "%s:%u: res=%d status=0x%lx\n",
373 __func__, __LINE__, res, status);
374 return IRQ_HANDLED;
375 }
376
377 host = dev->sbd.core.driver_data;
378 priv = shost_priv(host);
379 cmd = priv->curr_cmd;
380
381 if (!status) {
382 /* OK, completed */
383 if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
384 res = fill_from_dev_buffer(cmd, dev->bounce_buf);
385 if (res) {
386 cmd->result = DID_ERROR << 16;
387 goto done;
388 }
389 }
390 cmd->result = DID_OK << 16;
391 goto done;
392 }
393
394 if (cmd->cmnd[0] == REQUEST_SENSE) {
395 /* SCSI spec says request sense should never get error */
396 dev_err(&dev->sbd.core, "%s:%u: end error without autosense\n",
397 __func__, __LINE__);
398 cmd->result = DID_ERROR << 16 | SAM_STAT_CHECK_CONDITION;
399 goto done;
400 }
401
402 if (decode_lv1_status(status, &sense_key, &asc, &ascq)) {
403 cmd->result = DID_ERROR << 16;
404 goto done;
405 }
406
407 cmd->sense_buffer[0] = 0x70;
408 cmd->sense_buffer[2] = sense_key;
409 cmd->sense_buffer[7] = 16 - 6;
410 cmd->sense_buffer[12] = asc;
411 cmd->sense_buffer[13] = ascq;
412 cmd->result = SAM_STAT_CHECK_CONDITION;
413
414done:
415 priv->curr_cmd = NULL;
416 cmd->scsi_done(cmd);
417 return IRQ_HANDLED;
418}
419
420static struct scsi_host_template ps3rom_host_template = {
421 .name = DEVICE_NAME,
422 .slave_configure = ps3rom_slave_configure,
423 .queuecommand = ps3rom_queuecommand,
424 .can_queue = 1,
425 .this_id = 7,
426 .sg_tablesize = SG_ALL,
427 .cmd_per_lun = 1,
428 .emulated = 1, /* only sg driver uses this */
429 .max_sectors = PS3ROM_MAX_SECTORS,
430 .use_clustering = ENABLE_CLUSTERING,
431 .module = THIS_MODULE,
432};
433
434
435static int __devinit ps3rom_probe(struct ps3_system_bus_device *_dev)
436{
437 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
438 int error;
439 struct Scsi_Host *host;
440 struct ps3rom_private *priv;
441
442 if (dev->blk_size != CD_FRAMESIZE) {
443 dev_err(&dev->sbd.core,
444 "%s:%u: cannot handle block size %lu\n", __func__,
445 __LINE__, dev->blk_size);
446 return -EINVAL;
447 }
448
449 dev->bounce_size = BOUNCE_SIZE;
450 dev->bounce_buf = kmalloc(BOUNCE_SIZE, GFP_DMA);
451 if (!dev->bounce_buf)
452 return -ENOMEM;
453
454 error = ps3stor_setup(dev, ps3rom_interrupt);
455 if (error)
456 goto fail_free_bounce;
457
458 host = scsi_host_alloc(&ps3rom_host_template,
459 sizeof(struct ps3rom_private));
460 if (!host) {
461 dev_err(&dev->sbd.core, "%s:%u: scsi_host_alloc failed\n",
462 __func__, __LINE__);
463 goto fail_teardown;
464 }
465
466 priv = shost_priv(host);
467 dev->sbd.core.driver_data = host;
468 priv->dev = dev;
469
470 /* One device/LUN per SCSI bus */
471 host->max_id = 1;
472 host->max_lun = 1;
473
474 error = scsi_add_host(host, &dev->sbd.core);
475 if (error) {
476 dev_err(&dev->sbd.core, "%s:%u: scsi_host_alloc failed %d\n",
477 __func__, __LINE__, error);
478 error = -ENODEV;
479 goto fail_host_put;
480 }
481
482 scsi_scan_host(host);
483 return 0;
484
485fail_host_put:
486 scsi_host_put(host);
487 dev->sbd.core.driver_data = NULL;
488fail_teardown:
489 ps3stor_teardown(dev);
490fail_free_bounce:
491 kfree(dev->bounce_buf);
492 return error;
493}
494
495static int ps3rom_remove(struct ps3_system_bus_device *_dev)
496{
497 struct ps3_storage_device *dev = to_ps3_storage_device(&_dev->core);
498 struct Scsi_Host *host = dev->sbd.core.driver_data;
499
500 scsi_remove_host(host);
501 ps3stor_teardown(dev);
502 scsi_host_put(host);
503 dev->sbd.core.driver_data = NULL;
504 kfree(dev->bounce_buf);
505 return 0;
506}
507
508static struct ps3_system_bus_driver ps3rom = {
509 .match_id = PS3_MATCH_ID_STOR_ROM,
510 .core.name = DEVICE_NAME,
511 .core.owner = THIS_MODULE,
512 .probe = ps3rom_probe,
513 .remove = ps3rom_remove
514};
515
516
517static int __init ps3rom_init(void)
518{
519 return ps3_system_bus_driver_register(&ps3rom);
520}
521
522static void __exit ps3rom_exit(void)
523{
524 ps3_system_bus_driver_unregister(&ps3rom);
525}
526
527module_init(ps3rom_init);
528module_exit(ps3rom_exit);
529
530MODULE_LICENSE("GPL");
531MODULE_DESCRIPTION("PS3 BD/DVD/CD-ROM Storage Driver");
532MODULE_AUTHOR("Sony Corporation");
533MODULE_ALIAS(PS3_MODULE_ALIAS_STOR_ROM);
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 3eb2208675ae..1612f9200a52 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -98,7 +98,7 @@ qla2x00_sysfs_read_nvram(struct kobject *kobj,
98 98
99 /* Read NVRAM. */ 99 /* Read NVRAM. */
100 spin_lock_irqsave(&ha->hardware_lock, flags); 100 spin_lock_irqsave(&ha->hardware_lock, flags);
101 ha->isp_ops.read_nvram(ha, (uint8_t *)buf, ha->nvram_base, 101 ha->isp_ops->read_nvram(ha, (uint8_t *)buf, ha->nvram_base,
102 ha->nvram_size); 102 ha->nvram_size);
103 spin_unlock_irqrestore(&ha->hardware_lock, flags); 103 spin_unlock_irqrestore(&ha->hardware_lock, flags);
104 104
@@ -119,7 +119,7 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj,
119 return 0; 119 return 0;
120 120
121 /* Checksum NVRAM. */ 121 /* Checksum NVRAM. */
122 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 122 if (IS_FWI2_CAPABLE(ha)) {
123 uint32_t *iter; 123 uint32_t *iter;
124 uint32_t chksum; 124 uint32_t chksum;
125 125
@@ -143,7 +143,7 @@ qla2x00_sysfs_write_nvram(struct kobject *kobj,
143 143
144 /* Write NVRAM. */ 144 /* Write NVRAM. */
145 spin_lock_irqsave(&ha->hardware_lock, flags); 145 spin_lock_irqsave(&ha->hardware_lock, flags);
146 ha->isp_ops.write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count); 146 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->nvram_base, count);
147 spin_unlock_irqrestore(&ha->hardware_lock, flags); 147 spin_unlock_irqrestore(&ha->hardware_lock, flags);
148 148
149 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 149 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
@@ -206,7 +206,7 @@ static struct bin_attribute sysfs_optrom_attr = {
206 .name = "optrom", 206 .name = "optrom",
207 .mode = S_IRUSR | S_IWUSR, 207 .mode = S_IRUSR | S_IWUSR,
208 }, 208 },
209 .size = OPTROM_SIZE_24XX, 209 .size = 0,
210 .read = qla2x00_sysfs_read_optrom, 210 .read = qla2x00_sysfs_read_optrom,
211 .write = qla2x00_sysfs_write_optrom, 211 .write = qla2x00_sysfs_write_optrom,
212}; 212};
@@ -252,7 +252,7 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
252 } 252 }
253 253
254 memset(ha->optrom_buffer, 0, ha->optrom_size); 254 memset(ha->optrom_buffer, 0, ha->optrom_size);
255 ha->isp_ops.read_optrom(ha, ha->optrom_buffer, 0, 255 ha->isp_ops->read_optrom(ha, ha->optrom_buffer, 0,
256 ha->optrom_size); 256 ha->optrom_size);
257 break; 257 break;
258 case 2: 258 case 2:
@@ -275,7 +275,7 @@ qla2x00_sysfs_write_optrom_ctl(struct kobject *kobj,
275 if (ha->optrom_state != QLA_SWRITING) 275 if (ha->optrom_state != QLA_SWRITING)
276 break; 276 break;
277 277
278 ha->isp_ops.write_optrom(ha, ha->optrom_buffer, 0, 278 ha->isp_ops->write_optrom(ha, ha->optrom_buffer, 0,
279 ha->optrom_size); 279 ha->optrom_size);
280 break; 280 break;
281 } 281 }
@@ -305,7 +305,8 @@ qla2x00_sysfs_read_vpd(struct kobject *kobj,
305 305
306 /* Read NVRAM. */ 306 /* Read NVRAM. */
307 spin_lock_irqsave(&ha->hardware_lock, flags); 307 spin_lock_irqsave(&ha->hardware_lock, flags);
308 ha->isp_ops.read_nvram(ha, (uint8_t *)buf, ha->vpd_base, ha->vpd_size); 308 ha->isp_ops->read_nvram(ha, (uint8_t *)buf, ha->vpd_base,
309 ha->vpd_size);
309 spin_unlock_irqrestore(&ha->hardware_lock, flags); 310 spin_unlock_irqrestore(&ha->hardware_lock, flags);
310 311
311 return ha->vpd_size; 312 return ha->vpd_size;
@@ -325,7 +326,7 @@ qla2x00_sysfs_write_vpd(struct kobject *kobj,
325 326
326 /* Write NVRAM. */ 327 /* Write NVRAM. */
327 spin_lock_irqsave(&ha->hardware_lock, flags); 328 spin_lock_irqsave(&ha->hardware_lock, flags);
328 ha->isp_ops.write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count); 329 ha->isp_ops->write_nvram(ha, (uint8_t *)buf, ha->vpd_base, count);
329 spin_unlock_irqrestore(&ha->hardware_lock, flags); 330 spin_unlock_irqrestore(&ha->hardware_lock, flags);
330 331
331 return count; 332 return count;
@@ -410,7 +411,7 @@ qla2x00_alloc_sysfs_attr(scsi_qla_host_t *ha)
410 int ret; 411 int ret;
411 412
412 for (iter = bin_file_entries; iter->name; iter++) { 413 for (iter = bin_file_entries; iter->name; iter++) {
413 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))) 414 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
414 continue; 415 continue;
415 416
416 ret = sysfs_create_bin_file(&host->shost_gendev.kobj, 417 ret = sysfs_create_bin_file(&host->shost_gendev.kobj,
@@ -429,7 +430,7 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
429 struct sysfs_entry *iter; 430 struct sysfs_entry *iter;
430 431
431 for (iter = bin_file_entries; iter->name; iter++) { 432 for (iter = bin_file_entries; iter->name; iter++) {
432 if (iter->is4GBp_only && (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))) 433 if (iter->is4GBp_only && !IS_FWI2_CAPABLE(ha))
433 continue; 434 continue;
434 435
435 sysfs_remove_bin_file(&host->shost_gendev.kobj, 436 sysfs_remove_bin_file(&host->shost_gendev.kobj,
@@ -437,7 +438,7 @@ qla2x00_free_sysfs_attr(scsi_qla_host_t *ha)
437 } 438 }
438 439
439 if (ha->beacon_blink_led == 1) 440 if (ha->beacon_blink_led == 1)
440 ha->isp_ops.beacon_off(ha); 441 ha->isp_ops->beacon_off(ha);
441} 442}
442 443
443/* Scsi_Host attributes. */ 444/* Scsi_Host attributes. */
@@ -455,7 +456,7 @@ qla2x00_fw_version_show(struct class_device *cdev, char *buf)
455 char fw_str[30]; 456 char fw_str[30];
456 457
457 return snprintf(buf, PAGE_SIZE, "%s\n", 458 return snprintf(buf, PAGE_SIZE, "%s\n",
458 ha->isp_ops.fw_version_str(ha, fw_str)); 459 ha->isp_ops->fw_version_str(ha, fw_str));
459} 460}
460 461
461static ssize_t 462static ssize_t
@@ -507,7 +508,7 @@ qla2x00_pci_info_show(struct class_device *cdev, char *buf)
507 char pci_info[30]; 508 char pci_info[30];
508 509
509 return snprintf(buf, PAGE_SIZE, "%s\n", 510 return snprintf(buf, PAGE_SIZE, "%s\n",
510 ha->isp_ops.pci_info_str(ha, pci_info)); 511 ha->isp_ops->pci_info_str(ha, pci_info));
511} 512}
512 513
513static ssize_t 514static ssize_t
@@ -652,9 +653,9 @@ qla2x00_beacon_store(struct class_device *cdev, const char *buf,
652 return -EINVAL; 653 return -EINVAL;
653 654
654 if (val) 655 if (val)
655 rval = ha->isp_ops.beacon_on(ha); 656 rval = ha->isp_ops->beacon_on(ha);
656 else 657 else
657 rval = ha->isp_ops.beacon_off(ha); 658 rval = ha->isp_ops->beacon_off(ha);
658 659
659 if (rval != QLA_SUCCESS) 660 if (rval != QLA_SUCCESS)
660 count = 0; 661 count = 0;
@@ -898,7 +899,7 @@ qla2x00_get_fc_host_stats(struct Scsi_Host *shost)
898 pfc_host_stat = &ha->fc_host_stat; 899 pfc_host_stat = &ha->fc_host_stat;
899 memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics)); 900 memset(pfc_host_stat, -1, sizeof(struct fc_host_statistics));
900 901
901 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 902 if (IS_FWI2_CAPABLE(ha)) {
902 rval = qla24xx_get_isp_stats(ha, (uint32_t *)&stat_buf, 903 rval = qla24xx_get_isp_stats(ha, (uint32_t *)&stat_buf,
903 sizeof(stat_buf) / 4, mb_stat); 904 sizeof(stat_buf) / 4, mb_stat);
904 } else if (atomic_read(&ha->loop_state) == LOOP_READY && 905 } else if (atomic_read(&ha->loop_state) == LOOP_READY &&
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 996c47a63074..563d18f4ff50 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -37,6 +37,121 @@ qla2xxx_copy_queues(scsi_qla_host_t *ha, void *ptr)
37 return ptr + (ha->response_q_length * sizeof(response_t)); 37 return ptr + (ha->response_q_length * sizeof(response_t));
38} 38}
39 39
40static int
41qla2xxx_dump_memory(scsi_qla_host_t *ha, uint32_t *code_ram,
42 uint32_t cram_size, uint32_t *ext_mem, void **nxt)
43{
44 int rval;
45 uint32_t cnt, stat, timer, risc_address, ext_mem_cnt;
46 uint16_t mb[4];
47 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
48
49 rval = QLA_SUCCESS;
50 risc_address = ext_mem_cnt = 0;
51 memset(mb, 0, sizeof(mb));
52
53 /* Code RAM. */
54 risc_address = 0x20000;
55 WRT_REG_WORD(&reg->mailbox0, MBC_READ_RAM_EXTENDED);
56 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
57
58 for (cnt = 0; cnt < cram_size / 4 && rval == QLA_SUCCESS;
59 cnt++, risc_address++) {
60 WRT_REG_WORD(&reg->mailbox1, LSW(risc_address));
61 WRT_REG_WORD(&reg->mailbox8, MSW(risc_address));
62 RD_REG_WORD(&reg->mailbox8);
63 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
64
65 for (timer = 6000000; timer; timer--) {
66 /* Check for pending interrupts. */
67 stat = RD_REG_DWORD(&reg->host_status);
68 if (stat & HSRX_RISC_INT) {
69 stat &= 0xff;
70
71 if (stat == 0x1 || stat == 0x2 ||
72 stat == 0x10 || stat == 0x11) {
73 set_bit(MBX_INTERRUPT,
74 &ha->mbx_cmd_flags);
75
76 mb[0] = RD_REG_WORD(&reg->mailbox0);
77 mb[2] = RD_REG_WORD(&reg->mailbox2);
78 mb[3] = RD_REG_WORD(&reg->mailbox3);
79
80 WRT_REG_DWORD(&reg->hccr,
81 HCCRX_CLR_RISC_INT);
82 RD_REG_DWORD(&reg->hccr);
83 break;
84 }
85
86 /* Clear this intr; it wasn't a mailbox intr */
87 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
88 RD_REG_DWORD(&reg->hccr);
89 }
90 udelay(5);
91 }
92
93 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
94 rval = mb[0] & MBS_MASK;
95 code_ram[cnt] = htonl((mb[3] << 16) | mb[2]);
96 } else {
97 rval = QLA_FUNCTION_FAILED;
98 }
99 }
100
101 if (rval == QLA_SUCCESS) {
102 /* External Memory. */
103 risc_address = 0x100000;
104 ext_mem_cnt = ha->fw_memory_size - 0x100000 + 1;
105 WRT_REG_WORD(&reg->mailbox0, MBC_READ_RAM_EXTENDED);
106 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
107 }
108 for (cnt = 0; cnt < ext_mem_cnt && rval == QLA_SUCCESS;
109 cnt++, risc_address++) {
110 WRT_REG_WORD(&reg->mailbox1, LSW(risc_address));
111 WRT_REG_WORD(&reg->mailbox8, MSW(risc_address));
112 RD_REG_WORD(&reg->mailbox8);
113 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
114
115 for (timer = 6000000; timer; timer--) {
116 /* Check for pending interrupts. */
117 stat = RD_REG_DWORD(&reg->host_status);
118 if (stat & HSRX_RISC_INT) {
119 stat &= 0xff;
120
121 if (stat == 0x1 || stat == 0x2 ||
122 stat == 0x10 || stat == 0x11) {
123 set_bit(MBX_INTERRUPT,
124 &ha->mbx_cmd_flags);
125
126 mb[0] = RD_REG_WORD(&reg->mailbox0);
127 mb[2] = RD_REG_WORD(&reg->mailbox2);
128 mb[3] = RD_REG_WORD(&reg->mailbox3);
129
130 WRT_REG_DWORD(&reg->hccr,
131 HCCRX_CLR_RISC_INT);
132 RD_REG_DWORD(&reg->hccr);
133 break;
134 }
135
136 /* Clear this intr; it wasn't a mailbox intr */
137 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT);
138 RD_REG_DWORD(&reg->hccr);
139 }
140 udelay(5);
141 }
142
143 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) {
144 rval = mb[0] & MBS_MASK;
145 ext_mem[cnt] = htonl((mb[3] << 16) | mb[2]);
146 } else {
147 rval = QLA_FUNCTION_FAILED;
148 }
149 }
150
151 *nxt = rval == QLA_SUCCESS ? &ext_mem[cnt]: NULL;
152 return rval;
153}
154
40/** 155/**
41 * qla2300_fw_dump() - Dumps binary data from the 2300 firmware. 156 * qla2300_fw_dump() - Dumps binary data from the 2300 firmware.
42 * @ha: HA context 157 * @ha: HA context
@@ -633,11 +748,10 @@ void
633qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked) 748qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
634{ 749{
635 int rval; 750 int rval;
636 uint32_t cnt, timer; 751 uint32_t cnt;
637 uint32_t risc_address; 752 uint32_t risc_address;
638 uint16_t mb[4], wd; 753 uint16_t mb0, wd;
639 754
640 uint32_t stat;
641 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 755 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
642 uint32_t __iomem *dmp_reg; 756 uint32_t __iomem *dmp_reg;
643 uint32_t *iter_reg; 757 uint32_t *iter_reg;
@@ -645,10 +759,9 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
645 unsigned long flags; 759 unsigned long flags;
646 struct qla24xx_fw_dump *fw; 760 struct qla24xx_fw_dump *fw;
647 uint32_t ext_mem_cnt; 761 uint32_t ext_mem_cnt;
648 void *eft; 762 void *nxt;
649 763
650 risc_address = ext_mem_cnt = 0; 764 risc_address = ext_mem_cnt = 0;
651 memset(mb, 0, sizeof(mb));
652 flags = 0; 765 flags = 0;
653 766
654 if (!hardware_locked) 767 if (!hardware_locked)
@@ -701,250 +814,236 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
701 /* Shadow registers. */ 814 /* Shadow registers. */
702 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70); 815 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
703 RD_REG_DWORD(&reg->iobase_addr); 816 RD_REG_DWORD(&reg->iobase_addr);
704 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 817 WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
705 WRT_REG_DWORD(dmp_reg, 0xB0000000); 818 fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
706 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 819
707 fw->shadow_reg[0] = htonl(RD_REG_DWORD(dmp_reg)); 820 WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
708 821 fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
709 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 822
710 WRT_REG_DWORD(dmp_reg, 0xB0100000); 823 WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
711 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 824 fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
712 fw->shadow_reg[1] = htonl(RD_REG_DWORD(dmp_reg)); 825
713 826 WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
714 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 827 fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
715 WRT_REG_DWORD(dmp_reg, 0xB0200000); 828
716 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 829 WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
717 fw->shadow_reg[2] = htonl(RD_REG_DWORD(dmp_reg)); 830 fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
718 831
719 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0); 832 WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
720 WRT_REG_DWORD(dmp_reg, 0xB0300000); 833 fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
721 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC); 834
722 fw->shadow_reg[3] = htonl(RD_REG_DWORD(dmp_reg)); 835 WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
723 836 fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
724 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
725 WRT_REG_DWORD(dmp_reg, 0xB0400000);
726 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
727 fw->shadow_reg[4] = htonl(RD_REG_DWORD(dmp_reg));
728
729 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
730 WRT_REG_DWORD(dmp_reg, 0xB0500000);
731 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
732 fw->shadow_reg[5] = htonl(RD_REG_DWORD(dmp_reg));
733
734 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xF0);
735 WRT_REG_DWORD(dmp_reg, 0xB0600000);
736 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xFC);
737 fw->shadow_reg[6] = htonl(RD_REG_DWORD(dmp_reg));
738 837
739 /* Mailbox registers. */ 838 /* Mailbox registers. */
740 mbx_reg = (uint16_t __iomem *)((uint8_t __iomem *)reg + 0x80); 839 mbx_reg = &reg->mailbox0;
741 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++) 840 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
742 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg++)); 841 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg++));
743 842
744 /* Transfer sequence registers. */ 843 /* Transfer sequence registers. */
745 iter_reg = fw->xseq_gp_reg; 844 iter_reg = fw->xseq_gp_reg;
746 WRT_REG_DWORD(&reg->iobase_addr, 0xBF00); 845 WRT_REG_DWORD(&reg->iobase_addr, 0xBF00);
747 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 846 dmp_reg = &reg->iobase_window;
748 for (cnt = 0; cnt < 16; cnt++) 847 for (cnt = 0; cnt < 16; cnt++)
749 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 848 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
750 849
751 WRT_REG_DWORD(&reg->iobase_addr, 0xBF10); 850 WRT_REG_DWORD(&reg->iobase_addr, 0xBF10);
752 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 851 dmp_reg = &reg->iobase_window;
753 for (cnt = 0; cnt < 16; cnt++) 852 for (cnt = 0; cnt < 16; cnt++)
754 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 853 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
755 854
756 WRT_REG_DWORD(&reg->iobase_addr, 0xBF20); 855 WRT_REG_DWORD(&reg->iobase_addr, 0xBF20);
757 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 856 dmp_reg = &reg->iobase_window;
758 for (cnt = 0; cnt < 16; cnt++) 857 for (cnt = 0; cnt < 16; cnt++)
759 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 858 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
760 859
761 WRT_REG_DWORD(&reg->iobase_addr, 0xBF30); 860 WRT_REG_DWORD(&reg->iobase_addr, 0xBF30);
762 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 861 dmp_reg = &reg->iobase_window;
763 for (cnt = 0; cnt < 16; cnt++) 862 for (cnt = 0; cnt < 16; cnt++)
764 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 863 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
765 864
766 WRT_REG_DWORD(&reg->iobase_addr, 0xBF40); 865 WRT_REG_DWORD(&reg->iobase_addr, 0xBF40);
767 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 866 dmp_reg = &reg->iobase_window;
768 for (cnt = 0; cnt < 16; cnt++) 867 for (cnt = 0; cnt < 16; cnt++)
769 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 868 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
770 869
771 WRT_REG_DWORD(&reg->iobase_addr, 0xBF50); 870 WRT_REG_DWORD(&reg->iobase_addr, 0xBF50);
772 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 871 dmp_reg = &reg->iobase_window;
773 for (cnt = 0; cnt < 16; cnt++) 872 for (cnt = 0; cnt < 16; cnt++)
774 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 873 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
775 874
776 WRT_REG_DWORD(&reg->iobase_addr, 0xBF60); 875 WRT_REG_DWORD(&reg->iobase_addr, 0xBF60);
777 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 876 dmp_reg = &reg->iobase_window;
778 for (cnt = 0; cnt < 16; cnt++) 877 for (cnt = 0; cnt < 16; cnt++)
779 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 878 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
780 879
781 WRT_REG_DWORD(&reg->iobase_addr, 0xBF70); 880 WRT_REG_DWORD(&reg->iobase_addr, 0xBF70);
782 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 881 dmp_reg = &reg->iobase_window;
783 for (cnt = 0; cnt < 16; cnt++) 882 for (cnt = 0; cnt < 16; cnt++)
784 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 883 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
785 884
786 WRT_REG_DWORD(&reg->iobase_addr, 0xBFE0); 885 WRT_REG_DWORD(&reg->iobase_addr, 0xBFE0);
787 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 886 dmp_reg = &reg->iobase_window;
788 for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++) 887 for (cnt = 0; cnt < sizeof(fw->xseq_0_reg) / 4; cnt++)
789 fw->xseq_0_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 888 fw->xseq_0_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
790 889
791 WRT_REG_DWORD(&reg->iobase_addr, 0xBFF0); 890 WRT_REG_DWORD(&reg->iobase_addr, 0xBFF0);
792 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 891 dmp_reg = &reg->iobase_window;
793 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++) 892 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++)
794 fw->xseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 893 fw->xseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
795 894
796 /* Receive sequence registers. */ 895 /* Receive sequence registers. */
797 iter_reg = fw->rseq_gp_reg; 896 iter_reg = fw->rseq_gp_reg;
798 WRT_REG_DWORD(&reg->iobase_addr, 0xFF00); 897 WRT_REG_DWORD(&reg->iobase_addr, 0xFF00);
799 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 898 dmp_reg = &reg->iobase_window;
800 for (cnt = 0; cnt < 16; cnt++) 899 for (cnt = 0; cnt < 16; cnt++)
801 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 900 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
802 901
803 WRT_REG_DWORD(&reg->iobase_addr, 0xFF10); 902 WRT_REG_DWORD(&reg->iobase_addr, 0xFF10);
804 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 903 dmp_reg = &reg->iobase_window;
805 for (cnt = 0; cnt < 16; cnt++) 904 for (cnt = 0; cnt < 16; cnt++)
806 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 905 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
807 906
808 WRT_REG_DWORD(&reg->iobase_addr, 0xFF20); 907 WRT_REG_DWORD(&reg->iobase_addr, 0xFF20);
809 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 908 dmp_reg = &reg->iobase_window;
810 for (cnt = 0; cnt < 16; cnt++) 909 for (cnt = 0; cnt < 16; cnt++)
811 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 910 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
812 911
813 WRT_REG_DWORD(&reg->iobase_addr, 0xFF30); 912 WRT_REG_DWORD(&reg->iobase_addr, 0xFF30);
814 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 913 dmp_reg = &reg->iobase_window;
815 for (cnt = 0; cnt < 16; cnt++) 914 for (cnt = 0; cnt < 16; cnt++)
816 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 915 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
817 916
818 WRT_REG_DWORD(&reg->iobase_addr, 0xFF40); 917 WRT_REG_DWORD(&reg->iobase_addr, 0xFF40);
819 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 918 dmp_reg = &reg->iobase_window;
820 for (cnt = 0; cnt < 16; cnt++) 919 for (cnt = 0; cnt < 16; cnt++)
821 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 920 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
822 921
823 WRT_REG_DWORD(&reg->iobase_addr, 0xFF50); 922 WRT_REG_DWORD(&reg->iobase_addr, 0xFF50);
824 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 923 dmp_reg = &reg->iobase_window;
825 for (cnt = 0; cnt < 16; cnt++) 924 for (cnt = 0; cnt < 16; cnt++)
826 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 925 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
827 926
828 WRT_REG_DWORD(&reg->iobase_addr, 0xFF60); 927 WRT_REG_DWORD(&reg->iobase_addr, 0xFF60);
829 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 928 dmp_reg = &reg->iobase_window;
830 for (cnt = 0; cnt < 16; cnt++) 929 for (cnt = 0; cnt < 16; cnt++)
831 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 930 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
832 931
833 WRT_REG_DWORD(&reg->iobase_addr, 0xFF70); 932 WRT_REG_DWORD(&reg->iobase_addr, 0xFF70);
834 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 933 dmp_reg = &reg->iobase_window;
835 for (cnt = 0; cnt < 16; cnt++) 934 for (cnt = 0; cnt < 16; cnt++)
836 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 935 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
837 936
838 WRT_REG_DWORD(&reg->iobase_addr, 0xFFD0); 937 WRT_REG_DWORD(&reg->iobase_addr, 0xFFD0);
839 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 938 dmp_reg = &reg->iobase_window;
840 for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++) 939 for (cnt = 0; cnt < sizeof(fw->rseq_0_reg) / 4; cnt++)
841 fw->rseq_0_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 940 fw->rseq_0_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
842 941
843 WRT_REG_DWORD(&reg->iobase_addr, 0xFFE0); 942 WRT_REG_DWORD(&reg->iobase_addr, 0xFFE0);
844 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 943 dmp_reg = &reg->iobase_window;
845 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++) 944 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++)
846 fw->rseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 945 fw->rseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
847 946
848 WRT_REG_DWORD(&reg->iobase_addr, 0xFFF0); 947 WRT_REG_DWORD(&reg->iobase_addr, 0xFFF0);
849 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 948 dmp_reg = &reg->iobase_window;
850 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++) 949 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++)
851 fw->rseq_2_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 950 fw->rseq_2_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
852 951
853 /* Command DMA registers. */ 952 /* Command DMA registers. */
854 WRT_REG_DWORD(&reg->iobase_addr, 0x7100); 953 WRT_REG_DWORD(&reg->iobase_addr, 0x7100);
855 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 954 dmp_reg = &reg->iobase_window;
856 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++) 955 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++)
857 fw->cmd_dma_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++)); 956 fw->cmd_dma_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
858 957
859 /* Queues. */ 958 /* Queues. */
860 iter_reg = fw->req0_dma_reg; 959 iter_reg = fw->req0_dma_reg;
861 WRT_REG_DWORD(&reg->iobase_addr, 0x7200); 960 WRT_REG_DWORD(&reg->iobase_addr, 0x7200);
862 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 961 dmp_reg = &reg->iobase_window;
863 for (cnt = 0; cnt < 8; cnt++) 962 for (cnt = 0; cnt < 8; cnt++)
864 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 963 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
865 964
866 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4); 965 dmp_reg = &reg->iobase_q;
867 for (cnt = 0; cnt < 7; cnt++) 966 for (cnt = 0; cnt < 7; cnt++)
868 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 967 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
869 968
870 iter_reg = fw->resp0_dma_reg; 969 iter_reg = fw->resp0_dma_reg;
871 WRT_REG_DWORD(&reg->iobase_addr, 0x7300); 970 WRT_REG_DWORD(&reg->iobase_addr, 0x7300);
872 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 971 dmp_reg = &reg->iobase_window;
873 for (cnt = 0; cnt < 8; cnt++) 972 for (cnt = 0; cnt < 8; cnt++)
874 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 973 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
875 974
876 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4); 975 dmp_reg = &reg->iobase_q;
877 for (cnt = 0; cnt < 7; cnt++) 976 for (cnt = 0; cnt < 7; cnt++)
878 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 977 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
879 978
880 iter_reg = fw->req1_dma_reg; 979 iter_reg = fw->req1_dma_reg;
881 WRT_REG_DWORD(&reg->iobase_addr, 0x7400); 980 WRT_REG_DWORD(&reg->iobase_addr, 0x7400);
882 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 981 dmp_reg = &reg->iobase_window;
883 for (cnt = 0; cnt < 8; cnt++) 982 for (cnt = 0; cnt < 8; cnt++)
884 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 983 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
885 984
886 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xE4); 985 dmp_reg = &reg->iobase_q;
887 for (cnt = 0; cnt < 7; cnt++) 986 for (cnt = 0; cnt < 7; cnt++)
888 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 987 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
889 988
890 /* Transmit DMA registers. */ 989 /* Transmit DMA registers. */
891 iter_reg = fw->xmt0_dma_reg; 990 iter_reg = fw->xmt0_dma_reg;
892 WRT_REG_DWORD(&reg->iobase_addr, 0x7600); 991 WRT_REG_DWORD(&reg->iobase_addr, 0x7600);
893 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 992 dmp_reg = &reg->iobase_window;
894 for (cnt = 0; cnt < 16; cnt++) 993 for (cnt = 0; cnt < 16; cnt++)
895 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 994 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
896 995
897 WRT_REG_DWORD(&reg->iobase_addr, 0x7610); 996 WRT_REG_DWORD(&reg->iobase_addr, 0x7610);
898 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 997 dmp_reg = &reg->iobase_window;
899 for (cnt = 0; cnt < 16; cnt++) 998 for (cnt = 0; cnt < 16; cnt++)
900 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 999 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
901 1000
902 iter_reg = fw->xmt1_dma_reg; 1001 iter_reg = fw->xmt1_dma_reg;
903 WRT_REG_DWORD(&reg->iobase_addr, 0x7620); 1002 WRT_REG_DWORD(&reg->iobase_addr, 0x7620);
904 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1003 dmp_reg = &reg->iobase_window;
905 for (cnt = 0; cnt < 16; cnt++) 1004 for (cnt = 0; cnt < 16; cnt++)
906 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1005 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
907 1006
908 WRT_REG_DWORD(&reg->iobase_addr, 0x7630); 1007 WRT_REG_DWORD(&reg->iobase_addr, 0x7630);
909 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1008 dmp_reg = &reg->iobase_window;
910 for (cnt = 0; cnt < 16; cnt++) 1009 for (cnt = 0; cnt < 16; cnt++)
911 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1010 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
912 1011
913 iter_reg = fw->xmt2_dma_reg; 1012 iter_reg = fw->xmt2_dma_reg;
914 WRT_REG_DWORD(&reg->iobase_addr, 0x7640); 1013 WRT_REG_DWORD(&reg->iobase_addr, 0x7640);
915 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1014 dmp_reg = &reg->iobase_window;
916 for (cnt = 0; cnt < 16; cnt++) 1015 for (cnt = 0; cnt < 16; cnt++)
917 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1016 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
918 1017
919 WRT_REG_DWORD(&reg->iobase_addr, 0x7650); 1018 WRT_REG_DWORD(&reg->iobase_addr, 0x7650);
920 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1019 dmp_reg = &reg->iobase_window;
921 for (cnt = 0; cnt < 16; cnt++) 1020 for (cnt = 0; cnt < 16; cnt++)
922 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1021 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
923 1022
924 iter_reg = fw->xmt3_dma_reg; 1023 iter_reg = fw->xmt3_dma_reg;
925 WRT_REG_DWORD(&reg->iobase_addr, 0x7660); 1024 WRT_REG_DWORD(&reg->iobase_addr, 0x7660);
926 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1025 dmp_reg = &reg->iobase_window;
927 for (cnt = 0; cnt < 16; cnt++) 1026 for (cnt = 0; cnt < 16; cnt++)
928 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1027 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
929 1028
930 WRT_REG_DWORD(&reg->iobase_addr, 0x7670); 1029 WRT_REG_DWORD(&reg->iobase_addr, 0x7670);
931 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1030 dmp_reg = &reg->iobase_window;
932 for (cnt = 0; cnt < 16; cnt++) 1031 for (cnt = 0; cnt < 16; cnt++)
933 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1032 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
934 1033
935 iter_reg = fw->xmt4_dma_reg; 1034 iter_reg = fw->xmt4_dma_reg;
936 WRT_REG_DWORD(&reg->iobase_addr, 0x7680); 1035 WRT_REG_DWORD(&reg->iobase_addr, 0x7680);
937 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1036 dmp_reg = &reg->iobase_window;
938 for (cnt = 0; cnt < 16; cnt++) 1037 for (cnt = 0; cnt < 16; cnt++)
939 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1038 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
940 1039
941 WRT_REG_DWORD(&reg->iobase_addr, 0x7690); 1040 WRT_REG_DWORD(&reg->iobase_addr, 0x7690);
942 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1041 dmp_reg = &reg->iobase_window;
943 for (cnt = 0; cnt < 16; cnt++) 1042 for (cnt = 0; cnt < 16; cnt++)
944 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1043 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
945 1044
946 WRT_REG_DWORD(&reg->iobase_addr, 0x76A0); 1045 WRT_REG_DWORD(&reg->iobase_addr, 0x76A0);
947 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1046 dmp_reg = &reg->iobase_window;
948 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++) 1047 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++)
949 fw->xmt_data_dma_reg[cnt] = 1048 fw->xmt_data_dma_reg[cnt] =
950 htonl(RD_REG_DWORD(dmp_reg++)); 1049 htonl(RD_REG_DWORD(dmp_reg++));
@@ -952,221 +1051,221 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
952 /* Receive DMA registers. */ 1051 /* Receive DMA registers. */
953 iter_reg = fw->rcvt0_data_dma_reg; 1052 iter_reg = fw->rcvt0_data_dma_reg;
954 WRT_REG_DWORD(&reg->iobase_addr, 0x7700); 1053 WRT_REG_DWORD(&reg->iobase_addr, 0x7700);
955 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1054 dmp_reg = &reg->iobase_window;
956 for (cnt = 0; cnt < 16; cnt++) 1055 for (cnt = 0; cnt < 16; cnt++)
957 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1056 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
958 1057
959 WRT_REG_DWORD(&reg->iobase_addr, 0x7710); 1058 WRT_REG_DWORD(&reg->iobase_addr, 0x7710);
960 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1059 dmp_reg = &reg->iobase_window;
961 for (cnt = 0; cnt < 16; cnt++) 1060 for (cnt = 0; cnt < 16; cnt++)
962 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1061 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
963 1062
964 iter_reg = fw->rcvt1_data_dma_reg; 1063 iter_reg = fw->rcvt1_data_dma_reg;
965 WRT_REG_DWORD(&reg->iobase_addr, 0x7720); 1064 WRT_REG_DWORD(&reg->iobase_addr, 0x7720);
966 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1065 dmp_reg = &reg->iobase_window;
967 for (cnt = 0; cnt < 16; cnt++) 1066 for (cnt = 0; cnt < 16; cnt++)
968 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1067 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
969 1068
970 WRT_REG_DWORD(&reg->iobase_addr, 0x7730); 1069 WRT_REG_DWORD(&reg->iobase_addr, 0x7730);
971 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1070 dmp_reg = &reg->iobase_window;
972 for (cnt = 0; cnt < 16; cnt++) 1071 for (cnt = 0; cnt < 16; cnt++)
973 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1072 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
974 1073
975 /* RISC registers. */ 1074 /* RISC registers. */
976 iter_reg = fw->risc_gp_reg; 1075 iter_reg = fw->risc_gp_reg;
977 WRT_REG_DWORD(&reg->iobase_addr, 0x0F00); 1076 WRT_REG_DWORD(&reg->iobase_addr, 0x0F00);
978 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1077 dmp_reg = &reg->iobase_window;
979 for (cnt = 0; cnt < 16; cnt++) 1078 for (cnt = 0; cnt < 16; cnt++)
980 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1079 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
981 1080
982 WRT_REG_DWORD(&reg->iobase_addr, 0x0F10); 1081 WRT_REG_DWORD(&reg->iobase_addr, 0x0F10);
983 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1082 dmp_reg = &reg->iobase_window;
984 for (cnt = 0; cnt < 16; cnt++) 1083 for (cnt = 0; cnt < 16; cnt++)
985 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1084 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
986 1085
987 WRT_REG_DWORD(&reg->iobase_addr, 0x0F20); 1086 WRT_REG_DWORD(&reg->iobase_addr, 0x0F20);
988 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1087 dmp_reg = &reg->iobase_window;
989 for (cnt = 0; cnt < 16; cnt++) 1088 for (cnt = 0; cnt < 16; cnt++)
990 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1089 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
991 1090
992 WRT_REG_DWORD(&reg->iobase_addr, 0x0F30); 1091 WRT_REG_DWORD(&reg->iobase_addr, 0x0F30);
993 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1092 dmp_reg = &reg->iobase_window;
994 for (cnt = 0; cnt < 16; cnt++) 1093 for (cnt = 0; cnt < 16; cnt++)
995 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1094 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
996 1095
997 WRT_REG_DWORD(&reg->iobase_addr, 0x0F40); 1096 WRT_REG_DWORD(&reg->iobase_addr, 0x0F40);
998 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1097 dmp_reg = &reg->iobase_window;
999 for (cnt = 0; cnt < 16; cnt++) 1098 for (cnt = 0; cnt < 16; cnt++)
1000 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1099 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1001 1100
1002 WRT_REG_DWORD(&reg->iobase_addr, 0x0F50); 1101 WRT_REG_DWORD(&reg->iobase_addr, 0x0F50);
1003 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1102 dmp_reg = &reg->iobase_window;
1004 for (cnt = 0; cnt < 16; cnt++) 1103 for (cnt = 0; cnt < 16; cnt++)
1005 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1104 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1006 1105
1007 WRT_REG_DWORD(&reg->iobase_addr, 0x0F60); 1106 WRT_REG_DWORD(&reg->iobase_addr, 0x0F60);
1008 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1107 dmp_reg = &reg->iobase_window;
1009 for (cnt = 0; cnt < 16; cnt++) 1108 for (cnt = 0; cnt < 16; cnt++)
1010 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1109 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1011 1110
1012 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70); 1111 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
1013 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1112 dmp_reg = &reg->iobase_window;
1014 for (cnt = 0; cnt < 16; cnt++) 1113 for (cnt = 0; cnt < 16; cnt++)
1015 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1114 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1016 1115
1017 /* Local memory controller registers. */ 1116 /* Local memory controller registers. */
1018 iter_reg = fw->lmc_reg; 1117 iter_reg = fw->lmc_reg;
1019 WRT_REG_DWORD(&reg->iobase_addr, 0x3000); 1118 WRT_REG_DWORD(&reg->iobase_addr, 0x3000);
1020 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1119 dmp_reg = &reg->iobase_window;
1021 for (cnt = 0; cnt < 16; cnt++) 1120 for (cnt = 0; cnt < 16; cnt++)
1022 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1121 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1023 1122
1024 WRT_REG_DWORD(&reg->iobase_addr, 0x3010); 1123 WRT_REG_DWORD(&reg->iobase_addr, 0x3010);
1025 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1124 dmp_reg = &reg->iobase_window;
1026 for (cnt = 0; cnt < 16; cnt++) 1125 for (cnt = 0; cnt < 16; cnt++)
1027 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1126 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1028 1127
1029 WRT_REG_DWORD(&reg->iobase_addr, 0x3020); 1128 WRT_REG_DWORD(&reg->iobase_addr, 0x3020);
1030 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1129 dmp_reg = &reg->iobase_window;
1031 for (cnt = 0; cnt < 16; cnt++) 1130 for (cnt = 0; cnt < 16; cnt++)
1032 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1131 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1033 1132
1034 WRT_REG_DWORD(&reg->iobase_addr, 0x3030); 1133 WRT_REG_DWORD(&reg->iobase_addr, 0x3030);
1035 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1134 dmp_reg = &reg->iobase_window;
1036 for (cnt = 0; cnt < 16; cnt++) 1135 for (cnt = 0; cnt < 16; cnt++)
1037 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1136 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1038 1137
1039 WRT_REG_DWORD(&reg->iobase_addr, 0x3040); 1138 WRT_REG_DWORD(&reg->iobase_addr, 0x3040);
1040 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1139 dmp_reg = &reg->iobase_window;
1041 for (cnt = 0; cnt < 16; cnt++) 1140 for (cnt = 0; cnt < 16; cnt++)
1042 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1141 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1043 1142
1044 WRT_REG_DWORD(&reg->iobase_addr, 0x3050); 1143 WRT_REG_DWORD(&reg->iobase_addr, 0x3050);
1045 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1144 dmp_reg = &reg->iobase_window;
1046 for (cnt = 0; cnt < 16; cnt++) 1145 for (cnt = 0; cnt < 16; cnt++)
1047 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1146 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1048 1147
1049 WRT_REG_DWORD(&reg->iobase_addr, 0x3060); 1148 WRT_REG_DWORD(&reg->iobase_addr, 0x3060);
1050 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1149 dmp_reg = &reg->iobase_window;
1051 for (cnt = 0; cnt < 16; cnt++) 1150 for (cnt = 0; cnt < 16; cnt++)
1052 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1151 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1053 1152
1054 /* Fibre Protocol Module registers. */ 1153 /* Fibre Protocol Module registers. */
1055 iter_reg = fw->fpm_hdw_reg; 1154 iter_reg = fw->fpm_hdw_reg;
1056 WRT_REG_DWORD(&reg->iobase_addr, 0x4000); 1155 WRT_REG_DWORD(&reg->iobase_addr, 0x4000);
1057 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1156 dmp_reg = &reg->iobase_window;
1058 for (cnt = 0; cnt < 16; cnt++) 1157 for (cnt = 0; cnt < 16; cnt++)
1059 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1158 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1060 1159
1061 WRT_REG_DWORD(&reg->iobase_addr, 0x4010); 1160 WRT_REG_DWORD(&reg->iobase_addr, 0x4010);
1062 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1161 dmp_reg = &reg->iobase_window;
1063 for (cnt = 0; cnt < 16; cnt++) 1162 for (cnt = 0; cnt < 16; cnt++)
1064 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1163 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1065 1164
1066 WRT_REG_DWORD(&reg->iobase_addr, 0x4020); 1165 WRT_REG_DWORD(&reg->iobase_addr, 0x4020);
1067 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1166 dmp_reg = &reg->iobase_window;
1068 for (cnt = 0; cnt < 16; cnt++) 1167 for (cnt = 0; cnt < 16; cnt++)
1069 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1168 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1070 1169
1071 WRT_REG_DWORD(&reg->iobase_addr, 0x4030); 1170 WRT_REG_DWORD(&reg->iobase_addr, 0x4030);
1072 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1171 dmp_reg = &reg->iobase_window;
1073 for (cnt = 0; cnt < 16; cnt++) 1172 for (cnt = 0; cnt < 16; cnt++)
1074 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1173 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1075 1174
1076 WRT_REG_DWORD(&reg->iobase_addr, 0x4040); 1175 WRT_REG_DWORD(&reg->iobase_addr, 0x4040);
1077 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1176 dmp_reg = &reg->iobase_window;
1078 for (cnt = 0; cnt < 16; cnt++) 1177 for (cnt = 0; cnt < 16; cnt++)
1079 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1178 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1080 1179
1081 WRT_REG_DWORD(&reg->iobase_addr, 0x4050); 1180 WRT_REG_DWORD(&reg->iobase_addr, 0x4050);
1082 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1181 dmp_reg = &reg->iobase_window;
1083 for (cnt = 0; cnt < 16; cnt++) 1182 for (cnt = 0; cnt < 16; cnt++)
1084 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1183 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1085 1184
1086 WRT_REG_DWORD(&reg->iobase_addr, 0x4060); 1185 WRT_REG_DWORD(&reg->iobase_addr, 0x4060);
1087 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1186 dmp_reg = &reg->iobase_window;
1088 for (cnt = 0; cnt < 16; cnt++) 1187 for (cnt = 0; cnt < 16; cnt++)
1089 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1188 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1090 1189
1091 WRT_REG_DWORD(&reg->iobase_addr, 0x4070); 1190 WRT_REG_DWORD(&reg->iobase_addr, 0x4070);
1092 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1191 dmp_reg = &reg->iobase_window;
1093 for (cnt = 0; cnt < 16; cnt++) 1192 for (cnt = 0; cnt < 16; cnt++)
1094 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1193 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1095 1194
1096 WRT_REG_DWORD(&reg->iobase_addr, 0x4080); 1195 WRT_REG_DWORD(&reg->iobase_addr, 0x4080);
1097 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1196 dmp_reg = &reg->iobase_window;
1098 for (cnt = 0; cnt < 16; cnt++) 1197 for (cnt = 0; cnt < 16; cnt++)
1099 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1198 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1100 1199
1101 WRT_REG_DWORD(&reg->iobase_addr, 0x4090); 1200 WRT_REG_DWORD(&reg->iobase_addr, 0x4090);
1102 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1201 dmp_reg = &reg->iobase_window;
1103 for (cnt = 0; cnt < 16; cnt++) 1202 for (cnt = 0; cnt < 16; cnt++)
1104 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1203 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1105 1204
1106 WRT_REG_DWORD(&reg->iobase_addr, 0x40A0); 1205 WRT_REG_DWORD(&reg->iobase_addr, 0x40A0);
1107 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1206 dmp_reg = &reg->iobase_window;
1108 for (cnt = 0; cnt < 16; cnt++) 1207 for (cnt = 0; cnt < 16; cnt++)
1109 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1208 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1110 1209
1111 WRT_REG_DWORD(&reg->iobase_addr, 0x40B0); 1210 WRT_REG_DWORD(&reg->iobase_addr, 0x40B0);
1112 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1211 dmp_reg = &reg->iobase_window;
1113 for (cnt = 0; cnt < 16; cnt++) 1212 for (cnt = 0; cnt < 16; cnt++)
1114 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1213 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1115 1214
1116 /* Frame Buffer registers. */ 1215 /* Frame Buffer registers. */
1117 iter_reg = fw->fb_hdw_reg; 1216 iter_reg = fw->fb_hdw_reg;
1118 WRT_REG_DWORD(&reg->iobase_addr, 0x6000); 1217 WRT_REG_DWORD(&reg->iobase_addr, 0x6000);
1119 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1218 dmp_reg = &reg->iobase_window;
1120 for (cnt = 0; cnt < 16; cnt++) 1219 for (cnt = 0; cnt < 16; cnt++)
1121 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1220 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1122 1221
1123 WRT_REG_DWORD(&reg->iobase_addr, 0x6010); 1222 WRT_REG_DWORD(&reg->iobase_addr, 0x6010);
1124 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1223 dmp_reg = &reg->iobase_window;
1125 for (cnt = 0; cnt < 16; cnt++) 1224 for (cnt = 0; cnt < 16; cnt++)
1126 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1225 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1127 1226
1128 WRT_REG_DWORD(&reg->iobase_addr, 0x6020); 1227 WRT_REG_DWORD(&reg->iobase_addr, 0x6020);
1129 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1228 dmp_reg = &reg->iobase_window;
1130 for (cnt = 0; cnt < 16; cnt++) 1229 for (cnt = 0; cnt < 16; cnt++)
1131 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1230 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1132 1231
1133 WRT_REG_DWORD(&reg->iobase_addr, 0x6030); 1232 WRT_REG_DWORD(&reg->iobase_addr, 0x6030);
1134 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1233 dmp_reg = &reg->iobase_window;
1135 for (cnt = 0; cnt < 16; cnt++) 1234 for (cnt = 0; cnt < 16; cnt++)
1136 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1235 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1137 1236
1138 WRT_REG_DWORD(&reg->iobase_addr, 0x6040); 1237 WRT_REG_DWORD(&reg->iobase_addr, 0x6040);
1139 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1238 dmp_reg = &reg->iobase_window;
1140 for (cnt = 0; cnt < 16; cnt++) 1239 for (cnt = 0; cnt < 16; cnt++)
1141 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1240 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1142 1241
1143 WRT_REG_DWORD(&reg->iobase_addr, 0x6100); 1242 WRT_REG_DWORD(&reg->iobase_addr, 0x6100);
1144 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1243 dmp_reg = &reg->iobase_window;
1145 for (cnt = 0; cnt < 16; cnt++) 1244 for (cnt = 0; cnt < 16; cnt++)
1146 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1245 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1147 1246
1148 WRT_REG_DWORD(&reg->iobase_addr, 0x6130); 1247 WRT_REG_DWORD(&reg->iobase_addr, 0x6130);
1149 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1248 dmp_reg = &reg->iobase_window;
1150 for (cnt = 0; cnt < 16; cnt++) 1249 for (cnt = 0; cnt < 16; cnt++)
1151 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1250 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1152 1251
1153 WRT_REG_DWORD(&reg->iobase_addr, 0x6150); 1252 WRT_REG_DWORD(&reg->iobase_addr, 0x6150);
1154 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1253 dmp_reg = &reg->iobase_window;
1155 for (cnt = 0; cnt < 16; cnt++) 1254 for (cnt = 0; cnt < 16; cnt++)
1156 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1255 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1157 1256
1158 WRT_REG_DWORD(&reg->iobase_addr, 0x6170); 1257 WRT_REG_DWORD(&reg->iobase_addr, 0x6170);
1159 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1258 dmp_reg = &reg->iobase_window;
1160 for (cnt = 0; cnt < 16; cnt++) 1259 for (cnt = 0; cnt < 16; cnt++)
1161 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1260 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1162 1261
1163 WRT_REG_DWORD(&reg->iobase_addr, 0x6190); 1262 WRT_REG_DWORD(&reg->iobase_addr, 0x6190);
1164 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1263 dmp_reg = &reg->iobase_window;
1165 for (cnt = 0; cnt < 16; cnt++) 1264 for (cnt = 0; cnt < 16; cnt++)
1166 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1265 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1167 1266
1168 WRT_REG_DWORD(&reg->iobase_addr, 0x61B0); 1267 WRT_REG_DWORD(&reg->iobase_addr, 0x61B0);
1169 dmp_reg = (uint32_t __iomem *)((uint8_t __iomem *)reg + 0xC0); 1268 dmp_reg = &reg->iobase_window;
1170 for (cnt = 0; cnt < 16; cnt++) 1269 for (cnt = 0; cnt < 16; cnt++)
1171 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++)); 1270 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1172 1271
@@ -1187,10 +1286,10 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1187 1286
1188 udelay(100); 1287 udelay(100);
1189 /* Wait for firmware to complete NVRAM accesses. */ 1288 /* Wait for firmware to complete NVRAM accesses. */
1190 mb[0] = (uint32_t) RD_REG_WORD(&reg->mailbox0); 1289 mb0 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
1191 for (cnt = 10000 ; cnt && mb[0]; cnt--) { 1290 for (cnt = 10000 ; cnt && mb0; cnt--) {
1192 udelay(5); 1291 udelay(5);
1193 mb[0] = (uint32_t) RD_REG_WORD(&reg->mailbox0); 1292 mb0 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
1194 barrier(); 1293 barrier();
1195 } 1294 }
1196 1295
@@ -1214,110 +1313,717 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1214 rval = QLA_FUNCTION_TIMEOUT; 1313 rval = QLA_FUNCTION_TIMEOUT;
1215 } 1314 }
1216 1315
1217 /* Memory. */ 1316 if (rval == QLA_SUCCESS)
1317 rval = qla2xxx_dump_memory(ha, fw->code_ram,
1318 sizeof(fw->code_ram), fw->ext_mem, &nxt);
1319
1218 if (rval == QLA_SUCCESS) { 1320 if (rval == QLA_SUCCESS) {
1219 /* Code RAM. */ 1321 nxt = qla2xxx_copy_queues(ha, nxt);
1220 risc_address = 0x20000; 1322 if (ha->eft)
1221 WRT_REG_WORD(&reg->mailbox0, MBC_READ_RAM_EXTENDED); 1323 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size));
1222 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1223 } 1324 }
1224 for (cnt = 0; cnt < sizeof(fw->code_ram) / 4 && rval == QLA_SUCCESS;
1225 cnt++, risc_address++) {
1226 WRT_REG_WORD(&reg->mailbox1, LSW(risc_address));
1227 WRT_REG_WORD(&reg->mailbox8, MSW(risc_address));
1228 RD_REG_WORD(&reg->mailbox8);
1229 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
1230 1325
1231 for (timer = 6000000; timer; timer--) { 1326 if (rval != QLA_SUCCESS) {
1232 /* Check for pending interrupts. */ 1327 qla_printk(KERN_WARNING, ha,
1233 stat = RD_REG_DWORD(&reg->host_status); 1328 "Failed to dump firmware (%x)!!!\n", rval);
1234 if (stat & HSRX_RISC_INT) { 1329 ha->fw_dumped = 0;
1235 stat &= 0xff;
1236 1330
1237 if (stat == 0x1 || stat == 0x2 || 1331 } else {
1238 stat == 0x10 || stat == 0x11) { 1332 qla_printk(KERN_INFO, ha,
1239 set_bit(MBX_INTERRUPT, 1333 "Firmware dump saved to temp buffer (%ld/%p).\n",
1240 &ha->mbx_cmd_flags); 1334 ha->host_no, ha->fw_dump);
1335 ha->fw_dumped = 1;
1336 }
1241 1337
1242 mb[0] = RD_REG_WORD(&reg->mailbox0); 1338qla24xx_fw_dump_failed:
1243 mb[2] = RD_REG_WORD(&reg->mailbox2); 1339 if (!hardware_locked)
1244 mb[3] = RD_REG_WORD(&reg->mailbox3); 1340 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1341}
1245 1342
1246 WRT_REG_DWORD(&reg->hccr, 1343void
1247 HCCRX_CLR_RISC_INT); 1344qla25xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1248 RD_REG_DWORD(&reg->hccr); 1345{
1249 break; 1346 int rval;
1250 } 1347 uint32_t cnt;
1348 uint32_t risc_address;
1349 uint16_t mb0, wd;
1251 1350
1252 /* Clear this intr; it wasn't a mailbox intr */ 1351 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1253 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT); 1352 uint32_t __iomem *dmp_reg;
1254 RD_REG_DWORD(&reg->hccr); 1353 uint32_t *iter_reg;
1255 } 1354 uint16_t __iomem *mbx_reg;
1256 udelay(5); 1355 unsigned long flags;
1257 } 1356 struct qla25xx_fw_dump *fw;
1357 uint32_t ext_mem_cnt;
1358 void *nxt;
1258 1359
1259 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 1360 risc_address = ext_mem_cnt = 0;
1260 rval = mb[0] & MBS_MASK; 1361 flags = 0;
1261 fw->code_ram[cnt] = htonl((mb[3] << 16) | mb[2]); 1362
1262 } else { 1363 if (!hardware_locked)
1263 rval = QLA_FUNCTION_FAILED; 1364 spin_lock_irqsave(&ha->hardware_lock, flags);
1365
1366 if (!ha->fw_dump) {
1367 qla_printk(KERN_WARNING, ha,
1368 "No buffer available for dump!!!\n");
1369 goto qla25xx_fw_dump_failed;
1370 }
1371
1372 if (ha->fw_dumped) {
1373 qla_printk(KERN_WARNING, ha,
1374 "Firmware has been previously dumped (%p) -- ignoring "
1375 "request...\n", ha->fw_dump);
1376 goto qla25xx_fw_dump_failed;
1377 }
1378 fw = &ha->fw_dump->isp.isp25;
1379 qla2xxx_prep_dump(ha, ha->fw_dump);
1380
1381 rval = QLA_SUCCESS;
1382 fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
1383
1384 /* Pause RISC. */
1385 if ((RD_REG_DWORD(&reg->hccr) & HCCRX_RISC_PAUSE) == 0) {
1386 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET |
1387 HCCRX_CLR_HOST_INT);
1388 RD_REG_DWORD(&reg->hccr); /* PCI Posting. */
1389 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_PAUSE);
1390 for (cnt = 30000;
1391 (RD_REG_DWORD(&reg->hccr) & HCCRX_RISC_PAUSE) == 0 &&
1392 rval == QLA_SUCCESS; cnt--) {
1393 if (cnt)
1394 udelay(100);
1395 else
1396 rval = QLA_FUNCTION_TIMEOUT;
1264 } 1397 }
1265 } 1398 }
1266 1399
1267 if (rval == QLA_SUCCESS) { 1400 if (rval == QLA_SUCCESS) {
1268 /* External Memory. */ 1401 /* Host interface registers. */
1269 risc_address = 0x100000; 1402 dmp_reg = (uint32_t __iomem *)(reg + 0);
1270 ext_mem_cnt = ha->fw_memory_size - 0x100000 + 1; 1403 for (cnt = 0; cnt < sizeof(fw->host_reg) / 4; cnt++)
1271 WRT_REG_WORD(&reg->mailbox0, MBC_READ_RAM_EXTENDED); 1404 fw->host_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1272 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags);
1273 }
1274 for (cnt = 0; cnt < ext_mem_cnt && rval == QLA_SUCCESS;
1275 cnt++, risc_address++) {
1276 WRT_REG_WORD(&reg->mailbox1, LSW(risc_address));
1277 WRT_REG_WORD(&reg->mailbox8, MSW(risc_address));
1278 RD_REG_WORD(&reg->mailbox8);
1279 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_HOST_INT);
1280 1405
1281 for (timer = 6000000; timer; timer--) { 1406 /* Disable interrupts. */
1282 /* Check for pending interrupts. */ 1407 WRT_REG_DWORD(&reg->ictrl, 0);
1283 stat = RD_REG_DWORD(&reg->host_status); 1408 RD_REG_DWORD(&reg->ictrl);
1284 if (stat & HSRX_RISC_INT) {
1285 stat &= 0xff;
1286 1409
1287 if (stat == 0x1 || stat == 0x2 || 1410 /* Shadow registers. */
1288 stat == 0x10 || stat == 0x11) { 1411 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
1289 set_bit(MBX_INTERRUPT, 1412 RD_REG_DWORD(&reg->iobase_addr);
1290 &ha->mbx_cmd_flags); 1413 WRT_REG_DWORD(&reg->iobase_select, 0xB0000000);
1414 fw->shadow_reg[0] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1291 1415
1292 mb[0] = RD_REG_WORD(&reg->mailbox0); 1416 WRT_REG_DWORD(&reg->iobase_select, 0xB0100000);
1293 mb[2] = RD_REG_WORD(&reg->mailbox2); 1417 fw->shadow_reg[1] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1294 mb[3] = RD_REG_WORD(&reg->mailbox3);
1295 1418
1296 WRT_REG_DWORD(&reg->hccr, 1419 WRT_REG_DWORD(&reg->iobase_select, 0xB0200000);
1297 HCCRX_CLR_RISC_INT); 1420 fw->shadow_reg[2] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1298 RD_REG_DWORD(&reg->hccr);
1299 break;
1300 }
1301 1421
1302 /* Clear this intr; it wasn't a mailbox intr */ 1422 WRT_REG_DWORD(&reg->iobase_select, 0xB0300000);
1303 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_INT); 1423 fw->shadow_reg[3] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1304 RD_REG_DWORD(&reg->hccr); 1424
1305 } 1425 WRT_REG_DWORD(&reg->iobase_select, 0xB0400000);
1426 fw->shadow_reg[4] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1427
1428 WRT_REG_DWORD(&reg->iobase_select, 0xB0500000);
1429 fw->shadow_reg[5] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1430
1431 WRT_REG_DWORD(&reg->iobase_select, 0xB0600000);
1432 fw->shadow_reg[6] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1433
1434 WRT_REG_DWORD(&reg->iobase_select, 0xB0700000);
1435 fw->shadow_reg[7] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1436
1437 WRT_REG_DWORD(&reg->iobase_select, 0xB0800000);
1438 fw->shadow_reg[8] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1439
1440 WRT_REG_DWORD(&reg->iobase_select, 0xB0900000);
1441 fw->shadow_reg[9] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1442
1443 WRT_REG_DWORD(&reg->iobase_select, 0xB0A00000);
1444 fw->shadow_reg[10] = htonl(RD_REG_DWORD(&reg->iobase_sdata));
1445
1446 /* RISC I/O register. */
1447 WRT_REG_DWORD(&reg->iobase_addr, 0x0010);
1448 RD_REG_DWORD(&reg->iobase_addr);
1449 fw->risc_io_reg = htonl(RD_REG_DWORD(&reg->iobase_window));
1450
1451 /* Mailbox registers. */
1452 mbx_reg = &reg->mailbox0;
1453 for (cnt = 0; cnt < sizeof(fw->mailbox_reg) / 2; cnt++)
1454 fw->mailbox_reg[cnt] = htons(RD_REG_WORD(mbx_reg++));
1455
1456 /* Transfer sequence registers. */
1457 iter_reg = fw->xseq_gp_reg;
1458 WRT_REG_DWORD(&reg->iobase_addr, 0xBF00);
1459 dmp_reg = &reg->iobase_window;
1460 for (cnt = 0; cnt < 16; cnt++)
1461 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1462
1463 WRT_REG_DWORD(&reg->iobase_addr, 0xBF10);
1464 dmp_reg = &reg->iobase_window;
1465 for (cnt = 0; cnt < 16; cnt++)
1466 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1467
1468 WRT_REG_DWORD(&reg->iobase_addr, 0xBF20);
1469 dmp_reg = &reg->iobase_window;
1470 for (cnt = 0; cnt < 16; cnt++)
1471 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1472
1473 WRT_REG_DWORD(&reg->iobase_addr, 0xBF30);
1474 dmp_reg = &reg->iobase_window;
1475 for (cnt = 0; cnt < 16; cnt++)
1476 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1477
1478 WRT_REG_DWORD(&reg->iobase_addr, 0xBF40);
1479 dmp_reg = &reg->iobase_window;
1480 for (cnt = 0; cnt < 16; cnt++)
1481 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1482
1483 WRT_REG_DWORD(&reg->iobase_addr, 0xBF50);
1484 dmp_reg = &reg->iobase_window;
1485 for (cnt = 0; cnt < 16; cnt++)
1486 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1487
1488 WRT_REG_DWORD(&reg->iobase_addr, 0xBF60);
1489 dmp_reg = &reg->iobase_window;
1490 for (cnt = 0; cnt < 16; cnt++)
1491 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1492
1493 WRT_REG_DWORD(&reg->iobase_addr, 0xBF70);
1494 dmp_reg = &reg->iobase_window;
1495 for (cnt = 0; cnt < 16; cnt++)
1496 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1497
1498 iter_reg = fw->xseq_0_reg;
1499 WRT_REG_DWORD(&reg->iobase_addr, 0xBFC0);
1500 dmp_reg = &reg->iobase_window;
1501 for (cnt = 0; cnt < 16; cnt++)
1502 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1503
1504 WRT_REG_DWORD(&reg->iobase_addr, 0xBFD0);
1505 dmp_reg = &reg->iobase_window;
1506 for (cnt = 0; cnt < 16; cnt++)
1507 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1508
1509 WRT_REG_DWORD(&reg->iobase_addr, 0xBFE0);
1510 dmp_reg = &reg->iobase_window;
1511 for (cnt = 0; cnt < 16; cnt++)
1512 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1513
1514 WRT_REG_DWORD(&reg->iobase_addr, 0xBFF0);
1515 dmp_reg = &reg->iobase_window;
1516 for (cnt = 0; cnt < sizeof(fw->xseq_1_reg) / 4; cnt++)
1517 fw->xseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1518
1519 /* Receive sequence registers. */
1520 iter_reg = fw->rseq_gp_reg;
1521 WRT_REG_DWORD(&reg->iobase_addr, 0xFF00);
1522 dmp_reg = &reg->iobase_window;
1523 for (cnt = 0; cnt < 16; cnt++)
1524 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1525
1526 WRT_REG_DWORD(&reg->iobase_addr, 0xFF10);
1527 dmp_reg = &reg->iobase_window;
1528 for (cnt = 0; cnt < 16; cnt++)
1529 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1530
1531 WRT_REG_DWORD(&reg->iobase_addr, 0xFF20);
1532 dmp_reg = &reg->iobase_window;
1533 for (cnt = 0; cnt < 16; cnt++)
1534 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1535
1536 WRT_REG_DWORD(&reg->iobase_addr, 0xFF30);
1537 dmp_reg = &reg->iobase_window;
1538 for (cnt = 0; cnt < 16; cnt++)
1539 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1540
1541 WRT_REG_DWORD(&reg->iobase_addr, 0xFF40);
1542 dmp_reg = &reg->iobase_window;
1543 for (cnt = 0; cnt < 16; cnt++)
1544 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1545
1546 WRT_REG_DWORD(&reg->iobase_addr, 0xFF50);
1547 dmp_reg = &reg->iobase_window;
1548 for (cnt = 0; cnt < 16; cnt++)
1549 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1550
1551 WRT_REG_DWORD(&reg->iobase_addr, 0xFF60);
1552 dmp_reg = &reg->iobase_window;
1553 for (cnt = 0; cnt < 16; cnt++)
1554 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1555
1556 WRT_REG_DWORD(&reg->iobase_addr, 0xFF70);
1557 dmp_reg = &reg->iobase_window;
1558 for (cnt = 0; cnt < 16; cnt++)
1559 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1560
1561 iter_reg = fw->rseq_0_reg;
1562 WRT_REG_DWORD(&reg->iobase_addr, 0xFFC0);
1563 dmp_reg = &reg->iobase_window;
1564 for (cnt = 0; cnt < 16; cnt++)
1565 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1566
1567 WRT_REG_DWORD(&reg->iobase_addr, 0xFFD0);
1568 dmp_reg = &reg->iobase_window;
1569 for (cnt = 0; cnt < 16; cnt++)
1570 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1571
1572 WRT_REG_DWORD(&reg->iobase_addr, 0xFFE0);
1573 dmp_reg = &reg->iobase_window;
1574 for (cnt = 0; cnt < sizeof(fw->rseq_1_reg) / 4; cnt++)
1575 fw->rseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1576
1577 WRT_REG_DWORD(&reg->iobase_addr, 0xFFF0);
1578 dmp_reg = &reg->iobase_window;
1579 for (cnt = 0; cnt < sizeof(fw->rseq_2_reg) / 4; cnt++)
1580 fw->rseq_2_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1581
1582 /* Auxiliary sequence registers. */
1583 iter_reg = fw->aseq_gp_reg;
1584 WRT_REG_DWORD(&reg->iobase_addr, 0xB000);
1585 dmp_reg = &reg->iobase_window;
1586 for (cnt = 0; cnt < 16; cnt++)
1587 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1588
1589 WRT_REG_DWORD(&reg->iobase_addr, 0xB010);
1590 dmp_reg = &reg->iobase_window;
1591 for (cnt = 0; cnt < 16; cnt++)
1592 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1593
1594 WRT_REG_DWORD(&reg->iobase_addr, 0xB020);
1595 dmp_reg = &reg->iobase_window;
1596 for (cnt = 0; cnt < 16; cnt++)
1597 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1598
1599 WRT_REG_DWORD(&reg->iobase_addr, 0xB030);
1600 dmp_reg = &reg->iobase_window;
1601 for (cnt = 0; cnt < 16; cnt++)
1602 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1603
1604 WRT_REG_DWORD(&reg->iobase_addr, 0xB040);
1605 dmp_reg = &reg->iobase_window;
1606 for (cnt = 0; cnt < 16; cnt++)
1607 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1608
1609 WRT_REG_DWORD(&reg->iobase_addr, 0xB050);
1610 dmp_reg = &reg->iobase_window;
1611 for (cnt = 0; cnt < 16; cnt++)
1612 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1613
1614 WRT_REG_DWORD(&reg->iobase_addr, 0xB060);
1615 dmp_reg = &reg->iobase_window;
1616 for (cnt = 0; cnt < 16; cnt++)
1617 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1618
1619 WRT_REG_DWORD(&reg->iobase_addr, 0xB070);
1620 dmp_reg = &reg->iobase_window;
1621 for (cnt = 0; cnt < 16; cnt++)
1622 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1623
1624 iter_reg = fw->aseq_0_reg;
1625 WRT_REG_DWORD(&reg->iobase_addr, 0xB0C0);
1626 dmp_reg = &reg->iobase_window;
1627 for (cnt = 0; cnt < 16; cnt++)
1628 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1629
1630 WRT_REG_DWORD(&reg->iobase_addr, 0xB0D0);
1631 dmp_reg = &reg->iobase_window;
1632 for (cnt = 0; cnt < 16; cnt++)
1633 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1634
1635 WRT_REG_DWORD(&reg->iobase_addr, 0xB0E0);
1636 dmp_reg = &reg->iobase_window;
1637 for (cnt = 0; cnt < sizeof(fw->aseq_1_reg) / 4; cnt++)
1638 fw->aseq_1_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1639
1640 WRT_REG_DWORD(&reg->iobase_addr, 0xB0F0);
1641 dmp_reg = &reg->iobase_window;
1642 for (cnt = 0; cnt < sizeof(fw->aseq_2_reg) / 4; cnt++)
1643 fw->aseq_2_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1644
1645 /* Command DMA registers. */
1646 WRT_REG_DWORD(&reg->iobase_addr, 0x7100);
1647 dmp_reg = &reg->iobase_window;
1648 for (cnt = 0; cnt < sizeof(fw->cmd_dma_reg) / 4; cnt++)
1649 fw->cmd_dma_reg[cnt] = htonl(RD_REG_DWORD(dmp_reg++));
1650
1651 /* Queues. */
1652 iter_reg = fw->req0_dma_reg;
1653 WRT_REG_DWORD(&reg->iobase_addr, 0x7200);
1654 dmp_reg = &reg->iobase_window;
1655 for (cnt = 0; cnt < 8; cnt++)
1656 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1657
1658 dmp_reg = &reg->iobase_q;
1659 for (cnt = 0; cnt < 7; cnt++)
1660 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1661
1662 iter_reg = fw->resp0_dma_reg;
1663 WRT_REG_DWORD(&reg->iobase_addr, 0x7300);
1664 dmp_reg = &reg->iobase_window;
1665 for (cnt = 0; cnt < 8; cnt++)
1666 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1667
1668 dmp_reg = &reg->iobase_q;
1669 for (cnt = 0; cnt < 7; cnt++)
1670 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1671
1672 iter_reg = fw->req1_dma_reg;
1673 WRT_REG_DWORD(&reg->iobase_addr, 0x7400);
1674 dmp_reg = &reg->iobase_window;
1675 for (cnt = 0; cnt < 8; cnt++)
1676 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1677
1678 dmp_reg = &reg->iobase_q;
1679 for (cnt = 0; cnt < 7; cnt++)
1680 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1681
1682 /* Transmit DMA registers. */
1683 iter_reg = fw->xmt0_dma_reg;
1684 WRT_REG_DWORD(&reg->iobase_addr, 0x7600);
1685 dmp_reg = &reg->iobase_window;
1686 for (cnt = 0; cnt < 16; cnt++)
1687 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1688
1689 WRT_REG_DWORD(&reg->iobase_addr, 0x7610);
1690 dmp_reg = &reg->iobase_window;
1691 for (cnt = 0; cnt < 16; cnt++)
1692 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1693
1694 iter_reg = fw->xmt1_dma_reg;
1695 WRT_REG_DWORD(&reg->iobase_addr, 0x7620);
1696 dmp_reg = &reg->iobase_window;
1697 for (cnt = 0; cnt < 16; cnt++)
1698 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1699
1700 WRT_REG_DWORD(&reg->iobase_addr, 0x7630);
1701 dmp_reg = &reg->iobase_window;
1702 for (cnt = 0; cnt < 16; cnt++)
1703 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1704
1705 iter_reg = fw->xmt2_dma_reg;
1706 WRT_REG_DWORD(&reg->iobase_addr, 0x7640);
1707 dmp_reg = &reg->iobase_window;
1708 for (cnt = 0; cnt < 16; cnt++)
1709 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1710
1711 WRT_REG_DWORD(&reg->iobase_addr, 0x7650);
1712 dmp_reg = &reg->iobase_window;
1713 for (cnt = 0; cnt < 16; cnt++)
1714 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1715
1716 iter_reg = fw->xmt3_dma_reg;
1717 WRT_REG_DWORD(&reg->iobase_addr, 0x7660);
1718 dmp_reg = &reg->iobase_window;
1719 for (cnt = 0; cnt < 16; cnt++)
1720 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1721
1722 WRT_REG_DWORD(&reg->iobase_addr, 0x7670);
1723 dmp_reg = &reg->iobase_window;
1724 for (cnt = 0; cnt < 16; cnt++)
1725 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1726
1727 iter_reg = fw->xmt4_dma_reg;
1728 WRT_REG_DWORD(&reg->iobase_addr, 0x7680);
1729 dmp_reg = &reg->iobase_window;
1730 for (cnt = 0; cnt < 16; cnt++)
1731 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1732
1733 WRT_REG_DWORD(&reg->iobase_addr, 0x7690);
1734 dmp_reg = &reg->iobase_window;
1735 for (cnt = 0; cnt < 16; cnt++)
1736 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1737
1738 WRT_REG_DWORD(&reg->iobase_addr, 0x76A0);
1739 dmp_reg = &reg->iobase_window;
1740 for (cnt = 0; cnt < sizeof(fw->xmt_data_dma_reg) / 4; cnt++)
1741 fw->xmt_data_dma_reg[cnt] =
1742 htonl(RD_REG_DWORD(dmp_reg++));
1743
1744 /* Receive DMA registers. */
1745 iter_reg = fw->rcvt0_data_dma_reg;
1746 WRT_REG_DWORD(&reg->iobase_addr, 0x7700);
1747 dmp_reg = &reg->iobase_window;
1748 for (cnt = 0; cnt < 16; cnt++)
1749 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1750
1751 WRT_REG_DWORD(&reg->iobase_addr, 0x7710);
1752 dmp_reg = &reg->iobase_window;
1753 for (cnt = 0; cnt < 16; cnt++)
1754 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1755
1756 iter_reg = fw->rcvt1_data_dma_reg;
1757 WRT_REG_DWORD(&reg->iobase_addr, 0x7720);
1758 dmp_reg = &reg->iobase_window;
1759 for (cnt = 0; cnt < 16; cnt++)
1760 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1761
1762 WRT_REG_DWORD(&reg->iobase_addr, 0x7730);
1763 dmp_reg = &reg->iobase_window;
1764 for (cnt = 0; cnt < 16; cnt++)
1765 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1766
1767 /* RISC registers. */
1768 iter_reg = fw->risc_gp_reg;
1769 WRT_REG_DWORD(&reg->iobase_addr, 0x0F00);
1770 dmp_reg = &reg->iobase_window;
1771 for (cnt = 0; cnt < 16; cnt++)
1772 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1773
1774 WRT_REG_DWORD(&reg->iobase_addr, 0x0F10);
1775 dmp_reg = &reg->iobase_window;
1776 for (cnt = 0; cnt < 16; cnt++)
1777 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1778
1779 WRT_REG_DWORD(&reg->iobase_addr, 0x0F20);
1780 dmp_reg = &reg->iobase_window;
1781 for (cnt = 0; cnt < 16; cnt++)
1782 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1783
1784 WRT_REG_DWORD(&reg->iobase_addr, 0x0F30);
1785 dmp_reg = &reg->iobase_window;
1786 for (cnt = 0; cnt < 16; cnt++)
1787 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1788
1789 WRT_REG_DWORD(&reg->iobase_addr, 0x0F40);
1790 dmp_reg = &reg->iobase_window;
1791 for (cnt = 0; cnt < 16; cnt++)
1792 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1793
1794 WRT_REG_DWORD(&reg->iobase_addr, 0x0F50);
1795 dmp_reg = &reg->iobase_window;
1796 for (cnt = 0; cnt < 16; cnt++)
1797 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1798
1799 WRT_REG_DWORD(&reg->iobase_addr, 0x0F60);
1800 dmp_reg = &reg->iobase_window;
1801 for (cnt = 0; cnt < 16; cnt++)
1802 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1803
1804 WRT_REG_DWORD(&reg->iobase_addr, 0x0F70);
1805 dmp_reg = &reg->iobase_window;
1806 for (cnt = 0; cnt < 16; cnt++)
1807 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1808
1809 /* Local memory controller registers. */
1810 iter_reg = fw->lmc_reg;
1811 WRT_REG_DWORD(&reg->iobase_addr, 0x3000);
1812 dmp_reg = &reg->iobase_window;
1813 for (cnt = 0; cnt < 16; cnt++)
1814 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1815
1816 WRT_REG_DWORD(&reg->iobase_addr, 0x3010);
1817 dmp_reg = &reg->iobase_window;
1818 for (cnt = 0; cnt < 16; cnt++)
1819 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1820
1821 WRT_REG_DWORD(&reg->iobase_addr, 0x3020);
1822 dmp_reg = &reg->iobase_window;
1823 for (cnt = 0; cnt < 16; cnt++)
1824 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1825
1826 WRT_REG_DWORD(&reg->iobase_addr, 0x3030);
1827 dmp_reg = &reg->iobase_window;
1828 for (cnt = 0; cnt < 16; cnt++)
1829 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1830
1831 WRT_REG_DWORD(&reg->iobase_addr, 0x3040);
1832 dmp_reg = &reg->iobase_window;
1833 for (cnt = 0; cnt < 16; cnt++)
1834 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1835
1836 WRT_REG_DWORD(&reg->iobase_addr, 0x3050);
1837 dmp_reg = &reg->iobase_window;
1838 for (cnt = 0; cnt < 16; cnt++)
1839 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1840
1841 WRT_REG_DWORD(&reg->iobase_addr, 0x3060);
1842 dmp_reg = &reg->iobase_window;
1843 for (cnt = 0; cnt < 16; cnt++)
1844 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1845
1846 WRT_REG_DWORD(&reg->iobase_addr, 0x3070);
1847 dmp_reg = &reg->iobase_window;
1848 for (cnt = 0; cnt < 16; cnt++)
1849 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1850
1851 /* Fibre Protocol Module registers. */
1852 iter_reg = fw->fpm_hdw_reg;
1853 WRT_REG_DWORD(&reg->iobase_addr, 0x4000);
1854 dmp_reg = &reg->iobase_window;
1855 for (cnt = 0; cnt < 16; cnt++)
1856 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1857
1858 WRT_REG_DWORD(&reg->iobase_addr, 0x4010);
1859 dmp_reg = &reg->iobase_window;
1860 for (cnt = 0; cnt < 16; cnt++)
1861 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1862
1863 WRT_REG_DWORD(&reg->iobase_addr, 0x4020);
1864 dmp_reg = &reg->iobase_window;
1865 for (cnt = 0; cnt < 16; cnt++)
1866 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1867
1868 WRT_REG_DWORD(&reg->iobase_addr, 0x4030);
1869 dmp_reg = &reg->iobase_window;
1870 for (cnt = 0; cnt < 16; cnt++)
1871 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1872
1873 WRT_REG_DWORD(&reg->iobase_addr, 0x4040);
1874 dmp_reg = &reg->iobase_window;
1875 for (cnt = 0; cnt < 16; cnt++)
1876 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1877
1878 WRT_REG_DWORD(&reg->iobase_addr, 0x4050);
1879 dmp_reg = &reg->iobase_window;
1880 for (cnt = 0; cnt < 16; cnt++)
1881 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1882
1883 WRT_REG_DWORD(&reg->iobase_addr, 0x4060);
1884 dmp_reg = &reg->iobase_window;
1885 for (cnt = 0; cnt < 16; cnt++)
1886 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1887
1888 WRT_REG_DWORD(&reg->iobase_addr, 0x4070);
1889 dmp_reg = &reg->iobase_window;
1890 for (cnt = 0; cnt < 16; cnt++)
1891 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1892
1893 WRT_REG_DWORD(&reg->iobase_addr, 0x4080);
1894 dmp_reg = &reg->iobase_window;
1895 for (cnt = 0; cnt < 16; cnt++)
1896 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1897
1898 WRT_REG_DWORD(&reg->iobase_addr, 0x4090);
1899 dmp_reg = &reg->iobase_window;
1900 for (cnt = 0; cnt < 16; cnt++)
1901 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1902
1903 WRT_REG_DWORD(&reg->iobase_addr, 0x40A0);
1904 dmp_reg = &reg->iobase_window;
1905 for (cnt = 0; cnt < 16; cnt++)
1906 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1907
1908 WRT_REG_DWORD(&reg->iobase_addr, 0x40B0);
1909 dmp_reg = &reg->iobase_window;
1910 for (cnt = 0; cnt < 16; cnt++)
1911 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1912
1913 /* Frame Buffer registers. */
1914 iter_reg = fw->fb_hdw_reg;
1915 WRT_REG_DWORD(&reg->iobase_addr, 0x6000);
1916 dmp_reg = &reg->iobase_window;
1917 for (cnt = 0; cnt < 16; cnt++)
1918 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1919
1920 WRT_REG_DWORD(&reg->iobase_addr, 0x6010);
1921 dmp_reg = &reg->iobase_window;
1922 for (cnt = 0; cnt < 16; cnt++)
1923 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1924
1925 WRT_REG_DWORD(&reg->iobase_addr, 0x6020);
1926 dmp_reg = &reg->iobase_window;
1927 for (cnt = 0; cnt < 16; cnt++)
1928 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1929
1930 WRT_REG_DWORD(&reg->iobase_addr, 0x6030);
1931 dmp_reg = &reg->iobase_window;
1932 for (cnt = 0; cnt < 16; cnt++)
1933 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1934
1935 WRT_REG_DWORD(&reg->iobase_addr, 0x6040);
1936 dmp_reg = &reg->iobase_window;
1937 for (cnt = 0; cnt < 16; cnt++)
1938 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1939
1940 WRT_REG_DWORD(&reg->iobase_addr, 0x6100);
1941 dmp_reg = &reg->iobase_window;
1942 for (cnt = 0; cnt < 16; cnt++)
1943 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1944
1945 WRT_REG_DWORD(&reg->iobase_addr, 0x6130);
1946 dmp_reg = &reg->iobase_window;
1947 for (cnt = 0; cnt < 16; cnt++)
1948 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1949
1950 WRT_REG_DWORD(&reg->iobase_addr, 0x6150);
1951 dmp_reg = &reg->iobase_window;
1952 for (cnt = 0; cnt < 16; cnt++)
1953 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1954
1955 WRT_REG_DWORD(&reg->iobase_addr, 0x6170);
1956 dmp_reg = &reg->iobase_window;
1957 for (cnt = 0; cnt < 16; cnt++)
1958 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1959
1960 WRT_REG_DWORD(&reg->iobase_addr, 0x6190);
1961 dmp_reg = &reg->iobase_window;
1962 for (cnt = 0; cnt < 16; cnt++)
1963 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1964
1965 WRT_REG_DWORD(&reg->iobase_addr, 0x61B0);
1966 dmp_reg = &reg->iobase_window;
1967 for (cnt = 0; cnt < 16; cnt++)
1968 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1969
1970 WRT_REG_DWORD(&reg->iobase_addr, 0x6F00);
1971 dmp_reg = &reg->iobase_window;
1972 for (cnt = 0; cnt < 16; cnt++)
1973 *iter_reg++ = htonl(RD_REG_DWORD(dmp_reg++));
1974
1975 /* Reset RISC. */
1976 WRT_REG_DWORD(&reg->ctrl_status,
1977 CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
1978 for (cnt = 0; cnt < 30000; cnt++) {
1979 if ((RD_REG_DWORD(&reg->ctrl_status) &
1980 CSRX_DMA_ACTIVE) == 0)
1981 break;
1982
1983 udelay(10);
1984 }
1985
1986 WRT_REG_DWORD(&reg->ctrl_status,
1987 CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES);
1988 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
1989
1990 udelay(100);
1991 /* Wait for firmware to complete NVRAM accesses. */
1992 mb0 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
1993 for (cnt = 10000 ; cnt && mb0; cnt--) {
1306 udelay(5); 1994 udelay(5);
1995 mb0 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
1996 barrier();
1307 } 1997 }
1308 1998
1309 if (test_and_clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags)) { 1999 /* Wait for soft-reset to complete. */
1310 rval = mb[0] & MBS_MASK; 2000 for (cnt = 0; cnt < 30000; cnt++) {
1311 fw->ext_mem[cnt] = htonl((mb[3] << 16) | mb[2]); 2001 if ((RD_REG_DWORD(&reg->ctrl_status) &
1312 } else { 2002 CSRX_ISP_SOFT_RESET) == 0)
1313 rval = QLA_FUNCTION_FAILED; 2003 break;
2004
2005 udelay(10);
1314 } 2006 }
2007 WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_RESET);
2008 RD_REG_DWORD(&reg->hccr); /* PCI Posting. */
1315 } 2009 }
1316 2010
2011 for (cnt = 30000; RD_REG_WORD(&reg->mailbox0) != 0 &&
2012 rval == QLA_SUCCESS; cnt--) {
2013 if (cnt)
2014 udelay(100);
2015 else
2016 rval = QLA_FUNCTION_TIMEOUT;
2017 }
2018
2019 if (rval == QLA_SUCCESS)
2020 rval = qla2xxx_dump_memory(ha, fw->code_ram,
2021 sizeof(fw->code_ram), fw->ext_mem, &nxt);
2022
1317 if (rval == QLA_SUCCESS) { 2023 if (rval == QLA_SUCCESS) {
1318 eft = qla2xxx_copy_queues(ha, &fw->ext_mem[cnt]); 2024 nxt = qla2xxx_copy_queues(ha, nxt);
1319 if (ha->eft) 2025 if (ha->eft)
1320 memcpy(eft, ha->eft, ntohl(ha->fw_dump->eft_size)); 2026 memcpy(nxt, ha->eft, ntohl(ha->fw_dump->eft_size));
1321 } 2027 }
1322 2028
1323 if (rval != QLA_SUCCESS) { 2029 if (rval != QLA_SUCCESS) {
@@ -1332,7 +2038,7 @@ qla24xx_fw_dump(scsi_qla_host_t *ha, int hardware_locked)
1332 ha->fw_dumped = 1; 2038 ha->fw_dumped = 1;
1333 } 2039 }
1334 2040
1335qla24xx_fw_dump_failed: 2041qla25xx_fw_dump_failed:
1336 if (!hardware_locked) 2042 if (!hardware_locked)
1337 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2043 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1338} 2044}
diff --git a/drivers/scsi/qla2xxx/qla_dbg.h b/drivers/scsi/qla2xxx/qla_dbg.h
index 49dffeb78512..cca4b0d8253e 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.h
+++ b/drivers/scsi/qla2xxx/qla_dbg.h
@@ -213,6 +213,43 @@ struct qla24xx_fw_dump {
213 uint32_t ext_mem[1]; 213 uint32_t ext_mem[1];
214}; 214};
215 215
216struct qla25xx_fw_dump {
217 uint32_t host_status;
218 uint32_t host_reg[32];
219 uint32_t shadow_reg[11];
220 uint32_t risc_io_reg;
221 uint16_t mailbox_reg[32];
222 uint32_t xseq_gp_reg[128];
223 uint32_t xseq_0_reg[48];
224 uint32_t xseq_1_reg[16];
225 uint32_t rseq_gp_reg[128];
226 uint32_t rseq_0_reg[32];
227 uint32_t rseq_1_reg[16];
228 uint32_t rseq_2_reg[16];
229 uint32_t aseq_gp_reg[128];
230 uint32_t aseq_0_reg[32];
231 uint32_t aseq_1_reg[16];
232 uint32_t aseq_2_reg[16];
233 uint32_t cmd_dma_reg[16];
234 uint32_t req0_dma_reg[15];
235 uint32_t resp0_dma_reg[15];
236 uint32_t req1_dma_reg[15];
237 uint32_t xmt0_dma_reg[32];
238 uint32_t xmt1_dma_reg[32];
239 uint32_t xmt2_dma_reg[32];
240 uint32_t xmt3_dma_reg[32];
241 uint32_t xmt4_dma_reg[32];
242 uint32_t xmt_data_dma_reg[16];
243 uint32_t rcvt0_data_dma_reg[32];
244 uint32_t rcvt1_data_dma_reg[32];
245 uint32_t risc_gp_reg[128];
246 uint32_t lmc_reg[128];
247 uint32_t fpm_hdw_reg[192];
248 uint32_t fb_hdw_reg[192];
249 uint32_t code_ram[0x2000];
250 uint32_t ext_mem[1];
251};
252
216#define EFT_NUM_BUFFERS 4 253#define EFT_NUM_BUFFERS 4
217#define EFT_BYTES_PER_BUFFER 0x4000 254#define EFT_BYTES_PER_BUFFER 0x4000
218#define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS)) 255#define EFT_SIZE ((EFT_BYTES_PER_BUFFER) * (EFT_NUM_BUFFERS))
@@ -246,5 +283,6 @@ struct qla2xxx_fw_dump {
246 struct qla2100_fw_dump isp21; 283 struct qla2100_fw_dump isp21;
247 struct qla2300_fw_dump isp23; 284 struct qla2300_fw_dump isp23;
248 struct qla24xx_fw_dump isp24; 285 struct qla24xx_fw_dump isp24;
286 struct qla25xx_fw_dump isp25;
249 } isp; 287 } isp;
250}; 288};
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index a1ca590ba447..0c9f36c8a248 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -1711,6 +1711,14 @@ struct ct_fdmi_hba_attributes {
1711#define FDMI_PORT_OS_DEVICE_NAME 5 1711#define FDMI_PORT_OS_DEVICE_NAME 5
1712#define FDMI_PORT_HOST_NAME 6 1712#define FDMI_PORT_HOST_NAME 6
1713 1713
1714#define FDMI_PORT_SPEED_1GB 0x1
1715#define FDMI_PORT_SPEED_2GB 0x2
1716#define FDMI_PORT_SPEED_10GB 0x4
1717#define FDMI_PORT_SPEED_4GB 0x8
1718#define FDMI_PORT_SPEED_8GB 0x10
1719#define FDMI_PORT_SPEED_16GB 0x20
1720#define FDMI_PORT_SPEED_UNKNOWN 0x8000
1721
1714struct ct_fdmi_port_attr { 1722struct ct_fdmi_port_attr {
1715 uint16_t type; 1723 uint16_t type;
1716 uint16_t len; 1724 uint16_t len;
@@ -2201,6 +2209,7 @@ typedef struct scsi_qla_host {
2201#define SWITCH_FOUND BIT_3 2209#define SWITCH_FOUND BIT_3
2202#define DFLG_NO_CABLE BIT_4 2210#define DFLG_NO_CABLE BIT_4
2203 2211
2212#define PCI_DEVICE_ID_QLOGIC_ISP2532 0x2532
2204 uint32_t device_type; 2213 uint32_t device_type;
2205#define DT_ISP2100 BIT_0 2214#define DT_ISP2100 BIT_0
2206#define DT_ISP2200 BIT_1 2215#define DT_ISP2200 BIT_1
@@ -2213,8 +2222,11 @@ typedef struct scsi_qla_host {
2213#define DT_ISP2432 BIT_8 2222#define DT_ISP2432 BIT_8
2214#define DT_ISP5422 BIT_9 2223#define DT_ISP5422 BIT_9
2215#define DT_ISP5432 BIT_10 2224#define DT_ISP5432 BIT_10
2216#define DT_ISP_LAST (DT_ISP5432 << 1) 2225#define DT_ISP2532 BIT_11
2226#define DT_ISP_LAST (DT_ISP2532 << 1)
2217 2227
2228#define DT_IIDMA BIT_26
2229#define DT_FWI2 BIT_27
2218#define DT_ZIO_SUPPORTED BIT_28 2230#define DT_ZIO_SUPPORTED BIT_28
2219#define DT_OEM_001 BIT_29 2231#define DT_OEM_001 BIT_29
2220#define DT_ISP2200A BIT_30 2232#define DT_ISP2200A BIT_30
@@ -2232,12 +2244,16 @@ typedef struct scsi_qla_host {
2232#define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432) 2244#define IS_QLA2432(ha) (DT_MASK(ha) & DT_ISP2432)
2233#define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422) 2245#define IS_QLA5422(ha) (DT_MASK(ha) & DT_ISP5422)
2234#define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432) 2246#define IS_QLA5432(ha) (DT_MASK(ha) & DT_ISP5432)
2247#define IS_QLA2532(ha) (DT_MASK(ha) & DT_ISP2532)
2235 2248
2236#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \ 2249#define IS_QLA23XX(ha) (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
2237 IS_QLA6312(ha) || IS_QLA6322(ha)) 2250 IS_QLA6312(ha) || IS_QLA6322(ha))
2238#define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha)) 2251#define IS_QLA24XX(ha) (IS_QLA2422(ha) || IS_QLA2432(ha))
2239#define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha)) 2252#define IS_QLA54XX(ha) (IS_QLA5422(ha) || IS_QLA5432(ha))
2253#define IS_QLA25XX(ha) (IS_QLA2532(ha))
2240 2254
2255#define IS_IIDMA_CAPABLE(ha) ((ha)->device_type & DT_IIDMA)
2256#define IS_FWI2_CAPABLE(ha) ((ha)->device_type & DT_FWI2)
2241#define IS_ZIO_SUPPORTED(ha) ((ha)->device_type & DT_ZIO_SUPPORTED) 2257#define IS_ZIO_SUPPORTED(ha) ((ha)->device_type & DT_ZIO_SUPPORTED)
2242#define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001) 2258#define IS_OEM_001(ha) ((ha)->device_type & DT_OEM_001)
2243#define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS) 2259#define HAS_EXTENDED_IDS(ha) ((ha)->device_type & DT_EXTENDED_IDS)
@@ -2274,7 +2290,7 @@ typedef struct scsi_qla_host {
2274 uint16_t rsp_ring_index; /* Current index. */ 2290 uint16_t rsp_ring_index; /* Current index. */
2275 uint16_t response_q_length; 2291 uint16_t response_q_length;
2276 2292
2277 struct isp_operations isp_ops; 2293 struct isp_operations *isp_ops;
2278 2294
2279 /* Outstandings ISP commands. */ 2295 /* Outstandings ISP commands. */
2280 srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS]; 2296 srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
@@ -2298,6 +2314,7 @@ typedef struct scsi_qla_host {
2298#define PORT_SPEED_1GB 0x00 2314#define PORT_SPEED_1GB 0x00
2299#define PORT_SPEED_2GB 0x01 2315#define PORT_SPEED_2GB 0x01
2300#define PORT_SPEED_4GB 0x03 2316#define PORT_SPEED_4GB 0x03
2317#define PORT_SPEED_8GB 0x04
2301 uint16_t link_data_rate; /* F/W operating speed */ 2318 uint16_t link_data_rate; /* F/W operating speed */
2302 2319
2303 uint8_t current_topology; 2320 uint8_t current_topology;
@@ -2564,6 +2581,7 @@ typedef struct scsi_qla_host {
2564#define OPTROM_SIZE_2300 0x20000 2581#define OPTROM_SIZE_2300 0x20000
2565#define OPTROM_SIZE_2322 0x100000 2582#define OPTROM_SIZE_2322 0x100000
2566#define OPTROM_SIZE_24XX 0x100000 2583#define OPTROM_SIZE_24XX 0x100000
2584#define OPTROM_SIZE_25XX 0x200000
2567 2585
2568#include "qla_gbl.h" 2586#include "qla_gbl.h"
2569#include "qla_dbg.h" 2587#include "qla_dbg.h"
diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
index 63a11fef5d1b..99fe49618d61 100644
--- a/drivers/scsi/qla2xxx/qla_fw.h
+++ b/drivers/scsi/qla2xxx/qla_fw.h
@@ -8,14 +8,17 @@
8#define __QLA_FW_H 8#define __QLA_FW_H
9 9
10#define MBS_CHECKSUM_ERROR 0x4010 10#define MBS_CHECKSUM_ERROR 0x4010
11#define MBS_INVALID_PRODUCT_KEY 0x4020
11 12
12/* 13/*
13 * Firmware Options. 14 * Firmware Options.
14 */ 15 */
15#define FO1_ENABLE_PUREX BIT_10 16#define FO1_ENABLE_PUREX BIT_10
16#define FO1_DISABLE_LED_CTRL BIT_6 17#define FO1_DISABLE_LED_CTRL BIT_6
18#define FO1_ENABLE_8016 BIT_0
17#define FO2_ENABLE_SEL_CLASS2 BIT_5 19#define FO2_ENABLE_SEL_CLASS2 BIT_5
18#define FO3_NO_ABTS_ON_LINKDOWN BIT_14 20#define FO3_NO_ABTS_ON_LINKDOWN BIT_14
21#define FO3_HOLD_STS_IOCB BIT_12
19 22
20/* 23/*
21 * Port Database structure definition for ISP 24xx. 24 * Port Database structure definition for ISP 24xx.
@@ -341,7 +344,9 @@ struct init_cb_24xx {
341 * BIT 10 = Reserved 344 * BIT 10 = Reserved
342 * BIT 11 = Enable FC-SP Security 345 * BIT 11 = Enable FC-SP Security
343 * BIT 12 = FC Tape Enable 346 * BIT 12 = FC Tape Enable
344 * BIT 13-31 = Reserved 347 * BIT 13 = Reserved
348 * BIT 14 = Enable Target PRLI Control
349 * BIT 15-31 = Reserved
345 */ 350 */
346 uint32_t firmware_options_2; 351 uint32_t firmware_options_2;
347 352
@@ -363,7 +368,8 @@ struct init_cb_24xx {
363 * BIT 13 = Data Rate bit 0 368 * BIT 13 = Data Rate bit 0
364 * BIT 14 = Data Rate bit 1 369 * BIT 14 = Data Rate bit 1
365 * BIT 15 = Data Rate bit 2 370 * BIT 15 = Data Rate bit 2
366 * BIT 16-31 = Reserved 371 * BIT 16 = Enable 75 ohm Termination Select
372 * BIT 17-31 = Reserved
367 */ 373 */
368 uint32_t firmware_options_3; 374 uint32_t firmware_options_3;
369 375
@@ -435,6 +441,7 @@ struct cmd_type_7 {
435#define TMF_LUN_RESET BIT_12 441#define TMF_LUN_RESET BIT_12
436#define TMF_CLEAR_TASK_SET BIT_10 442#define TMF_CLEAR_TASK_SET BIT_10
437#define TMF_ABORT_TASK_SET BIT_9 443#define TMF_ABORT_TASK_SET BIT_9
444#define TMF_DSD_LIST_ENABLE BIT_2
438#define TMF_READ_DATA BIT_1 445#define TMF_READ_DATA BIT_1
439#define TMF_WRITE_DATA BIT_0 446#define TMF_WRITE_DATA BIT_0
440 447
@@ -589,7 +596,7 @@ struct els_entry_24xx {
589#define EST_SOFI3 (1 << 4) 596#define EST_SOFI3 (1 << 4)
590#define EST_SOFI2 (3 << 4) 597#define EST_SOFI2 (3 << 4)
591 598
592 uint32_t rx_xchg_address[2]; /* Receive exchange address. */ 599 uint32_t rx_xchg_address; /* Receive exchange address. */
593 uint16_t rx_dsd_count; 600 uint16_t rx_dsd_count;
594 601
595 uint8_t opcode; 602 uint8_t opcode;
@@ -650,6 +657,7 @@ struct logio_entry_24xx {
650 657
651 uint16_t control_flags; /* Control flags. */ 658 uint16_t control_flags; /* Control flags. */
652 /* Modifiers. */ 659 /* Modifiers. */
660#define LCF_INCLUDE_SNS BIT_10 /* Include SNS (FFFFFC) during LOGO. */
653#define LCF_FCP2_OVERRIDE BIT_9 /* Set/Reset word 3 of PRLI. */ 661#define LCF_FCP2_OVERRIDE BIT_9 /* Set/Reset word 3 of PRLI. */
654#define LCF_CLASS_2 BIT_8 /* Enable class 2 during PLOGI. */ 662#define LCF_CLASS_2 BIT_8 /* Enable class 2 during PLOGI. */
655#define LCF_FREE_NPORT BIT_7 /* Release NPORT handle after LOGO. */ 663#define LCF_FREE_NPORT BIT_7 /* Release NPORT handle after LOGO. */
@@ -779,6 +787,15 @@ struct device_reg_24xx {
779#define FA_RISC_CODE_ADDR 0x20000 787#define FA_RISC_CODE_ADDR 0x20000
780#define FA_RISC_CODE_SEGMENTS 2 788#define FA_RISC_CODE_SEGMENTS 2
781 789
790#define FA_FW_AREA_ADDR 0x40000
791#define FA_VPD_NVRAM_ADDR 0x48000
792#define FA_FEATURE_ADDR 0x4C000
793#define FA_FLASH_DESCR_ADDR 0x50000
794#define FA_HW_EVENT_ADDR 0x54000
795#define FA_BOOT_LOG_ADDR 0x58000
796#define FA_FW_DUMP0_ADDR 0x60000
797#define FA_FW_DUMP1_ADDR 0x70000
798
782 uint32_t flash_data; /* Flash/NVRAM BIOS data. */ 799 uint32_t flash_data; /* Flash/NVRAM BIOS data. */
783 800
784 uint32_t ctrl_status; /* Control/Status. */ 801 uint32_t ctrl_status; /* Control/Status. */
@@ -859,10 +876,13 @@ struct device_reg_24xx {
859#define HCCRX_CLR_RISC_INT 0xA0000000 876#define HCCRX_CLR_RISC_INT 0xA0000000
860 877
861 uint32_t gpiod; /* GPIO Data register. */ 878 uint32_t gpiod; /* GPIO Data register. */
879
862 /* LED update mask. */ 880 /* LED update mask. */
863#define GPDX_LED_UPDATE_MASK (BIT_20|BIT_19|BIT_18) 881#define GPDX_LED_UPDATE_MASK (BIT_20|BIT_19|BIT_18)
864 /* Data update mask. */ 882 /* Data update mask. */
865#define GPDX_DATA_UPDATE_MASK (BIT_17|BIT_16) 883#define GPDX_DATA_UPDATE_MASK (BIT_17|BIT_16)
884 /* Data update mask. */
885#define GPDX_DATA_UPDATE_2_MASK (BIT_28|BIT_27|BIT_26|BIT_17|BIT_16)
866 /* LED control mask. */ 886 /* LED control mask. */
867#define GPDX_LED_COLOR_MASK (BIT_4|BIT_3|BIT_2) 887#define GPDX_LED_COLOR_MASK (BIT_4|BIT_3|BIT_2)
868 /* LED bit values. Color names as 888 /* LED bit values. Color names as
@@ -877,6 +897,8 @@ struct device_reg_24xx {
877 uint32_t gpioe; /* GPIO Enable register. */ 897 uint32_t gpioe; /* GPIO Enable register. */
878 /* Enable update mask. */ 898 /* Enable update mask. */
879#define GPEX_ENABLE_UPDATE_MASK (BIT_17|BIT_16) 899#define GPEX_ENABLE_UPDATE_MASK (BIT_17|BIT_16)
900 /* Enable update mask. */
901#define GPEX_ENABLE_UPDATE_2_MASK (BIT_28|BIT_27|BIT_26|BIT_17|BIT_16)
880 /* Enable. */ 902 /* Enable. */
881#define GPEX_ENABLE (BIT_1|BIT_0) 903#define GPEX_ENABLE (BIT_1|BIT_0)
882 904
@@ -916,6 +938,14 @@ struct device_reg_24xx {
916 uint16_t mailbox29; 938 uint16_t mailbox29;
917 uint16_t mailbox30; 939 uint16_t mailbox30;
918 uint16_t mailbox31; 940 uint16_t mailbox31;
941
942 uint32_t iobase_window;
943 uint32_t unused_4[8]; /* Gap. */
944 uint32_t iobase_q;
945 uint32_t unused_5[2]; /* Gap. */
946 uint32_t iobase_select;
947 uint32_t unused_6[2]; /* Gap. */
948 uint32_t iobase_sdata;
919}; 949};
920 950
921/* MID Support ***************************************************************/ 951/* MID Support ***************************************************************/
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index b44eff2803ce..aa1e41152283 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -17,6 +17,7 @@ extern int qla2x00_initialize_adapter(scsi_qla_host_t *);
17extern int qla2100_pci_config(struct scsi_qla_host *); 17extern int qla2100_pci_config(struct scsi_qla_host *);
18extern int qla2300_pci_config(struct scsi_qla_host *); 18extern int qla2300_pci_config(struct scsi_qla_host *);
19extern int qla24xx_pci_config(scsi_qla_host_t *); 19extern int qla24xx_pci_config(scsi_qla_host_t *);
20extern int qla25xx_pci_config(scsi_qla_host_t *);
20extern void qla2x00_reset_chip(struct scsi_qla_host *); 21extern void qla2x00_reset_chip(struct scsi_qla_host *);
21extern void qla24xx_reset_chip(struct scsi_qla_host *); 22extern void qla24xx_reset_chip(struct scsi_qla_host *);
22extern int qla2x00_chip_diag(struct scsi_qla_host *); 23extern int qla2x00_chip_diag(struct scsi_qla_host *);
@@ -281,6 +282,10 @@ extern int qla2x00_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
281 uint32_t); 282 uint32_t);
282extern int qla24xx_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t, 283extern int qla24xx_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
283 uint32_t); 284 uint32_t);
285extern uint8_t *qla25xx_read_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
286 uint32_t);
287extern int qla25xx_write_nvram_data(scsi_qla_host_t *, uint8_t *, uint32_t,
288 uint32_t);
284 289
285extern int qla2x00_beacon_on(struct scsi_qla_host *); 290extern int qla2x00_beacon_on(struct scsi_qla_host *);
286extern int qla2x00_beacon_off(struct scsi_qla_host *); 291extern int qla2x00_beacon_off(struct scsi_qla_host *);
@@ -307,6 +312,7 @@ extern int qla24xx_get_flash_version(scsi_qla_host_t *, void *);
307extern void qla2100_fw_dump(scsi_qla_host_t *, int); 312extern void qla2100_fw_dump(scsi_qla_host_t *, int);
308extern void qla2300_fw_dump(scsi_qla_host_t *, int); 313extern void qla2300_fw_dump(scsi_qla_host_t *, int);
309extern void qla24xx_fw_dump(scsi_qla_host_t *, int); 314extern void qla24xx_fw_dump(scsi_qla_host_t *, int);
315extern void qla25xx_fw_dump(scsi_qla_host_t *, int);
310extern void qla2x00_dump_regs(scsi_qla_host_t *); 316extern void qla2x00_dump_regs(scsi_qla_host_t *);
311extern void qla2x00_dump_buffer(uint8_t *, uint32_t); 317extern void qla2x00_dump_buffer(uint8_t *, uint32_t);
312extern void qla2x00_print_scsi_cmd(struct scsi_cmnd *); 318extern void qla2x00_print_scsi_cmd(struct scsi_cmnd *);
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index a086b3f0df65..b06cbb8580d3 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -127,7 +127,7 @@ qla2x00_chk_ms_status(scsi_qla_host_t *ha, ms_iocb_entry_t *ms_pkt,
127 DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n", 127 DEBUG2_3(printk("scsi(%ld): %s failed, error status (%x).\n",
128 ha->host_no, routine, ms_pkt->entry_status)); 128 ha->host_no, routine, ms_pkt->entry_status));
129 } else { 129 } else {
130 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 130 if (IS_FWI2_CAPABLE(ha))
131 comp_status = le16_to_cpu( 131 comp_status = le16_to_cpu(
132 ((struct ct_entry_24xx *)ms_pkt)->comp_status); 132 ((struct ct_entry_24xx *)ms_pkt)->comp_status);
133 else 133 else
@@ -180,7 +180,8 @@ qla2x00_ga_nxt(scsi_qla_host_t *ha, fc_port_t *fcport)
180 180
181 /* Issue GA_NXT */ 181 /* Issue GA_NXT */
182 /* Prepare common MS IOCB */ 182 /* Prepare common MS IOCB */
183 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GA_NXT_REQ_SIZE, GA_NXT_RSP_SIZE); 183 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GA_NXT_REQ_SIZE,
184 GA_NXT_RSP_SIZE);
184 185
185 /* Prepare CT request */ 186 /* Prepare CT request */
186 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD, 187 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GA_NXT_CMD,
@@ -266,7 +267,8 @@ qla2x00_gid_pt(scsi_qla_host_t *ha, sw_info_t *list)
266 267
267 /* Issue GID_PT */ 268 /* Issue GID_PT */
268 /* Prepare common MS IOCB */ 269 /* Prepare common MS IOCB */
269 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GID_PT_REQ_SIZE, GID_PT_RSP_SIZE); 270 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GID_PT_REQ_SIZE,
271 GID_PT_RSP_SIZE);
270 272
271 /* Prepare CT request */ 273 /* Prepare CT request */
272 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD, 274 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, GID_PT_CMD,
@@ -338,7 +340,7 @@ qla2x00_gpn_id(scsi_qla_host_t *ha, sw_info_t *list)
338 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 340 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
339 /* Issue GPN_ID */ 341 /* Issue GPN_ID */
340 /* Prepare common MS IOCB */ 342 /* Prepare common MS IOCB */
341 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GPN_ID_REQ_SIZE, 343 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GPN_ID_REQ_SIZE,
342 GPN_ID_RSP_SIZE); 344 GPN_ID_RSP_SIZE);
343 345
344 /* Prepare CT request */ 346 /* Prepare CT request */
@@ -399,7 +401,7 @@ qla2x00_gnn_id(scsi_qla_host_t *ha, sw_info_t *list)
399 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 401 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
400 /* Issue GNN_ID */ 402 /* Issue GNN_ID */
401 /* Prepare common MS IOCB */ 403 /* Prepare common MS IOCB */
402 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GNN_ID_REQ_SIZE, 404 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GNN_ID_REQ_SIZE,
403 GNN_ID_RSP_SIZE); 405 GNN_ID_RSP_SIZE);
404 406
405 /* Prepare CT request */ 407 /* Prepare CT request */
@@ -473,7 +475,8 @@ qla2x00_rft_id(scsi_qla_host_t *ha)
473 475
474 /* Issue RFT_ID */ 476 /* Issue RFT_ID */
475 /* Prepare common MS IOCB */ 477 /* Prepare common MS IOCB */
476 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFT_ID_REQ_SIZE, RFT_ID_RSP_SIZE); 478 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, RFT_ID_REQ_SIZE,
479 RFT_ID_RSP_SIZE);
477 480
478 /* Prepare CT request */ 481 /* Prepare CT request */
479 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD, 482 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFT_ID_CMD,
@@ -528,7 +531,8 @@ qla2x00_rff_id(scsi_qla_host_t *ha)
528 531
529 /* Issue RFF_ID */ 532 /* Issue RFF_ID */
530 /* Prepare common MS IOCB */ 533 /* Prepare common MS IOCB */
531 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RFF_ID_REQ_SIZE, RFF_ID_RSP_SIZE); 534 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, RFF_ID_REQ_SIZE,
535 RFF_ID_RSP_SIZE);
532 536
533 /* Prepare CT request */ 537 /* Prepare CT request */
534 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD, 538 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RFF_ID_CMD,
@@ -582,7 +586,8 @@ qla2x00_rnn_id(scsi_qla_host_t *ha)
582 586
583 /* Issue RNN_ID */ 587 /* Issue RNN_ID */
584 /* Prepare common MS IOCB */ 588 /* Prepare common MS IOCB */
585 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, RNN_ID_REQ_SIZE, RNN_ID_RSP_SIZE); 589 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, RNN_ID_REQ_SIZE,
590 RNN_ID_RSP_SIZE);
586 591
587 /* Prepare CT request */ 592 /* Prepare CT request */
588 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD, 593 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RNN_ID_CMD,
@@ -645,7 +650,7 @@ qla2x00_rsnn_nn(scsi_qla_host_t *ha)
645 /* Issue RSNN_NN */ 650 /* Issue RSNN_NN */
646 /* Prepare common MS IOCB */ 651 /* Prepare common MS IOCB */
647 /* Request size adjusted after CT preparation */ 652 /* Request size adjusted after CT preparation */
648 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE); 653 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, 0, RSNN_NN_RSP_SIZE);
649 654
650 /* Prepare CT request */ 655 /* Prepare CT request */
651 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD, 656 ct_req = qla2x00_prep_ct_req(&ha->ct_sns->p.req, RSNN_NN_CMD,
@@ -1102,7 +1107,7 @@ qla2x00_mgmt_svr_login(scsi_qla_host_t *ha)
1102 if (ha->flags.management_server_logged_in) 1107 if (ha->flags.management_server_logged_in)
1103 return ret; 1108 return ret;
1104 1109
1105 ha->isp_ops.fabric_login(ha, ha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa, 1110 ha->isp_ops->fabric_login(ha, ha->mgmt_svr_loop_id, 0xff, 0xff, 0xfa,
1106 mb, BIT_1); 1111 mb, BIT_1);
1107 if (mb[0] != MBS_COMMAND_COMPLETE) { 1112 if (mb[0] != MBS_COMMAND_COMPLETE) {
1108 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: " 1113 DEBUG2_13(printk("%s(%ld): Failed MANAGEMENT_SERVER login: "
@@ -1198,7 +1203,7 @@ qla2x00_update_ms_fdmi_iocb(scsi_qla_host_t *ha, uint32_t req_size)
1198 ms_iocb_entry_t *ms_pkt = ha->ms_iocb; 1203 ms_iocb_entry_t *ms_pkt = ha->ms_iocb;
1199 struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb; 1204 struct ct_entry_24xx *ct_pkt = (struct ct_entry_24xx *)ha->ms_iocb;
1200 1205
1201 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1206 if (IS_FWI2_CAPABLE(ha)) {
1202 ct_pkt->cmd_byte_count = cpu_to_le32(req_size); 1207 ct_pkt->cmd_byte_count = cpu_to_le32(req_size);
1203 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count; 1208 ct_pkt->dseg_0_len = ct_pkt->cmd_byte_count;
1204 } else { 1209 } else {
@@ -1253,7 +1258,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1253 /* Issue RHBA */ 1258 /* Issue RHBA */
1254 /* Prepare common MS IOCB */ 1259 /* Prepare common MS IOCB */
1255 /* Request size adjusted after CT preparation */ 1260 /* Request size adjusted after CT preparation */
1256 ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE); 1261 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(ha, 0, RHBA_RSP_SIZE);
1257 1262
1258 /* Prepare CT request */ 1263 /* Prepare CT request */
1259 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD, 1264 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RHBA_CMD,
@@ -1373,7 +1378,7 @@ qla2x00_fdmi_rhba(scsi_qla_host_t *ha)
1373 /* Firmware version */ 1378 /* Firmware version */
1374 eiter = (struct ct_fdmi_hba_attr *) (entries + size); 1379 eiter = (struct ct_fdmi_hba_attr *) (entries + size);
1375 eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION); 1380 eiter->type = __constant_cpu_to_be16(FDMI_HBA_FIRMWARE_VERSION);
1376 ha->isp_ops.fw_version_str(ha, eiter->a.fw_version); 1381 ha->isp_ops->fw_version_str(ha, eiter->a.fw_version);
1377 alen = strlen(eiter->a.fw_version); 1382 alen = strlen(eiter->a.fw_version);
1378 alen += (alen & 3) ? (4 - (alen & 3)) : 4; 1383 alen += (alen & 3) ? (4 - (alen & 3)) : 4;
1379 eiter->len = cpu_to_be16(4 + alen); 1384 eiter->len = cpu_to_be16(4 + alen);
@@ -1439,7 +1444,7 @@ qla2x00_fdmi_dhba(scsi_qla_host_t *ha)
1439 1444
1440 /* Issue RPA */ 1445 /* Issue RPA */
1441 /* Prepare common MS IOCB */ 1446 /* Prepare common MS IOCB */
1442 ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, DHBA_REQ_SIZE, 1447 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(ha, DHBA_REQ_SIZE,
1443 DHBA_RSP_SIZE); 1448 DHBA_RSP_SIZE);
1444 1449
1445 /* Prepare CT request */ 1450 /* Prepare CT request */
@@ -1497,7 +1502,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1497 /* Issue RPA */ 1502 /* Issue RPA */
1498 /* Prepare common MS IOCB */ 1503 /* Prepare common MS IOCB */
1499 /* Request size adjusted after CT preparation */ 1504 /* Request size adjusted after CT preparation */
1500 ms_pkt = ha->isp_ops.prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE); 1505 ms_pkt = ha->isp_ops->prep_ms_fdmi_iocb(ha, 0, RPA_RSP_SIZE);
1501 1506
1502 /* Prepare CT request */ 1507 /* Prepare CT request */
1503 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD, 1508 ct_req = qla2x00_prep_ct_fdmi_req(&ha->ct_sns->p.req, RPA_CMD,
@@ -1527,12 +1532,20 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1527 eiter = (struct ct_fdmi_port_attr *) (entries + size); 1532 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1528 eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED); 1533 eiter->type = __constant_cpu_to_be16(FDMI_PORT_SUPPORT_SPEED);
1529 eiter->len = __constant_cpu_to_be16(4 + 4); 1534 eiter->len = __constant_cpu_to_be16(4 + 4);
1530 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 1535 if (IS_QLA25XX(ha))
1531 eiter->a.sup_speed = __constant_cpu_to_be32(4); 1536 eiter->a.sup_speed = __constant_cpu_to_be32(
1537 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB|
1538 FDMI_PORT_SPEED_4GB|FDMI_PORT_SPEED_8GB);
1539 else if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
1540 eiter->a.sup_speed = __constant_cpu_to_be32(
1541 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB|
1542 FDMI_PORT_SPEED_4GB);
1532 else if (IS_QLA23XX(ha)) 1543 else if (IS_QLA23XX(ha))
1533 eiter->a.sup_speed = __constant_cpu_to_be32(2); 1544 eiter->a.sup_speed =__constant_cpu_to_be32(
1545 FDMI_PORT_SPEED_1GB|FDMI_PORT_SPEED_2GB);
1534 else 1546 else
1535 eiter->a.sup_speed = __constant_cpu_to_be32(1); 1547 eiter->a.sup_speed = __constant_cpu_to_be32(
1548 FDMI_PORT_SPEED_1GB);
1536 size += 4 + 4; 1549 size += 4 + 4;
1537 1550
1538 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no, 1551 DEBUG13(printk("%s(%ld): SUPPORTED_SPEED=%x.\n", __func__, ha->host_no,
@@ -1543,14 +1556,25 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1543 eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED); 1556 eiter->type = __constant_cpu_to_be16(FDMI_PORT_CURRENT_SPEED);
1544 eiter->len = __constant_cpu_to_be16(4 + 4); 1557 eiter->len = __constant_cpu_to_be16(4 + 4);
1545 switch (ha->link_data_rate) { 1558 switch (ha->link_data_rate) {
1546 case 0: 1559 case PORT_SPEED_1GB:
1547 eiter->a.cur_speed = __constant_cpu_to_be32(1); 1560 eiter->a.cur_speed =
1561 __constant_cpu_to_be32(FDMI_PORT_SPEED_1GB);
1562 break;
1563 case PORT_SPEED_2GB:
1564 eiter->a.cur_speed =
1565 __constant_cpu_to_be32(FDMI_PORT_SPEED_2GB);
1566 break;
1567 case PORT_SPEED_4GB:
1568 eiter->a.cur_speed =
1569 __constant_cpu_to_be32(FDMI_PORT_SPEED_4GB);
1548 break; 1570 break;
1549 case 1: 1571 case PORT_SPEED_8GB:
1550 eiter->a.cur_speed = __constant_cpu_to_be32(2); 1572 eiter->a.cur_speed =
1573 __constant_cpu_to_be32(FDMI_PORT_SPEED_8GB);
1551 break; 1574 break;
1552 case 3: 1575 default:
1553 eiter->a.cur_speed = __constant_cpu_to_be32(4); 1576 eiter->a.cur_speed =
1577 __constant_cpu_to_be32(FDMI_PORT_SPEED_UNKNOWN);
1554 break; 1578 break;
1555 } 1579 }
1556 size += 4 + 4; 1580 size += 4 + 4;
@@ -1562,7 +1586,7 @@ qla2x00_fdmi_rpa(scsi_qla_host_t *ha)
1562 eiter = (struct ct_fdmi_port_attr *) (entries + size); 1586 eiter = (struct ct_fdmi_port_attr *) (entries + size);
1563 eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE); 1587 eiter->type = __constant_cpu_to_be16(FDMI_PORT_MAX_FRAME_SIZE);
1564 eiter->len = __constant_cpu_to_be16(4 + 4); 1588 eiter->len = __constant_cpu_to_be16(4 + 4);
1565 max_frame_size = IS_QLA24XX(ha) || IS_QLA54XX(ha) ? 1589 max_frame_size = IS_FWI2_CAPABLE(ha) ?
1566 (uint32_t) icb24->frame_payload_size: 1590 (uint32_t) icb24->frame_payload_size:
1567 (uint32_t) ha->init_cb->frame_payload_size; 1591 (uint32_t) ha->init_cb->frame_payload_size;
1568 eiter->a.max_frame_size = cpu_to_be32(max_frame_size); 1592 eiter->a.max_frame_size = cpu_to_be32(max_frame_size);
@@ -1678,7 +1702,7 @@ qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list)
1678 struct ct_sns_req *ct_req; 1702 struct ct_sns_req *ct_req;
1679 struct ct_sns_rsp *ct_rsp; 1703 struct ct_sns_rsp *ct_rsp;
1680 1704
1681 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 1705 if (!IS_IIDMA_CAPABLE(ha))
1682 return QLA_FUNCTION_FAILED; 1706 return QLA_FUNCTION_FAILED;
1683 1707
1684 for (i = 0; i < MAX_FIBRE_DEVICES; i++) { 1708 for (i = 0; i < MAX_FIBRE_DEVICES; i++) {
@@ -1686,7 +1710,7 @@ qla2x00_gfpn_id(scsi_qla_host_t *ha, sw_info_t *list)
1686 memset(list[i].fabric_port_name, 0, WWN_SIZE); 1710 memset(list[i].fabric_port_name, 0, WWN_SIZE);
1687 1711
1688 /* Prepare common MS IOCB */ 1712 /* Prepare common MS IOCB */
1689 ms_pkt = ha->isp_ops.prep_ms_iocb(ha, GFPN_ID_REQ_SIZE, 1713 ms_pkt = ha->isp_ops->prep_ms_iocb(ha, GFPN_ID_REQ_SIZE,
1690 GFPN_ID_RSP_SIZE); 1714 GFPN_ID_RSP_SIZE);
1691 1715
1692 /* Prepare CT request */ 1716 /* Prepare CT request */
@@ -1786,7 +1810,7 @@ qla2x00_gpsc(scsi_qla_host_t *ha, sw_info_t *list)
1786 struct ct_sns_req *ct_req; 1810 struct ct_sns_req *ct_req;
1787 struct ct_sns_rsp *ct_rsp; 1811 struct ct_sns_rsp *ct_rsp;
1788 1812
1789 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 1813 if (!IS_IIDMA_CAPABLE(ha))
1790 return QLA_FUNCTION_FAILED; 1814 return QLA_FUNCTION_FAILED;
1791 if (!ha->flags.gpsc_supported) 1815 if (!ha->flags.gpsc_supported)
1792 return QLA_FUNCTION_FAILED; 1816 return QLA_FUNCTION_FAILED;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index cc6ebb609e98..5ec798c2bf13 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -79,20 +79,20 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
79 set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); 79 set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags);
80 80
81 qla_printk(KERN_INFO, ha, "Configuring PCI space...\n"); 81 qla_printk(KERN_INFO, ha, "Configuring PCI space...\n");
82 rval = ha->isp_ops.pci_config(ha); 82 rval = ha->isp_ops->pci_config(ha);
83 if (rval) { 83 if (rval) {
84 DEBUG2(printk("scsi(%ld): Unable to configure PCI space.\n", 84 DEBUG2(printk("scsi(%ld): Unable to configure PCI space.\n",
85 ha->host_no)); 85 ha->host_no));
86 return (rval); 86 return (rval);
87 } 87 }
88 88
89 ha->isp_ops.reset_chip(ha); 89 ha->isp_ops->reset_chip(ha);
90 90
91 ha->isp_ops.get_flash_version(ha, ha->request_ring); 91 ha->isp_ops->get_flash_version(ha, ha->request_ring);
92 92
93 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); 93 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
94 94
95 ha->isp_ops.nvram_config(ha); 95 ha->isp_ops->nvram_config(ha);
96 96
97 if (ha->flags.disable_serdes) { 97 if (ha->flags.disable_serdes) {
98 /* Mask HBA via NVRAM settings? */ 98 /* Mask HBA via NVRAM settings? */
@@ -108,7 +108,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
108 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); 108 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n");
109 109
110 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) { 110 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
111 rval = ha->isp_ops.chip_diag(ha); 111 rval = ha->isp_ops->chip_diag(ha);
112 if (rval) 112 if (rval)
113 return (rval); 113 return (rval);
114 rval = qla2x00_setup_chip(ha); 114 rval = qla2x00_setup_chip(ha);
@@ -129,14 +129,13 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
129int 129int
130qla2100_pci_config(scsi_qla_host_t *ha) 130qla2100_pci_config(scsi_qla_host_t *ha)
131{ 131{
132 int ret;
133 uint16_t w; 132 uint16_t w;
134 uint32_t d; 133 uint32_t d;
135 unsigned long flags; 134 unsigned long flags;
136 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 135 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
137 136
138 pci_set_master(ha->pdev); 137 pci_set_master(ha->pdev);
139 ret = pci_set_mwi(ha->pdev); 138 pci_try_set_mwi(ha->pdev);
140 139
141 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); 140 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
142 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); 141 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
@@ -164,7 +163,6 @@ qla2100_pci_config(scsi_qla_host_t *ha)
164int 163int
165qla2300_pci_config(scsi_qla_host_t *ha) 164qla2300_pci_config(scsi_qla_host_t *ha)
166{ 165{
167 int ret;
168 uint16_t w; 166 uint16_t w;
169 uint32_t d; 167 uint32_t d;
170 unsigned long flags = 0; 168 unsigned long flags = 0;
@@ -172,7 +170,7 @@ qla2300_pci_config(scsi_qla_host_t *ha)
172 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 170 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
173 171
174 pci_set_master(ha->pdev); 172 pci_set_master(ha->pdev);
175 ret = pci_set_mwi(ha->pdev); 173 pci_try_set_mwi(ha->pdev);
176 174
177 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); 175 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
178 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); 176 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
@@ -250,15 +248,13 @@ qla2300_pci_config(scsi_qla_host_t *ha)
250int 248int
251qla24xx_pci_config(scsi_qla_host_t *ha) 249qla24xx_pci_config(scsi_qla_host_t *ha)
252{ 250{
253 int ret;
254 uint16_t w; 251 uint16_t w;
255 uint32_t d; 252 uint32_t d;
256 unsigned long flags = 0; 253 unsigned long flags = 0;
257 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 254 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
258 int pcix_cmd_reg, pcie_dctl_reg;
259 255
260 pci_set_master(ha->pdev); 256 pci_set_master(ha->pdev);
261 ret = pci_set_mwi(ha->pdev); 257 pci_try_set_mwi(ha->pdev);
262 258
263 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); 259 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
264 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); 260 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
@@ -268,28 +264,12 @@ qla24xx_pci_config(scsi_qla_host_t *ha)
268 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); 264 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
269 265
270 /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */ 266 /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */
271 pcix_cmd_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX); 267 if (pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX))
272 if (pcix_cmd_reg) { 268 pcix_set_mmrbc(ha->pdev, 2048);
273 uint16_t pcix_cmd;
274
275 pcix_cmd_reg += PCI_X_CMD;
276 pci_read_config_word(ha->pdev, pcix_cmd_reg, &pcix_cmd);
277 pcix_cmd &= ~PCI_X_CMD_MAX_READ;
278 pcix_cmd |= 0x0008;
279 pci_write_config_word(ha->pdev, pcix_cmd_reg, pcix_cmd);
280 }
281 269
282 /* PCIe -- adjust Maximum Read Request Size (2048). */ 270 /* PCIe -- adjust Maximum Read Request Size (2048). */
283 pcie_dctl_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP); 271 if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP))
284 if (pcie_dctl_reg) { 272 pcie_set_readrq(ha->pdev, 2048);
285 uint16_t pcie_dctl;
286
287 pcie_dctl_reg += PCI_EXP_DEVCTL;
288 pci_read_config_word(ha->pdev, pcie_dctl_reg, &pcie_dctl);
289 pcie_dctl &= ~PCI_EXP_DEVCTL_READRQ;
290 pcie_dctl |= 0x4000;
291 pci_write_config_word(ha->pdev, pcie_dctl_reg, pcie_dctl);
292 }
293 273
294 /* Reset expansion ROM address decode enable */ 274 /* Reset expansion ROM address decode enable */
295 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); 275 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
@@ -307,6 +287,40 @@ qla24xx_pci_config(scsi_qla_host_t *ha)
307} 287}
308 288
309/** 289/**
290 * qla25xx_pci_config() - Setup ISP25xx PCI configuration registers.
291 * @ha: HA context
292 *
293 * Returns 0 on success.
294 */
295int
296qla25xx_pci_config(scsi_qla_host_t *ha)
297{
298 uint16_t w;
299 uint32_t d;
300
301 pci_set_master(ha->pdev);
302 pci_try_set_mwi(ha->pdev);
303
304 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
305 w |= (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
306 w &= ~PCI_COMMAND_INTX_DISABLE;
307 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
308
309 /* PCIe -- adjust Maximum Read Request Size (2048). */
310 if (pci_find_capability(ha->pdev, PCI_CAP_ID_EXP))
311 pcie_set_readrq(ha->pdev, 2048);
312
313 /* Reset expansion ROM address decode enable */
314 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
315 d &= ~PCI_ROM_ADDRESS_ENABLE;
316 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
317
318 ha->chip_revision = ha->pdev->revision;
319
320 return QLA_SUCCESS;
321}
322
323/**
310 * qla2x00_isp_firmware() - Choose firmware image. 324 * qla2x00_isp_firmware() - Choose firmware image.
311 * @ha: HA context 325 * @ha: HA context
312 * 326 *
@@ -351,7 +365,7 @@ qla2x00_reset_chip(scsi_qla_host_t *ha)
351 uint32_t cnt; 365 uint32_t cnt;
352 uint16_t cmd; 366 uint16_t cmd;
353 367
354 ha->isp_ops.disable_intrs(ha); 368 ha->isp_ops->disable_intrs(ha);
355 369
356 spin_lock_irqsave(&ha->hardware_lock, flags); 370 spin_lock_irqsave(&ha->hardware_lock, flags);
357 371
@@ -551,7 +565,7 @@ qla24xx_reset_risc(scsi_qla_host_t *ha)
551void 565void
552qla24xx_reset_chip(scsi_qla_host_t *ha) 566qla24xx_reset_chip(scsi_qla_host_t *ha)
553{ 567{
554 ha->isp_ops.disable_intrs(ha); 568 ha->isp_ops->disable_intrs(ha);
555 569
556 /* Perform RISC reset. */ 570 /* Perform RISC reset. */
557 qla24xx_reset_risc(ha); 571 qla24xx_reset_risc(ha);
@@ -736,8 +750,10 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
736 fixed_size = offsetof(struct qla2300_fw_dump, data_ram); 750 fixed_size = offsetof(struct qla2300_fw_dump, data_ram);
737 mem_size = (ha->fw_memory_size - 0x11000 + 1) * 751 mem_size = (ha->fw_memory_size - 0x11000 + 1) *
738 sizeof(uint16_t); 752 sizeof(uint16_t);
739 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 753 } else if (IS_FWI2_CAPABLE(ha)) {
740 fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem); 754 fixed_size = IS_QLA25XX(ha) ?
755 offsetof(struct qla25xx_fw_dump, ext_mem):
756 offsetof(struct qla24xx_fw_dump, ext_mem);
741 mem_size = (ha->fw_memory_size - 0x100000 + 1) * 757 mem_size = (ha->fw_memory_size - 0x100000 + 1) *
742 sizeof(uint32_t); 758 sizeof(uint32_t);
743 759
@@ -879,7 +895,7 @@ qla2x00_setup_chip(scsi_qla_host_t *ha)
879 uint32_t srisc_address = 0; 895 uint32_t srisc_address = 0;
880 896
881 /* Load firmware sequences */ 897 /* Load firmware sequences */
882 rval = ha->isp_ops.load_risc(ha, &srisc_address); 898 rval = ha->isp_ops->load_risc(ha, &srisc_address);
883 if (rval == QLA_SUCCESS) { 899 if (rval == QLA_SUCCESS) {
884 DEBUG(printk("scsi(%ld): Verifying Checksum of loaded RISC " 900 DEBUG(printk("scsi(%ld): Verifying Checksum of loaded RISC "
885 "code.\n", ha->host_no)); 901 "code.\n", ha->host_no));
@@ -1130,12 +1146,12 @@ qla2x00_init_rings(scsi_qla_host_t *ha)
1130 /* Initialize response queue entries */ 1146 /* Initialize response queue entries */
1131 qla2x00_init_response_q_entries(ha); 1147 qla2x00_init_response_q_entries(ha);
1132 1148
1133 ha->isp_ops.config_rings(ha); 1149 ha->isp_ops->config_rings(ha);
1134 1150
1135 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1151 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1136 1152
1137 /* Update any ISP specific firmware options before initialization. */ 1153 /* Update any ISP specific firmware options before initialization. */
1138 ha->isp_ops.update_fw_options(ha); 1154 ha->isp_ops->update_fw_options(ha);
1139 1155
1140 DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no)); 1156 DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no));
1141 1157
@@ -1459,7 +1475,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha)
1459 ha->nvram_base = 0x80; 1475 ha->nvram_base = 0x80;
1460 1476
1461 /* Get NVRAM data and calculate checksum. */ 1477 /* Get NVRAM data and calculate checksum. */
1462 ha->isp_ops.read_nvram(ha, ptr, ha->nvram_base, ha->nvram_size); 1478 ha->isp_ops->read_nvram(ha, ptr, ha->nvram_base, ha->nvram_size);
1463 for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) 1479 for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++)
1464 chksum += *ptr++; 1480 chksum += *ptr++;
1465 1481
@@ -2119,7 +2135,7 @@ qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
2119 int rval; 2135 int rval;
2120 uint16_t port_speed, mb[6]; 2136 uint16_t port_speed, mb[6];
2121 2137
2122 if (!IS_QLA24XX(ha)) 2138 if (!IS_IIDMA_CAPABLE(ha))
2123 return; 2139 return;
2124 2140
2125 switch (be16_to_cpu(fcport->fp_speed)) { 2141 switch (be16_to_cpu(fcport->fp_speed)) {
@@ -2267,7 +2283,7 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
2267 scsi_qla_host_t *pha = to_qla_parent(ha); 2283 scsi_qla_host_t *pha = to_qla_parent(ha);
2268 2284
2269 /* If FL port exists, then SNS is present */ 2285 /* If FL port exists, then SNS is present */
2270 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 2286 if (IS_FWI2_CAPABLE(ha))
2271 loop_id = NPH_F_PORT; 2287 loop_id = NPH_F_PORT;
2272 else 2288 else
2273 loop_id = SNS_FL_PORT; 2289 loop_id = SNS_FL_PORT;
@@ -2294,11 +2310,11 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
2294 qla2x00_fdmi_register(ha); 2310 qla2x00_fdmi_register(ha);
2295 2311
2296 /* Ensure we are logged into the SNS. */ 2312 /* Ensure we are logged into the SNS. */
2297 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 2313 if (IS_FWI2_CAPABLE(ha))
2298 loop_id = NPH_SNS; 2314 loop_id = NPH_SNS;
2299 else 2315 else
2300 loop_id = SIMPLE_NAME_SERVER; 2316 loop_id = SIMPLE_NAME_SERVER;
2301 ha->isp_ops.fabric_login(ha, loop_id, 0xff, 0xff, 2317 ha->isp_ops->fabric_login(ha, loop_id, 0xff, 0xff,
2302 0xfc, mb, BIT_1 | BIT_0); 2318 0xfc, mb, BIT_1 | BIT_0);
2303 if (mb[0] != MBS_COMMAND_COMPLETE) { 2319 if (mb[0] != MBS_COMMAND_COMPLETE) {
2304 DEBUG2(qla_printk(KERN_INFO, ha, 2320 DEBUG2(qla_printk(KERN_INFO, ha,
@@ -2355,7 +2371,7 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
2355 (fcport->flags & FCF_TAPE_PRESENT) == 0 && 2371 (fcport->flags & FCF_TAPE_PRESENT) == 0 &&
2356 fcport->port_type != FCT_INITIATOR && 2372 fcport->port_type != FCT_INITIATOR &&
2357 fcport->port_type != FCT_BROADCAST) { 2373 fcport->port_type != FCT_BROADCAST) {
2358 ha->isp_ops.fabric_logout(ha, 2374 ha->isp_ops->fabric_logout(ha,
2359 fcport->loop_id, 2375 fcport->loop_id,
2360 fcport->d_id.b.domain, 2376 fcport->d_id.b.domain,
2361 fcport->d_id.b.area, 2377 fcport->d_id.b.area,
@@ -2664,7 +2680,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2664 (fcport->flags & FCF_TAPE_PRESENT) == 0 && 2680 (fcport->flags & FCF_TAPE_PRESENT) == 0 &&
2665 fcport->port_type != FCT_INITIATOR && 2681 fcport->port_type != FCT_INITIATOR &&
2666 fcport->port_type != FCT_BROADCAST) { 2682 fcport->port_type != FCT_BROADCAST) {
2667 ha->isp_ops.fabric_logout(ha, fcport->loop_id, 2683 ha->isp_ops->fabric_logout(ha, fcport->loop_id,
2668 fcport->d_id.b.domain, fcport->d_id.b.area, 2684 fcport->d_id.b.domain, fcport->d_id.b.area,
2669 fcport->d_id.b.al_pa); 2685 fcport->d_id.b.al_pa);
2670 fcport->loop_id = FC_NO_LOOP_ID; 2686 fcport->loop_id = FC_NO_LOOP_ID;
@@ -2919,7 +2935,7 @@ qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2919 opts |= BIT_1; 2935 opts |= BIT_1;
2920 rval = qla2x00_get_port_database(ha, fcport, opts); 2936 rval = qla2x00_get_port_database(ha, fcport, opts);
2921 if (rval != QLA_SUCCESS) { 2937 if (rval != QLA_SUCCESS) {
2922 ha->isp_ops.fabric_logout(ha, fcport->loop_id, 2938 ha->isp_ops->fabric_logout(ha, fcport->loop_id,
2923 fcport->d_id.b.domain, fcport->d_id.b.area, 2939 fcport->d_id.b.domain, fcport->d_id.b.area,
2924 fcport->d_id.b.al_pa); 2940 fcport->d_id.b.al_pa);
2925 qla2x00_mark_device_lost(ha, fcport, 1, 0); 2941 qla2x00_mark_device_lost(ha, fcport, 1, 0);
@@ -2964,7 +2980,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2964 fcport->d_id.b.area, fcport->d_id.b.al_pa)); 2980 fcport->d_id.b.area, fcport->d_id.b.al_pa));
2965 2981
2966 /* Login fcport on switch. */ 2982 /* Login fcport on switch. */
2967 ha->isp_ops.fabric_login(ha, fcport->loop_id, 2983 ha->isp_ops->fabric_login(ha, fcport->loop_id,
2968 fcport->d_id.b.domain, fcport->d_id.b.area, 2984 fcport->d_id.b.domain, fcport->d_id.b.area,
2969 fcport->d_id.b.al_pa, mb, BIT_0); 2985 fcport->d_id.b.al_pa, mb, BIT_0);
2970 if (mb[0] == MBS_PORT_ID_USED) { 2986 if (mb[0] == MBS_PORT_ID_USED) {
@@ -3032,7 +3048,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
3032 * dead. 3048 * dead.
3033 */ 3049 */
3034 *next_loopid = fcport->loop_id; 3050 *next_loopid = fcport->loop_id;
3035 ha->isp_ops.fabric_logout(ha, fcport->loop_id, 3051 ha->isp_ops->fabric_logout(ha, fcport->loop_id,
3036 fcport->d_id.b.domain, fcport->d_id.b.area, 3052 fcport->d_id.b.domain, fcport->d_id.b.area,
3037 fcport->d_id.b.al_pa); 3053 fcport->d_id.b.al_pa);
3038 qla2x00_mark_device_lost(ha, fcport, 1, 0); 3054 qla2x00_mark_device_lost(ha, fcport, 1, 0);
@@ -3050,7 +3066,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
3050 fcport->d_id.b.al_pa, fcport->loop_id, jiffies)); 3066 fcport->d_id.b.al_pa, fcport->loop_id, jiffies));
3051 3067
3052 *next_loopid = fcport->loop_id; 3068 *next_loopid = fcport->loop_id;
3053 ha->isp_ops.fabric_logout(ha, fcport->loop_id, 3069 ha->isp_ops->fabric_logout(ha, fcport->loop_id,
3054 fcport->d_id.b.domain, fcport->d_id.b.area, 3070 fcport->d_id.b.domain, fcport->d_id.b.area,
3055 fcport->d_id.b.al_pa); 3071 fcport->d_id.b.al_pa);
3056 fcport->loop_id = FC_NO_LOOP_ID; 3072 fcport->loop_id = FC_NO_LOOP_ID;
@@ -3206,7 +3222,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3206 3222
3207 qla_printk(KERN_INFO, ha, 3223 qla_printk(KERN_INFO, ha,
3208 "Performing ISP error recovery - ha= %p.\n", ha); 3224 "Performing ISP error recovery - ha= %p.\n", ha);
3209 ha->isp_ops.reset_chip(ha); 3225 ha->isp_ops->reset_chip(ha);
3210 3226
3211 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); 3227 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
3212 if (atomic_read(&ha->loop_state) != LOOP_DOWN) { 3228 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
@@ -3232,9 +3248,9 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3232 } 3248 }
3233 spin_unlock_irqrestore(&ha->hardware_lock, flags); 3249 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3234 3250
3235 ha->isp_ops.get_flash_version(ha, ha->request_ring); 3251 ha->isp_ops->get_flash_version(ha, ha->request_ring);
3236 3252
3237 ha->isp_ops.nvram_config(ha); 3253 ha->isp_ops->nvram_config(ha);
3238 3254
3239 if (!qla2x00_restart_isp(ha)) { 3255 if (!qla2x00_restart_isp(ha)) {
3240 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 3256 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
@@ -3249,7 +3265,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3249 3265
3250 ha->flags.online = 1; 3266 ha->flags.online = 1;
3251 3267
3252 ha->isp_ops.enable_intrs(ha); 3268 ha->isp_ops->enable_intrs(ha);
3253 3269
3254 ha->isp_abort_cnt = 0; 3270 ha->isp_abort_cnt = 0;
3255 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); 3271 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
@@ -3274,7 +3290,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
3274 * The next call disables the board 3290 * The next call disables the board
3275 * completely. 3291 * completely.
3276 */ 3292 */
3277 ha->isp_ops.reset_adapter(ha); 3293 ha->isp_ops->reset_adapter(ha);
3278 ha->flags.online = 0; 3294 ha->flags.online = 0;
3279 clear_bit(ISP_ABORT_RETRY, 3295 clear_bit(ISP_ABORT_RETRY,
3280 &ha->dpc_flags); 3296 &ha->dpc_flags);
@@ -3331,7 +3347,7 @@ qla2x00_restart_isp(scsi_qla_host_t *ha)
3331 /* If firmware needs to be loaded */ 3347 /* If firmware needs to be loaded */
3332 if (qla2x00_isp_firmware(ha)) { 3348 if (qla2x00_isp_firmware(ha)) {
3333 ha->flags.online = 0; 3349 ha->flags.online = 0;
3334 if (!(status = ha->isp_ops.chip_diag(ha))) { 3350 if (!(status = ha->isp_ops->chip_diag(ha))) {
3335 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 3351 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
3336 status = qla2x00_setup_chip(ha); 3352 status = qla2x00_setup_chip(ha);
3337 goto done; 3353 goto done;
@@ -3423,7 +3439,7 @@ qla2x00_reset_adapter(scsi_qla_host_t *ha)
3423 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; 3439 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
3424 3440
3425 ha->flags.online = 0; 3441 ha->flags.online = 0;
3426 ha->isp_ops.disable_intrs(ha); 3442 ha->isp_ops->disable_intrs(ha);
3427 3443
3428 spin_lock_irqsave(&ha->hardware_lock, flags); 3444 spin_lock_irqsave(&ha->hardware_lock, flags);
3429 WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC); 3445 WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
@@ -3440,7 +3456,7 @@ qla24xx_reset_adapter(scsi_qla_host_t *ha)
3440 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; 3456 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
3441 3457
3442 ha->flags.online = 0; 3458 ha->flags.online = 0;
3443 ha->isp_ops.disable_intrs(ha); 3459 ha->isp_ops->disable_intrs(ha);
3444 3460
3445 spin_lock_irqsave(&ha->hardware_lock, flags); 3461 spin_lock_irqsave(&ha->hardware_lock, flags);
3446 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET); 3462 WRT_REG_DWORD(&reg->hccr, HCCRX_SET_RISC_RESET);
@@ -3498,7 +3514,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha)
3498 3514
3499 /* Get NVRAM data and calculate checksum. */ 3515 /* Get NVRAM data and calculate checksum. */
3500 dptr = (uint32_t *)nv; 3516 dptr = (uint32_t *)nv;
3501 ha->isp_ops.read_nvram(ha, (uint8_t *)dptr, ha->nvram_base, 3517 ha->isp_ops->read_nvram(ha, (uint8_t *)dptr, ha->nvram_base,
3502 ha->nvram_size); 3518 ha->nvram_size);
3503 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) 3519 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
3504 chksum += le32_to_cpu(*dptr++); 3520 chksum += le32_to_cpu(*dptr++);
@@ -4012,7 +4028,7 @@ qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha)
4012{ 4028{
4013 int ret, retries; 4029 int ret, retries;
4014 4030
4015 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 4031 if (!IS_FWI2_CAPABLE(ha))
4016 return; 4032 return;
4017 if (!ha->fw_major_version) 4033 if (!ha->fw_major_version)
4018 return; 4034 return;
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index d3023338628f..8e3b04464cff 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -104,7 +104,7 @@ static __inline__ void qla2x00_poll(scsi_qla_host_t *);
104static inline void 104static inline void
105qla2x00_poll(scsi_qla_host_t *ha) 105qla2x00_poll(scsi_qla_host_t *ha)
106{ 106{
107 ha->isp_ops.intr_handler(0, ha); 107 ha->isp_ops->intr_handler(0, ha);
108} 108}
109 109
110static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *); 110static __inline__ void qla2x00_check_fabric_devices(scsi_qla_host_t *);
@@ -163,7 +163,7 @@ static inline int qla2x00_is_reserved_id(scsi_qla_host_t *, uint16_t);
163static inline int 163static inline int
164qla2x00_is_reserved_id(scsi_qla_host_t *ha, uint16_t loop_id) 164qla2x00_is_reserved_id(scsi_qla_host_t *ha, uint16_t loop_id)
165{ 165{
166 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 166 if (IS_FWI2_CAPABLE(ha))
167 return (loop_id > NPH_LAST_HANDLE); 167 return (loop_id > NPH_LAST_HANDLE);
168 168
169 return ((loop_id > ha->last_loop_id && loop_id < SNS_FIRST_LOOP_ID) || 169 return ((loop_id > ha->last_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index c71863ff5489..3a5e78cb6b3f 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -326,7 +326,7 @@ qla2x00_start_scsi(srb_t *sp)
326 tot_dsds = nseg; 326 tot_dsds = nseg;
327 327
328 /* Calculate the number of request entries needed. */ 328 /* Calculate the number of request entries needed. */
329 req_cnt = ha->isp_ops.calc_req_entries(tot_dsds); 329 req_cnt = ha->isp_ops->calc_req_entries(tot_dsds);
330 if (ha->req_q_cnt < (req_cnt + 2)) { 330 if (ha->req_q_cnt < (req_cnt + 2)) {
331 cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg)); 331 cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg));
332 if (ha->req_ring_index < cnt) 332 if (ha->req_ring_index < cnt)
@@ -364,7 +364,7 @@ qla2x00_start_scsi(srb_t *sp)
364 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd)); 364 cmd_pkt->byte_count = cpu_to_le32((uint32_t)scsi_bufflen(cmd));
365 365
366 /* Build IOCB segments */ 366 /* Build IOCB segments */
367 ha->isp_ops.build_iocbs(sp, cmd_pkt, tot_dsds); 367 ha->isp_ops->build_iocbs(sp, cmd_pkt, tot_dsds);
368 368
369 /* Set total data segment count. */ 369 /* Set total data segment count. */
370 cmd_pkt->entry_count = (uint8_t)req_cnt; 370 cmd_pkt->entry_count = (uint8_t)req_cnt;
@@ -432,7 +432,7 @@ __qla2x00_marker(scsi_qla_host_t *ha, uint16_t loop_id, uint16_t lun,
432 mrk->entry_type = MARKER_TYPE; 432 mrk->entry_type = MARKER_TYPE;
433 mrk->modifier = type; 433 mrk->modifier = type;
434 if (type != MK_SYNC_ALL) { 434 if (type != MK_SYNC_ALL) {
435 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 435 if (IS_FWI2_CAPABLE(ha)) {
436 mrk24 = (struct mrk_entry_24xx *) mrk; 436 mrk24 = (struct mrk_entry_24xx *) mrk;
437 mrk24->nport_handle = cpu_to_le16(loop_id); 437 mrk24->nport_handle = cpu_to_le16(loop_id);
438 mrk24->lun[1] = LSB(lun); 438 mrk24->lun[1] = LSB(lun);
@@ -487,7 +487,7 @@ qla2x00_req_pkt(scsi_qla_host_t *ha)
487 for (timer = HZ; timer; timer--) { 487 for (timer = HZ; timer; timer--) {
488 if ((req_cnt + 2) >= ha->req_q_cnt) { 488 if ((req_cnt + 2) >= ha->req_q_cnt) {
489 /* Calculate number of free request entries. */ 489 /* Calculate number of free request entries. */
490 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 490 if (IS_FWI2_CAPABLE(ha))
491 cnt = (uint16_t)RD_REG_DWORD( 491 cnt = (uint16_t)RD_REG_DWORD(
492 &reg->isp24.req_q_out); 492 &reg->isp24.req_q_out);
493 else 493 else
@@ -561,7 +561,7 @@ qla2x00_isp_cmd(scsi_qla_host_t *ha)
561 ha->request_ring_ptr++; 561 ha->request_ring_ptr++;
562 562
563 /* Set chip new ring index. */ 563 /* Set chip new ring index. */
564 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 564 if (IS_FWI2_CAPABLE(ha)) {
565 WRT_REG_DWORD(&reg->isp24.req_q_in, ha->req_ring_index); 565 WRT_REG_DWORD(&reg->isp24.req_q_in, ha->req_ring_index);
566 RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in); 566 RD_REG_DWORD_RELAXED(&reg->isp24.req_q_in);
567 } else { 567 } else {
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 0ba4c8d37879..b8f226ae2633 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -143,7 +143,7 @@ qla2300_intr_handler(int irq, void *dev_id)
143 WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC); 143 WRT_REG_WORD(&reg->hccr, HCCR_RESET_RISC);
144 RD_REG_WORD(&reg->hccr); 144 RD_REG_WORD(&reg->hccr);
145 145
146 ha->isp_ops.fw_dump(ha, 1); 146 ha->isp_ops->fw_dump(ha, 1);
147 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 147 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
148 break; 148 break;
149 } else if ((stat & HSR_RISC_INT) == 0) 149 } else if ((stat & HSR_RISC_INT) == 0)
@@ -247,7 +247,7 @@ void
247qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb) 247qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
248{ 248{
249#define LS_UNKNOWN 2 249#define LS_UNKNOWN 2
250 static char *link_speeds[5] = { "1", "2", "?", "4", "10" }; 250 static char *link_speeds[5] = { "1", "2", "?", "4", "8" };
251 char *link_speed; 251 char *link_speed;
252 uint16_t handle_cnt; 252 uint16_t handle_cnt;
253 uint16_t cnt; 253 uint16_t cnt;
@@ -334,9 +334,9 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
334 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n", 334 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
335 mb[1], mb[2], mb[3]); 335 mb[1], mb[2], mb[3]);
336 336
337 ha->isp_ops.fw_dump(ha, 1); 337 ha->isp_ops->fw_dump(ha, 1);
338 338
339 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 339 if (IS_FWI2_CAPABLE(ha)) {
340 if (mb[1] == 0 && mb[2] == 0) { 340 if (mb[1] == 0 && mb[2] == 0) {
341 qla_printk(KERN_ERR, ha, 341 qla_printk(KERN_ERR, ha,
342 "Unrecoverable Hardware Error: adapter " 342 "Unrecoverable Hardware Error: adapter "
@@ -601,7 +601,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint16_t *mb)
601 "scsi(%ld): [R|Z]IO update completion.\n", 601 "scsi(%ld): [R|Z]IO update completion.\n",
602 ha->host_no)); 602 ha->host_no));
603 603
604 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 604 if (IS_FWI2_CAPABLE(ha))
605 qla24xx_process_response_queue(ha); 605 qla24xx_process_response_queue(ha);
606 else 606 else
607 qla2x00_process_response_queue(ha); 607 qla2x00_process_response_queue(ha);
@@ -823,7 +823,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
823 823
824 sts = (sts_entry_t *) pkt; 824 sts = (sts_entry_t *) pkt;
825 sts24 = (struct sts_entry_24xx *) pkt; 825 sts24 = (struct sts_entry_24xx *) pkt;
826 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 826 if (IS_FWI2_CAPABLE(ha)) {
827 comp_status = le16_to_cpu(sts24->comp_status); 827 comp_status = le16_to_cpu(sts24->comp_status);
828 scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; 828 scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK;
829 } else { 829 } else {
@@ -872,7 +872,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
872 fcport = sp->fcport; 872 fcport = sp->fcport;
873 873
874 sense_len = rsp_info_len = resid_len = fw_resid_len = 0; 874 sense_len = rsp_info_len = resid_len = fw_resid_len = 0;
875 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 875 if (IS_FWI2_CAPABLE(ha)) {
876 sense_len = le32_to_cpu(sts24->sense_len); 876 sense_len = le32_to_cpu(sts24->sense_len);
877 rsp_info_len = le32_to_cpu(sts24->rsp_data_len); 877 rsp_info_len = le32_to_cpu(sts24->rsp_data_len);
878 resid_len = le32_to_cpu(sts24->rsp_residual_count); 878 resid_len = le32_to_cpu(sts24->rsp_residual_count);
@@ -891,7 +891,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
891 /* Check for any FCP transport errors. */ 891 /* Check for any FCP transport errors. */
892 if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) { 892 if (scsi_status & SS_RESPONSE_INFO_LEN_VALID) {
893 /* Sense data lies beyond any FCP RESPONSE data. */ 893 /* Sense data lies beyond any FCP RESPONSE data. */
894 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 894 if (IS_FWI2_CAPABLE(ha))
895 sense_data += rsp_info_len; 895 sense_data += rsp_info_len;
896 if (rsp_info_len > 3 && rsp_info[3]) { 896 if (rsp_info_len > 3 && rsp_info[3]) {
897 DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol " 897 DEBUG2(printk("scsi(%ld:%d:%d:%d) FCP I/O protocol "
@@ -990,7 +990,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
990 case CS_DATA_UNDERRUN: 990 case CS_DATA_UNDERRUN:
991 resid = resid_len; 991 resid = resid_len;
992 /* Use F/W calculated residual length. */ 992 /* Use F/W calculated residual length. */
993 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 993 if (IS_FWI2_CAPABLE(ha))
994 resid = fw_resid_len; 994 resid = fw_resid_len;
995 995
996 if (scsi_status & SS_RESIDUAL_UNDER) { 996 if (scsi_status & SS_RESIDUAL_UNDER) {
@@ -1062,6 +1062,25 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1062 cp->device->id, cp->device->lun, cp, 1062 cp->device->id, cp->device->lun, cp,
1063 cp->serial_number)); 1063 cp->serial_number));
1064 1064
1065 /*
1066 * In case of a Underrun condition, set both the lscsi
1067 * status and the completion status to appropriate
1068 * values.
1069 */
1070 if (resid &&
1071 ((unsigned)(cp->request_bufflen - resid) <
1072 cp->underflow)) {
1073 DEBUG2(qla_printk(KERN_INFO, ha,
1074 "scsi(%ld:%d:%d:%d): Mid-layer underflow "
1075 "detected (%x of %x bytes)...returning "
1076 "error status.\n", ha->host_no,
1077 cp->device->channel, cp->device->id,
1078 cp->device->lun, resid,
1079 cp->request_bufflen));
1080
1081 cp->result = DID_ERROR << 16 | lscsi_status;
1082 }
1083
1065 if (sense_len) 1084 if (sense_len)
1066 DEBUG5(qla2x00_dump_buffer(cp->sense_buffer, 1085 DEBUG5(qla2x00_dump_buffer(cp->sense_buffer,
1067 CMD_ACTUAL_SNSLEN(cp))); 1086 CMD_ACTUAL_SNSLEN(cp)));
@@ -1166,7 +1185,7 @@ qla2x00_status_entry(scsi_qla_host_t *ha, void *pkt)
1166 case CS_TIMEOUT: 1185 case CS_TIMEOUT:
1167 cp->result = DID_BUS_BUSY << 16; 1186 cp->result = DID_BUS_BUSY << 16;
1168 1187
1169 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1188 if (IS_FWI2_CAPABLE(ha)) {
1170 DEBUG2(printk(KERN_INFO 1189 DEBUG2(printk(KERN_INFO
1171 "scsi(%ld:%d:%d:%d): TIMEOUT status detected " 1190 "scsi(%ld:%d:%d:%d): TIMEOUT status detected "
1172 "0x%x-0x%x\n", ha->host_no, cp->device->channel, 1191 "0x%x-0x%x\n", ha->host_no, cp->device->channel,
@@ -1235,7 +1254,7 @@ qla2x00_status_cont_entry(scsi_qla_host_t *ha, sts_cont_entry_t *pkt)
1235 } 1254 }
1236 1255
1237 /* Move sense data. */ 1256 /* Move sense data. */
1238 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 1257 if (IS_FWI2_CAPABLE(ha))
1239 host_to_fcp_swap(pkt->data, sizeof(pkt->data)); 1258 host_to_fcp_swap(pkt->data, sizeof(pkt->data));
1240 memcpy(sp->request_sense_ptr, pkt->data, sense_sz); 1259 memcpy(sp->request_sense_ptr, pkt->data, sense_sz);
1241 DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz)); 1260 DEBUG5(qla2x00_dump_buffer(sp->request_sense_ptr, sense_sz));
@@ -1483,7 +1502,7 @@ qla24xx_intr_handler(int irq, void *dev_id)
1483 1502
1484 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " 1503 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, "
1485 "Dumping firmware!\n", hccr); 1504 "Dumping firmware!\n", hccr);
1486 ha->isp_ops.fw_dump(ha, 1); 1505 ha->isp_ops->fw_dump(ha, 1);
1487 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 1506 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1488 break; 1507 break;
1489 } else if ((stat & HSRX_RISC_INT) == 0) 1508 } else if ((stat & HSRX_RISC_INT) == 0)
@@ -1617,7 +1636,7 @@ qla24xx_msix_default(int irq, void *dev_id)
1617 1636
1618 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, " 1637 qla_printk(KERN_INFO, ha, "RISC paused -- HCCR=%x, "
1619 "Dumping firmware!\n", hccr); 1638 "Dumping firmware!\n", hccr);
1620 ha->isp_ops.fw_dump(ha, 1); 1639 ha->isp_ops->fw_dump(ha, 1);
1621 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); 1640 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1622 break; 1641 break;
1623 } else if ((stat & HSRX_RISC_INT) == 0) 1642 } else if ((stat & HSRX_RISC_INT) == 0)
@@ -1739,11 +1758,11 @@ qla2x00_request_irqs(scsi_qla_host_t *ha)
1739 int ret; 1758 int ret;
1740 1759
1741 /* If possible, enable MSI-X. */ 1760 /* If possible, enable MSI-X. */
1742 if (!IS_QLA2432(ha)) 1761 if (!IS_QLA2432(ha) && !IS_QLA2532(ha))
1743 goto skip_msix; 1762 goto skip_msix;
1744 1763
1745 if (ha->chip_revision < QLA_MSIX_CHIP_REV_24XX || 1764 if (IS_QLA2432(ha) && (ha->chip_revision < QLA_MSIX_CHIP_REV_24XX ||
1746 !QLA_MSIX_FW_MODE_1(ha->fw_attributes)) { 1765 !QLA_MSIX_FW_MODE_1(ha->fw_attributes))) {
1747 DEBUG2(qla_printk(KERN_WARNING, ha, 1766 DEBUG2(qla_printk(KERN_WARNING, ha,
1748 "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n", 1767 "MSI-X: Unsupported ISP2432 (0x%X, 0x%X).\n",
1749 ha->chip_revision, ha->fw_attributes)); 1768 ha->chip_revision, ha->fw_attributes));
@@ -1762,7 +1781,7 @@ qla2x00_request_irqs(scsi_qla_host_t *ha)
1762 "MSI-X: Falling back-to INTa mode -- %d.\n", ret); 1781 "MSI-X: Falling back-to INTa mode -- %d.\n", ret);
1763skip_msix: 1782skip_msix:
1764 1783
1765 if (!IS_QLA24XX(ha)) 1784 if (!IS_QLA24XX(ha) && !IS_QLA2532(ha))
1766 goto skip_msi; 1785 goto skip_msi;
1767 1786
1768 ret = pci_enable_msi(ha->pdev); 1787 ret = pci_enable_msi(ha->pdev);
@@ -1772,7 +1791,7 @@ skip_msix:
1772 } 1791 }
1773skip_msi: 1792skip_msi:
1774 1793
1775 ret = request_irq(ha->pdev->irq, ha->isp_ops.intr_handler, 1794 ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler,
1776 IRQF_DISABLED|IRQF_SHARED, QLA2XXX_DRIVER_NAME, ha); 1795 IRQF_DISABLED|IRQF_SHARED, QLA2XXX_DRIVER_NAME, ha);
1777 if (!ret) { 1796 if (!ret) {
1778 ha->flags.inta_enabled = 1; 1797 ha->flags.inta_enabled = 1;
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 2cd0cff25928..d3746ec80a85 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -90,7 +90,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
90 spin_lock_irqsave(&ha->hardware_lock, flags); 90 spin_lock_irqsave(&ha->hardware_lock, flags);
91 91
92 /* Load mailbox registers. */ 92 /* Load mailbox registers. */
93 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 93 if (IS_FWI2_CAPABLE(ha))
94 optr = (uint16_t __iomem *)&reg->isp24.mailbox0; 94 optr = (uint16_t __iomem *)&reg->isp24.mailbox0;
95 else 95 else
96 optr = (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 0); 96 optr = (uint16_t __iomem *)MAILBOX_REG(ha, &reg->isp, 0);
@@ -154,7 +154,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
154 154
155 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); 155 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
156 156
157 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 157 if (IS_FWI2_CAPABLE(ha))
158 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT); 158 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
159 else 159 else
160 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT); 160 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
@@ -175,7 +175,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
175 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__, 175 DEBUG3_11(printk("%s(%ld): cmd=%x POLLING MODE.\n", __func__,
176 ha->host_no, command)); 176 ha->host_no, command));
177 177
178 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 178 if (IS_FWI2_CAPABLE(ha))
179 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT); 179 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_SET_HOST_INT);
180 else 180 else
181 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT); 181 WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
@@ -228,7 +228,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *pvha, mbx_cmd_t *mcp)
228 uint16_t mb0; 228 uint16_t mb0;
229 uint32_t ictrl; 229 uint32_t ictrl;
230 230
231 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 231 if (IS_FWI2_CAPABLE(ha)) {
232 mb0 = RD_REG_WORD(&reg->isp24.mailbox0); 232 mb0 = RD_REG_WORD(&reg->isp24.mailbox0);
233 ictrl = RD_REG_DWORD(&reg->isp24.ictrl); 233 ictrl = RD_REG_DWORD(&reg->isp24.ictrl);
234 } else { 234 } else {
@@ -322,7 +322,7 @@ qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
322 322
323 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 323 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
324 324
325 if (MSW(risc_addr) || IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 325 if (MSW(risc_addr) || IS_FWI2_CAPABLE(ha)) {
326 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED; 326 mcp->mb[0] = MBC_LOAD_RISC_RAM_EXTENDED;
327 mcp->mb[8] = MSW(risc_addr); 327 mcp->mb[8] = MSW(risc_addr);
328 mcp->out_mb = MBX_8|MBX_0; 328 mcp->out_mb = MBX_8|MBX_0;
@@ -336,7 +336,7 @@ qla2x00_load_ram(scsi_qla_host_t *ha, dma_addr_t req_dma, uint32_t risc_addr,
336 mcp->mb[6] = MSW(MSD(req_dma)); 336 mcp->mb[6] = MSW(MSD(req_dma));
337 mcp->mb[7] = LSW(MSD(req_dma)); 337 mcp->mb[7] = LSW(MSD(req_dma));
338 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1; 338 mcp->out_mb |= MBX_7|MBX_6|MBX_3|MBX_2|MBX_1;
339 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 339 if (IS_FWI2_CAPABLE(ha)) {
340 mcp->mb[4] = MSW(risc_code_size); 340 mcp->mb[4] = MSW(risc_code_size);
341 mcp->mb[5] = LSW(risc_code_size); 341 mcp->mb[5] = LSW(risc_code_size);
342 mcp->out_mb |= MBX_5|MBX_4; 342 mcp->out_mb |= MBX_5|MBX_4;
@@ -387,7 +387,7 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
387 mcp->mb[0] = MBC_EXECUTE_FIRMWARE; 387 mcp->mb[0] = MBC_EXECUTE_FIRMWARE;
388 mcp->out_mb = MBX_0; 388 mcp->out_mb = MBX_0;
389 mcp->in_mb = MBX_0; 389 mcp->in_mb = MBX_0;
390 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 390 if (IS_FWI2_CAPABLE(ha)) {
391 mcp->mb[1] = MSW(risc_addr); 391 mcp->mb[1] = MSW(risc_addr);
392 mcp->mb[2] = LSW(risc_addr); 392 mcp->mb[2] = LSW(risc_addr);
393 mcp->mb[3] = 0; 393 mcp->mb[3] = 0;
@@ -410,7 +410,7 @@ qla2x00_execute_fw(scsi_qla_host_t *ha, uint32_t risc_addr)
410 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__, 410 DEBUG2_3_11(printk("%s(%ld): failed=%x mb[0]=%x.\n", __func__,
411 ha->host_no, rval, mcp->mb[0])); 411 ha->host_no, rval, mcp->mb[0]));
412 } else { 412 } else {
413 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 413 if (IS_FWI2_CAPABLE(ha)) {
414 DEBUG11(printk("%s(%ld): done exchanges=%x.\n", 414 DEBUG11(printk("%s(%ld): done exchanges=%x.\n",
415 __func__, ha->host_no, mcp->mb[1])); 415 __func__, ha->host_no, mcp->mb[1]));
416 } else { 416 } else {
@@ -551,7 +551,7 @@ qla2x00_set_fw_options(scsi_qla_host_t *ha, uint16_t *fwopts)
551 mcp->mb[3] = fwopts[3]; 551 mcp->mb[3] = fwopts[3];
552 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 552 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
553 mcp->in_mb = MBX_0; 553 mcp->in_mb = MBX_0;
554 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 554 if (IS_FWI2_CAPABLE(ha)) {
555 mcp->in_mb |= MBX_1; 555 mcp->in_mb |= MBX_1;
556 } else { 556 } else {
557 mcp->mb[10] = fwopts[10]; 557 mcp->mb[10] = fwopts[10];
@@ -664,7 +664,7 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
664 mcp->mb[0] = MBC_VERIFY_CHECKSUM; 664 mcp->mb[0] = MBC_VERIFY_CHECKSUM;
665 mcp->out_mb = MBX_0; 665 mcp->out_mb = MBX_0;
666 mcp->in_mb = MBX_0; 666 mcp->in_mb = MBX_0;
667 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 667 if (IS_FWI2_CAPABLE(ha)) {
668 mcp->mb[1] = MSW(risc_addr); 668 mcp->mb[1] = MSW(risc_addr);
669 mcp->mb[2] = LSW(risc_addr); 669 mcp->mb[2] = LSW(risc_addr);
670 mcp->out_mb |= MBX_2|MBX_1; 670 mcp->out_mb |= MBX_2|MBX_1;
@@ -681,8 +681,8 @@ qla2x00_verify_checksum(scsi_qla_host_t *ha, uint32_t risc_addr)
681 681
682 if (rval != QLA_SUCCESS) { 682 if (rval != QLA_SUCCESS) {
683 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__, 683 DEBUG2_3_11(printk("%s(%ld): failed=%x chk sum=%x.\n", __func__,
684 ha->host_no, rval, (IS_QLA24XX(ha) || IS_QLA54XX(ha) ? 684 ha->host_no, rval, IS_FWI2_CAPABLE(ha) ?
685 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]))); 685 (mcp->mb[2] << 16) | mcp->mb[1]: mcp->mb[1]));
686 } else { 686 } else {
687 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no)); 687 DEBUG11(printk("%s(%ld): done.\n", __func__, ha->host_no));
688 } 688 }
@@ -739,7 +739,7 @@ qla2x00_issue_iocb(scsi_qla_host_t *ha, void* buffer, dma_addr_t phys_addr,
739 739
740 /* Mask reserved bits. */ 740 /* Mask reserved bits. */
741 sts_entry->entry_status &= 741 sts_entry->entry_status &=
742 IS_QLA24XX(ha) || IS_QLA54XX(ha) ? RF_MASK_24XX :RF_MASK; 742 IS_FWI2_CAPABLE(ha) ? RF_MASK_24XX :RF_MASK;
743 } 743 }
744 744
745 return rval; 745 return rval;
@@ -1085,7 +1085,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1085 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE)); 1085 memset(pd, 0, max(PORT_DATABASE_SIZE, PORT_DATABASE_24XX_SIZE));
1086 1086
1087 mcp->mb[0] = MBC_GET_PORT_DATABASE; 1087 mcp->mb[0] = MBC_GET_PORT_DATABASE;
1088 if (opt != 0 && !IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 1088 if (opt != 0 && !IS_FWI2_CAPABLE(ha))
1089 mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE; 1089 mcp->mb[0] = MBC_ENHANCED_GET_PORT_DATABASE;
1090 mcp->mb[2] = MSW(pd_dma); 1090 mcp->mb[2] = MSW(pd_dma);
1091 mcp->mb[3] = LSW(pd_dma); 1091 mcp->mb[3] = LSW(pd_dma);
@@ -1094,7 +1094,7 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1094 mcp->mb[9] = ha->vp_idx; 1094 mcp->mb[9] = ha->vp_idx;
1095 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 1095 mcp->out_mb = MBX_9|MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
1096 mcp->in_mb = MBX_0; 1096 mcp->in_mb = MBX_0;
1097 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1097 if (IS_FWI2_CAPABLE(ha)) {
1098 mcp->mb[1] = fcport->loop_id; 1098 mcp->mb[1] = fcport->loop_id;
1099 mcp->mb[10] = opt; 1099 mcp->mb[10] = opt;
1100 mcp->out_mb |= MBX_10|MBX_1; 1100 mcp->out_mb |= MBX_10|MBX_1;
@@ -1107,15 +1107,15 @@ qla2x00_get_port_database(scsi_qla_host_t *ha, fc_port_t *fcport, uint8_t opt)
1107 mcp->mb[1] = fcport->loop_id << 8 | opt; 1107 mcp->mb[1] = fcport->loop_id << 8 | opt;
1108 mcp->out_mb |= MBX_1; 1108 mcp->out_mb |= MBX_1;
1109 } 1109 }
1110 mcp->buf_size = (IS_QLA24XX(ha) || IS_QLA54XX(ha) ? 1110 mcp->buf_size = IS_FWI2_CAPABLE(ha) ?
1111 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE); 1111 PORT_DATABASE_24XX_SIZE : PORT_DATABASE_SIZE;
1112 mcp->flags = MBX_DMA_IN; 1112 mcp->flags = MBX_DMA_IN;
1113 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2); 1113 mcp->tov = (ha->login_timeout * 2) + (ha->login_timeout / 2);
1114 rval = qla2x00_mailbox_command(ha, mcp); 1114 rval = qla2x00_mailbox_command(ha, mcp);
1115 if (rval != QLA_SUCCESS) 1115 if (rval != QLA_SUCCESS)
1116 goto gpd_error_out; 1116 goto gpd_error_out;
1117 1117
1118 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1118 if (IS_FWI2_CAPABLE(ha)) {
1119 pd24 = (struct port_database_24xx *) pd; 1119 pd24 = (struct port_database_24xx *) pd;
1120 1120
1121 /* Check for logged in state. */ 1121 /* Check for logged in state. */
@@ -1333,7 +1333,7 @@ qla2x00_lip_reset(scsi_qla_host_t *ha)
1333 1333
1334 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 1334 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
1335 1335
1336 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1336 if (IS_FWI2_CAPABLE(ha)) {
1337 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1337 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1338 mcp->mb[1] = BIT_6; 1338 mcp->mb[1] = BIT_6;
1339 mcp->mb[2] = 0; 1339 mcp->mb[2] = 0;
@@ -1637,7 +1637,7 @@ qla2x00_login_local_device(scsi_qla_host_t *ha, fc_port_t *fcport,
1637 mbx_cmd_t mc; 1637 mbx_cmd_t mc;
1638 mbx_cmd_t *mcp = &mc; 1638 mbx_cmd_t *mcp = &mc;
1639 1639
1640 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) 1640 if (IS_FWI2_CAPABLE(ha))
1641 return qla24xx_login_fabric(ha, fcport->loop_id, 1641 return qla24xx_login_fabric(ha, fcport->loop_id,
1642 fcport->d_id.b.domain, fcport->d_id.b.area, 1642 fcport->d_id.b.domain, fcport->d_id.b.area,
1643 fcport->d_id.b.al_pa, mb_ret, opt); 1643 fcport->d_id.b.al_pa, mb_ret, opt);
@@ -1821,7 +1821,7 @@ qla2x00_full_login_lip(scsi_qla_host_t *ha)
1821 ha->host_no)); 1821 ha->host_no));
1822 1822
1823 mcp->mb[0] = MBC_LIP_FULL_LOGIN; 1823 mcp->mb[0] = MBC_LIP_FULL_LOGIN;
1824 mcp->mb[1] = IS_QLA24XX(ha) || IS_QLA54XX(ha) ? BIT_3: 0; 1824 mcp->mb[1] = IS_FWI2_CAPABLE(ha) ? BIT_3: 0;
1825 mcp->mb[2] = 0; 1825 mcp->mb[2] = 0;
1826 mcp->mb[3] = 0; 1826 mcp->mb[3] = 0;
1827 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; 1827 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0;
@@ -1871,7 +1871,7 @@ qla2x00_get_id_list(scsi_qla_host_t *ha, void *id_list, dma_addr_t id_list_dma,
1871 1871
1872 mcp->mb[0] = MBC_GET_ID_LIST; 1872 mcp->mb[0] = MBC_GET_ID_LIST;
1873 mcp->out_mb = MBX_0; 1873 mcp->out_mb = MBX_0;
1874 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1874 if (IS_FWI2_CAPABLE(ha)) {
1875 mcp->mb[2] = MSW(id_list_dma); 1875 mcp->mb[2] = MSW(id_list_dma);
1876 mcp->mb[3] = LSW(id_list_dma); 1876 mcp->mb[3] = LSW(id_list_dma);
1877 mcp->mb[6] = MSW(MSD(id_list_dma)); 1877 mcp->mb[6] = MSW(MSD(id_list_dma));
@@ -2063,7 +2063,7 @@ qla2x00_get_link_status(scsi_qla_host_t *ha, uint16_t loop_id,
2063 mcp->mb[7] = LSW(MSD(stat_buf_dma)); 2063 mcp->mb[7] = LSW(MSD(stat_buf_dma));
2064 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0; 2064 mcp->out_mb = MBX_7|MBX_6|MBX_3|MBX_2|MBX_0;
2065 mcp->in_mb = MBX_0; 2065 mcp->in_mb = MBX_0;
2066 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 2066 if (IS_FWI2_CAPABLE(ha)) {
2067 mcp->mb[1] = loop_id; 2067 mcp->mb[1] = loop_id;
2068 mcp->mb[4] = 0; 2068 mcp->mb[4] = 0;
2069 mcp->mb[10] = 0; 2069 mcp->mb[10] = 0;
@@ -2334,7 +2334,7 @@ qla2x00_system_error(scsi_qla_host_t *ha)
2334 mbx_cmd_t mc; 2334 mbx_cmd_t mc;
2335 mbx_cmd_t *mcp = &mc; 2335 mbx_cmd_t *mcp = &mc;
2336 2336
2337 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 2337 if (!IS_FWI2_CAPABLE(ha))
2338 return QLA_FUNCTION_FAILED; 2338 return QLA_FUNCTION_FAILED;
2339 2339
2340 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2340 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
@@ -2444,7 +2444,7 @@ qla2x00_stop_firmware(scsi_qla_host_t *ha)
2444 mbx_cmd_t mc; 2444 mbx_cmd_t mc;
2445 mbx_cmd_t *mcp = &mc; 2445 mbx_cmd_t *mcp = &mc;
2446 2446
2447 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 2447 if (!IS_FWI2_CAPABLE(ha))
2448 return QLA_FUNCTION_FAILED; 2448 return QLA_FUNCTION_FAILED;
2449 2449
2450 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2450 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
@@ -2474,7 +2474,7 @@ qla2x00_trace_control(scsi_qla_host_t *ha, uint16_t ctrl, dma_addr_t eft_dma,
2474 mbx_cmd_t mc; 2474 mbx_cmd_t mc;
2475 mbx_cmd_t *mcp = &mc; 2475 mbx_cmd_t *mcp = &mc;
2476 2476
2477 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 2477 if (!IS_FWI2_CAPABLE(ha))
2478 return QLA_FUNCTION_FAILED; 2478 return QLA_FUNCTION_FAILED;
2479 2479
2480 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2480 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
@@ -2514,7 +2514,7 @@ qla2x00_read_sfp(scsi_qla_host_t *ha, dma_addr_t sfp_dma, uint16_t addr,
2514 mbx_cmd_t mc; 2514 mbx_cmd_t mc;
2515 mbx_cmd_t *mcp = &mc; 2515 mbx_cmd_t *mcp = &mc;
2516 2516
2517 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) 2517 if (!IS_FWI2_CAPABLE(ha))
2518 return QLA_FUNCTION_FAILED; 2518 return QLA_FUNCTION_FAILED;
2519 2519
2520 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2520 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
@@ -2552,7 +2552,7 @@ qla2x00_get_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2552 mbx_cmd_t mc; 2552 mbx_cmd_t mc;
2553 mbx_cmd_t *mcp = &mc; 2553 mbx_cmd_t *mcp = &mc;
2554 2554
2555 if (!IS_QLA24XX(ha)) 2555 if (!IS_IIDMA_CAPABLE(ha))
2556 return QLA_FUNCTION_FAILED; 2556 return QLA_FUNCTION_FAILED;
2557 2557
2558 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2558 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
@@ -2595,7 +2595,7 @@ qla2x00_set_idma_speed(scsi_qla_host_t *ha, uint16_t loop_id,
2595 mbx_cmd_t mc; 2595 mbx_cmd_t mc;
2596 mbx_cmd_t *mcp = &mc; 2596 mbx_cmd_t *mcp = &mc;
2597 2597
2598 if (!IS_QLA24XX(ha)) 2598 if (!IS_IIDMA_CAPABLE(ha))
2599 return QLA_FUNCTION_FAILED; 2599 return QLA_FUNCTION_FAILED;
2600 2600
2601 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no)); 2601 DEBUG11(printk("%s(%ld): entered.\n", __func__, ha->host_no));
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 92376f9dfdd5..c488996cb958 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -265,6 +265,8 @@ qla24xx_pci_info_str(struct scsi_qla_host *ha, char *str)
265 strcpy(str, "PCIe ("); 265 strcpy(str, "PCIe (");
266 if (lspeed == 1) 266 if (lspeed == 1)
267 strcat(str, "2.5Gb/s "); 267 strcat(str, "2.5Gb/s ");
268 else if (lspeed == 2)
269 strcat(str, "5.0Gb/s ");
268 else 270 else
269 strcat(str, "<unknown> "); 271 strcat(str, "<unknown> ");
270 snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); 272 snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth);
@@ -343,6 +345,12 @@ qla24xx_fw_version_str(struct scsi_qla_host *ha, char *str)
343 strcat(str, "[IP] "); 345 strcat(str, "[IP] ");
344 if (ha->fw_attributes & BIT_2) 346 if (ha->fw_attributes & BIT_2)
345 strcat(str, "[Multi-ID] "); 347 strcat(str, "[Multi-ID] ");
348 if (ha->fw_attributes & BIT_3)
349 strcat(str, "[SB-2] ");
350 if (ha->fw_attributes & BIT_4)
351 strcat(str, "[T10 CRC] ");
352 if (ha->fw_attributes & BIT_5)
353 strcat(str, "[VI] ");
346 if (ha->fw_attributes & BIT_13) 354 if (ha->fw_attributes & BIT_13)
347 strcat(str, "[Experimental]"); 355 strcat(str, "[Experimental]");
348 return str; 356 return str;
@@ -681,7 +689,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
681 DEBUG3(qla2x00_print_scsi_cmd(cmd)); 689 DEBUG3(qla2x00_print_scsi_cmd(cmd));
682 690
683 spin_unlock_irqrestore(&pha->hardware_lock, flags); 691 spin_unlock_irqrestore(&pha->hardware_lock, flags);
684 if (ha->isp_ops.abort_command(ha, sp)) { 692 if (ha->isp_ops->abort_command(ha, sp)) {
685 DEBUG2(printk("%s(%ld): abort_command " 693 DEBUG2(printk("%s(%ld): abort_command "
686 "mbx failed.\n", __func__, ha->host_no)); 694 "mbx failed.\n", __func__, ha->host_no));
687 } else { 695 } else {
@@ -813,7 +821,7 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
813#if defined(LOGOUT_AFTER_DEVICE_RESET) 821#if defined(LOGOUT_AFTER_DEVICE_RESET)
814 if (ret == SUCCESS) { 822 if (ret == SUCCESS) {
815 if (fcport->flags & FC_FABRIC_DEVICE) { 823 if (fcport->flags & FC_FABRIC_DEVICE) {
816 ha->isp_ops.fabric_logout(ha, fcport->loop_id); 824 ha->isp_ops->fabric_logout(ha, fcport->loop_id);
817 qla2x00_mark_device_lost(ha, fcport, 0, 0); 825 qla2x00_mark_device_lost(ha, fcport, 0, 0);
818 } 826 }
819 } 827 }
@@ -1105,7 +1113,7 @@ static int
1105qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport) 1113qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport)
1106{ 1114{
1107 /* Abort Target command will clear Reservation */ 1115 /* Abort Target command will clear Reservation */
1108 return ha->isp_ops.abort_target(reset_fcport); 1116 return ha->isp_ops->abort_target(reset_fcport);
1109} 1117}
1110 1118
1111static int 1119static int
@@ -1184,8 +1192,8 @@ qla2x00_config_dma_addressing(scsi_qla_host_t *ha)
1184 !pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) { 1192 !pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) {
1185 /* Ok, a 64bit DMA mask is applicable. */ 1193 /* Ok, a 64bit DMA mask is applicable. */
1186 ha->flags.enable_64bit_addressing = 1; 1194 ha->flags.enable_64bit_addressing = 1;
1187 ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_64; 1195 ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
1188 ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_64; 1196 ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
1189 return; 1197 return;
1190 } 1198 }
1191 } 1199 }
@@ -1194,6 +1202,193 @@ qla2x00_config_dma_addressing(scsi_qla_host_t *ha)
1194 pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK); 1202 pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK);
1195} 1203}
1196 1204
1205static void
1206qla2x00_enable_intrs(scsi_qla_host_t *ha)
1207{
1208 unsigned long flags = 0;
1209 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1210
1211 spin_lock_irqsave(&ha->hardware_lock, flags);
1212 ha->interrupts_on = 1;
1213 /* enable risc and host interrupts */
1214 WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
1215 RD_REG_WORD(&reg->ictrl);
1216 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1217
1218}
1219
1220static void
1221qla2x00_disable_intrs(scsi_qla_host_t *ha)
1222{
1223 unsigned long flags = 0;
1224 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1225
1226 spin_lock_irqsave(&ha->hardware_lock, flags);
1227 ha->interrupts_on = 0;
1228 /* disable risc and host interrupts */
1229 WRT_REG_WORD(&reg->ictrl, 0);
1230 RD_REG_WORD(&reg->ictrl);
1231 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1232}
1233
1234static void
1235qla24xx_enable_intrs(scsi_qla_host_t *ha)
1236{
1237 unsigned long flags = 0;
1238 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1239
1240 spin_lock_irqsave(&ha->hardware_lock, flags);
1241 ha->interrupts_on = 1;
1242 WRT_REG_DWORD(&reg->ictrl, ICRX_EN_RISC_INT);
1243 RD_REG_DWORD(&reg->ictrl);
1244 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1245}
1246
1247static void
1248qla24xx_disable_intrs(scsi_qla_host_t *ha)
1249{
1250 unsigned long flags = 0;
1251 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1252
1253 spin_lock_irqsave(&ha->hardware_lock, flags);
1254 ha->interrupts_on = 0;
1255 WRT_REG_DWORD(&reg->ictrl, 0);
1256 RD_REG_DWORD(&reg->ictrl);
1257 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1258}
1259
1260static struct isp_operations qla2100_isp_ops = {
1261 .pci_config = qla2100_pci_config,
1262 .reset_chip = qla2x00_reset_chip,
1263 .chip_diag = qla2x00_chip_diag,
1264 .config_rings = qla2x00_config_rings,
1265 .reset_adapter = qla2x00_reset_adapter,
1266 .nvram_config = qla2x00_nvram_config,
1267 .update_fw_options = qla2x00_update_fw_options,
1268 .load_risc = qla2x00_load_risc,
1269 .pci_info_str = qla2x00_pci_info_str,
1270 .fw_version_str = qla2x00_fw_version_str,
1271 .intr_handler = qla2100_intr_handler,
1272 .enable_intrs = qla2x00_enable_intrs,
1273 .disable_intrs = qla2x00_disable_intrs,
1274 .abort_command = qla2x00_abort_command,
1275 .abort_target = qla2x00_abort_target,
1276 .fabric_login = qla2x00_login_fabric,
1277 .fabric_logout = qla2x00_fabric_logout,
1278 .calc_req_entries = qla2x00_calc_iocbs_32,
1279 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1280 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1281 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1282 .read_nvram = qla2x00_read_nvram_data,
1283 .write_nvram = qla2x00_write_nvram_data,
1284 .fw_dump = qla2100_fw_dump,
1285 .beacon_on = NULL,
1286 .beacon_off = NULL,
1287 .beacon_blink = NULL,
1288 .read_optrom = qla2x00_read_optrom_data,
1289 .write_optrom = qla2x00_write_optrom_data,
1290 .get_flash_version = qla2x00_get_flash_version,
1291};
1292
1293static struct isp_operations qla2300_isp_ops = {
1294 .pci_config = qla2300_pci_config,
1295 .reset_chip = qla2x00_reset_chip,
1296 .chip_diag = qla2x00_chip_diag,
1297 .config_rings = qla2x00_config_rings,
1298 .reset_adapter = qla2x00_reset_adapter,
1299 .nvram_config = qla2x00_nvram_config,
1300 .update_fw_options = qla2x00_update_fw_options,
1301 .load_risc = qla2x00_load_risc,
1302 .pci_info_str = qla2x00_pci_info_str,
1303 .fw_version_str = qla2x00_fw_version_str,
1304 .intr_handler = qla2300_intr_handler,
1305 .enable_intrs = qla2x00_enable_intrs,
1306 .disable_intrs = qla2x00_disable_intrs,
1307 .abort_command = qla2x00_abort_command,
1308 .abort_target = qla2x00_abort_target,
1309 .fabric_login = qla2x00_login_fabric,
1310 .fabric_logout = qla2x00_fabric_logout,
1311 .calc_req_entries = qla2x00_calc_iocbs_32,
1312 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1313 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1314 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1315 .read_nvram = qla2x00_read_nvram_data,
1316 .write_nvram = qla2x00_write_nvram_data,
1317 .fw_dump = qla2300_fw_dump,
1318 .beacon_on = qla2x00_beacon_on,
1319 .beacon_off = qla2x00_beacon_off,
1320 .beacon_blink = qla2x00_beacon_blink,
1321 .read_optrom = qla2x00_read_optrom_data,
1322 .write_optrom = qla2x00_write_optrom_data,
1323 .get_flash_version = qla2x00_get_flash_version,
1324};
1325
1326static struct isp_operations qla24xx_isp_ops = {
1327 .pci_config = qla24xx_pci_config,
1328 .reset_chip = qla24xx_reset_chip,
1329 .chip_diag = qla24xx_chip_diag,
1330 .config_rings = qla24xx_config_rings,
1331 .reset_adapter = qla24xx_reset_adapter,
1332 .nvram_config = qla24xx_nvram_config,
1333 .update_fw_options = qla24xx_update_fw_options,
1334 .load_risc = qla24xx_load_risc,
1335 .pci_info_str = qla24xx_pci_info_str,
1336 .fw_version_str = qla24xx_fw_version_str,
1337 .intr_handler = qla24xx_intr_handler,
1338 .enable_intrs = qla24xx_enable_intrs,
1339 .disable_intrs = qla24xx_disable_intrs,
1340 .abort_command = qla24xx_abort_command,
1341 .abort_target = qla24xx_abort_target,
1342 .fabric_login = qla24xx_login_fabric,
1343 .fabric_logout = qla24xx_fabric_logout,
1344 .calc_req_entries = NULL,
1345 .build_iocbs = NULL,
1346 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1347 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1348 .read_nvram = qla24xx_read_nvram_data,
1349 .write_nvram = qla24xx_write_nvram_data,
1350 .fw_dump = qla24xx_fw_dump,
1351 .beacon_on = qla24xx_beacon_on,
1352 .beacon_off = qla24xx_beacon_off,
1353 .beacon_blink = qla24xx_beacon_blink,
1354 .read_optrom = qla24xx_read_optrom_data,
1355 .write_optrom = qla24xx_write_optrom_data,
1356 .get_flash_version = qla24xx_get_flash_version,
1357};
1358
1359static struct isp_operations qla25xx_isp_ops = {
1360 .pci_config = qla25xx_pci_config,
1361 .reset_chip = qla24xx_reset_chip,
1362 .chip_diag = qla24xx_chip_diag,
1363 .config_rings = qla24xx_config_rings,
1364 .reset_adapter = qla24xx_reset_adapter,
1365 .nvram_config = qla24xx_nvram_config,
1366 .update_fw_options = qla24xx_update_fw_options,
1367 .load_risc = qla24xx_load_risc,
1368 .pci_info_str = qla24xx_pci_info_str,
1369 .fw_version_str = qla24xx_fw_version_str,
1370 .intr_handler = qla24xx_intr_handler,
1371 .enable_intrs = qla24xx_enable_intrs,
1372 .disable_intrs = qla24xx_disable_intrs,
1373 .abort_command = qla24xx_abort_command,
1374 .abort_target = qla24xx_abort_target,
1375 .fabric_login = qla24xx_login_fabric,
1376 .fabric_logout = qla24xx_fabric_logout,
1377 .calc_req_entries = NULL,
1378 .build_iocbs = NULL,
1379 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1380 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1381 .read_nvram = qla25xx_read_nvram_data,
1382 .write_nvram = qla25xx_write_nvram_data,
1383 .fw_dump = qla25xx_fw_dump,
1384 .beacon_on = qla24xx_beacon_on,
1385 .beacon_off = qla24xx_beacon_off,
1386 .beacon_blink = qla24xx_beacon_blink,
1387 .read_optrom = qla24xx_read_optrom_data,
1388 .write_optrom = qla24xx_write_optrom_data,
1389 .get_flash_version = qla24xx_get_flash_version,
1390};
1391
1197static inline void 1392static inline void
1198qla2x00_set_isp_flags(scsi_qla_host_t *ha) 1393qla2x00_set_isp_flags(scsi_qla_host_t *ha)
1199{ 1394{
@@ -1238,19 +1433,32 @@ qla2x00_set_isp_flags(scsi_qla_host_t *ha)
1238 case PCI_DEVICE_ID_QLOGIC_ISP2422: 1433 case PCI_DEVICE_ID_QLOGIC_ISP2422:
1239 ha->device_type |= DT_ISP2422; 1434 ha->device_type |= DT_ISP2422;
1240 ha->device_type |= DT_ZIO_SUPPORTED; 1435 ha->device_type |= DT_ZIO_SUPPORTED;
1436 ha->device_type |= DT_FWI2;
1437 ha->device_type |= DT_IIDMA;
1241 ha->fw_srisc_address = RISC_START_ADDRESS_2400; 1438 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1242 break; 1439 break;
1243 case PCI_DEVICE_ID_QLOGIC_ISP2432: 1440 case PCI_DEVICE_ID_QLOGIC_ISP2432:
1244 ha->device_type |= DT_ISP2432; 1441 ha->device_type |= DT_ISP2432;
1245 ha->device_type |= DT_ZIO_SUPPORTED; 1442 ha->device_type |= DT_ZIO_SUPPORTED;
1443 ha->device_type |= DT_FWI2;
1444 ha->device_type |= DT_IIDMA;
1246 ha->fw_srisc_address = RISC_START_ADDRESS_2400; 1445 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1247 break; 1446 break;
1248 case PCI_DEVICE_ID_QLOGIC_ISP5422: 1447 case PCI_DEVICE_ID_QLOGIC_ISP5422:
1249 ha->device_type |= DT_ISP5422; 1448 ha->device_type |= DT_ISP5422;
1449 ha->device_type |= DT_FWI2;
1250 ha->fw_srisc_address = RISC_START_ADDRESS_2400; 1450 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1251 break; 1451 break;
1252 case PCI_DEVICE_ID_QLOGIC_ISP5432: 1452 case PCI_DEVICE_ID_QLOGIC_ISP5432:
1253 ha->device_type |= DT_ISP5432; 1453 ha->device_type |= DT_ISP5432;
1454 ha->device_type |= DT_FWI2;
1455 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1456 break;
1457 case PCI_DEVICE_ID_QLOGIC_ISP2532:
1458 ha->device_type |= DT_ISP2532;
1459 ha->device_type |= DT_ZIO_SUPPORTED;
1460 ha->device_type |= DT_FWI2;
1461 ha->device_type |= DT_IIDMA;
1254 ha->fw_srisc_address = RISC_START_ADDRESS_2400; 1462 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1255 break; 1463 break;
1256 } 1464 }
@@ -1323,61 +1531,6 @@ iospace_error_exit:
1323} 1531}
1324 1532
1325static void 1533static void
1326qla2x00_enable_intrs(scsi_qla_host_t *ha)
1327{
1328 unsigned long flags = 0;
1329 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1330
1331 spin_lock_irqsave(&ha->hardware_lock, flags);
1332 ha->interrupts_on = 1;
1333 /* enable risc and host interrupts */
1334 WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
1335 RD_REG_WORD(&reg->ictrl);
1336 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1337
1338}
1339
1340static void
1341qla2x00_disable_intrs(scsi_qla_host_t *ha)
1342{
1343 unsigned long flags = 0;
1344 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1345
1346 spin_lock_irqsave(&ha->hardware_lock, flags);
1347 ha->interrupts_on = 0;
1348 /* disable risc and host interrupts */
1349 WRT_REG_WORD(&reg->ictrl, 0);
1350 RD_REG_WORD(&reg->ictrl);
1351 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1352}
1353
1354static void
1355qla24xx_enable_intrs(scsi_qla_host_t *ha)
1356{
1357 unsigned long flags = 0;
1358 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1359
1360 spin_lock_irqsave(&ha->hardware_lock, flags);
1361 ha->interrupts_on = 1;
1362 WRT_REG_DWORD(&reg->ictrl, ICRX_EN_RISC_INT);
1363 RD_REG_DWORD(&reg->ictrl);
1364 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1365}
1366
1367static void
1368qla24xx_disable_intrs(scsi_qla_host_t *ha)
1369{
1370 unsigned long flags = 0;
1371 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1372
1373 spin_lock_irqsave(&ha->hardware_lock, flags);
1374 ha->interrupts_on = 0;
1375 WRT_REG_DWORD(&reg->ictrl, 0);
1376 RD_REG_DWORD(&reg->ictrl);
1377 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1378}
1379
1380static void
1381qla2xxx_scan_start(struct Scsi_Host *shost) 1534qla2xxx_scan_start(struct Scsi_Host *shost)
1382{ 1535{
1383 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata; 1536 scsi_qla_host_t *ha = (scsi_qla_host_t *)shost->hostdata;
@@ -1422,7 +1575,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1422 if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || 1575 if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 ||
1423 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || 1576 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 ||
1424 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || 1577 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 ||
1425 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432) 1578 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 ||
1579 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532)
1426 sht = &qla24xx_driver_template; 1580 sht = &qla24xx_driver_template;
1427 host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); 1581 host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t));
1428 if (host == NULL) { 1582 if (host == NULL) {
@@ -1466,33 +1620,6 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1466 ha->max_q_depth = ql2xmaxqdepth; 1620 ha->max_q_depth = ql2xmaxqdepth;
1467 1621
1468 /* Assign ISP specific operations. */ 1622 /* Assign ISP specific operations. */
1469 ha->isp_ops.pci_config = qla2100_pci_config;
1470 ha->isp_ops.reset_chip = qla2x00_reset_chip;
1471 ha->isp_ops.chip_diag = qla2x00_chip_diag;
1472 ha->isp_ops.config_rings = qla2x00_config_rings;
1473 ha->isp_ops.reset_adapter = qla2x00_reset_adapter;
1474 ha->isp_ops.nvram_config = qla2x00_nvram_config;
1475 ha->isp_ops.update_fw_options = qla2x00_update_fw_options;
1476 ha->isp_ops.load_risc = qla2x00_load_risc;
1477 ha->isp_ops.pci_info_str = qla2x00_pci_info_str;
1478 ha->isp_ops.fw_version_str = qla2x00_fw_version_str;
1479 ha->isp_ops.intr_handler = qla2100_intr_handler;
1480 ha->isp_ops.enable_intrs = qla2x00_enable_intrs;
1481 ha->isp_ops.disable_intrs = qla2x00_disable_intrs;
1482 ha->isp_ops.abort_command = qla2x00_abort_command;
1483 ha->isp_ops.abort_target = qla2x00_abort_target;
1484 ha->isp_ops.fabric_login = qla2x00_login_fabric;
1485 ha->isp_ops.fabric_logout = qla2x00_fabric_logout;
1486 ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_32;
1487 ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_32;
1488 ha->isp_ops.prep_ms_iocb = qla2x00_prep_ms_iocb;
1489 ha->isp_ops.prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb;
1490 ha->isp_ops.read_nvram = qla2x00_read_nvram_data;
1491 ha->isp_ops.write_nvram = qla2x00_write_nvram_data;
1492 ha->isp_ops.fw_dump = qla2100_fw_dump;
1493 ha->isp_ops.read_optrom = qla2x00_read_optrom_data;
1494 ha->isp_ops.write_optrom = qla2x00_write_optrom_data;
1495 ha->isp_ops.get_flash_version = qla2x00_get_flash_version;
1496 if (IS_QLA2100(ha)) { 1623 if (IS_QLA2100(ha)) {
1497 host->max_id = MAX_TARGETS_2100; 1624 host->max_id = MAX_TARGETS_2100;
1498 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; 1625 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
@@ -1501,6 +1628,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1501 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1628 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1502 host->sg_tablesize = 32; 1629 host->sg_tablesize = 32;
1503 ha->gid_list_info_size = 4; 1630 ha->gid_list_info_size = 4;
1631 ha->isp_ops = &qla2100_isp_ops;
1504 } else if (IS_QLA2200(ha)) { 1632 } else if (IS_QLA2200(ha)) {
1505 host->max_id = MAX_TARGETS_2200; 1633 host->max_id = MAX_TARGETS_2200;
1506 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1634 ha->mbx_count = MAILBOX_REGISTER_COUNT;
@@ -1508,21 +1636,17 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1508 ha->response_q_length = RESPONSE_ENTRY_CNT_2100; 1636 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1509 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1637 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1510 ha->gid_list_info_size = 4; 1638 ha->gid_list_info_size = 4;
1639 ha->isp_ops = &qla2100_isp_ops;
1511 } else if (IS_QLA23XX(ha)) { 1640 } else if (IS_QLA23XX(ha)) {
1512 host->max_id = MAX_TARGETS_2200; 1641 host->max_id = MAX_TARGETS_2200;
1513 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1642 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1514 ha->request_q_length = REQUEST_ENTRY_CNT_2200; 1643 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1515 ha->response_q_length = RESPONSE_ENTRY_CNT_2300; 1644 ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
1516 ha->last_loop_id = SNS_LAST_LOOP_ID_2300; 1645 ha->last_loop_id = SNS_LAST_LOOP_ID_2300;
1517 ha->isp_ops.pci_config = qla2300_pci_config;
1518 ha->isp_ops.intr_handler = qla2300_intr_handler;
1519 ha->isp_ops.fw_dump = qla2300_fw_dump;
1520 ha->isp_ops.beacon_on = qla2x00_beacon_on;
1521 ha->isp_ops.beacon_off = qla2x00_beacon_off;
1522 ha->isp_ops.beacon_blink = qla2x00_beacon_blink;
1523 ha->gid_list_info_size = 6; 1646 ha->gid_list_info_size = 6;
1524 if (IS_QLA2322(ha) || IS_QLA6322(ha)) 1647 if (IS_QLA2322(ha) || IS_QLA6322(ha))
1525 ha->optrom_size = OPTROM_SIZE_2322; 1648 ha->optrom_size = OPTROM_SIZE_2322;
1649 ha->isp_ops = &qla2300_isp_ops;
1526 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1650 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
1527 host->max_id = MAX_TARGETS_2200; 1651 host->max_id = MAX_TARGETS_2200;
1528 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1652 ha->mbx_count = MAILBOX_REGISTER_COUNT;
@@ -1531,36 +1655,20 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1531 ha->last_loop_id = SNS_LAST_LOOP_ID_2300; 1655 ha->last_loop_id = SNS_LAST_LOOP_ID_2300;
1532 ha->init_cb_size = sizeof(struct mid_init_cb_24xx); 1656 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
1533 ha->mgmt_svr_loop_id = 10 + ha->vp_idx; 1657 ha->mgmt_svr_loop_id = 10 + ha->vp_idx;
1534 ha->isp_ops.pci_config = qla24xx_pci_config;
1535 ha->isp_ops.reset_chip = qla24xx_reset_chip;
1536 ha->isp_ops.chip_diag = qla24xx_chip_diag;
1537 ha->isp_ops.config_rings = qla24xx_config_rings;
1538 ha->isp_ops.reset_adapter = qla24xx_reset_adapter;
1539 ha->isp_ops.nvram_config = qla24xx_nvram_config;
1540 ha->isp_ops.update_fw_options = qla24xx_update_fw_options;
1541 ha->isp_ops.load_risc = qla24xx_load_risc;
1542 ha->isp_ops.pci_info_str = qla24xx_pci_info_str;
1543 ha->isp_ops.fw_version_str = qla24xx_fw_version_str;
1544 ha->isp_ops.intr_handler = qla24xx_intr_handler;
1545 ha->isp_ops.enable_intrs = qla24xx_enable_intrs;
1546 ha->isp_ops.disable_intrs = qla24xx_disable_intrs;
1547 ha->isp_ops.abort_command = qla24xx_abort_command;
1548 ha->isp_ops.abort_target = qla24xx_abort_target;
1549 ha->isp_ops.fabric_login = qla24xx_login_fabric;
1550 ha->isp_ops.fabric_logout = qla24xx_fabric_logout;
1551 ha->isp_ops.prep_ms_iocb = qla24xx_prep_ms_iocb;
1552 ha->isp_ops.prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb;
1553 ha->isp_ops.read_nvram = qla24xx_read_nvram_data;
1554 ha->isp_ops.write_nvram = qla24xx_write_nvram_data;
1555 ha->isp_ops.fw_dump = qla24xx_fw_dump;
1556 ha->isp_ops.read_optrom = qla24xx_read_optrom_data;
1557 ha->isp_ops.write_optrom = qla24xx_write_optrom_data;
1558 ha->isp_ops.beacon_on = qla24xx_beacon_on;
1559 ha->isp_ops.beacon_off = qla24xx_beacon_off;
1560 ha->isp_ops.beacon_blink = qla24xx_beacon_blink;
1561 ha->isp_ops.get_flash_version = qla24xx_get_flash_version;
1562 ha->gid_list_info_size = 8; 1658 ha->gid_list_info_size = 8;
1563 ha->optrom_size = OPTROM_SIZE_24XX; 1659 ha->optrom_size = OPTROM_SIZE_24XX;
1660 ha->isp_ops = &qla24xx_isp_ops;
1661 } else if (IS_QLA25XX(ha)) {
1662 host->max_id = MAX_TARGETS_2200;
1663 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1664 ha->request_q_length = REQUEST_ENTRY_CNT_24XX;
1665 ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
1666 ha->last_loop_id = SNS_LAST_LOOP_ID_2300;
1667 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
1668 ha->mgmt_svr_loop_id = 10 + ha->vp_idx;
1669 ha->gid_list_info_size = 8;
1670 ha->optrom_size = OPTROM_SIZE_25XX;
1671 ha->isp_ops = &qla25xx_isp_ops;
1564 } 1672 }
1565 host->can_queue = ha->request_q_length + 128; 1673 host->can_queue = ha->request_q_length + 128;
1566 1674
@@ -1628,11 +1736,11 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1628 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n", 1736 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
1629 ha->host_no, ha)); 1737 ha->host_no, ha));
1630 1738
1631 ha->isp_ops.disable_intrs(ha); 1739 ha->isp_ops->disable_intrs(ha);
1632 1740
1633 spin_lock_irqsave(&ha->hardware_lock, flags); 1741 spin_lock_irqsave(&ha->hardware_lock, flags);
1634 reg = ha->iobase; 1742 reg = ha->iobase;
1635 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 1743 if (IS_FWI2_CAPABLE(ha)) {
1636 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_HOST_INT); 1744 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_HOST_INT);
1637 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_RISC_INT); 1745 WRT_REG_DWORD(&reg->isp24.hccr, HCCRX_CLR_RISC_INT);
1638 } else { 1746 } else {
@@ -1654,7 +1762,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1654 } 1762 }
1655 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1763 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1656 1764
1657 ha->isp_ops.enable_intrs(ha); 1765 ha->isp_ops->enable_intrs(ha);
1658 1766
1659 pci_set_drvdata(pdev, ha); 1767 pci_set_drvdata(pdev, ha);
1660 1768
@@ -1679,9 +1787,9 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
1679 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n", 1787 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
1680 qla2x00_version_str, ha->model_number, 1788 qla2x00_version_str, ha->model_number,
1681 ha->model_desc ? ha->model_desc: "", pdev->device, 1789 ha->model_desc ? ha->model_desc: "", pdev->device,
1682 ha->isp_ops.pci_info_str(ha, pci_info), pci_name(pdev), 1790 ha->isp_ops->pci_info_str(ha, pci_info), pci_name(pdev),
1683 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no, 1791 ha->flags.enable_64bit_addressing ? '+': '-', ha->host_no,
1684 ha->isp_ops.fw_version_str(ha, fw_str)); 1792 ha->isp_ops->fw_version_str(ha, fw_str));
1685 1793
1686 return 0; 1794 return 0;
1687 1795
@@ -1747,7 +1855,7 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1747 1855
1748 /* turn-off interrupts on the card */ 1856 /* turn-off interrupts on the card */
1749 if (ha->interrupts_on) 1857 if (ha->interrupts_on)
1750 ha->isp_ops.disable_intrs(ha); 1858 ha->isp_ops->disable_intrs(ha);
1751 1859
1752 qla2x00_mem_free(ha); 1860 qla2x00_mem_free(ha);
1753 1861
@@ -2025,7 +2133,7 @@ qla2x00_mem_alloc(scsi_qla_host_t *ha)
2025 } 2133 }
2026 memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt)); 2134 memset(ha->ct_sns, 0, sizeof(struct ct_sns_pkt));
2027 2135
2028 if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 2136 if (IS_FWI2_CAPABLE(ha)) {
2029 /* 2137 /*
2030 * Get consistent memory allocated for SFP 2138 * Get consistent memory allocated for SFP
2031 * block. 2139 * block.
@@ -2305,7 +2413,7 @@ qla2x00_do_dpc(void *data)
2305 if (fcport->flags & FCF_FABRIC_DEVICE) { 2413 if (fcport->flags & FCF_FABRIC_DEVICE) {
2306 if (fcport->flags & 2414 if (fcport->flags &
2307 FCF_TAPE_PRESENT) 2415 FCF_TAPE_PRESENT)
2308 ha->isp_ops.fabric_logout( 2416 ha->isp_ops->fabric_logout(
2309 ha, fcport->loop_id, 2417 ha, fcport->loop_id,
2310 fcport->d_id.b.domain, 2418 fcport->d_id.b.domain,
2311 fcport->d_id.b.area, 2419 fcport->d_id.b.area,
@@ -2385,10 +2493,10 @@ qla2x00_do_dpc(void *data)
2385 } 2493 }
2386 2494
2387 if (!ha->interrupts_on) 2495 if (!ha->interrupts_on)
2388 ha->isp_ops.enable_intrs(ha); 2496 ha->isp_ops->enable_intrs(ha);
2389 2497
2390 if (test_and_clear_bit(BEACON_BLINK_NEEDED, &ha->dpc_flags)) 2498 if (test_and_clear_bit(BEACON_BLINK_NEEDED, &ha->dpc_flags))
2391 ha->isp_ops.beacon_blink(ha); 2499 ha->isp_ops->beacon_blink(ha);
2392 2500
2393 qla2x00_do_dpc_all_vps(ha); 2501 qla2x00_do_dpc_all_vps(ha);
2394 2502
@@ -2617,18 +2725,20 @@ qla2x00_down_timeout(struct semaphore *sema, unsigned long timeout)
2617 2725
2618/* Firmware interface routines. */ 2726/* Firmware interface routines. */
2619 2727
2620#define FW_BLOBS 5 2728#define FW_BLOBS 6
2621#define FW_ISP21XX 0 2729#define FW_ISP21XX 0
2622#define FW_ISP22XX 1 2730#define FW_ISP22XX 1
2623#define FW_ISP2300 2 2731#define FW_ISP2300 2
2624#define FW_ISP2322 3 2732#define FW_ISP2322 3
2625#define FW_ISP24XX 4 2733#define FW_ISP24XX 4
2734#define FW_ISP25XX 5
2626 2735
2627#define FW_FILE_ISP21XX "ql2100_fw.bin" 2736#define FW_FILE_ISP21XX "ql2100_fw.bin"
2628#define FW_FILE_ISP22XX "ql2200_fw.bin" 2737#define FW_FILE_ISP22XX "ql2200_fw.bin"
2629#define FW_FILE_ISP2300 "ql2300_fw.bin" 2738#define FW_FILE_ISP2300 "ql2300_fw.bin"
2630#define FW_FILE_ISP2322 "ql2322_fw.bin" 2739#define FW_FILE_ISP2322 "ql2322_fw.bin"
2631#define FW_FILE_ISP24XX "ql2400_fw.bin" 2740#define FW_FILE_ISP24XX "ql2400_fw.bin"
2741#define FW_FILE_ISP25XX "ql2500_fw.bin"
2632 2742
2633static DECLARE_MUTEX(qla_fw_lock); 2743static DECLARE_MUTEX(qla_fw_lock);
2634 2744
@@ -2638,6 +2748,7 @@ static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
2638 { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, 2748 { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, },
2639 { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, 2749 { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, },
2640 { .name = FW_FILE_ISP24XX, }, 2750 { .name = FW_FILE_ISP24XX, },
2751 { .name = FW_FILE_ISP25XX, },
2641}; 2752};
2642 2753
2643struct fw_blob * 2754struct fw_blob *
@@ -2656,6 +2767,8 @@ qla2x00_request_firmware(scsi_qla_host_t *ha)
2656 blob = &qla_fw_blobs[FW_ISP2322]; 2767 blob = &qla_fw_blobs[FW_ISP2322];
2657 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { 2768 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
2658 blob = &qla_fw_blobs[FW_ISP24XX]; 2769 blob = &qla_fw_blobs[FW_ISP24XX];
2770 } else if (IS_QLA25XX(ha)) {
2771 blob = &qla_fw_blobs[FW_ISP25XX];
2659 } 2772 }
2660 2773
2661 down(&qla_fw_lock); 2774 down(&qla_fw_lock);
@@ -2699,6 +2812,7 @@ static struct pci_device_id qla2xxx_pci_tbl[] = {
2699 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, 2812 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) },
2700 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, 2813 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) },
2701 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, 2814 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) },
2815 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) },
2702 { 0 }, 2816 { 0 },
2703}; 2817};
2704MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); 2818MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
diff --git a/drivers/scsi/qla2xxx/qla_sup.c b/drivers/scsi/qla2xxx/qla_sup.c
index 206bda093da2..a925a3f179f9 100644
--- a/drivers/scsi/qla2xxx/qla_sup.c
+++ b/drivers/scsi/qla2xxx/qla_sup.c
@@ -766,6 +766,29 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
766 return ret; 766 return ret;
767} 767}
768 768
769uint8_t *
770qla25xx_read_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
771 uint32_t bytes)
772{
773 uint32_t i;
774 uint32_t *dwptr;
775
776 /* Dword reads to flash. */
777 dwptr = (uint32_t *)buf;
778 for (i = 0; i < bytes >> 2; i++, naddr++)
779 dwptr[i] = cpu_to_le32(qla24xx_read_flash_dword(ha,
780 flash_data_to_access_addr(FA_VPD_NVRAM_ADDR | naddr)));
781
782 return buf;
783}
784
785int
786qla25xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr,
787 uint32_t bytes)
788{
789 return qla24xx_write_flash_data(ha, (uint32_t *)buf,
790 FA_VPD_NVRAM_ADDR | naddr, bytes >> 2);
791}
769 792
770static inline void 793static inline void
771qla2x00_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags) 794qla2x00_flip_colors(scsi_qla_host_t *ha, uint16_t *pflags)
@@ -919,7 +942,7 @@ qla2x00_beacon_off(struct scsi_qla_host *ha)
919 else 942 else
920 ha->beacon_color_state = QLA_LED_GRN_ON; 943 ha->beacon_color_state = QLA_LED_GRN_ON;
921 944
922 ha->isp_ops.beacon_blink(ha); /* This turns green LED off */ 945 ha->isp_ops->beacon_blink(ha); /* This turns green LED off */
923 946
924 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; 947 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING;
925 ha->fw_options[1] &= ~FO1_DISABLE_GPIO6_7; 948 ha->fw_options[1] &= ~FO1_DISABLE_GPIO6_7;
@@ -1031,7 +1054,7 @@ qla24xx_beacon_off(struct scsi_qla_host *ha)
1031 ha->beacon_blink_led = 0; 1054 ha->beacon_blink_led = 0;
1032 ha->beacon_color_state = QLA_LED_ALL_ON; 1055 ha->beacon_color_state = QLA_LED_ALL_ON;
1033 1056
1034 ha->isp_ops.beacon_blink(ha); /* Will flip to all off. */ 1057 ha->isp_ops->beacon_blink(ha); /* Will flip to all off. */
1035 1058
1036 /* Give control back to firmware. */ 1059 /* Give control back to firmware. */
1037 spin_lock_irqsave(&ha->hardware_lock, flags); 1060 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -1419,7 +1442,7 @@ qla2x00_suspend_hba(struct scsi_qla_host *ha)
1419 1442
1420 /* Suspend HBA. */ 1443 /* Suspend HBA. */
1421 scsi_block_requests(ha->host); 1444 scsi_block_requests(ha->host);
1422 ha->isp_ops.disable_intrs(ha); 1445 ha->isp_ops->disable_intrs(ha);
1423 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 1446 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
1424 1447
1425 /* Pause RISC. */ 1448 /* Pause RISC. */
@@ -1705,7 +1728,7 @@ qla24xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1705{ 1728{
1706 /* Suspend HBA. */ 1729 /* Suspend HBA. */
1707 scsi_block_requests(ha->host); 1730 scsi_block_requests(ha->host);
1708 ha->isp_ops.disable_intrs(ha); 1731 ha->isp_ops->disable_intrs(ha);
1709 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 1732 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
1710 1733
1711 /* Go with read. */ 1734 /* Go with read. */
@@ -1713,7 +1736,7 @@ qla24xx_read_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1713 1736
1714 /* Resume HBA. */ 1737 /* Resume HBA. */
1715 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 1738 clear_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
1716 ha->isp_ops.enable_intrs(ha); 1739 ha->isp_ops->enable_intrs(ha);
1717 scsi_unblock_requests(ha->host); 1740 scsi_unblock_requests(ha->host);
1718 1741
1719 return buf; 1742 return buf;
@@ -1727,7 +1750,7 @@ qla24xx_write_optrom_data(struct scsi_qla_host *ha, uint8_t *buf,
1727 1750
1728 /* Suspend HBA. */ 1751 /* Suspend HBA. */
1729 scsi_block_requests(ha->host); 1752 scsi_block_requests(ha->host);
1730 ha->isp_ops.disable_intrs(ha); 1753 ha->isp_ops->disable_intrs(ha);
1731 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); 1754 set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags);
1732 1755
1733 /* Go with write. */ 1756 /* Go with write. */
diff --git a/drivers/scsi/qla2xxx/qla_version.h b/drivers/scsi/qla2xxx/qla_version.h
index fd2f10a25348..dd1f8ceb79c4 100644
--- a/drivers/scsi/qla2xxx/qla_version.h
+++ b/drivers/scsi/qla2xxx/qla_version.h
@@ -7,7 +7,7 @@
7/* 7/*
8 * Driver version 8 * Driver version
9 */ 9 */
10#define QLA2XXX_VERSION "8.02.00-k1" 10#define QLA2XXX_VERSION "8.02.00-k2"
11 11
12#define QLA_DRIVER_MAJOR_VER 8 12#define QLA_DRIVER_MAJOR_VER 8
13#define QLA_DRIVER_MINOR_VER 2 13#define QLA_DRIVER_MINOR_VER 2
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 4cd9c58efef1..4947dfe625a6 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -2875,7 +2875,7 @@ static int __init scsi_debug_init(void)
2875 2875
2876 init_all_queued(); 2876 init_all_queued();
2877 2877
2878 sdebug_driver_template.proc_name = (char *)sdebug_proc_name; 2878 sdebug_driver_template.proc_name = sdebug_proc_name;
2879 2879
2880 host_to_add = scsi_debug_add_host; 2880 host_to_add = scsi_debug_add_host;
2881 scsi_debug_add_host = 0; 2881 scsi_debug_add_host = 0;
diff --git a/drivers/scsi/scsi_sysctl.c b/drivers/scsi/scsi_sysctl.c
index 6cfaaa2d0c81..63a30f566f3a 100644
--- a/drivers/scsi/scsi_sysctl.c
+++ b/drivers/scsi/scsi_sysctl.c
@@ -9,6 +9,7 @@
9#include <linux/sysctl.h> 9#include <linux/sysctl.h>
10 10
11#include "scsi_logging.h" 11#include "scsi_logging.h"
12#include "scsi_priv.h"
12 13
13 14
14static ctl_table scsi_table[] = { 15static ctl_table scsi_table[] = {
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index ed720863ab97..34cdce6738a6 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -16,6 +16,7 @@
16#include <scsi/scsi_host.h> 16#include <scsi/scsi_host.h>
17#include <scsi/scsi_tcq.h> 17#include <scsi/scsi_tcq.h>
18#include <scsi/scsi_transport.h> 18#include <scsi/scsi_transport.h>
19#include <scsi/scsi_driver.h>
19 20
20#include "scsi_priv.h" 21#include "scsi_priv.h"
21#include "scsi_logging.h" 22#include "scsi_logging.h"
@@ -714,6 +715,7 @@ static int attr_add(struct device *dev, struct device_attribute *attr)
714int scsi_sysfs_add_sdev(struct scsi_device *sdev) 715int scsi_sysfs_add_sdev(struct scsi_device *sdev)
715{ 716{
716 int error, i; 717 int error, i;
718 struct request_queue *rq = sdev->request_queue;
717 719
718 if ((error = scsi_device_set_state(sdev, SDEV_RUNNING)) != 0) 720 if ((error = scsi_device_set_state(sdev, SDEV_RUNNING)) != 0)
719 return error; 721 return error;
@@ -733,6 +735,17 @@ int scsi_sysfs_add_sdev(struct scsi_device *sdev)
733 /* take a reference for the sdev_classdev; this is 735 /* take a reference for the sdev_classdev; this is
734 * released by the sdev_class .release */ 736 * released by the sdev_class .release */
735 get_device(&sdev->sdev_gendev); 737 get_device(&sdev->sdev_gendev);
738
739 error = bsg_register_queue(rq, &sdev->sdev_gendev, NULL);
740
741 if (error)
742 sdev_printk(KERN_INFO, sdev,
743 "Failed to register bsg queue, errno=%d\n", error);
744
745 /* we're treating error on bsg register as non-fatal, so pretend
746 * nothing went wrong */
747 error = 0;
748
736 if (sdev->host->hostt->sdev_attrs) { 749 if (sdev->host->hostt->sdev_attrs) {
737 for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) { 750 for (i = 0; sdev->host->hostt->sdev_attrs[i]; i++) {
738 error = attr_add(&sdev->sdev_gendev, 751 error = attr_add(&sdev->sdev_gendev,
@@ -779,6 +792,7 @@ void __scsi_remove_device(struct scsi_device *sdev)
779 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0) 792 if (scsi_device_set_state(sdev, SDEV_CANCEL) != 0)
780 return; 793 return;
781 794
795 bsg_unregister_queue(sdev->request_queue);
782 class_device_unregister(&sdev->sdev_classdev); 796 class_device_unregister(&sdev->sdev_classdev);
783 transport_remove_device(dev); 797 transport_remove_device(dev);
784 device_del(dev); 798 device_del(dev);
@@ -803,7 +817,7 @@ void scsi_remove_device(struct scsi_device *sdev)
803} 817}
804EXPORT_SYMBOL(scsi_remove_device); 818EXPORT_SYMBOL(scsi_remove_device);
805 819
806void __scsi_remove_target(struct scsi_target *starget) 820static void __scsi_remove_target(struct scsi_target *starget)
807{ 821{
808 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 822 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
809 unsigned long flags; 823 unsigned long flags;
diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
index e8825709797e..47057254850d 100644
--- a/drivers/scsi/scsi_transport_fc.c
+++ b/drivers/scsi/scsi_transport_fc.c
@@ -2358,7 +2358,7 @@ fc_rport_final_delete(struct work_struct *work)
2358 * Notes: 2358 * Notes:
2359 * This routine assumes no locks are held on entry. 2359 * This routine assumes no locks are held on entry.
2360 **/ 2360 **/
2361struct fc_rport * 2361static struct fc_rport *
2362fc_rport_create(struct Scsi_Host *shost, int channel, 2362fc_rport_create(struct Scsi_Host *shost, int channel,
2363 struct fc_rport_identifiers *ids) 2363 struct fc_rport_identifiers *ids)
2364{ 2364{
diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index b2ef71a86292..3120f4b3a11a 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -29,6 +29,8 @@
29#include <linux/err.h> 29#include <linux/err.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/string.h> 31#include <linux/string.h>
32#include <linux/blkdev.h>
33#include <linux/bsg.h>
32 34
33#include <scsi/scsi.h> 35#include <scsi/scsi.h>
34#include <scsi/scsi_device.h> 36#include <scsi/scsi_device.h>
@@ -40,6 +42,7 @@
40struct sas_host_attrs { 42struct sas_host_attrs {
41 struct list_head rphy_list; 43 struct list_head rphy_list;
42 struct mutex lock; 44 struct mutex lock;
45 struct request_queue *q;
43 u32 next_target_id; 46 u32 next_target_id;
44 u32 next_expander_id; 47 u32 next_expander_id;
45 int next_port_id; 48 int next_port_id;
@@ -152,6 +155,106 @@ static struct {
152sas_bitfield_name_search(linkspeed, sas_linkspeed_names) 155sas_bitfield_name_search(linkspeed, sas_linkspeed_names)
153sas_bitfield_name_set(linkspeed, sas_linkspeed_names) 156sas_bitfield_name_set(linkspeed, sas_linkspeed_names)
154 157
158static void sas_smp_request(struct request_queue *q, struct Scsi_Host *shost,
159 struct sas_rphy *rphy)
160{
161 struct request *req;
162 int ret;
163 int (*handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
164
165 while (!blk_queue_plugged(q)) {
166 req = elv_next_request(q);
167 if (!req)
168 break;
169
170 blkdev_dequeue_request(req);
171
172 spin_unlock_irq(q->queue_lock);
173
174 handler = to_sas_internal(shost->transportt)->f->smp_handler;
175 ret = handler(shost, rphy, req);
176
177 spin_lock_irq(q->queue_lock);
178
179 req->end_io(req, ret);
180 }
181}
182
183static void sas_host_smp_request(struct request_queue *q)
184{
185 sas_smp_request(q, (struct Scsi_Host *)q->queuedata, NULL);
186}
187
188static void sas_non_host_smp_request(struct request_queue *q)
189{
190 struct sas_rphy *rphy = q->queuedata;
191 sas_smp_request(q, rphy_to_shost(rphy), rphy);
192}
193
194static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
195{
196 struct request_queue *q;
197 int error;
198 struct device *dev;
199 char namebuf[BUS_ID_SIZE];
200 const char *name;
201
202 if (!to_sas_internal(shost->transportt)->f->smp_handler) {
203 printk("%s can't handle SMP requests\n", shost->hostt->name);
204 return 0;
205 }
206
207 if (rphy) {
208 q = blk_init_queue(sas_non_host_smp_request, NULL);
209 dev = &rphy->dev;
210 name = dev->bus_id;
211 } else {
212 q = blk_init_queue(sas_host_smp_request, NULL);
213 dev = &shost->shost_gendev;
214 snprintf(namebuf, sizeof(namebuf),
215 "sas_host%d", shost->host_no);
216 name = namebuf;
217 }
218 if (!q)
219 return -ENOMEM;
220
221 error = bsg_register_queue(q, dev, name);
222 if (error) {
223 blk_cleanup_queue(q);
224 return -ENOMEM;
225 }
226
227 if (rphy)
228 rphy->q = q;
229 else
230 to_sas_host_attrs(shost)->q = q;
231
232 if (rphy)
233 q->queuedata = rphy;
234 else
235 q->queuedata = shost;
236
237 set_bit(QUEUE_FLAG_BIDI, &q->queue_flags);
238
239 return 0;
240}
241
242static void sas_bsg_remove(struct Scsi_Host *shost, struct sas_rphy *rphy)
243{
244 struct request_queue *q;
245
246 if (rphy)
247 q = rphy->q;
248 else
249 q = to_sas_host_attrs(shost)->q;
250
251 if (!q)
252 return;
253
254 bsg_unregister_queue(q);
255 blk_cleanup_queue(q);
256}
257
155/* 258/*
156 * SAS host attributes 259 * SAS host attributes
157 */ 260 */
@@ -167,11 +270,26 @@ static int sas_host_setup(struct transport_container *tc, struct device *dev,
167 sas_host->next_target_id = 0; 270 sas_host->next_target_id = 0;
168 sas_host->next_expander_id = 0; 271 sas_host->next_expander_id = 0;
169 sas_host->next_port_id = 0; 272 sas_host->next_port_id = 0;
273
274 if (sas_bsg_initialize(shost, NULL))
275 dev_printk(KERN_ERR, dev, "fail to a bsg device %d\n",
276 shost->host_no);
277
278 return 0;
279}
280
281static int sas_host_remove(struct transport_container *tc, struct device *dev,
282 struct class_device *cdev)
283{
284 struct Scsi_Host *shost = dev_to_shost(dev);
285
286 sas_bsg_remove(shost, NULL);
287
170 return 0; 288 return 0;
171} 289}
172 290
173static DECLARE_TRANSPORT_CLASS(sas_host_class, 291static DECLARE_TRANSPORT_CLASS(sas_host_class,
174 "sas_host", sas_host_setup, NULL, NULL); 292 "sas_host", sas_host_setup, sas_host_remove, NULL);
175 293
176static int sas_host_match(struct attribute_container *cont, 294static int sas_host_match(struct attribute_container *cont,
177 struct device *dev) 295 struct device *dev)
@@ -1287,6 +1405,9 @@ int sas_rphy_add(struct sas_rphy *rphy)
1287 return error; 1405 return error;
1288 transport_add_device(&rphy->dev); 1406 transport_add_device(&rphy->dev);
1289 transport_configure_device(&rphy->dev); 1407 transport_configure_device(&rphy->dev);
1408 if (sas_bsg_initialize(shost, rphy))
1409 printk("fail to a bsg device %s\n", rphy->dev.bus_id);
1410
1290 1411
1291 mutex_lock(&sas_host->lock); 1412 mutex_lock(&sas_host->lock);
1292 list_add_tail(&rphy->list, &sas_host->rphy_list); 1413 list_add_tail(&rphy->list, &sas_host->rphy_list);
@@ -1329,6 +1450,8 @@ void sas_rphy_free(struct sas_rphy *rphy)
1329 list_del(&rphy->list); 1450 list_del(&rphy->list);
1330 mutex_unlock(&sas_host->lock); 1451 mutex_unlock(&sas_host->lock);
1331 1452
1453 sas_bsg_remove(shost, rphy);
1454
1332 transport_destroy_device(dev); 1455 transport_destroy_device(dev);
1333 1456
1334 put_device(dev); 1457 put_device(dev);
diff --git a/drivers/scsi/seagate.c b/drivers/scsi/seagate.c
index ff62e9708e1c..ce80fa9ad815 100644
--- a/drivers/scsi/seagate.c
+++ b/drivers/scsi/seagate.c
@@ -420,7 +420,7 @@ static inline void borken_wait (void)
420#define ULOOP( i ) for (clock = i*8;;) 420#define ULOOP( i ) for (clock = i*8;;)
421#define TIMEOUT (!(clock--)) 421#define TIMEOUT (!(clock--))
422 422
423int __init seagate_st0x_detect (struct scsi_host_template * tpnt) 423static int __init seagate_st0x_detect (struct scsi_host_template * tpnt)
424{ 424{
425 struct Scsi_Host *instance; 425 struct Scsi_Host *instance;
426 int i, j; 426 int i, j;
diff --git a/drivers/scsi/sim710.c b/drivers/scsi/sim710.c
index 710f19de3d40..d63d229e2323 100644
--- a/drivers/scsi/sim710.c
+++ b/drivers/scsi/sim710.c
@@ -138,6 +138,7 @@ sim710_probe_common(struct device *dev, unsigned long base_addr,
138 goto out_put_host; 138 goto out_put_host;
139 } 139 }
140 140
141 dev_set_drvdata(dev, host);
141 scsi_scan_host(host); 142 scsi_scan_host(host);
142 143
143 return 0; 144 return 0;
@@ -155,7 +156,7 @@ sim710_probe_common(struct device *dev, unsigned long base_addr,
155static __devexit int 156static __devexit int
156sim710_device_remove(struct device *dev) 157sim710_device_remove(struct device *dev)
157{ 158{
158 struct Scsi_Host *host = dev_to_shost(dev); 159 struct Scsi_Host *host = dev_get_drvdata(dev);
159 struct NCR_700_Host_Parameters *hostdata = 160 struct NCR_700_Host_Parameters *hostdata =
160 (struct NCR_700_Host_Parameters *)host->hostdata[0]; 161 (struct NCR_700_Host_Parameters *)host->hostdata[0];
161 162
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 5143c8990845..e7b6a7fde1cb 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -175,7 +175,7 @@ static void scsi_cd_put(struct scsi_cd *cd)
175 * an inode for that to work, and we do not always have one. 175 * an inode for that to work, and we do not always have one.
176 */ 176 */
177 177
178int sr_media_change(struct cdrom_device_info *cdi, int slot) 178static int sr_media_change(struct cdrom_device_info *cdi, int slot)
179{ 179{
180 struct scsi_cd *cd = cdi->handle; 180 struct scsi_cd *cd = cdi->handle;
181 int retval; 181 int retval;
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index fa4e08e508ad..b92ff047af38 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -89,6 +89,8 @@
89#include <scsi/scsi_device.h> 89#include <scsi/scsi_device.h>
90#include <scsi/scsi_host.h> 90#include <scsi/scsi_host.h>
91 91
92#include <asm/irq.h>
93
92#include "wd33c93.h" 94#include "wd33c93.h"
93 95
94#define optimum_sx_per(hostdata) (hostdata)->sx_table[1].period_ns 96#define optimum_sx_per(hostdata) (hostdata)->sx_table[1].period_ns
@@ -1762,7 +1764,7 @@ static char setup_buffer[SETUP_BUFFER_SIZE];
1762static char setup_used[MAX_SETUP_ARGS]; 1764static char setup_used[MAX_SETUP_ARGS];
1763static int done_setup = 0; 1765static int done_setup = 0;
1764 1766
1765int 1767static int
1766wd33c93_setup(char *str) 1768wd33c93_setup(char *str)
1767{ 1769{
1768 int i; 1770 int i;
diff --git a/drivers/scsi/zorro7xx.c b/drivers/scsi/zorro7xx.c
index 50703877a585..c822debc2668 100644
--- a/drivers/scsi/zorro7xx.c
+++ b/drivers/scsi/zorro7xx.c
@@ -130,6 +130,7 @@ static int __devinit zorro7xx_init_one(struct zorro_dev *z,
130 goto out_put_host; 130 goto out_put_host;
131 } 131 }
132 132
133 zorro_set_drvdata(z, host);
133 scsi_scan_host(host); 134 scsi_scan_host(host);
134 135
135 return 0; 136 return 0;
@@ -148,7 +149,7 @@ static int __devinit zorro7xx_init_one(struct zorro_dev *z,
148 149
149static __devexit void zorro7xx_remove_one(struct zorro_dev *z) 150static __devexit void zorro7xx_remove_one(struct zorro_dev *z)
150{ 151{
151 struct Scsi_Host *host = dev_to_shost(&z->dev); 152 struct Scsi_Host *host = zorro_get_drvdata(z);
152 struct NCR_700_Host_Parameters *hostdata = shost_priv(host); 153 struct NCR_700_Host_Parameters *hostdata = shost_priv(host);
153 154
154 scsi_remove_host(host); 155 scsi_remove_host(host);
diff --git a/drivers/serial/imx.c b/drivers/serial/imx.c
index e42faa4e4282..dc1967176fe2 100644
--- a/drivers/serial/imx.c
+++ b/drivers/serial/imx.c
@@ -1114,8 +1114,8 @@ static int __init imx_serial_init(void)
1114 1114
1115static void __exit imx_serial_exit(void) 1115static void __exit imx_serial_exit(void)
1116{ 1116{
1117 uart_unregister_driver(&imx_reg);
1118 platform_driver_unregister(&serial_imx_driver); 1117 platform_driver_unregister(&serial_imx_driver);
1118 uart_unregister_driver(&imx_reg);
1119} 1119}
1120 1120
1121module_init(imx_serial_init); 1121module_init(imx_serial_init);
diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c
index 10bc0209cd66..3f26c4b2f322 100644
--- a/drivers/serial/s3c2410.c
+++ b/drivers/serial/s3c2410.c
@@ -78,7 +78,7 @@
78 78
79#include <asm/hardware.h> 79#include <asm/hardware.h>
80 80
81#include <asm/arch/regs-serial.h> 81#include <asm/plat-s3c/regs-serial.h>
82#include <asm/arch/regs-gpio.h> 82#include <asm/arch/regs-gpio.h>
83 83
84/* structures */ 84/* structures */
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 018884d7a5fa..b05de30b5d9b 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -303,8 +303,7 @@ spi_register_board_info(struct spi_board_info const *info, unsigned n)
303 * creates board info from kernel command lines 303 * creates board info from kernel command lines
304 */ 304 */
305 305
306static void __init_or_module 306static void scan_boardinfo(struct spi_master *master)
307scan_boardinfo(struct spi_master *master)
308{ 307{
309 struct boardinfo *bi; 308 struct boardinfo *bi;
310 struct device *dev = master->cdev.dev; 309 struct device *dev = master->cdev.dev;
diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
index b09c83568c1a..1cb56f2d5c84 100644
--- a/drivers/usb/misc/appledisplay.c
+++ b/drivers/usb/misc/appledisplay.c
@@ -138,7 +138,7 @@ exit:
138 138
139static int appledisplay_bl_update_status(struct backlight_device *bd) 139static int appledisplay_bl_update_status(struct backlight_device *bd)
140{ 140{
141 struct appledisplay *pdata = class_get_devdata(&bd->class_dev); 141 struct appledisplay *pdata = bl_get_data(bd);
142 int retval; 142 int retval;
143 143
144 pdata->msgdata[0] = 0x10; 144 pdata->msgdata[0] = 0x10;
@@ -159,7 +159,7 @@ static int appledisplay_bl_update_status(struct backlight_device *bd)
159 159
160static int appledisplay_bl_get_brightness(struct backlight_device *bd) 160static int appledisplay_bl_get_brightness(struct backlight_device *bd)
161{ 161{
162 struct appledisplay *pdata = class_get_devdata(&bd->class_dev); 162 struct appledisplay *pdata = bl_get_data(bd);
163 int retval; 163 int retval;
164 164
165 retval = usb_control_msg( 165 retval = usb_control_msg(
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 0c5644bb59af..564cc9b51822 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -12,6 +12,13 @@ config VGASTATE
12 tristate 12 tristate
13 default n 13 default n
14 14
15config VIDEO_OUTPUT_CONTROL
16 tristate "Lowlevel video output switch controls"
17 default m
18 help
19 This framework adds support for low-level control of the video
20 output switch.
21
15config FB 22config FB
16 tristate "Support for frame buffer devices" 23 tristate "Support for frame buffer devices"
17 ---help--- 24 ---help---
@@ -849,6 +856,16 @@ config FB_INTSRAM
849 Say Y if you want to map Frame Buffer in internal SRAM. Say N if you want 856 Say Y if you want to map Frame Buffer in internal SRAM. Say N if you want
850 to let frame buffer in external SDRAM. 857 to let frame buffer in external SDRAM.
851 858
859config FB_ATMEL_STN
860 bool "Use a STN display with AT91/AT32 LCD Controller"
861 depends on FB_ATMEL && MACH_AT91SAM9261EK
862 default n
863 help
864 Say Y if you want to connect a STN LCD display to the AT91/AT32 LCD
865 Controller. Say N if you want to connect a TFT.
866
867 If unsure, say N.
868
852config FB_NVIDIA 869config FB_NVIDIA
853 tristate "nVidia Framebuffer Support" 870 tristate "nVidia Framebuffer Support"
854 depends on FB && PCI 871 depends on FB && PCI
@@ -1796,13 +1813,14 @@ config FB_PS3
1796 select FB_SYS_COPYAREA 1813 select FB_SYS_COPYAREA
1797 select FB_SYS_IMAGEBLIT 1814 select FB_SYS_IMAGEBLIT
1798 select FB_SYS_FOPS 1815 select FB_SYS_FOPS
1816 select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE
1799 ---help--- 1817 ---help---
1800 Include support for the virtual frame buffer in the PS3 platform. 1818 Include support for the virtual frame buffer in the PS3 platform.
1801 1819
1802config FB_PS3_DEFAULT_SIZE_M 1820config FB_PS3_DEFAULT_SIZE_M
1803 int "PS3 default frame buffer size (in MiB)" 1821 int "PS3 default frame buffer size (in MiB)"
1804 depends on FB_PS3 1822 depends on FB_PS3
1805 default 18 1823 default 9
1806 ---help--- 1824 ---help---
1807 This is the default size (in MiB) of the virtual frame buffer in 1825 This is the default size (in MiB) of the virtual frame buffer in
1808 the PS3. 1826 the PS3.
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index a562f9d69d2c..518933d4905f 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -123,3 +123,6 @@ obj-$(CONFIG_FB_OF) += offb.o
123 123
124# the test framebuffer is last 124# the test framebuffer is last
125obj-$(CONFIG_FB_VIRTUAL) += vfb.o 125obj-$(CONFIG_FB_VIRTUAL) += vfb.o
126
127#video output switch sysfs driver
128obj-$(CONFIG_VIDEO_OUTPUT_CONTROL) += output.o
diff --git a/drivers/video/atmel_lcdfb.c b/drivers/video/atmel_lcdfb.c
index e1d5bd0c98c4..235b618b4117 100644
--- a/drivers/video/atmel_lcdfb.c
+++ b/drivers/video/atmel_lcdfb.c
@@ -79,6 +79,29 @@ static struct fb_fix_screeninfo atmel_lcdfb_fix __initdata = {
79 .accel = FB_ACCEL_NONE, 79 .accel = FB_ACCEL_NONE,
80}; 80};
81 81
82static unsigned long compute_hozval(unsigned long xres, unsigned long lcdcon2)
83{
84 unsigned long value;
85
86 if (!(cpu_is_at91sam9261() || cpu_is_at32ap7000()))
87 return xres;
88
89 value = xres;
90 if ((lcdcon2 & ATMEL_LCDC_DISTYPE) != ATMEL_LCDC_DISTYPE_TFT) {
91 /* STN display */
92 if ((lcdcon2 & ATMEL_LCDC_DISTYPE) == ATMEL_LCDC_DISTYPE_STNCOLOR) {
93 value *= 3;
94 }
95 if ( (lcdcon2 & ATMEL_LCDC_IFWIDTH) == ATMEL_LCDC_IFWIDTH_4
96 || ( (lcdcon2 & ATMEL_LCDC_IFWIDTH) == ATMEL_LCDC_IFWIDTH_8
97 && (lcdcon2 & ATMEL_LCDC_SCANMOD) == ATMEL_LCDC_SCANMOD_DUAL ))
98 value = DIV_ROUND_UP(value, 4);
99 else
100 value = DIV_ROUND_UP(value, 8);
101 }
102
103 return value;
104}
82 105
83static void atmel_lcdfb_update_dma(struct fb_info *info, 106static void atmel_lcdfb_update_dma(struct fb_info *info,
84 struct fb_var_screeninfo *var) 107 struct fb_var_screeninfo *var)
@@ -181,6 +204,7 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
181 var->xoffset = var->yoffset = 0; 204 var->xoffset = var->yoffset = 0;
182 205
183 switch (var->bits_per_pixel) { 206 switch (var->bits_per_pixel) {
207 case 1:
184 case 2: 208 case 2:
185 case 4: 209 case 4:
186 case 8: 210 case 8:
@@ -195,8 +219,11 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
195 var->blue.offset = 10; 219 var->blue.offset = 10;
196 var->red.length = var->green.length = var->blue.length = 5; 220 var->red.length = var->green.length = var->blue.length = 5;
197 break; 221 break;
198 case 24:
199 case 32: 222 case 32:
223 var->transp.offset = 24;
224 var->transp.length = 8;
225 /* fall through */
226 case 24:
200 var->red.offset = 0; 227 var->red.offset = 0;
201 var->green.offset = 8; 228 var->green.offset = 8;
202 var->blue.offset = 16; 229 var->blue.offset = 16;
@@ -228,8 +255,10 @@ static int atmel_lcdfb_check_var(struct fb_var_screeninfo *var,
228static int atmel_lcdfb_set_par(struct fb_info *info) 255static int atmel_lcdfb_set_par(struct fb_info *info)
229{ 256{
230 struct atmel_lcdfb_info *sinfo = info->par; 257 struct atmel_lcdfb_info *sinfo = info->par;
258 unsigned long hozval_linesz;
231 unsigned long value; 259 unsigned long value;
232 unsigned long clk_value_khz; 260 unsigned long clk_value_khz;
261 unsigned long bits_per_line;
233 262
234 dev_dbg(info->device, "%s:\n", __func__); 263 dev_dbg(info->device, "%s:\n", __func__);
235 dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n", 264 dev_dbg(info->device, " * resolution: %ux%u (%ux%u virtual)\n",
@@ -241,12 +270,15 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
241 270
242 lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0); 271 lcdc_writel(sinfo, ATMEL_LCDC_DMACON, 0);
243 272
244 if (info->var.bits_per_pixel <= 8) 273 if (info->var.bits_per_pixel == 1)
274 info->fix.visual = FB_VISUAL_MONO01;
275 else if (info->var.bits_per_pixel <= 8)
245 info->fix.visual = FB_VISUAL_PSEUDOCOLOR; 276 info->fix.visual = FB_VISUAL_PSEUDOCOLOR;
246 else 277 else
247 info->fix.visual = FB_VISUAL_TRUECOLOR; 278 info->fix.visual = FB_VISUAL_TRUECOLOR;
248 279
249 info->fix.line_length = info->var.xres_virtual * (info->var.bits_per_pixel / 8); 280 bits_per_line = info->var.xres_virtual * info->var.bits_per_pixel;
281 info->fix.line_length = DIV_ROUND_UP(bits_per_line, 8);
250 282
251 /* Re-initialize the DMA engine... */ 283 /* Re-initialize the DMA engine... */
252 dev_dbg(info->device, " * update DMA engine\n"); 284 dev_dbg(info->device, " * update DMA engine\n");
@@ -262,18 +294,21 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
262 /* Set pixel clock */ 294 /* Set pixel clock */
263 clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000; 295 clk_value_khz = clk_get_rate(sinfo->lcdc_clk) / 1000;
264 296
265 value = clk_value_khz / PICOS2KHZ(info->var.pixclock); 297 value = DIV_ROUND_UP(clk_value_khz, PICOS2KHZ(info->var.pixclock));
266
267 if (clk_value_khz % PICOS2KHZ(info->var.pixclock))
268 value++;
269 298
270 value = (value / 2) - 1; 299 value = (value / 2) - 1;
300 dev_dbg(info->device, " * programming CLKVAL = 0x%08lx\n", value);
271 301
272 if (value <= 0) { 302 if (value <= 0) {
273 dev_notice(info->device, "Bypassing pixel clock divider\n"); 303 dev_notice(info->device, "Bypassing pixel clock divider\n");
274 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS); 304 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, ATMEL_LCDC_BYPASS);
275 } else 305 } else {
276 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET); 306 lcdc_writel(sinfo, ATMEL_LCDC_LCDCON1, value << ATMEL_LCDC_CLKVAL_OFFSET);
307 info->var.pixclock = KHZ2PICOS(clk_value_khz / (2 * (value + 1)));
308 dev_dbg(info->device, " updated pixclk: %lu KHz\n",
309 PICOS2KHZ(info->var.pixclock));
310 }
311
277 312
278 /* Initialize control register 2 */ 313 /* Initialize control register 2 */
279 value = sinfo->default_lcdcon2; 314 value = sinfo->default_lcdcon2;
@@ -311,9 +346,14 @@ static int atmel_lcdfb_set_par(struct fb_info *info)
311 dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value); 346 dev_dbg(info->device, " * LCDTIM2 = %08lx\n", value);
312 lcdc_writel(sinfo, ATMEL_LCDC_TIM2, value); 347 lcdc_writel(sinfo, ATMEL_LCDC_TIM2, value);
313 348
349 /* Horizontal value (aka line size) */
350 hozval_linesz = compute_hozval(info->var.xres,
351 lcdc_readl(sinfo, ATMEL_LCDC_LCDCON2));
352
314 /* Display size */ 353 /* Display size */
315 value = (info->var.xres - 1) << ATMEL_LCDC_HOZVAL_OFFSET; 354 value = (hozval_linesz - 1) << ATMEL_LCDC_HOZVAL_OFFSET;
316 value |= info->var.yres - 1; 355 value |= info->var.yres - 1;
356 dev_dbg(info->device, " * LCDFRMCFG = %08lx\n", value);
317 lcdc_writel(sinfo, ATMEL_LCDC_LCDFRMCFG, value); 357 lcdc_writel(sinfo, ATMEL_LCDC_LCDFRMCFG, value);
318 358
319 /* FIFO Threshold: Use formula from data sheet */ 359 /* FIFO Threshold: Use formula from data sheet */
@@ -421,6 +461,15 @@ static int atmel_lcdfb_setcolreg(unsigned int regno, unsigned int red,
421 ret = 0; 461 ret = 0;
422 } 462 }
423 break; 463 break;
464
465 case FB_VISUAL_MONO01:
466 if (regno < 2) {
467 val = (regno == 0) ? 0x00 : 0x1F;
468 lcdc_writel(sinfo, ATMEL_LCDC_LUT(regno), val);
469 ret = 0;
470 }
471 break;
472
424 } 473 }
425 474
426 return ret; 475 return ret;
diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
index 7fea4d8ae8e2..cfcbe37d2d70 100644
--- a/drivers/video/aty/aty128fb.c
+++ b/drivers/video/aty/aty128fb.c
@@ -1733,7 +1733,7 @@ static int aty128_bl_get_level_brightness(struct aty128fb_par *par,
1733 1733
1734static int aty128_bl_update_status(struct backlight_device *bd) 1734static int aty128_bl_update_status(struct backlight_device *bd)
1735{ 1735{
1736 struct aty128fb_par *par = class_get_devdata(&bd->class_dev); 1736 struct aty128fb_par *par = bl_get_data(bd);
1737 unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL); 1737 unsigned int reg = aty_ld_le32(LVDS_GEN_CNTL);
1738 int level; 1738 int level;
1739 1739
diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
index 13990697b5c1..bc6f0096aa04 100644
--- a/drivers/video/aty/atyfb_base.c
+++ b/drivers/video/aty/atyfb_base.c
@@ -2141,7 +2141,7 @@ static int aty_bl_get_level_brightness(struct atyfb_par *par, int level)
2141 2141
2142static int aty_bl_update_status(struct backlight_device *bd) 2142static int aty_bl_update_status(struct backlight_device *bd)
2143{ 2143{
2144 struct atyfb_par *par = class_get_devdata(&bd->class_dev); 2144 struct atyfb_par *par = bl_get_data(bd);
2145 unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par); 2145 unsigned int reg = aty_ld_lcd(LCD_MISC_CNTL, par);
2146 int level; 2146 int level;
2147 2147
diff --git a/drivers/video/aty/radeon_backlight.c b/drivers/video/aty/radeon_backlight.c
index 0be25fa5540c..1a056adb61c8 100644
--- a/drivers/video/aty/radeon_backlight.c
+++ b/drivers/video/aty/radeon_backlight.c
@@ -47,7 +47,7 @@ static int radeon_bl_get_level_brightness(struct radeon_bl_privdata *pdata,
47 47
48static int radeon_bl_update_status(struct backlight_device *bd) 48static int radeon_bl_update_status(struct backlight_device *bd)
49{ 49{
50 struct radeon_bl_privdata *pdata = class_get_devdata(&bd->class_dev); 50 struct radeon_bl_privdata *pdata = bl_get_data(bd);
51 struct radeonfb_info *rinfo = pdata->rinfo; 51 struct radeonfb_info *rinfo = pdata->rinfo;
52 u32 lvds_gen_cntl, tmpPixclksCntl; 52 u32 lvds_gen_cntl, tmpPixclksCntl;
53 int level; 53 int level;
@@ -206,7 +206,7 @@ void radeonfb_bl_exit(struct radeonfb_info *rinfo)
206 if (bd) { 206 if (bd) {
207 struct radeon_bl_privdata *pdata; 207 struct radeon_bl_privdata *pdata;
208 208
209 pdata = class_get_devdata(&bd->class_dev); 209 pdata = bl_get_data(bd);
210 backlight_device_unregister(bd); 210 backlight_device_unregister(bd);
211 kfree(pdata); 211 kfree(pdata);
212 rinfo->info->bl_dev = NULL; 212 rinfo->info->bl_dev = NULL;
diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index fbef663fc057..2580f5fa2486 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -8,26 +8,32 @@ menuconfig BACKLIGHT_LCD_SUPPORT
8 Enable this to be able to choose the drivers for controlling the 8 Enable this to be able to choose the drivers for controlling the
9 backlight and the LCD panel on some platforms, for example on PDAs. 9 backlight and the LCD panel on some platforms, for example on PDAs.
10 10
11config BACKLIGHT_CLASS_DEVICE 11#
12 tristate "Lowlevel Backlight controls" 12# LCD
13#
14config LCD_CLASS_DEVICE
15 tristate "Lowlevel LCD controls"
13 depends on BACKLIGHT_LCD_SUPPORT 16 depends on BACKLIGHT_LCD_SUPPORT
14 default m 17 default m
15 help 18 help
16 This framework adds support for low-level control of the LCD 19 This framework adds support for low-level control of LCD.
17 backlight. This includes support for brightness and power. 20 Some framebuffer devices connect to platform-specific LCD modules
21 in order to have a platform-specific way to control the flat panel
22 (contrast and applying power to the LCD (not to the backlight!)).
18 23
19 To have support for your specific LCD panel you will have to 24 To have support for your specific LCD panel you will have to
20 select the proper drivers which depend on this option. 25 select the proper drivers which depend on this option.
21 26
22config LCD_CLASS_DEVICE 27#
23 tristate "Lowlevel LCD controls" 28# Backlight
29#
30config BACKLIGHT_CLASS_DEVICE
31 tristate "Lowlevel Backlight controls"
24 depends on BACKLIGHT_LCD_SUPPORT 32 depends on BACKLIGHT_LCD_SUPPORT
25 default m 33 default m
26 help 34 help
27 This framework adds support for low-level control of LCD. 35 This framework adds support for low-level control of the LCD
28 Some framebuffer devices connect to platform-specific LCD modules 36 backlight. This includes support for brightness and power.
29 in order to have a platform-specific way to control the flat panel
30 (contrast and applying power to the LCD (not to the backlight!)).
31 37
32 To have support for your specific LCD panel you will have to 38 To have support for your specific LCD panel you will have to
33 select the proper drivers which depend on this option. 39 select the proper drivers which depend on this option.
diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
index 7e06223bca94..b26de8cf3112 100644
--- a/drivers/video/backlight/backlight.c
+++ b/drivers/video/backlight/backlight.c
@@ -69,18 +69,20 @@ static inline void backlight_unregister_fb(struct backlight_device *bd)
69} 69}
70#endif /* CONFIG_FB */ 70#endif /* CONFIG_FB */
71 71
72static ssize_t backlight_show_power(struct class_device *cdev, char *buf) 72static ssize_t backlight_show_power(struct device *dev,
73 struct device_attribute *attr,char *buf)
73{ 74{
74 struct backlight_device *bd = to_backlight_device(cdev); 75 struct backlight_device *bd = to_backlight_device(dev);
75 76
76 return sprintf(buf, "%d\n", bd->props.power); 77 return sprintf(buf, "%d\n", bd->props.power);
77} 78}
78 79
79static ssize_t backlight_store_power(struct class_device *cdev, const char *buf, size_t count) 80static ssize_t backlight_store_power(struct device *dev,
81 struct device_attribute *attr, const char *buf, size_t count)
80{ 82{
81 int rc = -ENXIO; 83 int rc = -ENXIO;
82 char *endp; 84 char *endp;
83 struct backlight_device *bd = to_backlight_device(cdev); 85 struct backlight_device *bd = to_backlight_device(dev);
84 int power = simple_strtoul(buf, &endp, 0); 86 int power = simple_strtoul(buf, &endp, 0);
85 size_t size = endp - buf; 87 size_t size = endp - buf;
86 88
@@ -101,18 +103,20 @@ static ssize_t backlight_store_power(struct class_device *cdev, const char *buf,
101 return rc; 103 return rc;
102} 104}
103 105
104static ssize_t backlight_show_brightness(struct class_device *cdev, char *buf) 106static ssize_t backlight_show_brightness(struct device *dev,
107 struct device_attribute *attr, char *buf)
105{ 108{
106 struct backlight_device *bd = to_backlight_device(cdev); 109 struct backlight_device *bd = to_backlight_device(dev);
107 110
108 return sprintf(buf, "%d\n", bd->props.brightness); 111 return sprintf(buf, "%d\n", bd->props.brightness);
109} 112}
110 113
111static ssize_t backlight_store_brightness(struct class_device *cdev, const char *buf, size_t count) 114static ssize_t backlight_store_brightness(struct device *dev,
115 struct device_attribute *attr, const char *buf, size_t count)
112{ 116{
113 int rc = -ENXIO; 117 int rc = -ENXIO;
114 char *endp; 118 char *endp;
115 struct backlight_device *bd = to_backlight_device(cdev); 119 struct backlight_device *bd = to_backlight_device(dev);
116 int brightness = simple_strtoul(buf, &endp, 0); 120 int brightness = simple_strtoul(buf, &endp, 0);
117 size_t size = endp - buf; 121 size_t size = endp - buf;
118 122
@@ -138,18 +142,19 @@ static ssize_t backlight_store_brightness(struct class_device *cdev, const char
138 return rc; 142 return rc;
139} 143}
140 144
141static ssize_t backlight_show_max_brightness(struct class_device *cdev, char *buf) 145static ssize_t backlight_show_max_brightness(struct device *dev,
146 struct device_attribute *attr, char *buf)
142{ 147{
143 struct backlight_device *bd = to_backlight_device(cdev); 148 struct backlight_device *bd = to_backlight_device(dev);
144 149
145 return sprintf(buf, "%d\n", bd->props.max_brightness); 150 return sprintf(buf, "%d\n", bd->props.max_brightness);
146} 151}
147 152
148static ssize_t backlight_show_actual_brightness(struct class_device *cdev, 153static ssize_t backlight_show_actual_brightness(struct device *dev,
149 char *buf) 154 struct device_attribute *attr, char *buf)
150{ 155{
151 int rc = -ENXIO; 156 int rc = -ENXIO;
152 struct backlight_device *bd = to_backlight_device(cdev); 157 struct backlight_device *bd = to_backlight_device(dev);
153 158
154 mutex_lock(&bd->ops_lock); 159 mutex_lock(&bd->ops_lock);
155 if (bd->ops && bd->ops->get_brightness) 160 if (bd->ops && bd->ops->get_brightness)
@@ -159,31 +164,22 @@ static ssize_t backlight_show_actual_brightness(struct class_device *cdev,
159 return rc; 164 return rc;
160} 165}
161 166
162static void backlight_class_release(struct class_device *dev) 167struct class *backlight_class;
168
169static void bl_device_release(struct device *dev)
163{ 170{
164 struct backlight_device *bd = to_backlight_device(dev); 171 struct backlight_device *bd = to_backlight_device(dev);
165 kfree(bd); 172 kfree(bd);
166} 173}
167 174
168static struct class backlight_class = { 175static struct device_attribute bl_device_attributes[] = {
169 .name = "backlight", 176 __ATTR(bl_power, 0644, backlight_show_power, backlight_store_power),
170 .release = backlight_class_release, 177 __ATTR(brightness, 0644, backlight_show_brightness,
171};
172
173#define DECLARE_ATTR(_name,_mode,_show,_store) \
174{ \
175 .attr = { .name = __stringify(_name), .mode = _mode }, \
176 .show = _show, \
177 .store = _store, \
178}
179
180static const struct class_device_attribute bl_class_device_attributes[] = {
181 DECLARE_ATTR(power, 0644, backlight_show_power, backlight_store_power),
182 DECLARE_ATTR(brightness, 0644, backlight_show_brightness,
183 backlight_store_brightness), 178 backlight_store_brightness),
184 DECLARE_ATTR(actual_brightness, 0444, backlight_show_actual_brightness, 179 __ATTR(actual_brightness, 0444, backlight_show_actual_brightness,
185 NULL), 180 NULL),
186 DECLARE_ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL), 181 __ATTR(max_brightness, 0444, backlight_show_max_brightness, NULL),
182 __ATTR_NULL,
187}; 183};
188 184
189/** 185/**
@@ -191,22 +187,20 @@ static const struct class_device_attribute bl_class_device_attributes[] = {
191 * backlight_device class. 187 * backlight_device class.
192 * @name: the name of the new object(must be the same as the name of the 188 * @name: the name of the new object(must be the same as the name of the
193 * respective framebuffer device). 189 * respective framebuffer device).
194 * @devdata: an optional pointer to be stored in the class_device. The 190 * @devdata: an optional pointer to be stored for private driver use. The
195 * methods may retrieve it by using class_get_devdata(&bd->class_dev). 191 * methods may retrieve it by using bl_get_data(bd).
196 * @ops: the backlight operations structure. 192 * @ops: the backlight operations structure.
197 * 193 *
198 * Creates and registers new backlight class_device. Returns either an 194 * Creates and registers new backlight device. Returns either an
199 * ERR_PTR() or a pointer to the newly allocated device. 195 * ERR_PTR() or a pointer to the newly allocated device.
200 */ 196 */
201struct backlight_device *backlight_device_register(const char *name, 197struct backlight_device *backlight_device_register(const char *name,
202 struct device *dev, 198 struct device *parent, void *devdata, struct backlight_ops *ops)
203 void *devdata,
204 struct backlight_ops *ops)
205{ 199{
206 int i, rc;
207 struct backlight_device *new_bd; 200 struct backlight_device *new_bd;
201 int rc;
208 202
209 pr_debug("backlight_device_alloc: name=%s\n", name); 203 pr_debug("backlight_device_register: name=%s\n", name);
210 204
211 new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL); 205 new_bd = kzalloc(sizeof(struct backlight_device), GFP_KERNEL);
212 if (!new_bd) 206 if (!new_bd)
@@ -214,13 +208,14 @@ struct backlight_device *backlight_device_register(const char *name,
214 208
215 mutex_init(&new_bd->update_lock); 209 mutex_init(&new_bd->update_lock);
216 mutex_init(&new_bd->ops_lock); 210 mutex_init(&new_bd->ops_lock);
217 new_bd->ops = ops;
218 new_bd->class_dev.class = &backlight_class;
219 new_bd->class_dev.dev = dev;
220 strlcpy(new_bd->class_dev.class_id, name, KOBJ_NAME_LEN);
221 class_set_devdata(&new_bd->class_dev, devdata);
222 211
223 rc = class_device_register(&new_bd->class_dev); 212 new_bd->dev.class = backlight_class;
213 new_bd->dev.parent = parent;
214 new_bd->dev.release = bl_device_release;
215 strlcpy(new_bd->dev.bus_id, name, BUS_ID_SIZE);
216 dev_set_drvdata(&new_bd->dev, devdata);
217
218 rc = device_register(&new_bd->dev);
224 if (rc) { 219 if (rc) {
225 kfree(new_bd); 220 kfree(new_bd);
226 return ERR_PTR(rc); 221 return ERR_PTR(rc);
@@ -228,23 +223,11 @@ struct backlight_device *backlight_device_register(const char *name,
228 223
229 rc = backlight_register_fb(new_bd); 224 rc = backlight_register_fb(new_bd);
230 if (rc) { 225 if (rc) {
231 class_device_unregister(&new_bd->class_dev); 226 device_unregister(&new_bd->dev);
232 return ERR_PTR(rc); 227 return ERR_PTR(rc);
233 } 228 }
234 229
235 230 new_bd->ops = ops;
236 for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++) {
237 rc = class_device_create_file(&new_bd->class_dev,
238 &bl_class_device_attributes[i]);
239 if (rc) {
240 while (--i >= 0)
241 class_device_remove_file(&new_bd->class_dev,
242 &bl_class_device_attributes[i]);
243 class_device_unregister(&new_bd->class_dev);
244 /* No need to kfree(new_bd) since release() method was called */
245 return ERR_PTR(rc);
246 }
247 }
248 231
249#ifdef CONFIG_PMAC_BACKLIGHT 232#ifdef CONFIG_PMAC_BACKLIGHT
250 mutex_lock(&pmac_backlight_mutex); 233 mutex_lock(&pmac_backlight_mutex);
@@ -265,42 +248,40 @@ EXPORT_SYMBOL(backlight_device_register);
265 */ 248 */
266void backlight_device_unregister(struct backlight_device *bd) 249void backlight_device_unregister(struct backlight_device *bd)
267{ 250{
268 int i;
269
270 if (!bd) 251 if (!bd)
271 return; 252 return;
272 253
273 pr_debug("backlight_device_unregister: name=%s\n", bd->class_dev.class_id);
274
275#ifdef CONFIG_PMAC_BACKLIGHT 254#ifdef CONFIG_PMAC_BACKLIGHT
276 mutex_lock(&pmac_backlight_mutex); 255 mutex_lock(&pmac_backlight_mutex);
277 if (pmac_backlight == bd) 256 if (pmac_backlight == bd)
278 pmac_backlight = NULL; 257 pmac_backlight = NULL;
279 mutex_unlock(&pmac_backlight_mutex); 258 mutex_unlock(&pmac_backlight_mutex);
280#endif 259#endif
281
282 for (i = 0; i < ARRAY_SIZE(bl_class_device_attributes); i++)
283 class_device_remove_file(&bd->class_dev,
284 &bl_class_device_attributes[i]);
285
286 mutex_lock(&bd->ops_lock); 260 mutex_lock(&bd->ops_lock);
287 bd->ops = NULL; 261 bd->ops = NULL;
288 mutex_unlock(&bd->ops_lock); 262 mutex_unlock(&bd->ops_lock);
289 263
290 backlight_unregister_fb(bd); 264 backlight_unregister_fb(bd);
291 265 device_unregister(&bd->dev);
292 class_device_unregister(&bd->class_dev);
293} 266}
294EXPORT_SYMBOL(backlight_device_unregister); 267EXPORT_SYMBOL(backlight_device_unregister);
295 268
296static void __exit backlight_class_exit(void) 269static void __exit backlight_class_exit(void)
297{ 270{
298 class_unregister(&backlight_class); 271 class_destroy(backlight_class);
299} 272}
300 273
301static int __init backlight_class_init(void) 274static int __init backlight_class_init(void)
302{ 275{
303 return class_register(&backlight_class); 276 backlight_class = class_create(THIS_MODULE, "backlight");
277 if (IS_ERR(backlight_class)) {
278 printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n",
279 PTR_ERR(backlight_class));
280 return PTR_ERR(backlight_class);
281 }
282
283 backlight_class->dev_attrs = bl_device_attributes;
284 return 0;
304} 285}
305 286
306/* 287/*
diff --git a/drivers/video/backlight/cr_bllcd.c b/drivers/video/backlight/cr_bllcd.c
index 1b3f6586bc9f..b7904da51b23 100644
--- a/drivers/video/backlight/cr_bllcd.c
+++ b/drivers/video/backlight/cr_bllcd.c
@@ -202,7 +202,7 @@ static int cr_backlight_probe(struct platform_device *pdev)
202 } 202 }
203 203
204 crp->cr_lcd_device = lcd_device_register("cr-lcd", 204 crp->cr_lcd_device = lcd_device_register("cr-lcd",
205 &pdev->dev, 205 &pdev->dev, NULL,
206 &cr_lcd_ops); 206 &cr_lcd_ops);
207 207
208 if (IS_ERR(crp->cr_lcd_device)) { 208 if (IS_ERR(crp->cr_lcd_device)) {
diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
index 648b53c1fdea..6f652c65fae1 100644
--- a/drivers/video/backlight/lcd.c
+++ b/drivers/video/backlight/lcd.c
@@ -61,10 +61,11 @@ static inline void lcd_unregister_fb(struct lcd_device *ld)
61} 61}
62#endif /* CONFIG_FB */ 62#endif /* CONFIG_FB */
63 63
64static ssize_t lcd_show_power(struct class_device *cdev, char *buf) 64static ssize_t lcd_show_power(struct device *dev, struct device_attribute *attr,
65 char *buf)
65{ 66{
66 int rc; 67 int rc;
67 struct lcd_device *ld = to_lcd_device(cdev); 68 struct lcd_device *ld = to_lcd_device(dev);
68 69
69 mutex_lock(&ld->ops_lock); 70 mutex_lock(&ld->ops_lock);
70 if (ld->ops && ld->ops->get_power) 71 if (ld->ops && ld->ops->get_power)
@@ -76,11 +77,12 @@ static ssize_t lcd_show_power(struct class_device *cdev, char *buf)
76 return rc; 77 return rc;
77} 78}
78 79
79static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_t count) 80static ssize_t lcd_store_power(struct device *dev,
81 struct device_attribute *attr, const char *buf, size_t count)
80{ 82{
81 int rc = -ENXIO; 83 int rc = -ENXIO;
82 char *endp; 84 char *endp;
83 struct lcd_device *ld = to_lcd_device(cdev); 85 struct lcd_device *ld = to_lcd_device(dev);
84 int power = simple_strtoul(buf, &endp, 0); 86 int power = simple_strtoul(buf, &endp, 0);
85 size_t size = endp - buf; 87 size_t size = endp - buf;
86 88
@@ -100,10 +102,11 @@ static ssize_t lcd_store_power(struct class_device *cdev, const char *buf, size_
100 return rc; 102 return rc;
101} 103}
102 104
103static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf) 105static ssize_t lcd_show_contrast(struct device *dev,
106 struct device_attribute *attr, char *buf)
104{ 107{
105 int rc = -ENXIO; 108 int rc = -ENXIO;
106 struct lcd_device *ld = to_lcd_device(cdev); 109 struct lcd_device *ld = to_lcd_device(dev);
107 110
108 mutex_lock(&ld->ops_lock); 111 mutex_lock(&ld->ops_lock);
109 if (ld->ops && ld->ops->get_contrast) 112 if (ld->ops && ld->ops->get_contrast)
@@ -113,11 +116,12 @@ static ssize_t lcd_show_contrast(struct class_device *cdev, char *buf)
113 return rc; 116 return rc;
114} 117}
115 118
116static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, size_t count) 119static ssize_t lcd_store_contrast(struct device *dev,
120 struct device_attribute *attr, const char *buf, size_t count)
117{ 121{
118 int rc = -ENXIO; 122 int rc = -ENXIO;
119 char *endp; 123 char *endp;
120 struct lcd_device *ld = to_lcd_device(cdev); 124 struct lcd_device *ld = to_lcd_device(dev);
121 int contrast = simple_strtoul(buf, &endp, 0); 125 int contrast = simple_strtoul(buf, &endp, 0);
122 size_t size = endp - buf; 126 size_t size = endp - buf;
123 127
@@ -137,53 +141,45 @@ static ssize_t lcd_store_contrast(struct class_device *cdev, const char *buf, si
137 return rc; 141 return rc;
138} 142}
139 143
140static ssize_t lcd_show_max_contrast(struct class_device *cdev, char *buf) 144static ssize_t lcd_show_max_contrast(struct device *dev,
145 struct device_attribute *attr, char *buf)
141{ 146{
142 struct lcd_device *ld = to_lcd_device(cdev); 147 struct lcd_device *ld = to_lcd_device(dev);
143 148
144 return sprintf(buf, "%d\n", ld->props.max_contrast); 149 return sprintf(buf, "%d\n", ld->props.max_contrast);
145} 150}
146 151
147static void lcd_class_release(struct class_device *dev) 152struct class *lcd_class;
153
154static void lcd_device_release(struct device *dev)
148{ 155{
149 struct lcd_device *ld = to_lcd_device(dev); 156 struct lcd_device *ld = to_lcd_device(dev);
150 kfree(ld); 157 kfree(ld);
151} 158}
152 159
153static struct class lcd_class = { 160static struct device_attribute lcd_device_attributes[] = {
154 .name = "lcd", 161 __ATTR(lcd_power, 0644, lcd_show_power, lcd_store_power),
155 .release = lcd_class_release, 162 __ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
156}; 163 __ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
157 164 __ATTR_NULL,
158#define DECLARE_ATTR(_name,_mode,_show,_store) \
159{ \
160 .attr = { .name = __stringify(_name), .mode = _mode }, \
161 .show = _show, \
162 .store = _store, \
163}
164
165static const struct class_device_attribute lcd_class_device_attributes[] = {
166 DECLARE_ATTR(power, 0644, lcd_show_power, lcd_store_power),
167 DECLARE_ATTR(contrast, 0644, lcd_show_contrast, lcd_store_contrast),
168 DECLARE_ATTR(max_contrast, 0444, lcd_show_max_contrast, NULL),
169}; 165};
170 166
171/** 167/**
172 * lcd_device_register - register a new object of lcd_device class. 168 * lcd_device_register - register a new object of lcd_device class.
173 * @name: the name of the new object(must be the same as the name of the 169 * @name: the name of the new object(must be the same as the name of the
174 * respective framebuffer device). 170 * respective framebuffer device).
175 * @devdata: an optional pointer to be stored in the class_device. The 171 * @devdata: an optional pointer to be stored in the device. The
176 * methods may retrieve it by using class_get_devdata(ld->class_dev). 172 * methods may retrieve it by using lcd_get_data(ld).
177 * @ops: the lcd operations structure. 173 * @ops: the lcd operations structure.
178 * 174 *
179 * Creates and registers a new lcd class_device. Returns either an ERR_PTR() 175 * Creates and registers a new lcd device. Returns either an ERR_PTR()
180 * or a pointer to the newly allocated device. 176 * or a pointer to the newly allocated device.
181 */ 177 */
182struct lcd_device *lcd_device_register(const char *name, void *devdata, 178struct lcd_device *lcd_device_register(const char *name, struct device *parent,
183 struct lcd_ops *ops) 179 void *devdata, struct lcd_ops *ops)
184{ 180{
185 int i, rc;
186 struct lcd_device *new_ld; 181 struct lcd_device *new_ld;
182 int rc;
187 183
188 pr_debug("lcd_device_register: name=%s\n", name); 184 pr_debug("lcd_device_register: name=%s\n", name);
189 185
@@ -193,12 +189,14 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
193 189
194 mutex_init(&new_ld->ops_lock); 190 mutex_init(&new_ld->ops_lock);
195 mutex_init(&new_ld->update_lock); 191 mutex_init(&new_ld->update_lock);
196 new_ld->ops = ops;
197 new_ld->class_dev.class = &lcd_class;
198 strlcpy(new_ld->class_dev.class_id, name, KOBJ_NAME_LEN);
199 class_set_devdata(&new_ld->class_dev, devdata);
200 192
201 rc = class_device_register(&new_ld->class_dev); 193 new_ld->dev.class = lcd_class;
194 new_ld->dev.parent = parent;
195 new_ld->dev.release = lcd_device_release;
196 strlcpy(new_ld->dev.bus_id, name, BUS_ID_SIZE);
197 dev_set_drvdata(&new_ld->dev, devdata);
198
199 rc = device_register(&new_ld->dev);
202 if (rc) { 200 if (rc) {
203 kfree(new_ld); 201 kfree(new_ld);
204 return ERR_PTR(rc); 202 return ERR_PTR(rc);
@@ -206,22 +204,11 @@ struct lcd_device *lcd_device_register(const char *name, void *devdata,
206 204
207 rc = lcd_register_fb(new_ld); 205 rc = lcd_register_fb(new_ld);
208 if (rc) { 206 if (rc) {
209 class_device_unregister(&new_ld->class_dev); 207 device_unregister(&new_ld->dev);
210 return ERR_PTR(rc); 208 return ERR_PTR(rc);
211 } 209 }
212 210
213 for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++) { 211 new_ld->ops = ops;
214 rc = class_device_create_file(&new_ld->class_dev,
215 &lcd_class_device_attributes[i]);
216 if (rc) {
217 while (--i >= 0)
218 class_device_remove_file(&new_ld->class_dev,
219 &lcd_class_device_attributes[i]);
220 class_device_unregister(&new_ld->class_dev);
221 /* No need to kfree(new_ld) since release() method was called */
222 return ERR_PTR(rc);
223 }
224 }
225 212
226 return new_ld; 213 return new_ld;
227} 214}
@@ -235,33 +222,34 @@ EXPORT_SYMBOL(lcd_device_register);
235 */ 222 */
236void lcd_device_unregister(struct lcd_device *ld) 223void lcd_device_unregister(struct lcd_device *ld)
237{ 224{
238 int i;
239
240 if (!ld) 225 if (!ld)
241 return; 226 return;
242 227
243 pr_debug("lcd_device_unregister: name=%s\n", ld->class_dev.class_id);
244
245 for (i = 0; i < ARRAY_SIZE(lcd_class_device_attributes); i++)
246 class_device_remove_file(&ld->class_dev,
247 &lcd_class_device_attributes[i]);
248
249 mutex_lock(&ld->ops_lock); 228 mutex_lock(&ld->ops_lock);
250 ld->ops = NULL; 229 ld->ops = NULL;
251 mutex_unlock(&ld->ops_lock); 230 mutex_unlock(&ld->ops_lock);
252 lcd_unregister_fb(ld); 231 lcd_unregister_fb(ld);
253 class_device_unregister(&ld->class_dev); 232
233 device_unregister(&ld->dev);
254} 234}
255EXPORT_SYMBOL(lcd_device_unregister); 235EXPORT_SYMBOL(lcd_device_unregister);
256 236
257static void __exit lcd_class_exit(void) 237static void __exit lcd_class_exit(void)
258{ 238{
259 class_unregister(&lcd_class); 239 class_destroy(lcd_class);
260} 240}
261 241
262static int __init lcd_class_init(void) 242static int __init lcd_class_init(void)
263{ 243{
264 return class_register(&lcd_class); 244 lcd_class = class_create(THIS_MODULE, "lcd");
245 if (IS_ERR(lcd_class)) {
246 printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n",
247 PTR_ERR(lcd_class));
248 return PTR_ERR(lcd_class);
249 }
250
251 lcd_class->dev_attrs = lcd_device_attributes;
252 return 0;
265} 253}
266 254
267/* 255/*
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c
index f46fe95f69fb..d18b73aafa0d 100644
--- a/drivers/video/console/vgacon.c
+++ b/drivers/video/console/vgacon.c
@@ -187,7 +187,11 @@ static void vgacon_scrollback_init(int pitch)
187 } 187 }
188} 188}
189 189
190static void vgacon_scrollback_startup(void) 190/*
191 * Called only duing init so call of alloc_bootmen is ok.
192 * Marked __init_refok to silence modpost.
193 */
194static void __init_refok vgacon_scrollback_startup(void)
191{ 195{
192 vgacon_scrollback = alloc_bootmem(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE 196 vgacon_scrollback = alloc_bootmem(CONFIG_VGACON_SOFT_SCROLLBACK_SIZE
193 * 1024); 197 * 1024);
diff --git a/drivers/video/nvidia/nv_backlight.c b/drivers/video/nvidia/nv_backlight.c
index 43f62d8ee41d..443e3c85a9a0 100644
--- a/drivers/video/nvidia/nv_backlight.c
+++ b/drivers/video/nvidia/nv_backlight.c
@@ -50,7 +50,7 @@ static int nvidia_bl_get_level_brightness(struct nvidia_par *par,
50 50
51static int nvidia_bl_update_status(struct backlight_device *bd) 51static int nvidia_bl_update_status(struct backlight_device *bd)
52{ 52{
53 struct nvidia_par *par = class_get_devdata(&bd->class_dev); 53 struct nvidia_par *par = bl_get_data(bd);
54 u32 tmp_pcrt, tmp_pmc, fpcontrol; 54 u32 tmp_pcrt, tmp_pmc, fpcontrol;
55 int level; 55 int level;
56 56
diff --git a/drivers/video/ps3fb.c b/drivers/video/ps3fb.c
index 3972aa8cf859..646ec823c168 100644
--- a/drivers/video/ps3fb.c
+++ b/drivers/video/ps3fb.c
@@ -1067,7 +1067,7 @@ static int __devinit ps3fb_probe(struct ps3_system_bus_device *dev)
1067 info->fix.smem_len = ps3fb_videomemory.size - offset; 1067 info->fix.smem_len = ps3fb_videomemory.size - offset;
1068 info->pseudo_palette = info->par; 1068 info->pseudo_palette = info->par;
1069 info->par = NULL; 1069 info->par = NULL;
1070 info->flags = FBINFO_FLAG_DEFAULT; 1070 info->flags = FBINFO_DEFAULT | FBINFO_READS_FAST;
1071 1071
1072 retval = fb_alloc_cmap(&info->cmap, 256, 0); 1072 retval = fb_alloc_cmap(&info->cmap, 256, 0);
1073 if (retval < 0) 1073 if (retval < 0)
diff --git a/drivers/video/riva/fbdev.c b/drivers/video/riva/fbdev.c
index 0fe547842c64..5c47968e7f21 100644
--- a/drivers/video/riva/fbdev.c
+++ b/drivers/video/riva/fbdev.c
@@ -307,7 +307,7 @@ static int riva_bl_get_level_brightness(struct riva_par *par,
307 307
308static int riva_bl_update_status(struct backlight_device *bd) 308static int riva_bl_update_status(struct backlight_device *bd)
309{ 309{
310 struct riva_par *par = class_get_devdata(&bd->class_dev); 310 struct riva_par *par = bl_get_data(bd);
311 U032 tmp_pcrt, tmp_pmc; 311 U032 tmp_pcrt, tmp_pmc;
312 int level; 312 int level;
313 313
@@ -2146,7 +2146,7 @@ static void __devexit rivafb_remove(struct pci_dev *pd)
2146 * ------------------------------------------------------------------------- */ 2146 * ------------------------------------------------------------------------- */
2147 2147
2148#ifndef MODULE 2148#ifndef MODULE
2149static int __init rivafb_setup(char *options) 2149static int __devinit rivafb_setup(char *options)
2150{ 2150{
2151 char *this_opt; 2151 char *this_opt;
2152 2152
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index ba24cb2ff6ce..4482a0673b15 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -45,7 +45,7 @@
45 45
46static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs); 46static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs);
47static int load_elf_library(struct file *); 47static int load_elf_library(struct file *);
48static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int, unsigned long); 48static unsigned long elf_map (struct file *, unsigned long, struct elf_phdr *, int, int);
49 49
50/* 50/*
51 * If we don't support core dumping, then supply a NULL so we 51 * If we don't support core dumping, then supply a NULL so we
@@ -80,7 +80,7 @@ static struct linux_binfmt elf_format = {
80 .hasvdso = 1 80 .hasvdso = 1
81}; 81};
82 82
83#define BAD_ADDR(x) IS_ERR_VALUE(x) 83#define BAD_ADDR(x) ((unsigned long)(x) >= TASK_SIZE)
84 84
85static int set_brk(unsigned long start, unsigned long end) 85static int set_brk(unsigned long start, unsigned long end)
86{ 86{
@@ -295,70 +295,33 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
295#ifndef elf_map 295#ifndef elf_map
296 296
297static unsigned long elf_map(struct file *filep, unsigned long addr, 297static unsigned long elf_map(struct file *filep, unsigned long addr,
298 struct elf_phdr *eppnt, int prot, int type, 298 struct elf_phdr *eppnt, int prot, int type)
299 unsigned long total_size)
300{ 299{
301 unsigned long map_addr; 300 unsigned long map_addr;
302 unsigned long size = eppnt->p_filesz + ELF_PAGEOFFSET(eppnt->p_vaddr); 301 unsigned long pageoffset = ELF_PAGEOFFSET(eppnt->p_vaddr);
303 unsigned long off = eppnt->p_offset - ELF_PAGEOFFSET(eppnt->p_vaddr);
304 addr = ELF_PAGESTART(addr);
305 size = ELF_PAGEALIGN(size);
306 302
303 down_write(&current->mm->mmap_sem);
307 /* mmap() will return -EINVAL if given a zero size, but a 304 /* mmap() will return -EINVAL if given a zero size, but a
308 * segment with zero filesize is perfectly valid */ 305 * segment with zero filesize is perfectly valid */
309 if (!size) 306 if (eppnt->p_filesz + pageoffset)
310 return addr; 307 map_addr = do_mmap(filep, ELF_PAGESTART(addr),
311 308 eppnt->p_filesz + pageoffset, prot, type,
312 down_write(&current->mm->mmap_sem); 309 eppnt->p_offset - pageoffset);
313 /* 310 else
314 * total_size is the size of the ELF (interpreter) image. 311 map_addr = ELF_PAGESTART(addr);
315 * The _first_ mmap needs to know the full size, otherwise
316 * randomization might put this image into an overlapping
317 * position with the ELF binary image. (since size < total_size)
318 * So we first map the 'big' image - and unmap the remainder at
319 * the end. (which unmap is needed for ELF images with holes.)
320 */
321 if (total_size) {
322 total_size = ELF_PAGEALIGN(total_size);
323 map_addr = do_mmap(filep, addr, total_size, prot, type, off);
324 if (!BAD_ADDR(map_addr))
325 do_munmap(current->mm, map_addr+size, total_size-size);
326 } else
327 map_addr = do_mmap(filep, addr, size, prot, type, off);
328
329 up_write(&current->mm->mmap_sem); 312 up_write(&current->mm->mmap_sem);
330 return(map_addr); 313 return(map_addr);
331} 314}
332 315
333#endif /* !elf_map */ 316#endif /* !elf_map */
334 317
335static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
336{
337 int i, first_idx = -1, last_idx = -1;
338
339 for (i = 0; i < nr; i++) {
340 if (cmds[i].p_type == PT_LOAD) {
341 last_idx = i;
342 if (first_idx == -1)
343 first_idx = i;
344 }
345 }
346 if (first_idx == -1)
347 return 0;
348
349 return cmds[last_idx].p_vaddr + cmds[last_idx].p_memsz -
350 ELF_PAGESTART(cmds[first_idx].p_vaddr);
351}
352
353
354/* This is much more generalized than the library routine read function, 318/* This is much more generalized than the library routine read function,
355 so we keep this separate. Technically the library read function 319 so we keep this separate. Technically the library read function
356 is only provided so that we can read a.out libraries that have 320 is only provided so that we can read a.out libraries that have
357 an ELF header */ 321 an ELF header */
358 322
359static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex, 323static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
360 struct file *interpreter, unsigned long *interp_map_addr, 324 struct file *interpreter, unsigned long *interp_load_addr)
361 unsigned long no_base)
362{ 325{
363 struct elf_phdr *elf_phdata; 326 struct elf_phdr *elf_phdata;
364 struct elf_phdr *eppnt; 327 struct elf_phdr *eppnt;
@@ -366,7 +329,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
366 int load_addr_set = 0; 329 int load_addr_set = 0;
367 unsigned long last_bss = 0, elf_bss = 0; 330 unsigned long last_bss = 0, elf_bss = 0;
368 unsigned long error = ~0UL; 331 unsigned long error = ~0UL;
369 unsigned long total_size;
370 int retval, i, size; 332 int retval, i, size;
371 333
372 /* First of all, some simple consistency checks */ 334 /* First of all, some simple consistency checks */
@@ -405,12 +367,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
405 goto out_close; 367 goto out_close;
406 } 368 }
407 369
408 total_size = total_mapping_size(elf_phdata, interp_elf_ex->e_phnum);
409 if (!total_size) {
410 error = -EINVAL;
411 goto out_close;
412 }
413
414 eppnt = elf_phdata; 370 eppnt = elf_phdata;
415 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) { 371 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
416 if (eppnt->p_type == PT_LOAD) { 372 if (eppnt->p_type == PT_LOAD) {
@@ -428,14 +384,9 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
428 vaddr = eppnt->p_vaddr; 384 vaddr = eppnt->p_vaddr;
429 if (interp_elf_ex->e_type == ET_EXEC || load_addr_set) 385 if (interp_elf_ex->e_type == ET_EXEC || load_addr_set)
430 elf_type |= MAP_FIXED; 386 elf_type |= MAP_FIXED;
431 else if (no_base && interp_elf_ex->e_type == ET_DYN)
432 load_addr = -vaddr;
433 387
434 map_addr = elf_map(interpreter, load_addr + vaddr, 388 map_addr = elf_map(interpreter, load_addr + vaddr,
435 eppnt, elf_prot, elf_type, total_size); 389 eppnt, elf_prot, elf_type);
436 total_size = 0;
437 if (!*interp_map_addr)
438 *interp_map_addr = map_addr;
439 error = map_addr; 390 error = map_addr;
440 if (BAD_ADDR(map_addr)) 391 if (BAD_ADDR(map_addr))
441 goto out_close; 392 goto out_close;
@@ -501,7 +452,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
501 goto out_close; 452 goto out_close;
502 } 453 }
503 454
504 error = load_addr; 455 *interp_load_addr = load_addr;
456 error = ((unsigned long)interp_elf_ex->e_entry) + load_addr;
505 457
506out_close: 458out_close:
507 kfree(elf_phdata); 459 kfree(elf_phdata);
@@ -598,8 +550,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
598 int elf_exec_fileno; 550 int elf_exec_fileno;
599 int retval, i; 551 int retval, i;
600 unsigned int size; 552 unsigned int size;
601 unsigned long elf_entry; 553 unsigned long elf_entry, interp_load_addr = 0;
602 unsigned long interp_load_addr = 0;
603 unsigned long start_code, end_code, start_data, end_data; 554 unsigned long start_code, end_code, start_data, end_data;
604 unsigned long reloc_func_desc = 0; 555 unsigned long reloc_func_desc = 0;
605 char passed_fileno[6]; 556 char passed_fileno[6];
@@ -863,7 +814,9 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
863 current->mm->start_stack = bprm->p; 814 current->mm->start_stack = bprm->p;
864 815
865 /* Now we do a little grungy work by mmaping the ELF image into 816 /* Now we do a little grungy work by mmaping the ELF image into
866 the correct location in memory. */ 817 the correct location in memory. At this point, we assume that
818 the image should be loaded at fixed address, not at a variable
819 address. */
867 for(i = 0, elf_ppnt = elf_phdata; 820 for(i = 0, elf_ppnt = elf_phdata;
868 i < loc->elf_ex.e_phnum; i++, elf_ppnt++) { 821 i < loc->elf_ex.e_phnum; i++, elf_ppnt++) {
869 int elf_prot = 0, elf_flags; 822 int elf_prot = 0, elf_flags;
@@ -917,15 +870,11 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
917 * default mmap base, as well as whatever program they 870 * default mmap base, as well as whatever program they
918 * might try to exec. This is because the brk will 871 * might try to exec. This is because the brk will
919 * follow the loader, and is not movable. */ 872 * follow the loader, and is not movable. */
920#ifdef CONFIG_X86
921 load_bias = 0;
922#else
923 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr); 873 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
924#endif
925 } 874 }
926 875
927 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt, 876 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
928 elf_prot, elf_flags,0); 877 elf_prot, elf_flags);
929 if (BAD_ADDR(error)) { 878 if (BAD_ADDR(error)) {
930 send_sig(SIGKILL, current, 0); 879 send_sig(SIGKILL, current, 0);
931 retval = IS_ERR((void *)error) ? 880 retval = IS_ERR((void *)error) ?
@@ -1001,25 +950,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs)
1001 } 950 }
1002 951
1003 if (elf_interpreter) { 952 if (elf_interpreter) {
1004 if (interpreter_type == INTERPRETER_AOUT) { 953 if (interpreter_type == INTERPRETER_AOUT)
1005 elf_entry = load_aout_interp(&loc->interp_ex, 954 elf_entry = load_aout_interp(&loc->interp_ex,
1006 interpreter); 955 interpreter);
1007 } else { 956 else
1008 unsigned long uninitialized_var(interp_map_addr);
1009
1010 elf_entry = load_elf_interp(&loc->interp_elf_ex, 957 elf_entry = load_elf_interp(&loc->interp_elf_ex,
1011 interpreter, 958 interpreter,
1012 &interp_map_addr, 959 &interp_load_addr);
1013 load_bias);
1014 if (!BAD_ADDR(elf_entry)) {
1015 /*
1016 * load_elf_interp() returns relocation
1017 * adjustment
1018 */
1019 interp_load_addr = elf_entry;
1020 elf_entry += loc->interp_elf_ex.e_entry;
1021 }
1022 }
1023 if (BAD_ADDR(elf_entry)) { 960 if (BAD_ADDR(elf_entry)) {
1024 force_sig(SIGSEGV, current); 961 force_sig(SIGSEGV, current);
1025 retval = IS_ERR((void *)elf_entry) ? 962 retval = IS_ERR((void *)elf_entry) ?
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 8e61236abf4a..f89ff083079b 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -86,7 +86,6 @@ const struct file_operations coda_dir_operations = {
86 .read = generic_read_dir, 86 .read = generic_read_dir,
87 .readdir = coda_readdir, 87 .readdir = coda_readdir,
88 .open = coda_open, 88 .open = coda_open,
89 .flush = coda_flush,
90 .release = coda_release, 89 .release = coda_release,
91 .fsync = coda_fsync, 90 .fsync = coda_fsync,
92}; 91};
diff --git a/fs/coda/file.c b/fs/coda/file.c
index 7594962604c2..29137ff3ca67 100644
--- a/fs/coda/file.c
+++ b/fs/coda/file.c
@@ -25,10 +25,6 @@
25 25
26#include "coda_int.h" 26#include "coda_int.h"
27 27
28/* if CODA_STORE fails with EOPNOTSUPP, venus clearly doesn't support
29 * CODA_STORE/CODA_RELEASE and we fall back on using the CODA_CLOSE upcall */
30static int use_coda_close;
31
32static ssize_t 28static ssize_t
33coda_file_read(struct file *coda_file, char __user *buf, size_t count, loff_t *ppos) 29coda_file_read(struct file *coda_file, char __user *buf, size_t count, loff_t *ppos)
34{ 30{
@@ -163,47 +159,6 @@ int coda_open(struct inode *coda_inode, struct file *coda_file)
163 return 0; 159 return 0;
164} 160}
165 161
166int coda_flush(struct file *coda_file, fl_owner_t id)
167{
168 unsigned short flags = coda_file->f_flags & ~O_EXCL;
169 unsigned short coda_flags = coda_flags_to_cflags(flags);
170 struct coda_file_info *cfi;
171 struct inode *coda_inode;
172 int err = 0, fcnt;
173
174 lock_kernel();
175
176 /* last close semantics */
177 fcnt = file_count(coda_file);
178 if (fcnt > 1)
179 goto out;
180
181 /* No need to make an upcall when we have not made any modifications
182 * to the file */
183 if ((coda_file->f_flags & O_ACCMODE) == O_RDONLY)
184 goto out;
185
186 if (use_coda_close)
187 goto out;
188
189 cfi = CODA_FTOC(coda_file);
190 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
191
192 coda_inode = coda_file->f_path.dentry->d_inode;
193
194 err = venus_store(coda_inode->i_sb, coda_i2f(coda_inode), coda_flags,
195 coda_file->f_uid);
196
197 if (err == -EOPNOTSUPP) {
198 use_coda_close = 1;
199 err = 0;
200 }
201
202out:
203 unlock_kernel();
204 return err;
205}
206
207int coda_release(struct inode *coda_inode, struct file *coda_file) 162int coda_release(struct inode *coda_inode, struct file *coda_file)
208{ 163{
209 unsigned short flags = (coda_file->f_flags) & (~O_EXCL); 164 unsigned short flags = (coda_file->f_flags) & (~O_EXCL);
@@ -215,21 +170,11 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
215 170
216 lock_kernel(); 171 lock_kernel();
217 172
218 if (!use_coda_close) {
219 err = venus_release(coda_inode->i_sb, coda_i2f(coda_inode),
220 coda_flags);
221 if (err == -EOPNOTSUPP) {
222 use_coda_close = 1;
223 err = 0;
224 }
225 }
226
227 cfi = CODA_FTOC(coda_file); 173 cfi = CODA_FTOC(coda_file);
228 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC); 174 BUG_ON(!cfi || cfi->cfi_magic != CODA_MAGIC);
229 175
230 if (use_coda_close) 176 err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode),
231 err = venus_close(coda_inode->i_sb, coda_i2f(coda_inode), 177 coda_flags, coda_file->f_uid);
232 coda_flags, coda_file->f_uid);
233 178
234 host_inode = cfi->cfi_container->f_path.dentry->d_inode; 179 host_inode = cfi->cfi_container->f_path.dentry->d_inode;
235 cii = ITOC(coda_inode); 180 cii = ITOC(coda_inode);
@@ -246,7 +191,10 @@ int coda_release(struct inode *coda_inode, struct file *coda_file)
246 coda_file->private_data = NULL; 191 coda_file->private_data = NULL;
247 192
248 unlock_kernel(); 193 unlock_kernel();
249 return err; 194
195 /* VFS fput ignores the return value from file_operations->release, so
196 * there is no use returning an error here */
197 return 0;
250} 198}
251 199
252int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync) 200int coda_fsync(struct file *coda_file, struct dentry *coda_dentry, int datasync)
@@ -288,7 +236,6 @@ const struct file_operations coda_file_operations = {
288 .write = coda_file_write, 236 .write = coda_file_write,
289 .mmap = coda_file_mmap, 237 .mmap = coda_file_mmap,
290 .open = coda_open, 238 .open = coda_open,
291 .flush = coda_flush,
292 .release = coda_release, 239 .release = coda_release,
293 .fsync = coda_fsync, 240 .fsync = coda_fsync,
294 .splice_read = coda_file_splice_read, 241 .splice_read = coda_file_splice_read,
diff --git a/fs/coda/upcall.c b/fs/coda/upcall.c
index cd561d2e90b0..cdb4c07a7870 100644
--- a/fs/coda/upcall.c
+++ b/fs/coda/upcall.c
@@ -160,55 +160,8 @@ int venus_lookup(struct super_block *sb, struct CodaFid *fid,
160 return error; 160 return error;
161} 161}
162 162
163int venus_store(struct super_block *sb, struct CodaFid *fid, int flags,
164 vuid_t uid)
165{
166 union inputArgs *inp;
167 union outputArgs *outp;
168 int insize, outsize, error;
169#ifdef CONFIG_CODA_FS_OLD_API
170 struct coda_cred cred = { 0, };
171 cred.cr_fsuid = uid;
172#endif
173
174 insize = SIZE(store);
175 UPARG(CODA_STORE);
176
177#ifdef CONFIG_CODA_FS_OLD_API
178 memcpy(&(inp->ih.cred), &cred, sizeof(cred));
179#else
180 inp->ih.uid = uid;
181#endif
182
183 inp->coda_store.VFid = *fid;
184 inp->coda_store.flags = flags;
185
186 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
187
188 CODA_FREE(inp, insize);
189 return error;
190}
191
192int venus_release(struct super_block *sb, struct CodaFid *fid, int flags)
193{
194 union inputArgs *inp;
195 union outputArgs *outp;
196 int insize, outsize, error;
197
198 insize = SIZE(release);
199 UPARG(CODA_RELEASE);
200
201 inp->coda_release.VFid = *fid;
202 inp->coda_release.flags = flags;
203
204 error = coda_upcall(coda_vcp(sb), insize, &outsize, inp);
205
206 CODA_FREE(inp, insize);
207 return error;
208}
209
210int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, 163int venus_close(struct super_block *sb, struct CodaFid *fid, int flags,
211 vuid_t uid) 164 vuid_t uid)
212{ 165{
213 union inputArgs *inp; 166 union inputArgs *inp;
214 union outputArgs *outp; 167 union outputArgs *outp;
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index b34b7a711d5b..b2a851c1b8cb 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -732,7 +732,7 @@ static int nfs_parse_mount_options(char *raw,
732 return 0; 732 return 0;
733 if (option < 0 || option > 65535) 733 if (option < 0 || option > 65535)
734 return 0; 734 return 0;
735 mnt->nfs_server.address.sin_port = htonl(option); 735 mnt->nfs_server.address.sin_port = htons(option);
736 break; 736 break;
737 case Opt_rsize: 737 case Opt_rsize:
738 if (match_int(args, &mnt->rsize)) 738 if (match_int(args, &mnt->rsize))
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 6ab8de40904c..2d295dda4c1d 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1503,9 +1503,9 @@ static void exp_flags(struct seq_file *m, int flag, int fsid,
1503 if (flag & NFSEXP_FSID) 1503 if (flag & NFSEXP_FSID)
1504 seq_printf(m, ",fsid=%d", fsid); 1504 seq_printf(m, ",fsid=%d", fsid);
1505 if (anonu != (uid_t)-2 && anonu != (0x10000-2)) 1505 if (anonu != (uid_t)-2 && anonu != (0x10000-2))
1506 seq_printf(m, ",sanonuid=%d", anonu); 1506 seq_printf(m, ",anonuid=%u", anonu);
1507 if (anong != (gid_t)-2 && anong != (0x10000-2)) 1507 if (anong != (gid_t)-2 && anong != (0x10000-2))
1508 seq_printf(m, ",sanongid=%d", anong); 1508 seq_printf(m, ",anongid=%u", anong);
1509 if (fsloc && fsloc->locations_count > 0) { 1509 if (fsloc && fsloc->locations_count > 0) {
1510 char *loctype = (fsloc->migrated) ? "refer" : "replicas"; 1510 char *loctype = (fsloc->migrated) ? "refer" : "replicas";
1511 int i; 1511 int i;
diff --git a/fs/proc/proc_misc.c b/fs/proc/proc_misc.c
index f133afebed7a..bee251cb87c8 100644
--- a/fs/proc/proc_misc.c
+++ b/fs/proc/proc_misc.c
@@ -507,7 +507,8 @@ static int show_stat(struct seq_file *p, void *v)
507 } 507 }
508 seq_printf(p, "intr %llu", (unsigned long long)sum); 508 seq_printf(p, "intr %llu", (unsigned long long)sum);
509 509
510#if !defined(CONFIG_PPC64) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64) 510#ifndef CONFIG_SMP
511 /* Touches too many cache lines on SMP setups */
511 for (i = 0; i < NR_IRQS; i++) 512 for (i = 0; i < NR_IRQS; i++)
512 seq_printf(p, " %u", per_irq_sum[i]); 513 seq_printf(p, " %u", per_irq_sum[i]);
513#endif 514#endif
diff --git a/fs/udf/balloc.c b/fs/udf/balloc.c
index ef48d094dd2b..276f7207a564 100644
--- a/fs/udf/balloc.c
+++ b/fs/udf/balloc.c
@@ -70,9 +70,9 @@ static inline int find_next_one_bit(void *addr, int size, int offset)
70 if (!size) 70 if (!size)
71 return result; 71 return result;
72 tmp = leBPL_to_cpup(p); 72 tmp = leBPL_to_cpup(p);
73 found_first: 73found_first:
74 tmp &= ~0UL >> (BITS_PER_LONG - size); 74 tmp &= ~0UL >> (BITS_PER_LONG - size);
75 found_middle: 75found_middle:
76 return result + ffz(~tmp); 76 return result + ffz(~tmp);
77} 77}
78 78
@@ -110,11 +110,11 @@ static int __load_block_bitmap(struct super_block *sb,
110 nr_groups); 110 nr_groups);
111 } 111 }
112 112
113 if (bitmap->s_block_bitmap[block_group]) 113 if (bitmap->s_block_bitmap[block_group]) {
114 return block_group; 114 return block_group;
115 else { 115 } else {
116 retval = 116 retval = read_block_bitmap(sb, bitmap, block_group,
117 read_block_bitmap(sb, bitmap, block_group, block_group); 117 block_group);
118 if (retval < 0) 118 if (retval < 0)
119 return retval; 119 return retval;
120 return block_group; 120 return block_group;
@@ -155,22 +155,16 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
155 155
156 mutex_lock(&sbi->s_alloc_mutex); 156 mutex_lock(&sbi->s_alloc_mutex);
157 if (bloc.logicalBlockNum < 0 || 157 if (bloc.logicalBlockNum < 0 ||
158 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, 158 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
159 bloc. 159 udf_debug("%d < %d || %d + %d > %d\n",
160 partitionReferenceNum)) 160 bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
161 { 161 UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
162 udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0,
163 bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb,
164 bloc.
165 partitionReferenceNum));
166 goto error_return; 162 goto error_return;
167 } 163 }
168 164
169 block = 165 block = bloc.logicalBlockNum + offset + (sizeof(struct spaceBitmapDesc) << 3);
170 bloc.logicalBlockNum + offset +
171 (sizeof(struct spaceBitmapDesc) << 3);
172 166
173 do_more: 167do_more:
174 overflow = 0; 168 overflow = 0;
175 block_group = block >> (sb->s_blocksize_bits + 3); 169 block_group = block >> (sb->s_blocksize_bits + 3);
176 bit = block % (sb->s_blocksize << 3); 170 bit = block % (sb->s_blocksize << 3);
@@ -190,18 +184,13 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
190 for (i = 0; i < count; i++) { 184 for (i = 0; i < count; i++) {
191 if (udf_set_bit(bit + i, bh->b_data)) { 185 if (udf_set_bit(bit + i, bh->b_data)) {
192 udf_debug("bit %ld already set\n", bit + i); 186 udf_debug("bit %ld already set\n", bit + i);
193 udf_debug("byte=%2x\n", 187 udf_debug("byte=%2x\n", ((char *)bh->b_data)[(bit + i) >> 3]);
194 ((char *)bh->b_data)[(bit + i) >> 3]);
195 } else { 188 } else {
196 if (inode) 189 if (inode)
197 DQUOT_FREE_BLOCK(inode, 1); 190 DQUOT_FREE_BLOCK(inode, 1);
198 if (UDF_SB_LVIDBH(sb)) { 191 if (UDF_SB_LVIDBH(sb)) {
199 UDF_SB_LVID(sb)-> 192 UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] =
200 freeSpaceTable[UDF_SB_PARTITION(sb)] = 193 cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + 1);
201 cpu_to_le32(le32_to_cpu
202 (UDF_SB_LVID(sb)->
203 freeSpaceTable[UDF_SB_PARTITION
204 (sb)]) + 1);
205 } 194 }
206 } 195 }
207 } 196 }
@@ -211,7 +200,7 @@ static void udf_bitmap_free_blocks(struct super_block *sb,
211 count = overflow; 200 count = overflow;
212 goto do_more; 201 goto do_more;
213 } 202 }
214 error_return: 203error_return:
215 sb->s_dirt = 1; 204 sb->s_dirt = 1;
216 if (UDF_SB_LVIDBH(sb)) 205 if (UDF_SB_LVIDBH(sb))
217 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 206 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
@@ -238,7 +227,7 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
238 if (first_block + block_count > UDF_SB_PARTLEN(sb, partition)) 227 if (first_block + block_count > UDF_SB_PARTLEN(sb, partition))
239 block_count = UDF_SB_PARTLEN(sb, partition) - first_block; 228 block_count = UDF_SB_PARTLEN(sb, partition) - first_block;
240 229
241 repeat: 230repeat:
242 nr_groups = (UDF_SB_PARTLEN(sb, partition) + 231 nr_groups = (UDF_SB_PARTLEN(sb, partition) +
243 (sizeof(struct spaceBitmapDesc) << 3) + 232 (sizeof(struct spaceBitmapDesc) << 3) +
244 (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8); 233 (sb->s_blocksize * 8) - 1) / (sb->s_blocksize * 8);
@@ -254,11 +243,11 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
254 bit = block % (sb->s_blocksize << 3); 243 bit = block % (sb->s_blocksize << 3);
255 244
256 while (bit < (sb->s_blocksize << 3) && block_count > 0) { 245 while (bit < (sb->s_blocksize << 3) && block_count > 0) {
257 if (!udf_test_bit(bit, bh->b_data)) 246 if (!udf_test_bit(bit, bh->b_data)) {
258 goto out; 247 goto out;
259 else if (DQUOT_PREALLOC_BLOCK(inode, 1)) 248 } else if (DQUOT_PREALLOC_BLOCK(inode, 1)) {
260 goto out; 249 goto out;
261 else if (!udf_clear_bit(bit, bh->b_data)) { 250 } else if (!udf_clear_bit(bit, bh->b_data)) {
262 udf_debug("bit already cleared for block %d\n", bit); 251 udf_debug("bit already cleared for block %d\n", bit);
263 DQUOT_FREE_BLOCK(inode, 1); 252 DQUOT_FREE_BLOCK(inode, 1);
264 goto out; 253 goto out;
@@ -271,12 +260,10 @@ static int udf_bitmap_prealloc_blocks(struct super_block *sb,
271 mark_buffer_dirty(bh); 260 mark_buffer_dirty(bh);
272 if (block_count > 0) 261 if (block_count > 0)
273 goto repeat; 262 goto repeat;
274 out: 263out:
275 if (UDF_SB_LVIDBH(sb)) { 264 if (UDF_SB_LVIDBH(sb)) {
276 UDF_SB_LVID(sb)->freeSpaceTable[partition] = 265 UDF_SB_LVID(sb)->freeSpaceTable[partition] =
277 cpu_to_le32(le32_to_cpu 266 cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
278 (UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
279 alloc_count);
280 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 267 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
281 } 268 }
282 sb->s_dirt = 1; 269 sb->s_dirt = 1;
@@ -299,7 +286,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
299 *err = -ENOSPC; 286 *err = -ENOSPC;
300 mutex_lock(&sbi->s_alloc_mutex); 287 mutex_lock(&sbi->s_alloc_mutex);
301 288
302 repeat: 289repeat:
303 if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition)) 290 if (goal < 0 || goal >= UDF_SB_PARTLEN(sb, partition))
304 goal = 0; 291 goal = 0;
305 292
@@ -312,31 +299,27 @@ static int udf_bitmap_new_block(struct super_block *sb,
312 if (bitmap_nr < 0) 299 if (bitmap_nr < 0)
313 goto error_return; 300 goto error_return;
314 bh = bitmap->s_block_bitmap[bitmap_nr]; 301 bh = bitmap->s_block_bitmap[bitmap_nr];
315 ptr = 302 ptr = memscan((char *)bh->b_data + group_start, 0xFF,
316 memscan((char *)bh->b_data + group_start, 0xFF, 303 sb->s_blocksize - group_start);
317 sb->s_blocksize - group_start);
318 304
319 if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) { 305 if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
320 bit = block % (sb->s_blocksize << 3); 306 bit = block % (sb->s_blocksize << 3);
321 307 if (udf_test_bit(bit, bh->b_data))
322 if (udf_test_bit(bit, bh->b_data)) {
323 goto got_block; 308 goto got_block;
324 } 309
325 end_goal = (bit + 63) & ~63; 310 end_goal = (bit + 63) & ~63;
326 bit = udf_find_next_one_bit(bh->b_data, end_goal, bit); 311 bit = udf_find_next_one_bit(bh->b_data, end_goal, bit);
327 if (bit < end_goal) 312 if (bit < end_goal)
328 goto got_block; 313 goto got_block;
329 ptr = 314
330 memscan((char *)bh->b_data + (bit >> 3), 0xFF, 315 ptr = memscan((char *)bh->b_data + (bit >> 3), 0xFF, sb->s_blocksize - ((bit + 7) >> 3));
331 sb->s_blocksize - ((bit + 7) >> 3));
332 newbit = (ptr - ((char *)bh->b_data)) << 3; 316 newbit = (ptr - ((char *)bh->b_data)) << 3;
333 if (newbit < sb->s_blocksize << 3) { 317 if (newbit < sb->s_blocksize << 3) {
334 bit = newbit; 318 bit = newbit;
335 goto search_back; 319 goto search_back;
336 } 320 }
337 newbit = 321
338 udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, 322 newbit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, bit);
339 bit);
340 if (newbit < sb->s_blocksize << 3) { 323 if (newbit < sb->s_blocksize << 3) {
341 bit = newbit; 324 bit = newbit;
342 goto got_block; 325 goto got_block;
@@ -354,18 +337,16 @@ static int udf_bitmap_new_block(struct super_block *sb,
354 goto error_return; 337 goto error_return;
355 bh = bitmap->s_block_bitmap[bitmap_nr]; 338 bh = bitmap->s_block_bitmap[bitmap_nr];
356 if (i < nr_groups) { 339 if (i < nr_groups) {
357 ptr = 340 ptr = memscan((char *)bh->b_data + group_start, 0xFF,
358 memscan((char *)bh->b_data + group_start, 0xFF, 341 sb->s_blocksize - group_start);
359 sb->s_blocksize - group_start);
360 if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) { 342 if ((ptr - ((char *)bh->b_data)) < sb->s_blocksize) {
361 bit = (ptr - ((char *)bh->b_data)) << 3; 343 bit = (ptr - ((char *)bh->b_data)) << 3;
362 break; 344 break;
363 } 345 }
364 } else { 346 } else {
365 bit = 347 bit = udf_find_next_one_bit((char *)bh->b_data,
366 udf_find_next_one_bit((char *)bh->b_data, 348 sb->s_blocksize << 3,
367 sb->s_blocksize << 3, 349 group_start << 3);
368 group_start << 3);
369 if (bit < sb->s_blocksize << 3) 350 if (bit < sb->s_blocksize << 3)
370 break; 351 break;
371 } 352 }
@@ -377,20 +358,17 @@ static int udf_bitmap_new_block(struct super_block *sb,
377 if (bit < sb->s_blocksize << 3) 358 if (bit < sb->s_blocksize << 3)
378 goto search_back; 359 goto search_back;
379 else 360 else
380 bit = 361 bit = udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3, group_start << 3);
381 udf_find_next_one_bit(bh->b_data, sb->s_blocksize << 3,
382 group_start << 3);
383 if (bit >= sb->s_blocksize << 3) { 362 if (bit >= sb->s_blocksize << 3) {
384 mutex_unlock(&sbi->s_alloc_mutex); 363 mutex_unlock(&sbi->s_alloc_mutex);
385 return 0; 364 return 0;
386 } 365 }
387 366
388 search_back: 367search_back:
389 for (i = 0; 368 for (i = 0; i < 7 && bit > (group_start << 3) && udf_test_bit(bit - 1, bh->b_data); i++, bit--)
390 i < 7 && bit > (group_start << 3) 369 ; /* empty loop */
391 && udf_test_bit(bit - 1, bh->b_data); i++, bit--) ;
392 370
393 got_block: 371got_block:
394 372
395 /* 373 /*
396 * Check quota for allocation of this block. 374 * Check quota for allocation of this block.
@@ -402,7 +380,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
402 } 380 }
403 381
404 newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) - 382 newblock = bit + (block_group << (sb->s_blocksize_bits + 3)) -
405 (sizeof(struct spaceBitmapDesc) << 3); 383 (sizeof(struct spaceBitmapDesc) << 3);
406 384
407 if (!udf_clear_bit(bit, bh->b_data)) { 385 if (!udf_clear_bit(bit, bh->b_data)) {
408 udf_debug("bit already cleared for block %d\n", bit); 386 udf_debug("bit already cleared for block %d\n", bit);
@@ -413,9 +391,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
413 391
414 if (UDF_SB_LVIDBH(sb)) { 392 if (UDF_SB_LVIDBH(sb)) {
415 UDF_SB_LVID(sb)->freeSpaceTable[partition] = 393 UDF_SB_LVID(sb)->freeSpaceTable[partition] =
416 cpu_to_le32(le32_to_cpu 394 cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
417 (UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
418 1);
419 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 395 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
420 } 396 }
421 sb->s_dirt = 1; 397 sb->s_dirt = 1;
@@ -423,7 +399,7 @@ static int udf_bitmap_new_block(struct super_block *sb,
423 *err = 0; 399 *err = 0;
424 return newblock; 400 return newblock;
425 401
426 error_return: 402error_return:
427 *err = -EIO; 403 *err = -EIO;
428 mutex_unlock(&sbi->s_alloc_mutex); 404 mutex_unlock(&sbi->s_alloc_mutex);
429 return 0; 405 return 0;
@@ -445,14 +421,10 @@ static void udf_table_free_blocks(struct super_block *sb,
445 421
446 mutex_lock(&sbi->s_alloc_mutex); 422 mutex_lock(&sbi->s_alloc_mutex);
447 if (bloc.logicalBlockNum < 0 || 423 if (bloc.logicalBlockNum < 0 ||
448 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, 424 (bloc.logicalBlockNum + count) > UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum)) {
449 bloc. 425 udf_debug("%d < %d || %d + %d > %d\n",
450 partitionReferenceNum)) 426 bloc.logicalBlockNum, 0, bloc.logicalBlockNum, count,
451 { 427 UDF_SB_PARTLEN(sb, bloc.partitionReferenceNum));
452 udf_debug("%d < %d || %d + %d > %d\n", bloc.logicalBlockNum, 0,
453 bloc.logicalBlockNum, count, UDF_SB_PARTLEN(sb,
454 bloc.
455 partitionReferenceNum));
456 goto error_return; 428 goto error_return;
457 } 429 }
458 430
@@ -462,9 +434,7 @@ static void udf_table_free_blocks(struct super_block *sb,
462 DQUOT_FREE_BLOCK(inode, count); 434 DQUOT_FREE_BLOCK(inode, count);
463 if (UDF_SB_LVIDBH(sb)) { 435 if (UDF_SB_LVIDBH(sb)) {
464 UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] = 436 UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)] =
465 cpu_to_le32(le32_to_cpu 437 cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]) + count);
466 (UDF_SB_LVID(sb)->
467 freeSpaceTable[UDF_SB_PARTITION(sb)]) + count);
468 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 438 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
469 } 439 }
470 440
@@ -476,47 +446,28 @@ static void udf_table_free_blocks(struct super_block *sb,
476 epos.block = oepos.block = UDF_I_LOCATION(table); 446 epos.block = oepos.block = UDF_I_LOCATION(table);
477 epos.bh = oepos.bh = NULL; 447 epos.bh = oepos.bh = NULL;
478 448
479 while (count && (etype = 449 while (count &&
480 udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { 450 (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
481 if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == 451 if (((eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits)) == start)) {
482 start)) { 452 if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) {
483 if ((0x3FFFFFFF - elen) < 453 count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
484 (count << sb->s_blocksize_bits)) { 454 start += ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
485 count -= 455 elen = (etype << 30) | (0x40000000 - sb->s_blocksize);
486 ((0x3FFFFFFF -
487 elen) >> sb->s_blocksize_bits);
488 start +=
489 ((0x3FFFFFFF -
490 elen) >> sb->s_blocksize_bits);
491 elen =
492 (etype << 30) | (0x40000000 -
493 sb->s_blocksize);
494 } else { 456 } else {
495 elen = (etype << 30) | 457 elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits));
496 (elen + (count << sb->s_blocksize_bits));
497 start += count; 458 start += count;
498 count = 0; 459 count = 0;
499 } 460 }
500 udf_write_aext(table, &oepos, eloc, elen, 1); 461 udf_write_aext(table, &oepos, eloc, elen, 1);
501 } else if (eloc.logicalBlockNum == (end + 1)) { 462 } else if (eloc.logicalBlockNum == (end + 1)) {
502 if ((0x3FFFFFFF - elen) < 463 if ((0x3FFFFFFF - elen) < (count << sb->s_blocksize_bits)) {
503 (count << sb->s_blocksize_bits)) { 464 count -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
504 count -= 465 end -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
505 ((0x3FFFFFFF - 466 eloc.logicalBlockNum -= ((0x3FFFFFFF - elen) >> sb->s_blocksize_bits);
506 elen) >> sb->s_blocksize_bits); 467 elen = (etype << 30) | (0x40000000 - sb->s_blocksize);
507 end -=
508 ((0x3FFFFFFF -
509 elen) >> sb->s_blocksize_bits);
510 eloc.logicalBlockNum -=
511 ((0x3FFFFFFF -
512 elen) >> sb->s_blocksize_bits);
513 elen =
514 (etype << 30) | (0x40000000 -
515 sb->s_blocksize);
516 } else { 468 } else {
517 eloc.logicalBlockNum = start; 469 eloc.logicalBlockNum = start;
518 elen = (etype << 30) | 470 elen = (etype << 30) | (elen + (count << sb->s_blocksize_bits));
519 (elen + (count << sb->s_blocksize_bits));
520 end -= count; 471 end -= count;
521 count = 0; 472 count = 0;
522 } 473 }
@@ -530,21 +481,23 @@ static void udf_table_free_blocks(struct super_block *sb,
530 get_bh(epos.bh); 481 get_bh(epos.bh);
531 oepos.bh = epos.bh; 482 oepos.bh = epos.bh;
532 oepos.offset = 0; 483 oepos.offset = 0;
533 } else 484 } else {
534 oepos.offset = epos.offset; 485 oepos.offset = epos.offset;
486 }
535 } 487 }
536 488
537 if (count) { 489 if (count) {
538 /* NOTE: we CANNOT use udf_add_aext here, as it can try to allocate 490 /*
539 a new block, and since we hold the super block lock already 491 * NOTE: we CANNOT use udf_add_aext here, as it can try to allocate
540 very bad things would happen :) 492 * a new block, and since we hold the super block lock already
541 493 * very bad things would happen :)
542 We copy the behavior of udf_add_aext, but instead of 494 *
543 trying to allocate a new block close to the existing one, 495 * We copy the behavior of udf_add_aext, but instead of
544 we just steal a block from the extent we are trying to add. 496 * trying to allocate a new block close to the existing one,
545 497 * we just steal a block from the extent we are trying to add.
546 It would be nice if the blocks were close together, but it 498 *
547 isn't required. 499 * It would be nice if the blocks were close together, but it
500 * isn't required.
548 */ 501 */
549 502
550 int adsize; 503 int adsize;
@@ -553,13 +506,14 @@ static void udf_table_free_blocks(struct super_block *sb,
553 struct allocExtDesc *aed; 506 struct allocExtDesc *aed;
554 507
555 eloc.logicalBlockNum = start; 508 eloc.logicalBlockNum = start;
556 elen = EXT_RECORDED_ALLOCATED | (count << sb->s_blocksize_bits); 509 elen = EXT_RECORDED_ALLOCATED |
510 (count << sb->s_blocksize_bits);
557 511
558 if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) 512 if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_SHORT) {
559 adsize = sizeof(short_ad); 513 adsize = sizeof(short_ad);
560 else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) 514 } else if (UDF_I_ALLOCTYPE(table) == ICBTAG_FLAG_AD_LONG) {
561 adsize = sizeof(long_ad); 515 adsize = sizeof(long_ad);
562 else { 516 } else {
563 brelse(oepos.bh); 517 brelse(oepos.bh);
564 brelse(epos.bh); 518 brelse(epos.bh);
565 goto error_return; 519 goto error_return;
@@ -577,28 +531,21 @@ static void udf_table_free_blocks(struct super_block *sb,
577 eloc.logicalBlockNum++; 531 eloc.logicalBlockNum++;
578 elen -= sb->s_blocksize; 532 elen -= sb->s_blocksize;
579 533
580 if (!(epos.bh = udf_tread(sb, 534 if (!(epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, epos.block, 0)))) {
581 udf_get_lb_pblock(sb,
582 epos.block,
583 0)))) {
584 brelse(oepos.bh); 535 brelse(oepos.bh);
585 goto error_return; 536 goto error_return;
586 } 537 }
587 aed = (struct allocExtDesc *)(epos.bh->b_data); 538 aed = (struct allocExtDesc *)(epos.bh->b_data);
588 aed->previousAllocExtLocation = 539 aed->previousAllocExtLocation = cpu_to_le32(oepos.block.logicalBlockNum);
589 cpu_to_le32(oepos.block.logicalBlockNum);
590 if (epos.offset + adsize > sb->s_blocksize) { 540 if (epos.offset + adsize > sb->s_blocksize) {
591 loffset = epos.offset; 541 loffset = epos.offset;
592 aed->lengthAllocDescs = cpu_to_le32(adsize); 542 aed->lengthAllocDescs = cpu_to_le32(adsize);
593 sptr = UDF_I_DATA(inode) + epos.offset - 543 sptr = UDF_I_DATA(inode) + epos.offset -
594 udf_file_entry_alloc_offset(inode) + 544 udf_file_entry_alloc_offset(inode) +
595 UDF_I_LENEATTR(inode) - adsize; 545 UDF_I_LENEATTR(inode) - adsize;
596 dptr = 546 dptr = epos.bh->b_data + sizeof(struct allocExtDesc);
597 epos.bh->b_data +
598 sizeof(struct allocExtDesc);
599 memcpy(dptr, sptr, adsize); 547 memcpy(dptr, sptr, adsize);
600 epos.offset = 548 epos.offset = sizeof(struct allocExtDesc) + adsize;
601 sizeof(struct allocExtDesc) + adsize;
602 } else { 549 } else {
603 loffset = epos.offset + adsize; 550 loffset = epos.offset + adsize;
604 aed->lengthAllocDescs = cpu_to_le32(0); 551 aed->lengthAllocDescs = cpu_to_le32(0);
@@ -606,60 +553,46 @@ static void udf_table_free_blocks(struct super_block *sb,
606 epos.offset = sizeof(struct allocExtDesc); 553 epos.offset = sizeof(struct allocExtDesc);
607 554
608 if (oepos.bh) { 555 if (oepos.bh) {
609 aed = 556 aed = (struct allocExtDesc *)oepos.bh->b_data;
610 (struct allocExtDesc *)oepos.bh->
611 b_data;
612 aed->lengthAllocDescs = 557 aed->lengthAllocDescs =
613 cpu_to_le32(le32_to_cpu 558 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
614 (aed->
615 lengthAllocDescs) +
616 adsize);
617 } else { 559 } else {
618 UDF_I_LENALLOC(table) += adsize; 560 UDF_I_LENALLOC(table) += adsize;
619 mark_inode_dirty(table); 561 mark_inode_dirty(table);
620 } 562 }
621 } 563 }
622 if (UDF_SB_UDFREV(sb) >= 0x0200) 564 if (UDF_SB_UDFREV(sb) >= 0x0200)
623 udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 565 udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 3, 1,
624 1, epos.block.logicalBlockNum, 566 epos.block.logicalBlockNum, sizeof(tag));
625 sizeof(tag));
626 else 567 else
627 udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, 568 udf_new_tag(epos.bh->b_data, TAG_IDENT_AED, 2, 1,
628 1, epos.block.logicalBlockNum, 569 epos.block.logicalBlockNum, sizeof(tag));
629 sizeof(tag)); 570
630 switch (UDF_I_ALLOCTYPE(table)) { 571 switch (UDF_I_ALLOCTYPE(table)) {
631 case ICBTAG_FLAG_AD_SHORT: 572 case ICBTAG_FLAG_AD_SHORT:
632 { 573 sad = (short_ad *)sptr;
633 sad = (short_ad *) sptr; 574 sad->extLength = cpu_to_le32(
634 sad->extLength = 575 EXT_NEXT_EXTENT_ALLOCDECS |
635 cpu_to_le32 576 sb->s_blocksize);
636 (EXT_NEXT_EXTENT_ALLOCDECS | sb-> 577 sad->extPosition = cpu_to_le32(epos.block.logicalBlockNum);
637 s_blocksize);
638 sad->extPosition =
639 cpu_to_le32(epos.block.
640 logicalBlockNum);
641 break; 578 break;
642 } 579 case ICBTAG_FLAG_AD_LONG:
643 case ICBTAG_FLAG_AD_LONG: 580 lad = (long_ad *)sptr;
644 { 581 lad->extLength = cpu_to_le32(
645 lad = (long_ad *) sptr; 582 EXT_NEXT_EXTENT_ALLOCDECS |
646 lad->extLength = 583 sb->s_blocksize);
647 cpu_to_le32 584 lad->extLocation = cpu_to_lelb(epos.block);
648 (EXT_NEXT_EXTENT_ALLOCDECS | sb->
649 s_blocksize);
650 lad->extLocation =
651 cpu_to_lelb(epos.block);
652 break; 585 break;
653 }
654 } 586 }
655 if (oepos.bh) { 587 if (oepos.bh) {
656 udf_update_tag(oepos.bh->b_data, loffset); 588 udf_update_tag(oepos.bh->b_data, loffset);
657 mark_buffer_dirty(oepos.bh); 589 mark_buffer_dirty(oepos.bh);
658 } else 590 } else {
659 mark_inode_dirty(table); 591 mark_inode_dirty(table);
592 }
660 } 593 }
661 594
662 if (elen) { /* It's possible that stealing the block emptied the extent */ 595 if (elen) { /* It's possible that stealing the block emptied the extent */
663 udf_write_aext(table, &epos, eloc, elen, 1); 596 udf_write_aext(table, &epos, eloc, elen, 1);
664 597
665 if (!epos.bh) { 598 if (!epos.bh) {
@@ -668,9 +601,7 @@ static void udf_table_free_blocks(struct super_block *sb,
668 } else { 601 } else {
669 aed = (struct allocExtDesc *)epos.bh->b_data; 602 aed = (struct allocExtDesc *)epos.bh->b_data;
670 aed->lengthAllocDescs = 603 aed->lengthAllocDescs =
671 cpu_to_le32(le32_to_cpu 604 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
672 (aed->lengthAllocDescs) +
673 adsize);
674 udf_update_tag(epos.bh->b_data, epos.offset); 605 udf_update_tag(epos.bh->b_data, epos.offset);
675 mark_buffer_dirty(epos.bh); 606 mark_buffer_dirty(epos.bh);
676 } 607 }
@@ -680,7 +611,7 @@ static void udf_table_free_blocks(struct super_block *sb,
680 brelse(epos.bh); 611 brelse(epos.bh);
681 brelse(oepos.bh); 612 brelse(oepos.bh);
682 613
683 error_return: 614error_return:
684 sb->s_dirt = 1; 615 sb->s_dirt = 1;
685 mutex_unlock(&sbi->s_alloc_mutex); 616 mutex_unlock(&sbi->s_alloc_mutex);
686 return; 617 return;
@@ -714,47 +645,36 @@ static int udf_table_prealloc_blocks(struct super_block *sb,
714 epos.bh = NULL; 645 epos.bh = NULL;
715 eloc.logicalBlockNum = 0xFFFFFFFF; 646 eloc.logicalBlockNum = 0xFFFFFFFF;
716 647
717 while (first_block != eloc.logicalBlockNum && (etype = 648 while (first_block != eloc.logicalBlockNum &&
718 udf_next_aext(table, 649 (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
719 &epos,
720 &eloc,
721 &elen,
722 1)) !=
723 -1) {
724 udf_debug("eloc=%d, elen=%d, first_block=%d\n", 650 udf_debug("eloc=%d, elen=%d, first_block=%d\n",
725 eloc.logicalBlockNum, elen, first_block); 651 eloc.logicalBlockNum, elen, first_block);
726 ; /* empty loop body */ 652 ; /* empty loop body */
727 } 653 }
728 654
729 if (first_block == eloc.logicalBlockNum) { 655 if (first_block == eloc.logicalBlockNum) {
730 epos.offset -= adsize; 656 epos.offset -= adsize;
731 657
732 alloc_count = (elen >> sb->s_blocksize_bits); 658 alloc_count = (elen >> sb->s_blocksize_bits);
733 if (inode 659 if (inode && DQUOT_PREALLOC_BLOCK(inode, alloc_count > block_count ? block_count : alloc_count)) {
734 && DQUOT_PREALLOC_BLOCK(inode,
735 alloc_count >
736 block_count ? block_count :
737 alloc_count))
738 alloc_count = 0; 660 alloc_count = 0;
739 else if (alloc_count > block_count) { 661 } else if (alloc_count > block_count) {
740 alloc_count = block_count; 662 alloc_count = block_count;
741 eloc.logicalBlockNum += alloc_count; 663 eloc.logicalBlockNum += alloc_count;
742 elen -= (alloc_count << sb->s_blocksize_bits); 664 elen -= (alloc_count << sb->s_blocksize_bits);
743 udf_write_aext(table, &epos, eloc, (etype << 30) | elen, 665 udf_write_aext(table, &epos, eloc, (etype << 30) | elen, 1);
744 1); 666 } else {
745 } else 667 udf_delete_aext(table, epos, eloc, (etype << 30) | elen);
746 udf_delete_aext(table, epos, eloc, 668 }
747 (etype << 30) | elen); 669 } else {
748 } else
749 alloc_count = 0; 670 alloc_count = 0;
671 }
750 672
751 brelse(epos.bh); 673 brelse(epos.bh);
752 674
753 if (alloc_count && UDF_SB_LVIDBH(sb)) { 675 if (alloc_count && UDF_SB_LVIDBH(sb)) {
754 UDF_SB_LVID(sb)->freeSpaceTable[partition] = 676 UDF_SB_LVID(sb)->freeSpaceTable[partition] =
755 cpu_to_le32(le32_to_cpu 677 cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - alloc_count);
756 (UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
757 alloc_count);
758 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 678 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
759 sb->s_dirt = 1; 679 sb->s_dirt = 1;
760 } 680 }
@@ -797,18 +717,17 @@ static int udf_table_new_block(struct super_block *sb,
797 epos.block = UDF_I_LOCATION(table); 717 epos.block = UDF_I_LOCATION(table);
798 epos.bh = goal_epos.bh = NULL; 718 epos.bh = goal_epos.bh = NULL;
799 719
800 while (spread && (etype = 720 while (spread &&
801 udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) { 721 (etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
802 if (goal >= eloc.logicalBlockNum) { 722 if (goal >= eloc.logicalBlockNum) {
803 if (goal < 723 if (goal < eloc.logicalBlockNum + (elen >> sb->s_blocksize_bits))
804 eloc.logicalBlockNum +
805 (elen >> sb->s_blocksize_bits))
806 nspread = 0; 724 nspread = 0;
807 else 725 else
808 nspread = goal - eloc.logicalBlockNum - 726 nspread = goal - eloc.logicalBlockNum -
809 (elen >> sb->s_blocksize_bits); 727 (elen >> sb->s_blocksize_bits);
810 } else 728 } else {
811 nspread = eloc.logicalBlockNum - goal; 729 nspread = eloc.logicalBlockNum - goal;
730 }
812 731
813 if (nspread < spread) { 732 if (nspread < spread) {
814 spread = nspread; 733 spread = nspread;
@@ -856,9 +775,7 @@ static int udf_table_new_block(struct super_block *sb,
856 775
857 if (UDF_SB_LVIDBH(sb)) { 776 if (UDF_SB_LVIDBH(sb)) {
858 UDF_SB_LVID(sb)->freeSpaceTable[partition] = 777 UDF_SB_LVID(sb)->freeSpaceTable[partition] =
859 cpu_to_le32(le32_to_cpu 778 cpu_to_le32(le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[partition]) - 1);
860 (UDF_SB_LVID(sb)->freeSpaceTable[partition]) -
861 1);
862 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 779 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
863 } 780 }
864 781
@@ -877,27 +794,23 @@ inline void udf_free_blocks(struct super_block *sb,
877 794
878 if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { 795 if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
879 return udf_bitmap_free_blocks(sb, inode, 796 return udf_bitmap_free_blocks(sb, inode,
880 UDF_SB_PARTMAPS(sb)[partition]. 797 UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
881 s_uspace.s_bitmap, bloc, offset, 798 bloc, offset, count);
882 count); 799 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
883 } else if (UDF_SB_PARTFLAGS(sb, partition) &
884 UDF_PART_FLAG_UNALLOC_TABLE) {
885 return udf_table_free_blocks(sb, inode, 800 return udf_table_free_blocks(sb, inode,
886 UDF_SB_PARTMAPS(sb)[partition]. 801 UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
887 s_uspace.s_table, bloc, offset, 802 bloc, offset, count);
888 count);
889 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { 803 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
890 return udf_bitmap_free_blocks(sb, inode, 804 return udf_bitmap_free_blocks(sb, inode,
891 UDF_SB_PARTMAPS(sb)[partition]. 805 UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
892 s_fspace.s_bitmap, bloc, offset, 806 bloc, offset, count);
893 count);
894 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { 807 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
895 return udf_table_free_blocks(sb, inode, 808 return udf_table_free_blocks(sb, inode,
896 UDF_SB_PARTMAPS(sb)[partition]. 809 UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
897 s_fspace.s_table, bloc, offset, 810 bloc, offset, count);
898 count); 811 } else {
899 } else
900 return; 812 return;
813 }
901} 814}
902 815
903inline int udf_prealloc_blocks(struct super_block *sb, 816inline int udf_prealloc_blocks(struct super_block *sb,
@@ -907,29 +820,23 @@ inline int udf_prealloc_blocks(struct super_block *sb,
907{ 820{
908 if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { 821 if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
909 return udf_bitmap_prealloc_blocks(sb, inode, 822 return udf_bitmap_prealloc_blocks(sb, inode,
910 UDF_SB_PARTMAPS(sb) 823 UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
911 [partition].s_uspace.s_bitmap, 824 partition, first_block, block_count);
912 partition, first_block, 825 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
913 block_count);
914 } else if (UDF_SB_PARTFLAGS(sb, partition) &
915 UDF_PART_FLAG_UNALLOC_TABLE) {
916 return udf_table_prealloc_blocks(sb, inode, 826 return udf_table_prealloc_blocks(sb, inode,
917 UDF_SB_PARTMAPS(sb)[partition]. 827 UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
918 s_uspace.s_table, partition, 828 partition, first_block, block_count);
919 first_block, block_count);
920 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { 829 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
921 return udf_bitmap_prealloc_blocks(sb, inode, 830 return udf_bitmap_prealloc_blocks(sb, inode,
922 UDF_SB_PARTMAPS(sb) 831 UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
923 [partition].s_fspace.s_bitmap, 832 partition, first_block, block_count);
924 partition, first_block,
925 block_count);
926 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { 833 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
927 return udf_table_prealloc_blocks(sb, inode, 834 return udf_table_prealloc_blocks(sb, inode,
928 UDF_SB_PARTMAPS(sb)[partition]. 835 UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
929 s_fspace.s_table, partition, 836 partition, first_block, block_count);
930 first_block, block_count); 837 } else {
931 } else
932 return 0; 838 return 0;
839 }
933} 840}
934 841
935inline int udf_new_block(struct super_block *sb, 842inline int udf_new_block(struct super_block *sb,
@@ -940,26 +847,21 @@ inline int udf_new_block(struct super_block *sb,
940 847
941 if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) { 848 if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_BITMAP) {
942 ret = udf_bitmap_new_block(sb, inode, 849 ret = udf_bitmap_new_block(sb, inode,
943 UDF_SB_PARTMAPS(sb)[partition]. 850 UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_bitmap,
944 s_uspace.s_bitmap, partition, goal, 851 partition, goal, err);
945 err);
946 return ret; 852 return ret;
947 } else if (UDF_SB_PARTFLAGS(sb, partition) & 853 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_UNALLOC_TABLE) {
948 UDF_PART_FLAG_UNALLOC_TABLE) {
949 return udf_table_new_block(sb, inode, 854 return udf_table_new_block(sb, inode,
950 UDF_SB_PARTMAPS(sb)[partition]. 855 UDF_SB_PARTMAPS(sb)[partition].s_uspace.s_table,
951 s_uspace.s_table, partition, goal, 856 partition, goal, err);
952 err);
953 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) { 857 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_BITMAP) {
954 return udf_bitmap_new_block(sb, inode, 858 return udf_bitmap_new_block(sb, inode,
955 UDF_SB_PARTMAPS(sb)[partition]. 859 UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_bitmap,
956 s_fspace.s_bitmap, partition, goal, 860 partition, goal, err);
957 err);
958 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) { 861 } else if (UDF_SB_PARTFLAGS(sb, partition) & UDF_PART_FLAG_FREED_TABLE) {
959 return udf_table_new_block(sb, inode, 862 return udf_table_new_block(sb, inode,
960 UDF_SB_PARTMAPS(sb)[partition]. 863 UDF_SB_PARTMAPS(sb)[partition].s_fspace.s_table,
961 s_fspace.s_table, partition, goal, 864 partition, goal, err);
962 err);
963 } else { 865 } else {
964 *err = -EIO; 866 *err = -EIO;
965 return 0; 867 return 0;
diff --git a/fs/udf/crc.c b/fs/udf/crc.c
index ae3d49790941..85aaee5fab26 100644
--- a/fs/udf/crc.c
+++ b/fs/udf/crc.c
@@ -111,7 +111,7 @@ int main(void)
111 return 0; 111 return 0;
112} 112}
113 113
114#endif /* defined(TEST) */ 114#endif /* defined(TEST) */
115 115
116/****************************************************************************/ 116/****************************************************************************/
117#if defined(GENERATE) 117#if defined(GENERATE)
@@ -169,4 +169,4 @@ int main(int argc, char **argv)
169 return 0; 169 return 0;
170} 170}
171 171
172#endif /* defined(GENERATE) */ 172#endif /* defined(GENERATE) */
diff --git a/fs/udf/dir.c b/fs/udf/dir.c
index 79bab9fe120c..9e3b9f97ddbc 100644
--- a/fs/udf/dir.c
+++ b/fs/udf/dir.c
@@ -43,10 +43,10 @@ static int do_udf_readdir(struct inode *, struct file *, filldir_t, void *);
43/* readdir and lookup functions */ 43/* readdir and lookup functions */
44 44
45const struct file_operations udf_dir_operations = { 45const struct file_operations udf_dir_operations = {
46 .read = generic_read_dir, 46 .read = generic_read_dir,
47 .readdir = udf_readdir, 47 .readdir = udf_readdir,
48 .ioctl = udf_ioctl, 48 .ioctl = udf_ioctl,
49 .fsync = udf_fsync_file, 49 .fsync = udf_fsync_file,
50}; 50};
51 51
52/* 52/*
@@ -83,8 +83,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
83 lock_kernel(); 83 lock_kernel();
84 84
85 if (filp->f_pos == 0) { 85 if (filp->f_pos == 0) {
86 if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 86 if (filldir(dirent, ".", 1, filp->f_pos, dir->i_ino, DT_DIR) < 0) {
87 0) {
88 unlock_kernel(); 87 unlock_kernel();
89 return 0; 88 return 0;
90 } 89 }
@@ -93,7 +92,7 @@ int udf_readdir(struct file *filp, void *dirent, filldir_t filldir)
93 92
94 result = do_udf_readdir(dir, filp, filldir, dirent); 93 result = do_udf_readdir(dir, filp, filldir, dirent);
95 unlock_kernel(); 94 unlock_kernel();
96 return result; 95 return result;
97} 96}
98 97
99static int 98static int
@@ -125,21 +124,20 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
125 if (nf_pos == 0) 124 if (nf_pos == 0)
126 nf_pos = (udf_ext0_offset(dir) >> 2); 125 nf_pos = (udf_ext0_offset(dir) >> 2);
127 126
128 fibh.soffset = fibh.eoffset = 127 fibh.soffset = fibh.eoffset = (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
129 (nf_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; 128 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
130 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
131 fibh.sbh = fibh.ebh = NULL; 129 fibh.sbh = fibh.ebh = NULL;
132 else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2), 130 } else if (inode_bmap(dir, nf_pos >> (dir->i_sb->s_blocksize_bits - 2),
133 &epos, &eloc, &elen, 131 &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
134 &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
135 block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 132 block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
136 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 133 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
137 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 134 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
138 epos.offset -= sizeof(short_ad); 135 epos.offset -= sizeof(short_ad);
139 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) 136 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
140 epos.offset -= sizeof(long_ad); 137 epos.offset -= sizeof(long_ad);
141 } else 138 } else {
142 offset = 0; 139 offset = 0;
140 }
143 141
144 if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { 142 if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
145 brelse(epos.bh); 143 brelse(epos.bh);
@@ -149,15 +147,11 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
149 if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) { 147 if (!(offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
150 i = 16 >> (dir->i_sb->s_blocksize_bits - 9); 148 i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
151 if (i + offset > (elen >> dir->i_sb->s_blocksize_bits)) 149 if (i + offset > (elen >> dir->i_sb->s_blocksize_bits))
152 i = (elen >> dir->i_sb->s_blocksize_bits) - 150 i = (elen >> dir->i_sb->s_blocksize_bits) - offset;
153 offset;
154 for (num = 0; i > 0; i--) { 151 for (num = 0; i > 0; i--) {
155 block = 152 block = udf_get_lb_pblock(dir->i_sb, eloc, offset + i);
156 udf_get_lb_pblock(dir->i_sb, eloc,
157 offset + i);
158 tmp = udf_tgetblk(dir->i_sb, block); 153 tmp = udf_tgetblk(dir->i_sb, block);
159 if (tmp && !buffer_uptodate(tmp) 154 if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
160 && !buffer_locked(tmp))
161 bha[num++] = tmp; 155 bha[num++] = tmp;
162 else 156 else
163 brelse(tmp); 157 brelse(tmp);
@@ -178,7 +172,6 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
178 172
179 fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc, 173 fi = udf_fileident_read(dir, &nf_pos, &fibh, &cfi, &epos, &eloc,
180 &elen, &offset); 174 &elen, &offset);
181
182 if (!fi) { 175 if (!fi) {
183 if (fibh.sbh != fibh.ebh) 176 if (fibh.sbh != fibh.ebh)
184 brelse(fibh.ebh); 177 brelse(fibh.ebh);
@@ -190,19 +183,16 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
190 liu = le16_to_cpu(cfi.lengthOfImpUse); 183 liu = le16_to_cpu(cfi.lengthOfImpUse);
191 lfi = cfi.lengthFileIdent; 184 lfi = cfi.lengthFileIdent;
192 185
193 if (fibh.sbh == fibh.ebh) 186 if (fibh.sbh == fibh.ebh) {
194 nameptr = fi->fileIdent + liu; 187 nameptr = fi->fileIdent + liu;
195 else { 188 } else {
196 int poffset; /* Unpaded ending offset */ 189 int poffset; /* Unpaded ending offset */
197 190
198 poffset = 191 poffset = fibh.soffset + sizeof(struct fileIdentDesc) + liu + lfi;
199 fibh.soffset + sizeof(struct fileIdentDesc) + liu +
200 lfi;
201 192
202 if (poffset >= lfi) 193 if (poffset >= lfi) {
203 nameptr = 194 nameptr = (char *)(fibh.ebh->b_data + poffset - lfi);
204 (char *)(fibh.ebh->b_data + poffset - lfi); 195 } else {
205 else {
206 nameptr = fname; 196 nameptr = fname;
207 memcpy(nameptr, fi->fileIdent + liu, 197 memcpy(nameptr, fi->fileIdent + liu,
208 lfi - poffset); 198 lfi - poffset);
@@ -235,17 +225,15 @@ do_udf_readdir(struct inode *dir, struct file *filp, filldir_t filldir,
235 } 225 }
236 226
237 if (flen) { 227 if (flen) {
238 if (filldir 228 if (filldir(dirent, fname, flen, filp->f_pos, iblock, dt_type) < 0) {
239 (dirent, fname, flen, filp->f_pos, iblock,
240 dt_type) < 0) {
241 if (fibh.sbh != fibh.ebh) 229 if (fibh.sbh != fibh.ebh)
242 brelse(fibh.ebh); 230 brelse(fibh.ebh);
243 brelse(fibh.sbh); 231 brelse(fibh.sbh);
244 brelse(epos.bh); 232 brelse(epos.bh);
245 return 0; 233 return 0;
246 } 234 }
247 } 235 }
248 } /* end while */ 236 } /* end while */
249 237
250 filp->f_pos = nf_pos + 1; 238 filp->f_pos = nf_pos + 1;
251 239
diff --git a/fs/udf/directory.c b/fs/udf/directory.c
index 8adc77c1d579..ff8c08fd7bf5 100644
--- a/fs/udf/directory.c
+++ b/fs/udf/directory.c
@@ -31,7 +31,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
31 31
32 *error = 0; 32 *error = 0;
33 33
34 ad = (uint8_t *) (*bh)->b_data + *offset; 34 ad = (uint8_t *)(*bh)->b_data + *offset;
35 *offset += ad_size; 35 *offset += ad_size;
36 36
37 if (!ad) { 37 if (!ad) {
@@ -51,7 +51,7 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
51 ad = tmpad; 51 ad = tmpad;
52 52
53 remainder = dir->i_sb->s_blocksize - loffset; 53 remainder = dir->i_sb->s_blocksize - loffset;
54 memcpy((uint8_t *) ad, (*bh)->b_data + loffset, remainder); 54 memcpy((uint8_t *)ad, (*bh)->b_data + loffset, remainder);
55 55
56 brelse(*bh); 56 brelse(*bh);
57 block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos); 57 block = udf_get_lb_pblock(dir->i_sb, fe_loc, ++*pos);
@@ -60,10 +60,10 @@ static uint8_t *udf_filead_read(struct inode *dir, uint8_t * tmpad,
60 if (!((*bh) = udf_tread(dir->i_sb, block))) 60 if (!((*bh) = udf_tread(dir->i_sb, block)))
61 return NULL; 61 return NULL;
62 62
63 memcpy((uint8_t *) ad + remainder, (*bh)->b_data, 63 memcpy((uint8_t *)ad + remainder, (*bh)->b_data, ad_size - remainder);
64 ad_size - remainder);
65 *offset = ad_size - remainder; 64 *offset = ad_size - remainder;
66 } 65 }
66
67 return ad; 67 return ad;
68} 68}
69#endif 69#endif
@@ -86,15 +86,13 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
86 (UDF_I_EFE(dir) ? 86 (UDF_I_EFE(dir) ?
87 sizeof(struct extendedFileEntry) : 87 sizeof(struct extendedFileEntry) :
88 sizeof(struct fileEntry)), 88 sizeof(struct fileEntry)),
89 dir->i_sb->s_blocksize, 89 dir->i_sb->s_blocksize, &(fibh->eoffset));
90 &(fibh->eoffset));
91
92 if (!fi) 90 if (!fi)
93 return NULL; 91 return NULL;
94 92
95 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); 93 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
96 94
97 memcpy((uint8_t *) cfi, (uint8_t *) fi, 95 memcpy((uint8_t *)cfi, (uint8_t *)fi,
98 sizeof(struct fileIdentDesc)); 96 sizeof(struct fileIdentDesc));
99 97
100 return fi; 98 return fi;
@@ -121,21 +119,14 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
121 return NULL; 119 return NULL;
122 fibh->soffset = fibh->eoffset = 0; 120 fibh->soffset = fibh->eoffset = 0;
123 121
124 if (! 122 if (!(*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1))) {
125 (*offset & ((16 >> (dir->i_sb->s_blocksize_bits - 9)) - 1)))
126 {
127 i = 16 >> (dir->i_sb->s_blocksize_bits - 9); 123 i = 16 >> (dir->i_sb->s_blocksize_bits - 9);
128 if (i + *offset > 124 if (i + *offset > (*elen >> dir->i_sb->s_blocksize_bits))
129 (*elen >> dir->i_sb->s_blocksize_bits)) 125 i = (*elen >> dir->i_sb->s_blocksize_bits)-*offset;
130 i = (*elen >> dir->i_sb->s_blocksize_bits) -
131 *offset;
132 for (num = 0; i > 0; i--) { 126 for (num = 0; i > 0; i--) {
133 block = 127 block = udf_get_lb_pblock(dir->i_sb, *eloc, *offset + i);
134 udf_get_lb_pblock(dir->i_sb, *eloc,
135 *offset + i);
136 tmp = udf_tgetblk(dir->i_sb, block); 128 tmp = udf_tgetblk(dir->i_sb, block);
137 if (tmp && !buffer_uptodate(tmp) 129 if (tmp && !buffer_uptodate(tmp) && !buffer_locked(tmp))
138 && !buffer_locked(tmp))
139 bha[num++] = tmp; 130 bha[num++] = tmp;
140 else 131 else
141 brelse(tmp); 132 brelse(tmp);
@@ -160,7 +151,7 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
160 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2); 151 *nf_pos += ((fibh->eoffset - fibh->soffset) >> 2);
161 152
162 if (fibh->eoffset <= dir->i_sb->s_blocksize) { 153 if (fibh->eoffset <= dir->i_sb->s_blocksize) {
163 memcpy((uint8_t *) cfi, (uint8_t *) fi, 154 memcpy((uint8_t *)cfi, (uint8_t *)fi,
164 sizeof(struct fileIdentDesc)); 155 sizeof(struct fileIdentDesc));
165 } else if (fibh->eoffset > dir->i_sb->s_blocksize) { 156 } else if (fibh->eoffset > dir->i_sb->s_blocksize) {
166 int lextoffset = epos->offset; 157 int lextoffset = epos->offset;
@@ -187,21 +178,17 @@ struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t * nf_pos,
187 if (sizeof(struct fileIdentDesc) > -fibh->soffset) { 178 if (sizeof(struct fileIdentDesc) > -fibh->soffset) {
188 int fi_len; 179 int fi_len;
189 180
190 memcpy((uint8_t *) cfi, (uint8_t *) fi, -fibh->soffset); 181 memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset);
191 memcpy((uint8_t *) cfi - fibh->soffset, 182 memcpy((uint8_t *)cfi - fibh->soffset, fibh->ebh->b_data,
192 fibh->ebh->b_data,
193 sizeof(struct fileIdentDesc) + fibh->soffset); 183 sizeof(struct fileIdentDesc) + fibh->soffset);
194 184
195 fi_len = 185 fi_len = (sizeof(struct fileIdentDesc) + cfi->lengthFileIdent +
196 (sizeof(struct fileIdentDesc) + 186 le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
197 cfi->lengthFileIdent +
198 le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3;
199 187
200 *nf_pos += 188 *nf_pos += ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
201 ((fi_len - (fibh->eoffset - fibh->soffset)) >> 2);
202 fibh->eoffset = fibh->soffset + fi_len; 189 fibh->eoffset = fibh->soffset + fi_len;
203 } else { 190 } else {
204 memcpy((uint8_t *) cfi, (uint8_t *) fi, 191 memcpy((uint8_t *)cfi, (uint8_t *)fi,
205 sizeof(struct fileIdentDesc)); 192 sizeof(struct fileIdentDesc));
206 } 193 }
207 } 194 }
@@ -237,9 +224,10 @@ struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset)
237 } 224 }
238 if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) { 225 if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) {
239 lengthThisIdent = sizeof(struct fileIdentDesc); 226 lengthThisIdent = sizeof(struct fileIdentDesc);
240 } else 227 } else {
241 lengthThisIdent = sizeof(struct fileIdentDesc) + 228 lengthThisIdent = sizeof(struct fileIdentDesc) +
242 fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); 229 fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse);
230 }
243 231
244 /* we need to figure padding, too! */ 232 /* we need to figure padding, too! */
245 padlen = lengthThisIdent % UDF_NAME_PAD; 233 padlen = lengthThisIdent % UDF_NAME_PAD;
@@ -270,22 +258,20 @@ static extent_ad *udf_get_fileextent(void *buffer, int bufsize, int *offset)
270 return NULL; 258 return NULL;
271 } 259 }
272 260
273 ptr = 261 ptr = (uint8_t *)(fe->extendedAttr) + le32_to_cpu(fe->lengthExtendedAttr);
274 (uint8_t *) (fe->extendedAttr) +
275 le32_to_cpu(fe->lengthExtendedAttr);
276 262
277 if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) { 263 if ((*offset > 0) && (*offset < le32_to_cpu(fe->lengthAllocDescs))) {
278 ptr += *offset; 264 ptr += *offset;
279 } 265 }
280 266
281 ext = (extent_ad *) ptr; 267 ext = (extent_ad *)ptr;
282 268
283 *offset = *offset + sizeof(extent_ad); 269 *offset = *offset + sizeof(extent_ad);
284 return ext; 270 return ext;
285} 271}
286#endif 272#endif
287 273
288short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset, 274short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, int *offset,
289 int inc) 275 int inc)
290{ 276{
291 short_ad *sa; 277 short_ad *sa;
@@ -297,7 +283,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
297 283
298 if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset)) 284 if ((*offset < 0) || ((*offset + sizeof(short_ad)) > maxoffset))
299 return NULL; 285 return NULL;
300 else if ((sa = (short_ad *) ptr)->extLength == 0) 286 else if ((sa = (short_ad *)ptr)->extLength == 0)
301 return NULL; 287 return NULL;
302 288
303 if (inc) 289 if (inc)
@@ -305,7 +291,7 @@ short_ad *udf_get_fileshortad(uint8_t * ptr, int maxoffset, int *offset,
305 return sa; 291 return sa;
306} 292}
307 293
308long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc) 294long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, int *offset, int inc)
309{ 295{
310 long_ad *la; 296 long_ad *la;
311 297
@@ -316,7 +302,7 @@ long_ad *udf_get_filelongad(uint8_t * ptr, int maxoffset, int *offset, int inc)
316 302
317 if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset)) 303 if ((*offset < 0) || ((*offset + sizeof(long_ad)) > maxoffset))
318 return NULL; 304 return NULL;
319 else if ((la = (long_ad *) ptr)->extLength == 0) 305 else if ((la = (long_ad *)ptr)->extLength == 0)
320 return NULL; 306 return NULL;
321 307
322 if (inc) 308 if (inc)
diff --git a/fs/udf/ecma_167.h b/fs/udf/ecma_167.h
index 294ce2daa03a..56387711589b 100644
--- a/fs/udf/ecma_167.h
+++ b/fs/udf/ecma_167.h
@@ -39,8 +39,8 @@
39 39
40/* Character set specification (ECMA 167r3 1/7.2.1) */ 40/* Character set specification (ECMA 167r3 1/7.2.1) */
41typedef struct { 41typedef struct {
42 uint8_t charSetType; 42 uint8_t charSetType;
43 uint8_t charSetInfo[63]; 43 uint8_t charSetInfo[63];
44} __attribute__ ((packed)) charspec; 44} __attribute__ ((packed)) charspec;
45 45
46/* Character Set Type (ECMA 167r3 1/7.2.1.1) */ 46/* Character Set Type (ECMA 167r3 1/7.2.1.1) */
@@ -54,33 +54,33 @@ typedef struct {
54#define CHARSPEC_TYPE_CS7 0x07 /* (1/7.2.9) */ 54#define CHARSPEC_TYPE_CS7 0x07 /* (1/7.2.9) */
55#define CHARSPEC_TYPE_CS8 0x08 /* (1/7.2.10) */ 55#define CHARSPEC_TYPE_CS8 0x08 /* (1/7.2.10) */
56 56
57typedef uint8_t dstring; 57typedef uint8_t dstring;
58 58
59/* Timestamp (ECMA 167r3 1/7.3) */ 59/* Timestamp (ECMA 167r3 1/7.3) */
60typedef struct { 60typedef struct {
61 __le16 typeAndTimezone; 61 __le16 typeAndTimezone;
62 __le16 year; 62 __le16 year;
63 uint8_t month; 63 uint8_t month;
64 uint8_t day; 64 uint8_t day;
65 uint8_t hour; 65 uint8_t hour;
66 uint8_t minute; 66 uint8_t minute;
67 uint8_t second; 67 uint8_t second;
68 uint8_t centiseconds; 68 uint8_t centiseconds;
69 uint8_t hundredsOfMicroseconds; 69 uint8_t hundredsOfMicroseconds;
70 uint8_t microseconds; 70 uint8_t microseconds;
71} __attribute__ ((packed)) timestamp; 71} __attribute__ ((packed)) timestamp;
72 72
73typedef struct { 73typedef struct {
74 uint16_t typeAndTimezone; 74 uint16_t typeAndTimezone;
75 int16_t year; 75 int16_t year;
76 uint8_t month; 76 uint8_t month;
77 uint8_t day; 77 uint8_t day;
78 uint8_t hour; 78 uint8_t hour;
79 uint8_t minute; 79 uint8_t minute;
80 uint8_t second; 80 uint8_t second;
81 uint8_t centiseconds; 81 uint8_t centiseconds;
82 uint8_t hundredsOfMicroseconds; 82 uint8_t hundredsOfMicroseconds;
83 uint8_t microseconds; 83 uint8_t microseconds;
84} __attribute__ ((packed)) kernel_timestamp; 84} __attribute__ ((packed)) kernel_timestamp;
85 85
86/* Type and Time Zone (ECMA 167r3 1/7.3.1) */ 86/* Type and Time Zone (ECMA 167r3 1/7.3.1) */
@@ -92,9 +92,9 @@ typedef struct {
92 92
93/* Entity identifier (ECMA 167r3 1/7.4) */ 93/* Entity identifier (ECMA 167r3 1/7.4) */
94typedef struct { 94typedef struct {
95 uint8_t flags; 95 uint8_t flags;
96 uint8_t ident[23]; 96 uint8_t ident[23];
97 uint8_t identSuffix[8]; 97 uint8_t identSuffix[8];
98} __attribute__ ((packed)) regid; 98} __attribute__ ((packed)) regid;
99 99
100/* Flags (ECMA 167r3 1/7.4.1) */ 100/* Flags (ECMA 167r3 1/7.4.1) */
@@ -104,10 +104,10 @@ typedef struct {
104/* Volume Structure Descriptor (ECMA 167r3 2/9.1) */ 104/* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
105#define VSD_STD_ID_LEN 5 105#define VSD_STD_ID_LEN 5
106struct volStructDesc { 106struct volStructDesc {
107 uint8_t structType; 107 uint8_t structType;
108 uint8_t stdIdent[VSD_STD_ID_LEN]; 108 uint8_t stdIdent[VSD_STD_ID_LEN];
109 uint8_t structVersion; 109 uint8_t structVersion;
110 uint8_t structData[2041]; 110 uint8_t structData[2041];
111} __attribute__ ((packed)); 111} __attribute__ ((packed));
112 112
113/* Standard Identifier (EMCA 167r2 2/9.1.2) */ 113/* Standard Identifier (EMCA 167r2 2/9.1.2) */
@@ -123,36 +123,36 @@ struct volStructDesc {
123 123
124/* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */ 124/* Beginning Extended Area Descriptor (ECMA 167r3 2/9.2) */
125struct beginningExtendedAreaDesc { 125struct beginningExtendedAreaDesc {
126 uint8_t structType; 126 uint8_t structType;
127 uint8_t stdIdent[VSD_STD_ID_LEN]; 127 uint8_t stdIdent[VSD_STD_ID_LEN];
128 uint8_t structVersion; 128 uint8_t structVersion;
129 uint8_t structData[2041]; 129 uint8_t structData[2041];
130} __attribute__ ((packed)); 130} __attribute__ ((packed));
131 131
132/* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */ 132/* Terminating Extended Area Descriptor (ECMA 167r3 2/9.3) */
133struct terminatingExtendedAreaDesc { 133struct terminatingExtendedAreaDesc {
134 uint8_t structType; 134 uint8_t structType;
135 uint8_t stdIdent[VSD_STD_ID_LEN]; 135 uint8_t stdIdent[VSD_STD_ID_LEN];
136 uint8_t structVersion; 136 uint8_t structVersion;
137 uint8_t structData[2041]; 137 uint8_t structData[2041];
138} __attribute__ ((packed)); 138} __attribute__ ((packed));
139 139
140/* Boot Descriptor (ECMA 167r3 2/9.4) */ 140/* Boot Descriptor (ECMA 167r3 2/9.4) */
141struct bootDesc { 141struct bootDesc {
142 uint8_t structType; 142 uint8_t structType;
143 uint8_t stdIdent[VSD_STD_ID_LEN]; 143 uint8_t stdIdent[VSD_STD_ID_LEN];
144 uint8_t structVersion; 144 uint8_t structVersion;
145 uint8_t reserved1; 145 uint8_t reserved1;
146 regid archType; 146 regid archType;
147 regid bootIdent; 147 regid bootIdent;
148 __le32 bootExtLocation; 148 __le32 bootExtLocation;
149 __le32 bootExtLength; 149 __le32 bootExtLength;
150 __le64 loadAddress; 150 __le64 loadAddress;
151 __le64 startAddress; 151 __le64 startAddress;
152 timestamp descCreationDateAndTime; 152 timestamp descCreationDateAndTime;
153 __le16 flags; 153 __le16 flags;
154 uint8_t reserved2[32]; 154 uint8_t reserved2[32];
155 uint8_t bootUse[1906]; 155 uint8_t bootUse[1906];
156} __attribute__ ((packed)); 156} __attribute__ ((packed));
157 157
158/* Flags (ECMA 167r3 2/9.4.12) */ 158/* Flags (ECMA 167r3 2/9.4.12) */
@@ -160,25 +160,25 @@ struct bootDesc {
160 160
161/* Extent Descriptor (ECMA 167r3 3/7.1) */ 161/* Extent Descriptor (ECMA 167r3 3/7.1) */
162typedef struct { 162typedef struct {
163 __le32 extLength; 163 __le32 extLength;
164 __le32 extLocation; 164 __le32 extLocation;
165} __attribute__ ((packed)) extent_ad; 165} __attribute__ ((packed)) extent_ad;
166 166
167typedef struct { 167typedef struct {
168 uint32_t extLength; 168 uint32_t extLength;
169 uint32_t extLocation; 169 uint32_t extLocation;
170} kernel_extent_ad; 170} kernel_extent_ad;
171 171
172/* Descriptor Tag (ECMA 167r3 3/7.2) */ 172/* Descriptor Tag (ECMA 167r3 3/7.2) */
173typedef struct { 173typedef struct {
174 __le16 tagIdent; 174 __le16 tagIdent;
175 __le16 descVersion; 175 __le16 descVersion;
176 uint8_t tagChecksum; 176 uint8_t tagChecksum;
177 uint8_t reserved; 177 uint8_t reserved;
178 __le16 tagSerialNum; 178 __le16 tagSerialNum;
179 __le16 descCRC; 179 __le16 descCRC;
180 __le16 descCRCLength; 180 __le16 descCRCLength;
181 __le32 tagLocation; 181 __le32 tagLocation;
182} __attribute__ ((packed)) tag; 182} __attribute__ ((packed)) tag;
183 183
184/* Tag Identifier (ECMA 167r3 3/7.2.1) */ 184/* Tag Identifier (ECMA 167r3 3/7.2.1) */
@@ -194,37 +194,37 @@ typedef struct {
194 194
195/* NSR Descriptor (ECMA 167r3 3/9.1) */ 195/* NSR Descriptor (ECMA 167r3 3/9.1) */
196struct NSRDesc { 196struct NSRDesc {
197 uint8_t structType; 197 uint8_t structType;
198 uint8_t stdIdent[VSD_STD_ID_LEN]; 198 uint8_t stdIdent[VSD_STD_ID_LEN];
199 uint8_t structVersion; 199 uint8_t structVersion;
200 uint8_t reserved; 200 uint8_t reserved;
201 uint8_t structData[2040]; 201 uint8_t structData[2040];
202} __attribute__ ((packed)); 202} __attribute__ ((packed));
203 203
204/* Primary Volume Descriptor (ECMA 167r3 3/10.1) */ 204/* Primary Volume Descriptor (ECMA 167r3 3/10.1) */
205struct primaryVolDesc { 205struct primaryVolDesc {
206 tag descTag; 206 tag descTag;
207 __le32 volDescSeqNum; 207 __le32 volDescSeqNum;
208 __le32 primaryVolDescNum; 208 __le32 primaryVolDescNum;
209 dstring volIdent[32]; 209 dstring volIdent[32];
210 __le16 volSeqNum; 210 __le16 volSeqNum;
211 __le16 maxVolSeqNum; 211 __le16 maxVolSeqNum;
212 __le16 interchangeLvl; 212 __le16 interchangeLvl;
213 __le16 maxInterchangeLvl; 213 __le16 maxInterchangeLvl;
214 __le32 charSetList; 214 __le32 charSetList;
215 __le32 maxCharSetList; 215 __le32 maxCharSetList;
216 dstring volSetIdent[128]; 216 dstring volSetIdent[128];
217 charspec descCharSet; 217 charspec descCharSet;
218 charspec explanatoryCharSet; 218 charspec explanatoryCharSet;
219 extent_ad volAbstract; 219 extent_ad volAbstract;
220 extent_ad volCopyright; 220 extent_ad volCopyright;
221 regid appIdent; 221 regid appIdent;
222 timestamp recordingDateAndTime; 222 timestamp recordingDateAndTime;
223 regid impIdent; 223 regid impIdent;
224 uint8_t impUse[64]; 224 uint8_t impUse[64];
225 __le32 predecessorVolDescSeqLocation; 225 __le32 predecessorVolDescSeqLocation;
226 __le16 flags; 226 __le16 flags;
227 uint8_t reserved[22]; 227 uint8_t reserved[22];
228} __attribute__ ((packed)); 228} __attribute__ ((packed));
229 229
230/* Flags (ECMA 167r3 3/10.1.21) */ 230/* Flags (ECMA 167r3 3/10.1.21) */
@@ -232,26 +232,26 @@ struct primaryVolDesc {
232 232
233/* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */ 233/* Anchor Volume Descriptor Pointer (ECMA 167r3 3/10.2) */
234struct anchorVolDescPtr { 234struct anchorVolDescPtr {
235 tag descTag; 235 tag descTag;
236 extent_ad mainVolDescSeqExt; 236 extent_ad mainVolDescSeqExt;
237 extent_ad reserveVolDescSeqExt; 237 extent_ad reserveVolDescSeqExt;
238 uint8_t reserved[480]; 238 uint8_t reserved[480];
239} __attribute__ ((packed)); 239} __attribute__ ((packed));
240 240
241/* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */ 241/* Volume Descriptor Pointer (ECMA 167r3 3/10.3) */
242struct volDescPtr { 242struct volDescPtr {
243 tag descTag; 243 tag descTag;
244 __le32 volDescSeqNum; 244 __le32 volDescSeqNum;
245 extent_ad nextVolDescSeqExt; 245 extent_ad nextVolDescSeqExt;
246 uint8_t reserved[484]; 246 uint8_t reserved[484];
247} __attribute__ ((packed)); 247} __attribute__ ((packed));
248 248
249/* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */ 249/* Implementation Use Volume Descriptor (ECMA 167r3 3/10.4) */
250struct impUseVolDesc { 250struct impUseVolDesc {
251 tag descTag; 251 tag descTag;
252 __le32 volDescSeqNum; 252 __le32 volDescSeqNum;
253 regid impIdent; 253 regid impIdent;
254 uint8_t impUse[460]; 254 uint8_t impUse[460];
255} __attribute__ ((packed)); 255} __attribute__ ((packed));
256 256
257/* Partition Descriptor (ECMA 167r3 3/10.5) */ 257/* Partition Descriptor (ECMA 167r3 3/10.5) */
@@ -291,26 +291,26 @@ struct partitionDesc {
291 291
292/* Logical Volume Descriptor (ECMA 167r3 3/10.6) */ 292/* Logical Volume Descriptor (ECMA 167r3 3/10.6) */
293struct logicalVolDesc { 293struct logicalVolDesc {
294 tag descTag; 294 tag descTag;
295 __le32 volDescSeqNum; 295 __le32 volDescSeqNum;
296 charspec descCharSet; 296 charspec descCharSet;
297 dstring logicalVolIdent[128]; 297 dstring logicalVolIdent[128];
298 __le32 logicalBlockSize; 298 __le32 logicalBlockSize;
299 regid domainIdent; 299 regid domainIdent;
300 uint8_t logicalVolContentsUse[16]; 300 uint8_t logicalVolContentsUse[16];
301 __le32 mapTableLength; 301 __le32 mapTableLength;
302 __le32 numPartitionMaps; 302 __le32 numPartitionMaps;
303 regid impIdent; 303 regid impIdent;
304 uint8_t impUse[128]; 304 uint8_t impUse[128];
305 extent_ad integritySeqExt; 305 extent_ad integritySeqExt;
306 uint8_t partitionMaps[0]; 306 uint8_t partitionMaps[0];
307} __attribute__ ((packed)); 307} __attribute__ ((packed));
308 308
309/* Generic Partition Map (ECMA 167r3 3/10.7.1) */ 309/* Generic Partition Map (ECMA 167r3 3/10.7.1) */
310struct genericPartitionMap { 310struct genericPartitionMap {
311 uint8_t partitionMapType; 311 uint8_t partitionMapType;
312 uint8_t partitionMapLength; 312 uint8_t partitionMapLength;
313 uint8_t partitionMapping[0]; 313 uint8_t partitionMapping[0];
314} __attribute__ ((packed)); 314} __attribute__ ((packed));
315 315
316/* Partition Map Type (ECMA 167r3 3/10.7.1.1) */ 316/* Partition Map Type (ECMA 167r3 3/10.7.1.1) */
@@ -320,45 +320,45 @@ struct genericPartitionMap {
320 320
321/* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */ 321/* Type 1 Partition Map (ECMA 167r3 3/10.7.2) */
322struct genericPartitionMap1 { 322struct genericPartitionMap1 {
323 uint8_t partitionMapType; 323 uint8_t partitionMapType;
324 uint8_t partitionMapLength; 324 uint8_t partitionMapLength;
325 __le16 volSeqNum; 325 __le16 volSeqNum;
326 __le16 partitionNum; 326 __le16 partitionNum;
327} __attribute__ ((packed)); 327} __attribute__ ((packed));
328 328
329/* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */ 329/* Type 2 Partition Map (ECMA 167r3 3/10.7.3) */
330struct genericPartitionMap2 { 330struct genericPartitionMap2 {
331 uint8_t partitionMapType; 331 uint8_t partitionMapType;
332 uint8_t partitionMapLength; 332 uint8_t partitionMapLength;
333 uint8_t partitionIdent[62]; 333 uint8_t partitionIdent[62];
334} __attribute__ ((packed)); 334} __attribute__ ((packed));
335 335
336/* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */ 336/* Unallocated Space Descriptor (ECMA 167r3 3/10.8) */
337struct unallocSpaceDesc { 337struct unallocSpaceDesc {
338 tag descTag; 338 tag descTag;
339 __le32 volDescSeqNum; 339 __le32 volDescSeqNum;
340 __le32 numAllocDescs; 340 __le32 numAllocDescs;
341 extent_ad allocDescs[0]; 341 extent_ad allocDescs[0];
342} __attribute__ ((packed)); 342} __attribute__ ((packed));
343 343
344/* Terminating Descriptor (ECMA 167r3 3/10.9) */ 344/* Terminating Descriptor (ECMA 167r3 3/10.9) */
345struct terminatingDesc { 345struct terminatingDesc {
346 tag descTag; 346 tag descTag;
347 uint8_t reserved[496]; 347 uint8_t reserved[496];
348} __attribute__ ((packed)); 348} __attribute__ ((packed));
349 349
350/* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */ 350/* Logical Volume Integrity Descriptor (ECMA 167r3 3/10.10) */
351struct logicalVolIntegrityDesc { 351struct logicalVolIntegrityDesc {
352 tag descTag; 352 tag descTag;
353 timestamp recordingDateAndTime; 353 timestamp recordingDateAndTime;
354 __le32 integrityType; 354 __le32 integrityType;
355 extent_ad nextIntegrityExt; 355 extent_ad nextIntegrityExt;
356 uint8_t logicalVolContentsUse[32]; 356 uint8_t logicalVolContentsUse[32];
357 __le32 numOfPartitions; 357 __le32 numOfPartitions;
358 __le32 lengthOfImpUse; 358 __le32 lengthOfImpUse;
359 __le32 freeSpaceTable[0]; 359 __le32 freeSpaceTable[0];
360 __le32 sizeTable[0]; 360 __le32 sizeTable[0];
361 uint8_t impUse[0]; 361 uint8_t impUse[0];
362} __attribute__ ((packed)); 362} __attribute__ ((packed));
363 363
364/* Integrity Type (ECMA 167r3 3/10.10.3) */ 364/* Integrity Type (ECMA 167r3 3/10.10.3) */
@@ -367,48 +367,48 @@ struct logicalVolIntegrityDesc {
367 367
368/* Recorded Address (ECMA 167r3 4/7.1) */ 368/* Recorded Address (ECMA 167r3 4/7.1) */
369typedef struct { 369typedef struct {
370 __le32 logicalBlockNum; 370 __le32 logicalBlockNum;
371 __le16 partitionReferenceNum; 371 __le16 partitionReferenceNum;
372} __attribute__ ((packed)) lb_addr; 372} __attribute__ ((packed)) lb_addr;
373 373
374/* ... and its in-core analog */ 374/* ... and its in-core analog */
375typedef struct { 375typedef struct {
376 uint32_t logicalBlockNum; 376 uint32_t logicalBlockNum;
377 uint16_t partitionReferenceNum; 377 uint16_t partitionReferenceNum;
378} kernel_lb_addr; 378} kernel_lb_addr;
379 379
380/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */ 380/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
381typedef struct { 381typedef struct {
382 __le32 extLength; 382 __le32 extLength;
383 __le32 extPosition; 383 __le32 extPosition;
384} __attribute__ ((packed)) short_ad; 384} __attribute__ ((packed)) short_ad;
385 385
386/* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */ 386/* Long Allocation Descriptor (ECMA 167r3 4/14.14.2) */
387typedef struct { 387typedef struct {
388 __le32 extLength; 388 __le32 extLength;
389 lb_addr extLocation; 389 lb_addr extLocation;
390 uint8_t impUse[6]; 390 uint8_t impUse[6];
391} __attribute__ ((packed)) long_ad; 391} __attribute__ ((packed)) long_ad;
392 392
393typedef struct { 393typedef struct {
394 uint32_t extLength; 394 uint32_t extLength;
395 kernel_lb_addr extLocation; 395 kernel_lb_addr extLocation;
396 uint8_t impUse[6]; 396 uint8_t impUse[6];
397} kernel_long_ad; 397} kernel_long_ad;
398 398
399/* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */ 399/* Extended Allocation Descriptor (ECMA 167r3 4/14.14.3) */
400typedef struct { 400typedef struct {
401 __le32 extLength; 401 __le32 extLength;
402 __le32 recordedLength; 402 __le32 recordedLength;
403 __le32 informationLength; 403 __le32 informationLength;
404 lb_addr extLocation; 404 lb_addr extLocation;
405} __attribute__ ((packed)) ext_ad; 405} __attribute__ ((packed)) ext_ad;
406 406
407typedef struct { 407typedef struct {
408 uint32_t extLength; 408 uint32_t extLength;
409 uint32_t recordedLength; 409 uint32_t recordedLength;
410 uint32_t informationLength; 410 uint32_t informationLength;
411 kernel_lb_addr extLocation; 411 kernel_lb_addr extLocation;
412} kernel_ext_ad; 412} kernel_ext_ad;
413 413
414/* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */ 414/* Descriptor Tag (ECMA 167r3 4/7.2 - See 3/7.2) */
@@ -428,48 +428,48 @@ typedef struct {
428 428
429/* File Set Descriptor (ECMA 167r3 4/14.1) */ 429/* File Set Descriptor (ECMA 167r3 4/14.1) */
430struct fileSetDesc { 430struct fileSetDesc {
431 tag descTag; 431 tag descTag;
432 timestamp recordingDateAndTime; 432 timestamp recordingDateAndTime;
433 __le16 interchangeLvl; 433 __le16 interchangeLvl;
434 __le16 maxInterchangeLvl; 434 __le16 maxInterchangeLvl;
435 __le32 charSetList; 435 __le32 charSetList;
436 __le32 maxCharSetList; 436 __le32 maxCharSetList;
437 __le32 fileSetNum; 437 __le32 fileSetNum;
438 __le32 fileSetDescNum; 438 __le32 fileSetDescNum;
439 charspec logicalVolIdentCharSet; 439 charspec logicalVolIdentCharSet;
440 dstring logicalVolIdent[128]; 440 dstring logicalVolIdent[128];
441 charspec fileSetCharSet; 441 charspec fileSetCharSet;
442 dstring fileSetIdent[32]; 442 dstring fileSetIdent[32];
443 dstring copyrightFileIdent[32]; 443 dstring copyrightFileIdent[32];
444 dstring abstractFileIdent[32]; 444 dstring abstractFileIdent[32];
445 long_ad rootDirectoryICB; 445 long_ad rootDirectoryICB;
446 regid domainIdent; 446 regid domainIdent;
447 long_ad nextExt; 447 long_ad nextExt;
448 long_ad streamDirectoryICB; 448 long_ad streamDirectoryICB;
449 uint8_t reserved[32]; 449 uint8_t reserved[32];
450} __attribute__ ((packed)); 450} __attribute__ ((packed));
451 451
452/* Partition Header Descriptor (ECMA 167r3 4/14.3) */ 452/* Partition Header Descriptor (ECMA 167r3 4/14.3) */
453struct partitionHeaderDesc { 453struct partitionHeaderDesc {
454 short_ad unallocSpaceTable; 454 short_ad unallocSpaceTable;
455 short_ad unallocSpaceBitmap; 455 short_ad unallocSpaceBitmap;
456 short_ad partitionIntegrityTable; 456 short_ad partitionIntegrityTable;
457 short_ad freedSpaceTable; 457 short_ad freedSpaceTable;
458 short_ad freedSpaceBitmap; 458 short_ad freedSpaceBitmap;
459 uint8_t reserved[88]; 459 uint8_t reserved[88];
460} __attribute__ ((packed)); 460} __attribute__ ((packed));
461 461
462/* File Identifier Descriptor (ECMA 167r3 4/14.4) */ 462/* File Identifier Descriptor (ECMA 167r3 4/14.4) */
463struct fileIdentDesc { 463struct fileIdentDesc {
464 tag descTag; 464 tag descTag;
465 __le16 fileVersionNum; 465 __le16 fileVersionNum;
466 uint8_t fileCharacteristics; 466 uint8_t fileCharacteristics;
467 uint8_t lengthFileIdent; 467 uint8_t lengthFileIdent;
468 long_ad icb; 468 long_ad icb;
469 __le16 lengthOfImpUse; 469 __le16 lengthOfImpUse;
470 uint8_t impUse[0]; 470 uint8_t impUse[0];
471 uint8_t fileIdent[0]; 471 uint8_t fileIdent[0];
472 uint8_t padding[0]; 472 uint8_t padding[0];
473} __attribute__ ((packed)); 473} __attribute__ ((packed));
474 474
475/* File Characteristics (ECMA 167r3 4/14.4.3) */ 475/* File Characteristics (ECMA 167r3 4/14.4.3) */
@@ -481,21 +481,21 @@ struct fileIdentDesc {
481 481
482/* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */ 482/* Allocation Ext Descriptor (ECMA 167r3 4/14.5) */
483struct allocExtDesc { 483struct allocExtDesc {
484 tag descTag; 484 tag descTag;
485 __le32 previousAllocExtLocation; 485 __le32 previousAllocExtLocation;
486 __le32 lengthAllocDescs; 486 __le32 lengthAllocDescs;
487} __attribute__ ((packed)); 487} __attribute__ ((packed));
488 488
489/* ICB Tag (ECMA 167r3 4/14.6) */ 489/* ICB Tag (ECMA 167r3 4/14.6) */
490typedef struct { 490typedef struct {
491 __le32 priorRecordedNumDirectEntries; 491 __le32 priorRecordedNumDirectEntries;
492 __le16 strategyType; 492 __le16 strategyType;
493 __le16 strategyParameter; 493 __le16 strategyParameter;
494 __le16 numEntries; 494 __le16 numEntries;
495 uint8_t reserved; 495 uint8_t reserved;
496 uint8_t fileType; 496 uint8_t fileType;
497 lb_addr parentICBLocation; 497 lb_addr parentICBLocation;
498 __le16 flags; 498 __le16 flags;
499} __attribute__ ((packed)) icbtag; 499} __attribute__ ((packed)) icbtag;
500 500
501/* Strategy Type (ECMA 167r3 4/14.6.2) */ 501/* Strategy Type (ECMA 167r3 4/14.6.2) */
@@ -541,41 +541,41 @@ typedef struct {
541 541
542/* Indirect Entry (ECMA 167r3 4/14.7) */ 542/* Indirect Entry (ECMA 167r3 4/14.7) */
543struct indirectEntry { 543struct indirectEntry {
544 tag descTag; 544 tag descTag;
545 icbtag icbTag; 545 icbtag icbTag;
546 long_ad indirectICB; 546 long_ad indirectICB;
547} __attribute__ ((packed)); 547} __attribute__ ((packed));
548 548
549/* Terminal Entry (ECMA 167r3 4/14.8) */ 549/* Terminal Entry (ECMA 167r3 4/14.8) */
550struct terminalEntry { 550struct terminalEntry {
551 tag descTag; 551 tag descTag;
552 icbtag icbTag; 552 icbtag icbTag;
553} __attribute__ ((packed)); 553} __attribute__ ((packed));
554 554
555/* File Entry (ECMA 167r3 4/14.9) */ 555/* File Entry (ECMA 167r3 4/14.9) */
556struct fileEntry { 556struct fileEntry {
557 tag descTag; 557 tag descTag;
558 icbtag icbTag; 558 icbtag icbTag;
559 __le32 uid; 559 __le32 uid;
560 __le32 gid; 560 __le32 gid;
561 __le32 permissions; 561 __le32 permissions;
562 __le16 fileLinkCount; 562 __le16 fileLinkCount;
563 uint8_t recordFormat; 563 uint8_t recordFormat;
564 uint8_t recordDisplayAttr; 564 uint8_t recordDisplayAttr;
565 __le32 recordLength; 565 __le32 recordLength;
566 __le64 informationLength; 566 __le64 informationLength;
567 __le64 logicalBlocksRecorded; 567 __le64 logicalBlocksRecorded;
568 timestamp accessTime; 568 timestamp accessTime;
569 timestamp modificationTime; 569 timestamp modificationTime;
570 timestamp attrTime; 570 timestamp attrTime;
571 __le32 checkpoint; 571 __le32 checkpoint;
572 long_ad extendedAttrICB; 572 long_ad extendedAttrICB;
573 regid impIdent; 573 regid impIdent;
574 __le64 uniqueID; 574 __le64 uniqueID;
575 __le32 lengthExtendedAttr; 575 __le32 lengthExtendedAttr;
576 __le32 lengthAllocDescs; 576 __le32 lengthAllocDescs;
577 uint8_t extendedAttr[0]; 577 uint8_t extendedAttr[0];
578 uint8_t allocDescs[0]; 578 uint8_t allocDescs[0];
579} __attribute__ ((packed)); 579} __attribute__ ((packed));
580 580
581/* Permissions (ECMA 167r3 4/14.9.5) */ 581/* Permissions (ECMA 167r3 4/14.9.5) */
@@ -617,51 +617,51 @@ struct fileEntry {
617 617
618/* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */ 618/* Extended Attribute Header Descriptor (ECMA 167r3 4/14.10.1) */
619struct extendedAttrHeaderDesc { 619struct extendedAttrHeaderDesc {
620 tag descTag; 620 tag descTag;
621 __le32 impAttrLocation; 621 __le32 impAttrLocation;
622 __le32 appAttrLocation; 622 __le32 appAttrLocation;
623} __attribute__ ((packed)); 623} __attribute__ ((packed));
624 624
625/* Generic Format (ECMA 167r3 4/14.10.2) */ 625/* Generic Format (ECMA 167r3 4/14.10.2) */
626struct genericFormat { 626struct genericFormat {
627 __le32 attrType; 627 __le32 attrType;
628 uint8_t attrSubtype; 628 uint8_t attrSubtype;
629 uint8_t reserved[3]; 629 uint8_t reserved[3];
630 __le32 attrLength; 630 __le32 attrLength;
631 uint8_t attrData[0]; 631 uint8_t attrData[0];
632} __attribute__ ((packed)); 632} __attribute__ ((packed));
633 633
634/* Character Set Information (ECMA 167r3 4/14.10.3) */ 634/* Character Set Information (ECMA 167r3 4/14.10.3) */
635struct charSetInfo { 635struct charSetInfo {
636 __le32 attrType; 636 __le32 attrType;
637 uint8_t attrSubtype; 637 uint8_t attrSubtype;
638 uint8_t reserved[3]; 638 uint8_t reserved[3];
639 __le32 attrLength; 639 __le32 attrLength;
640 __le32 escapeSeqLength; 640 __le32 escapeSeqLength;
641 uint8_t charSetType; 641 uint8_t charSetType;
642 uint8_t escapeSeq[0]; 642 uint8_t escapeSeq[0];
643} __attribute__ ((packed)); 643} __attribute__ ((packed));
644 644
645/* Alternate Permissions (ECMA 167r3 4/14.10.4) */ 645/* Alternate Permissions (ECMA 167r3 4/14.10.4) */
646struct altPerms { 646struct altPerms {
647 __le32 attrType; 647 __le32 attrType;
648 uint8_t attrSubtype; 648 uint8_t attrSubtype;
649 uint8_t reserved[3]; 649 uint8_t reserved[3];
650 __le32 attrLength; 650 __le32 attrLength;
651 __le16 ownerIdent; 651 __le16 ownerIdent;
652 __le16 groupIdent; 652 __le16 groupIdent;
653 __le16 permission; 653 __le16 permission;
654} __attribute__ ((packed)); 654} __attribute__ ((packed));
655 655
656/* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */ 656/* File Times Extended Attribute (ECMA 167r3 4/14.10.5) */
657struct fileTimesExtAttr { 657struct fileTimesExtAttr {
658 __le32 attrType; 658 __le32 attrType;
659 uint8_t attrSubtype; 659 uint8_t attrSubtype;
660 uint8_t reserved[3]; 660 uint8_t reserved[3];
661 __le32 attrLength; 661 __le32 attrLength;
662 __le32 dataLength; 662 __le32 dataLength;
663 __le32 fileTimeExistence; 663 __le32 fileTimeExistence;
664 uint8_t fileTimes; 664 uint8_t fileTimes;
665} __attribute__ ((packed)); 665} __attribute__ ((packed));
666 666
667/* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */ 667/* FileTimeExistence (ECMA 167r3 4/14.10.5.6) */
@@ -672,47 +672,47 @@ struct fileTimesExtAttr {
672 672
673/* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */ 673/* Information Times Extended Attribute (ECMA 167r3 4/14.10.6) */
674struct infoTimesExtAttr { 674struct infoTimesExtAttr {
675 __le32 attrType; 675 __le32 attrType;
676 uint8_t attrSubtype; 676 uint8_t attrSubtype;
677 uint8_t reserved[3]; 677 uint8_t reserved[3];
678 __le32 attrLength; 678 __le32 attrLength;
679 __le32 dataLength; 679 __le32 dataLength;
680 __le32 infoTimeExistence; 680 __le32 infoTimeExistence;
681 uint8_t infoTimes[0]; 681 uint8_t infoTimes[0];
682} __attribute__ ((packed)); 682} __attribute__ ((packed));
683 683
684/* Device Specification (ECMA 167r3 4/14.10.7) */ 684/* Device Specification (ECMA 167r3 4/14.10.7) */
685struct deviceSpec { 685struct deviceSpec {
686 __le32 attrType; 686 __le32 attrType;
687 uint8_t attrSubtype; 687 uint8_t attrSubtype;
688 uint8_t reserved[3]; 688 uint8_t reserved[3];
689 __le32 attrLength; 689 __le32 attrLength;
690 __le32 impUseLength; 690 __le32 impUseLength;
691 __le32 majorDeviceIdent; 691 __le32 majorDeviceIdent;
692 __le32 minorDeviceIdent; 692 __le32 minorDeviceIdent;
693 uint8_t impUse[0]; 693 uint8_t impUse[0];
694} __attribute__ ((packed)); 694} __attribute__ ((packed));
695 695
696/* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */ 696/* Implementation Use Extended Attr (ECMA 167r3 4/14.10.8) */
697struct impUseExtAttr { 697struct impUseExtAttr {
698 __le32 attrType; 698 __le32 attrType;
699 uint8_t attrSubtype; 699 uint8_t attrSubtype;
700 uint8_t reserved[3]; 700 uint8_t reserved[3];
701 __le32 attrLength; 701 __le32 attrLength;
702 __le32 impUseLength; 702 __le32 impUseLength;
703 regid impIdent; 703 regid impIdent;
704 uint8_t impUse[0]; 704 uint8_t impUse[0];
705} __attribute__ ((packed)); 705} __attribute__ ((packed));
706 706
707/* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */ 707/* Application Use Extended Attribute (ECMA 167r3 4/14.10.9) */
708struct appUseExtAttr { 708struct appUseExtAttr {
709 __le32 attrType; 709 __le32 attrType;
710 uint8_t attrSubtype; 710 uint8_t attrSubtype;
711 uint8_t reserved[3]; 711 uint8_t reserved[3];
712 __le32 attrLength; 712 __le32 attrLength;
713 __le32 appUseLength; 713 __le32 appUseLength;
714 regid appIdent; 714 regid appIdent;
715 uint8_t appUse[0]; 715 uint8_t appUse[0];
716} __attribute__ ((packed)); 716} __attribute__ ((packed));
717 717
718#define EXTATTR_CHAR_SET 1 718#define EXTATTR_CHAR_SET 1
@@ -725,29 +725,29 @@ struct appUseExtAttr {
725 725
726/* Unallocated Space Entry (ECMA 167r3 4/14.11) */ 726/* Unallocated Space Entry (ECMA 167r3 4/14.11) */
727struct unallocSpaceEntry { 727struct unallocSpaceEntry {
728 tag descTag; 728 tag descTag;
729 icbtag icbTag; 729 icbtag icbTag;
730 __le32 lengthAllocDescs; 730 __le32 lengthAllocDescs;
731 uint8_t allocDescs[0]; 731 uint8_t allocDescs[0];
732} __attribute__ ((packed)); 732} __attribute__ ((packed));
733 733
734/* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */ 734/* Space Bitmap Descriptor (ECMA 167r3 4/14.12) */
735struct spaceBitmapDesc { 735struct spaceBitmapDesc {
736 tag descTag; 736 tag descTag;
737 __le32 numOfBits; 737 __le32 numOfBits;
738 __le32 numOfBytes; 738 __le32 numOfBytes;
739 uint8_t bitmap[0]; 739 uint8_t bitmap[0];
740} __attribute__ ((packed)); 740} __attribute__ ((packed));
741 741
742/* Partition Integrity Entry (ECMA 167r3 4/14.13) */ 742/* Partition Integrity Entry (ECMA 167r3 4/14.13) */
743struct partitionIntegrityEntry { 743struct partitionIntegrityEntry {
744 tag descTag; 744 tag descTag;
745 icbtag icbTag; 745 icbtag icbTag;
746 timestamp recordingDateAndTime; 746 timestamp recordingDateAndTime;
747 uint8_t integrityType; 747 uint8_t integrityType;
748 uint8_t reserved[175]; 748 uint8_t reserved[175];
749 regid impIdent; 749 regid impIdent;
750 uint8_t impUse[256]; 750 uint8_t impUse[256];
751} __attribute__ ((packed)); 751} __attribute__ ((packed));
752 752
753/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */ 753/* Short Allocation Descriptor (ECMA 167r3 4/14.14.1) */
@@ -764,46 +764,46 @@ struct partitionIntegrityEntry {
764 764
765/* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */ 765/* Logical Volume Header Descriptor (ECMA 167r3 4/14.15) */
766struct logicalVolHeaderDesc { 766struct logicalVolHeaderDesc {
767 __le64 uniqueID; 767 __le64 uniqueID;
768 uint8_t reserved[24]; 768 uint8_t reserved[24];
769} __attribute__ ((packed)); 769} __attribute__ ((packed));
770 770
771/* Path Component (ECMA 167r3 4/14.16.1) */ 771/* Path Component (ECMA 167r3 4/14.16.1) */
772struct pathComponent { 772struct pathComponent {
773 uint8_t componentType; 773 uint8_t componentType;
774 uint8_t lengthComponentIdent; 774 uint8_t lengthComponentIdent;
775 __le16 componentFileVersionNum; 775 __le16 componentFileVersionNum;
776 dstring componentIdent[0]; 776 dstring componentIdent[0];
777} __attribute__ ((packed)); 777} __attribute__ ((packed));
778 778
779/* File Entry (ECMA 167r3 4/14.17) */ 779/* File Entry (ECMA 167r3 4/14.17) */
780struct extendedFileEntry { 780struct extendedFileEntry {
781 tag descTag; 781 tag descTag;
782 icbtag icbTag; 782 icbtag icbTag;
783 __le32 uid; 783 __le32 uid;
784 __le32 gid; 784 __le32 gid;
785 __le32 permissions; 785 __le32 permissions;
786 __le16 fileLinkCount; 786 __le16 fileLinkCount;
787 uint8_t recordFormat; 787 uint8_t recordFormat;
788 uint8_t recordDisplayAttr; 788 uint8_t recordDisplayAttr;
789 __le32 recordLength; 789 __le32 recordLength;
790 __le64 informationLength; 790 __le64 informationLength;
791 __le64 objectSize; 791 __le64 objectSize;
792 __le64 logicalBlocksRecorded; 792 __le64 logicalBlocksRecorded;
793 timestamp accessTime; 793 timestamp accessTime;
794 timestamp modificationTime; 794 timestamp modificationTime;
795 timestamp createTime; 795 timestamp createTime;
796 timestamp attrTime; 796 timestamp attrTime;
797 __le32 checkpoint; 797 __le32 checkpoint;
798 __le32 reserved; 798 __le32 reserved;
799 long_ad extendedAttrICB; 799 long_ad extendedAttrICB;
800 long_ad streamDirectoryICB; 800 long_ad streamDirectoryICB;
801 regid impIdent; 801 regid impIdent;
802 __le64 uniqueID; 802 __le64 uniqueID;
803 __le32 lengthExtendedAttr; 803 __le32 lengthExtendedAttr;
804 __le32 lengthAllocDescs; 804 __le32 lengthAllocDescs;
805 uint8_t extendedAttr[0]; 805 uint8_t extendedAttr[0];
806 uint8_t allocDescs[0]; 806 uint8_t allocDescs[0];
807} __attribute__ ((packed)); 807} __attribute__ ((packed));
808 808
809#endif /* _ECMA_167_H */ 809#endif /* _ECMA_167_H */
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 67bf36bd3e6e..5d7a4ea27753 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -30,7 +30,7 @@
30#include <linux/udf_fs.h> 30#include <linux/udf_fs.h>
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32#include <linux/kernel.h> 32#include <linux/kernel.h>
33#include <linux/string.h> /* memset */ 33#include <linux/string.h> /* memset */
34#include <linux/capability.h> 34#include <linux/capability.h>
35#include <linux/errno.h> 35#include <linux/errno.h>
36#include <linux/smp_lock.h> 36#include <linux/smp_lock.h>
@@ -55,11 +55,11 @@ static int udf_adinicb_readpage(struct file *file, struct page *page)
55 SetPageUptodate(page); 55 SetPageUptodate(page);
56 kunmap(page); 56 kunmap(page);
57 unlock_page(page); 57 unlock_page(page);
58
58 return 0; 59 return 0;
59} 60}
60 61
61static int udf_adinicb_writepage(struct page *page, 62static int udf_adinicb_writepage(struct page *page, struct writeback_control *wbc)
62 struct writeback_control *wbc)
63{ 63{
64 struct inode *inode = page->mapping->host; 64 struct inode *inode = page->mapping->host;
65 char *kaddr; 65 char *kaddr;
@@ -72,6 +72,7 @@ static int udf_adinicb_writepage(struct page *page,
72 SetPageUptodate(page); 72 SetPageUptodate(page);
73 kunmap(page); 73 kunmap(page);
74 unlock_page(page); 74 unlock_page(page);
75
75 return 0; 76 return 0;
76} 77}
77 78
@@ -100,11 +101,11 @@ static int udf_adinicb_commit_write(struct file *file, struct page *page,
100} 101}
101 102
102const struct address_space_operations udf_adinicb_aops = { 103const struct address_space_operations udf_adinicb_aops = {
103 .readpage = udf_adinicb_readpage, 104 .readpage = udf_adinicb_readpage,
104 .writepage = udf_adinicb_writepage, 105 .writepage = udf_adinicb_writepage,
105 .sync_page = block_sync_page, 106 .sync_page = block_sync_page,
106 .prepare_write = udf_adinicb_prepare_write, 107 .prepare_write = udf_adinicb_prepare_write,
107 .commit_write = udf_adinicb_commit_write, 108 .commit_write = udf_adinicb_commit_write,
108}; 109};
109 110
110static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 111static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
@@ -122,8 +123,8 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
122 else 123 else
123 pos = ppos; 124 pos = ppos;
124 125
125 if (inode->i_sb->s_blocksize < 126 if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
126 (udf_file_entry_alloc_offset(inode) + pos + count)) { 127 pos + count)) {
127 udf_expand_file_adinicb(inode, pos + count, &err); 128 udf_expand_file_adinicb(inode, pos + count, &err);
128 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { 129 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
129 udf_debug("udf_expand_adinicb: err=%d\n", err); 130 udf_debug("udf_expand_adinicb: err=%d\n", err);
@@ -138,9 +139,9 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
138 } 139 }
139 140
140 retval = generic_file_aio_write(iocb, iov, nr_segs, ppos); 141 retval = generic_file_aio_write(iocb, iov, nr_segs, ppos);
141
142 if (retval > 0) 142 if (retval > 0)
143 mark_inode_dirty(inode); 143 mark_inode_dirty(inode);
144
144 return retval; 145 return retval;
145} 146}
146 147
@@ -181,10 +182,12 @@ static ssize_t udf_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
181int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, 182int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
182 unsigned long arg) 183 unsigned long arg)
183{ 184{
185 long old_block, new_block;
184 int result = -EINVAL; 186 int result = -EINVAL;
185 187
186 if (file_permission(filp, MAY_READ) != 0) { 188 if (file_permission(filp, MAY_READ) != 0) {
187 udf_debug("no permission to access inode %lu\n", inode->i_ino); 189 udf_debug("no permission to access inode %lu\n",
190 inode->i_ino);
188 return -EPERM; 191 return -EPERM;
189 } 192 }
190 193
@@ -196,26 +199,19 @@ int udf_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
196 switch (cmd) { 199 switch (cmd) {
197 case UDF_GETVOLIDENT: 200 case UDF_GETVOLIDENT:
198 return copy_to_user((char __user *)arg, 201 return copy_to_user((char __user *)arg,
199 UDF_SB_VOLIDENT(inode->i_sb), 202 UDF_SB_VOLIDENT(inode->i_sb), 32) ? -EFAULT : 0;
200 32) ? -EFAULT : 0;
201 case UDF_RELOCATE_BLOCKS: 203 case UDF_RELOCATE_BLOCKS:
202 { 204 if (!capable(CAP_SYS_ADMIN))
203 long old, new; 205 return -EACCES;
204 206 if (get_user(old_block, (long __user *)arg))
205 if (!capable(CAP_SYS_ADMIN)) 207 return -EFAULT;
206 return -EACCES; 208 if ((result = udf_relocate_blocks(inode->i_sb,
207 if (get_user(old, (long __user *)arg)) 209 old_block, &new_block)) == 0)
208 return -EFAULT; 210 result = put_user(new_block, (long __user *)arg);
209 if ((result = udf_relocate_blocks(inode->i_sb, 211 return result;
210 old, &new)) == 0)
211 result = put_user(new, (long __user *)arg);
212
213 return result;
214 }
215 case UDF_GETEASIZE: 212 case UDF_GETEASIZE:
216 result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg); 213 result = put_user(UDF_I_LENEATTR(inode), (int __user *)arg);
217 break; 214 break;
218
219 case UDF_GETEABLOCK: 215 case UDF_GETEABLOCK:
220 result = copy_to_user((char __user *)arg, UDF_I_DATA(inode), 216 result = copy_to_user((char __user *)arg, UDF_I_DATA(inode),
221 UDF_I_LENEATTR(inode)) ? -EFAULT : 0; 217 UDF_I_LENEATTR(inode)) ? -EFAULT : 0;
@@ -248,16 +244,16 @@ static int udf_release_file(struct inode *inode, struct file *filp)
248} 244}
249 245
250const struct file_operations udf_file_operations = { 246const struct file_operations udf_file_operations = {
251 .read = do_sync_read, 247 .read = do_sync_read,
252 .aio_read = generic_file_aio_read, 248 .aio_read = generic_file_aio_read,
253 .ioctl = udf_ioctl, 249 .ioctl = udf_ioctl,
254 .open = generic_file_open, 250 .open = generic_file_open,
255 .mmap = generic_file_mmap, 251 .mmap = generic_file_mmap,
256 .write = do_sync_write, 252 .write = do_sync_write,
257 .aio_write = udf_file_aio_write, 253 .aio_write = udf_file_aio_write,
258 .release = udf_release_file, 254 .release = udf_release_file,
259 .fsync = udf_fsync_file, 255 .fsync = udf_fsync_file,
260 .splice_read = generic_file_splice_read, 256 .splice_read = generic_file_splice_read,
261}; 257};
262 258
263const struct inode_operations udf_file_inode_operations = { 259const struct inode_operations udf_file_inode_operations = {
diff --git a/fs/udf/fsync.c b/fs/udf/fsync.c
index 7f0901c4f1f1..b2c472b733b8 100644
--- a/fs/udf/fsync.c
+++ b/fs/udf/fsync.c
@@ -32,6 +32,7 @@ static int udf_fsync_inode(struct inode *, int);
32int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync) 32int udf_fsync_file(struct file *file, struct dentry *dentry, int datasync)
33{ 33{
34 struct inode *inode = dentry->d_inode; 34 struct inode *inode = dentry->d_inode;
35
35 return udf_fsync_inode(inode, datasync); 36 return udf_fsync_inode(inode, datasync);
36} 37}
37 38
@@ -46,5 +47,6 @@ static int udf_fsync_inode(struct inode *inode, int datasync)
46 return err; 47 return err;
47 48
48 err |= udf_sync_inode(inode); 49 err |= udf_sync_inode(inode);
50
49 return err ? -EIO : 0; 51 return err ? -EIO : 0;
50} 52}
diff --git a/fs/udf/ialloc.c b/fs/udf/ialloc.c
index 2eb503806bce..636d8f613929 100644
--- a/fs/udf/ialloc.c
+++ b/fs/udf/ialloc.c
@@ -46,12 +46,10 @@ void udf_free_inode(struct inode *inode)
46 if (sbi->s_lvidbh) { 46 if (sbi->s_lvidbh) {
47 if (S_ISDIR(inode->i_mode)) 47 if (S_ISDIR(inode->i_mode))
48 UDF_SB_LVIDIU(sb)->numDirs = 48 UDF_SB_LVIDIU(sb)->numDirs =
49 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) 49 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) - 1);
50 - 1);
51 else 50 else
52 UDF_SB_LVIDIU(sb)->numFiles = 51 UDF_SB_LVIDIU(sb)->numFiles =
53 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) 52 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) - 1);
54 - 1);
55 53
56 mark_buffer_dirty(sbi->s_lvidbh); 54 mark_buffer_dirty(sbi->s_lvidbh);
57 } 55 }
@@ -82,10 +80,8 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
82 UDF_I_NEXT_ALLOC_GOAL(inode) = 0; 80 UDF_I_NEXT_ALLOC_GOAL(inode) = 0;
83 UDF_I_STRAT4096(inode) = 0; 81 UDF_I_STRAT4096(inode) = 0;
84 82
85 block = 83 block = udf_new_block(dir->i_sb, NULL, UDF_I_LOCATION(dir).partitionReferenceNum,
86 udf_new_block(dir->i_sb, NULL, 84 start, err);
87 UDF_I_LOCATION(dir).partitionReferenceNum, start,
88 err);
89 if (*err) { 85 if (*err) {
90 iput(inode); 86 iput(inode);
91 return NULL; 87 return NULL;
@@ -95,17 +91,13 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
95 if (UDF_SB_LVIDBH(sb)) { 91 if (UDF_SB_LVIDBH(sb)) {
96 struct logicalVolHeaderDesc *lvhd; 92 struct logicalVolHeaderDesc *lvhd;
97 uint64_t uniqueID; 93 uint64_t uniqueID;
98 lvhd = 94 lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->logicalVolContentsUse);
99 (struct logicalVolHeaderDesc *)(UDF_SB_LVID(sb)->
100 logicalVolContentsUse);
101 if (S_ISDIR(mode)) 95 if (S_ISDIR(mode))
102 UDF_SB_LVIDIU(sb)->numDirs = 96 UDF_SB_LVIDIU(sb)->numDirs =
103 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) 97 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs) + 1);
104 + 1);
105 else 98 else
106 UDF_SB_LVIDIU(sb)->numFiles = 99 UDF_SB_LVIDIU(sb)->numFiles =
107 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) 100 cpu_to_le32(le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1);
108 + 1);
109 UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID); 101 UDF_I_UNIQUE(inode) = uniqueID = le64_to_cpu(lvhd->uniqueID);
110 if (!(++uniqueID & 0x00000000FFFFFFFFUL)) 102 if (!(++uniqueID & 0x00000000FFFFFFFFUL))
111 uniqueID += 16; 103 uniqueID += 16;
@@ -118,12 +110,12 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
118 inode->i_gid = dir->i_gid; 110 inode->i_gid = dir->i_gid;
119 if (S_ISDIR(mode)) 111 if (S_ISDIR(mode))
120 mode |= S_ISGID; 112 mode |= S_ISGID;
121 } else 113 } else {
122 inode->i_gid = current->fsgid; 114 inode->i_gid = current->fsgid;
115 }
123 116
124 UDF_I_LOCATION(inode).logicalBlockNum = block; 117 UDF_I_LOCATION(inode).logicalBlockNum = block;
125 UDF_I_LOCATION(inode).partitionReferenceNum = 118 UDF_I_LOCATION(inode).partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
126 UDF_I_LOCATION(dir).partitionReferenceNum;
127 inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0); 119 inode->i_ino = udf_get_lb_pblock(sb, UDF_I_LOCATION(inode), 0);
128 inode->i_blocks = 0; 120 inode->i_blocks = 0;
129 UDF_I_LENEATTR(inode) = 0; 121 UDF_I_LENEATTR(inode) = 0;
@@ -132,14 +124,10 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
132 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) { 124 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_USE_EXTENDED_FE)) {
133 UDF_I_EFE(inode) = 1; 125 UDF_I_EFE(inode) = 1;
134 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE); 126 UDF_UPDATE_UDFREV(inode->i_sb, UDF_VERS_USE_EXTENDED_FE);
135 UDF_I_DATA(inode) = 127 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry), GFP_KERNEL);
136 kzalloc(inode->i_sb->s_blocksize -
137 sizeof(struct extendedFileEntry), GFP_KERNEL);
138 } else { 128 } else {
139 UDF_I_EFE(inode) = 0; 129 UDF_I_EFE(inode) = 0;
140 UDF_I_DATA(inode) = 130 UDF_I_DATA(inode) = kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry), GFP_KERNEL);
141 kzalloc(inode->i_sb->s_blocksize - sizeof(struct fileEntry),
142 GFP_KERNEL);
143 } 131 }
144 if (!UDF_I_DATA(inode)) { 132 if (!UDF_I_DATA(inode)) {
145 iput(inode); 133 iput(inode);
@@ -154,7 +142,7 @@ struct inode *udf_new_inode(struct inode *dir, int mode, int *err)
154 else 142 else
155 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG; 143 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_LONG;
156 inode->i_mtime = inode->i_atime = inode->i_ctime = 144 inode->i_mtime = inode->i_atime = inode->i_ctime =
157 UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb); 145 UDF_I_CRTIME(inode) = current_fs_time(inode->i_sb);
158 insert_inode_hash(inode); 146 insert_inode_hash(inode);
159 mark_inode_dirty(inode); 147 mark_inode_dirty(inode);
160 mutex_unlock(&sbi->s_alloc_mutex); 148 mutex_unlock(&sbi->s_alloc_mutex);
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index be6326f449a1..0d2c41666cd2 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -97,7 +97,8 @@ void udf_delete_inode(struct inode *inode)
97 97
98 unlock_kernel(); 98 unlock_kernel();
99 return; 99 return;
100 no_delete: 100
101no_delete:
101 clear_inode(inode); 102 clear_inode(inode);
102} 103}
103 104
@@ -144,12 +145,12 @@ static sector_t udf_bmap(struct address_space *mapping, sector_t block)
144} 145}
145 146
146const struct address_space_operations udf_aops = { 147const struct address_space_operations udf_aops = {
147 .readpage = udf_readpage, 148 .readpage = udf_readpage,
148 .writepage = udf_writepage, 149 .writepage = udf_writepage,
149 .sync_page = block_sync_page, 150 .sync_page = block_sync_page,
150 .prepare_write = udf_prepare_write, 151 .prepare_write = udf_prepare_write,
151 .commit_write = generic_commit_write, 152 .commit_write = generic_commit_write,
152 .bmap = udf_bmap, 153 .bmap = udf_bmap,
153}; 154};
154 155
155void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err) 156void udf_expand_file_adinicb(struct inode *inode, int newsize, int *err)
@@ -230,12 +231,10 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
230 *block = udf_new_block(inode->i_sb, inode, 231 *block = udf_new_block(inode->i_sb, inode,
231 UDF_I_LOCATION(inode).partitionReferenceNum, 232 UDF_I_LOCATION(inode).partitionReferenceNum,
232 UDF_I_LOCATION(inode).logicalBlockNum, err); 233 UDF_I_LOCATION(inode).logicalBlockNum, err);
233
234 if (!(*block)) 234 if (!(*block))
235 return NULL; 235 return NULL;
236 newblock = udf_get_pblock(inode->i_sb, *block, 236 newblock = udf_get_pblock(inode->i_sb, *block,
237 UDF_I_LOCATION(inode).partitionReferenceNum, 237 UDF_I_LOCATION(inode).partitionReferenceNum, 0);
238 0);
239 if (!newblock) 238 if (!newblock)
240 return NULL; 239 return NULL;
241 dbh = udf_tgetblk(inode->i_sb, newblock); 240 dbh = udf_tgetblk(inode->i_sb, newblock);
@@ -247,16 +246,13 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
247 unlock_buffer(dbh); 246 unlock_buffer(dbh);
248 mark_buffer_dirty_inode(dbh, inode); 247 mark_buffer_dirty_inode(dbh, inode);
249 248
250 sfibh.soffset = sfibh.eoffset = 249 sfibh.soffset = sfibh.eoffset = (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2;
251 (f_pos & ((inode->i_sb->s_blocksize - 1) >> 2)) << 2;
252 sfibh.sbh = sfibh.ebh = NULL; 250 sfibh.sbh = sfibh.ebh = NULL;
253 dfibh.soffset = dfibh.eoffset = 0; 251 dfibh.soffset = dfibh.eoffset = 0;
254 dfibh.sbh = dfibh.ebh = dbh; 252 dfibh.sbh = dfibh.ebh = dbh;
255 while ((f_pos < size)) { 253 while ((f_pos < size)) {
256 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; 254 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
257 sfi = 255 sfi = udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL, NULL, NULL);
258 udf_fileident_read(inode, &f_pos, &sfibh, &cfi, NULL, NULL,
259 NULL, NULL);
260 if (!sfi) { 256 if (!sfi) {
261 brelse(dbh); 257 brelse(dbh);
262 return NULL; 258 return NULL;
@@ -267,8 +263,7 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
267 dfibh.eoffset += (sfibh.eoffset - sfibh.soffset); 263 dfibh.eoffset += (sfibh.eoffset - sfibh.soffset);
268 dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset); 264 dfi = (struct fileIdentDesc *)(dbh->b_data + dfibh.soffset);
269 if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse, 265 if (udf_write_fi(inode, sfi, dfi, &dfibh, sfi->impUse,
270 sfi->fileIdent + 266 sfi->fileIdent + le16_to_cpu(sfi->lengthOfImpUse))) {
271 le16_to_cpu(sfi->lengthOfImpUse))) {
272 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB; 267 UDF_I_ALLOCTYPE(inode) = ICBTAG_FLAG_AD_IN_ICB;
273 brelse(dbh); 268 brelse(dbh);
274 return NULL; 269 return NULL;
@@ -276,12 +271,10 @@ struct buffer_head *udf_expand_dir_adinicb(struct inode *inode, int *block,
276 } 271 }
277 mark_buffer_dirty_inode(dbh, inode); 272 mark_buffer_dirty_inode(dbh, inode);
278 273
279 memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, 274 memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode), 0, UDF_I_LENALLOC(inode));
280 UDF_I_LENALLOC(inode));
281 UDF_I_LENALLOC(inode) = 0; 275 UDF_I_LENALLOC(inode) = 0;
282 eloc.logicalBlockNum = *block; 276 eloc.logicalBlockNum = *block;
283 eloc.partitionReferenceNum = 277 eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
284 UDF_I_LOCATION(inode).partitionReferenceNum;
285 elen = inode->i_size; 278 elen = inode->i_size;
286 UDF_I_LENEXTENTS(inode) = elen; 279 UDF_I_LENEXTENTS(inode) = elen;
287 epos.bh = NULL; 280 epos.bh = NULL;
@@ -334,11 +327,12 @@ static int udf_get_block(struct inode *inode, sector_t block,
334 if (new) 327 if (new)
335 set_buffer_new(bh_result); 328 set_buffer_new(bh_result);
336 map_bh(bh_result, inode->i_sb, phys); 329 map_bh(bh_result, inode->i_sb, phys);
337 abort: 330
331abort:
338 unlock_kernel(); 332 unlock_kernel();
339 return err; 333 return err;
340 334
341 abort_negative: 335abort_negative:
342 udf_warning(inode->i_sb, "udf_get_block", "block < 0"); 336 udf_warning(inode->i_sb, "udf_get_block", "block < 0");
343 goto abort; 337 goto abort;
344} 338}
@@ -346,13 +340,13 @@ static int udf_get_block(struct inode *inode, sector_t block,
346static struct buffer_head *udf_getblk(struct inode *inode, long block, 340static struct buffer_head *udf_getblk(struct inode *inode, long block,
347 int create, int *err) 341 int create, int *err)
348{ 342{
343 struct buffer_head *bh;
349 struct buffer_head dummy; 344 struct buffer_head dummy;
350 345
351 dummy.b_state = 0; 346 dummy.b_state = 0;
352 dummy.b_blocknr = -1000; 347 dummy.b_blocknr = -1000;
353 *err = udf_get_block(inode, block, &dummy, create); 348 *err = udf_get_block(inode, block, &dummy, create);
354 if (!*err && buffer_mapped(&dummy)) { 349 if (!*err && buffer_mapped(&dummy)) {
355 struct buffer_head *bh;
356 bh = sb_getblk(inode->i_sb, dummy.b_blocknr); 350 bh = sb_getblk(inode->i_sb, dummy.b_blocknr);
357 if (buffer_new(&dummy)) { 351 if (buffer_new(&dummy)) {
358 lock_buffer(bh); 352 lock_buffer(bh);
@@ -363,6 +357,7 @@ static struct buffer_head *udf_getblk(struct inode *inode, long block,
363 } 357 }
364 return bh; 358 return bh;
365 } 359 }
360
366 return NULL; 361 return NULL;
367} 362}
368 363
@@ -373,42 +368,41 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
373 sector_t add; 368 sector_t add;
374 int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK); 369 int count = 0, fake = !(last_ext->extLength & UDF_EXTENT_LENGTH_MASK);
375 struct super_block *sb = inode->i_sb; 370 struct super_block *sb = inode->i_sb;
376 kernel_lb_addr prealloc_loc = { 0, 0 }; 371 kernel_lb_addr prealloc_loc = {};
377 int prealloc_len = 0; 372 int prealloc_len = 0;
378 373
379 /* The previous extent is fake and we should not extend by anything 374 /* The previous extent is fake and we should not extend by anything
380 * - there's nothing to do... */ 375 * - there's nothing to do... */
381 if (!blocks && fake) 376 if (!blocks && fake)
382 return 0; 377 return 0;
378
383 /* Round the last extent up to a multiple of block size */ 379 /* Round the last extent up to a multiple of block size */
384 if (last_ext->extLength & (sb->s_blocksize - 1)) { 380 if (last_ext->extLength & (sb->s_blocksize - 1)) {
385 last_ext->extLength = 381 last_ext->extLength =
386 (last_ext->extLength & UDF_EXTENT_FLAG_MASK) | 382 (last_ext->extLength & UDF_EXTENT_FLAG_MASK) |
387 (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) + 383 (((last_ext->extLength & UDF_EXTENT_LENGTH_MASK) +
388 sb->s_blocksize - 1) & ~(sb->s_blocksize - 1)); 384 sb->s_blocksize - 1) & ~(sb->s_blocksize - 1));
389 UDF_I_LENEXTENTS(inode) = 385 UDF_I_LENEXTENTS(inode) =
390 (UDF_I_LENEXTENTS(inode) + sb->s_blocksize - 1) & 386 (UDF_I_LENEXTENTS(inode) + sb->s_blocksize - 1) &
391 ~(sb->s_blocksize - 1); 387 ~(sb->s_blocksize - 1);
392 } 388 }
389
393 /* Last extent are just preallocated blocks? */ 390 /* Last extent are just preallocated blocks? */
394 if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == 391 if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_ALLOCATED) {
395 EXT_NOT_RECORDED_ALLOCATED) {
396 /* Save the extent so that we can reattach it to the end */ 392 /* Save the extent so that we can reattach it to the end */
397 prealloc_loc = last_ext->extLocation; 393 prealloc_loc = last_ext->extLocation;
398 prealloc_len = last_ext->extLength; 394 prealloc_len = last_ext->extLength;
399 /* Mark the extent as a hole */ 395 /* Mark the extent as a hole */
400 last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | 396 last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED |
401 (last_ext->extLength & UDF_EXTENT_LENGTH_MASK); 397 (last_ext->extLength & UDF_EXTENT_LENGTH_MASK);
402 last_ext->extLocation.logicalBlockNum = 0; 398 last_ext->extLocation.logicalBlockNum = 0;
403 last_ext->extLocation.partitionReferenceNum = 0; 399 last_ext->extLocation.partitionReferenceNum = 0;
404 } 400 }
401
405 /* Can we merge with the previous extent? */ 402 /* Can we merge with the previous extent? */
406 if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == 403 if ((last_ext->extLength & UDF_EXTENT_FLAG_MASK) == EXT_NOT_RECORDED_NOT_ALLOCATED) {
407 EXT_NOT_RECORDED_NOT_ALLOCATED) { 404 add = ((1 << 30) - sb->s_blocksize - (last_ext->extLength &
408 add = 405 UDF_EXTENT_LENGTH_MASK)) >> sb->s_blocksize_bits;
409 ((1 << 30) - sb->s_blocksize -
410 (last_ext->extLength & UDF_EXTENT_LENGTH_MASK)) >> sb->
411 s_blocksize_bits;
412 if (add > blocks) 406 if (add > blocks)
413 add = blocks; 407 add = blocks;
414 blocks -= add; 408 blocks -= add;
@@ -419,19 +413,20 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
419 udf_add_aext(inode, last_pos, last_ext->extLocation, 413 udf_add_aext(inode, last_pos, last_ext->extLocation,
420 last_ext->extLength, 1); 414 last_ext->extLength, 1);
421 count++; 415 count++;
422 } else 416 } else {
423 udf_write_aext(inode, last_pos, last_ext->extLocation, 417 udf_write_aext(inode, last_pos, last_ext->extLocation, last_ext->extLength, 1);
424 last_ext->extLength, 1); 418 }
419
425 /* Managed to do everything necessary? */ 420 /* Managed to do everything necessary? */
426 if (!blocks) 421 if (!blocks)
427 goto out; 422 goto out;
428 423
429 /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */ 424 /* All further extents will be NOT_RECORDED_NOT_ALLOCATED */
430 last_ext->extLocation.logicalBlockNum = 0; 425 last_ext->extLocation.logicalBlockNum = 0;
431 last_ext->extLocation.partitionReferenceNum = 0; 426 last_ext->extLocation.partitionReferenceNum = 0;
432 add = (1 << (30 - sb->s_blocksize_bits)) - 1; 427 add = (1 << (30-sb->s_blocksize_bits)) - 1;
433 last_ext->extLength = 428 last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | (add << sb->s_blocksize_bits);
434 EXT_NOT_RECORDED_NOT_ALLOCATED | (add << sb->s_blocksize_bits); 429
435 /* Create enough extents to cover the whole hole */ 430 /* Create enough extents to cover the whole hole */
436 while (blocks > add) { 431 while (blocks > add) {
437 blocks -= add; 432 blocks -= add;
@@ -442,22 +437,23 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
442 } 437 }
443 if (blocks) { 438 if (blocks) {
444 last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | 439 last_ext->extLength = EXT_NOT_RECORDED_NOT_ALLOCATED |
445 (blocks << sb->s_blocksize_bits); 440 (blocks << sb->s_blocksize_bits);
446 if (udf_add_aext(inode, last_pos, last_ext->extLocation, 441 if (udf_add_aext(inode, last_pos, last_ext->extLocation,
447 last_ext->extLength, 1) == -1) 442 last_ext->extLength, 1) == -1)
448 return -1; 443 return -1;
449 count++; 444 count++;
450 } 445 }
451 out: 446
447out:
452 /* Do we have some preallocated blocks saved? */ 448 /* Do we have some preallocated blocks saved? */
453 if (prealloc_len) { 449 if (prealloc_len) {
454 if (udf_add_aext(inode, last_pos, prealloc_loc, prealloc_len, 1) 450 if (udf_add_aext(inode, last_pos, prealloc_loc, prealloc_len, 1) == -1)
455 == -1)
456 return -1; 451 return -1;
457 last_ext->extLocation = prealloc_loc; 452 last_ext->extLocation = prealloc_loc;
458 last_ext->extLength = prealloc_len; 453 last_ext->extLength = prealloc_len;
459 count++; 454 count++;
460 } 455 }
456
461 /* last_pos should point to the last written extent... */ 457 /* last_pos should point to the last written extent... */
462 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT) 458 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_SHORT)
463 last_pos->offset -= sizeof(short_ad); 459 last_pos->offset -= sizeof(short_ad);
@@ -465,6 +461,7 @@ int udf_extend_file(struct inode *inode, struct extent_position *last_pos,
465 last_pos->offset -= sizeof(long_ad); 461 last_pos->offset -= sizeof(long_ad);
466 else 462 else
467 return -1; 463 return -1;
464
468 return count; 465 return count;
469} 466}
470 467
@@ -490,7 +487,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
490 prev_epos.block = UDF_I_LOCATION(inode); 487 prev_epos.block = UDF_I_LOCATION(inode);
491 prev_epos.bh = NULL; 488 prev_epos.bh = NULL;
492 cur_epos = next_epos = prev_epos; 489 cur_epos = next_epos = prev_epos;
493 b_off = (loff_t) block << inode->i_sb->s_blocksize_bits; 490 b_off = (loff_t)block << inode->i_sb->s_blocksize_bits;
494 491
495 /* find the extent which contains the block we are looking for. 492 /* find the extent which contains the block we are looking for.
496 alternate between laarr[0] and laarr[1] for locations of the 493 alternate between laarr[0] and laarr[1] for locations of the
@@ -515,8 +512,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
515 prev_epos.offset = cur_epos.offset; 512 prev_epos.offset = cur_epos.offset;
516 cur_epos.offset = next_epos.offset; 513 cur_epos.offset = next_epos.offset;
517 514
518 if ((etype = 515 if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1)
519 udf_next_aext(inode, &next_epos, &eloc, &elen, 1)) == -1)
520 break; 516 break;
521 517
522 c = !c; 518 c = !c;
@@ -526,8 +522,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
526 522
527 if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) 523 if (etype != (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
528 pgoal = eloc.logicalBlockNum + 524 pgoal = eloc.logicalBlockNum +
529 ((elen + inode->i_sb->s_blocksize - 1) >> 525 ((elen + inode->i_sb->s_blocksize - 1) >>
530 inode->i_sb->s_blocksize_bits); 526 inode->i_sb->s_blocksize_bits);
531 527
532 count++; 528 count++;
533 } while (lbcount + elen <= b_off); 529 } while (lbcount + elen <= b_off);
@@ -547,8 +543,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
547 if (etype == (EXT_RECORDED_ALLOCATED >> 30)) { 543 if (etype == (EXT_RECORDED_ALLOCATED >> 30)) {
548 if (elen & (inode->i_sb->s_blocksize - 1)) { 544 if (elen & (inode->i_sb->s_blocksize - 1)) {
549 elen = EXT_RECORDED_ALLOCATED | 545 elen = EXT_RECORDED_ALLOCATED |
550 ((elen + inode->i_sb->s_blocksize - 1) & 546 ((elen + inode->i_sb->s_blocksize - 1) &
551 ~(inode->i_sb->s_blocksize - 1)); 547 ~(inode->i_sb->s_blocksize - 1));
552 etype = udf_write_aext(inode, &cur_epos, eloc, elen, 1); 548 etype = udf_write_aext(inode, &cur_epos, eloc, elen, 1);
553 } 549 }
554 brelse(prev_epos.bh); 550 brelse(prev_epos.bh);
@@ -570,8 +566,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
570 startnum = 1; 566 startnum = 1;
571 } else { 567 } else {
572 /* Create a fake extent when there's not one */ 568 /* Create a fake extent when there's not one */
573 memset(&laarr[0].extLocation, 0x00, 569 memset(&laarr[0].extLocation, 0x00, sizeof(kernel_lb_addr));
574 sizeof(kernel_lb_addr));
575 laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; 570 laarr[0].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED;
576 /* Will udf_extend_file() create real extent from a fake one? */ 571 /* Will udf_extend_file() create real extent from a fake one? */
577 startnum = (offset > 0); 572 startnum = (offset > 0);
@@ -591,16 +586,14 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
591 offset = 0; 586 offset = 0;
592 count += ret; 587 count += ret;
593 /* We are not covered by a preallocated extent? */ 588 /* We are not covered by a preallocated extent? */
594 if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != 589 if ((laarr[0].extLength & UDF_EXTENT_FLAG_MASK) != EXT_NOT_RECORDED_ALLOCATED) {
595 EXT_NOT_RECORDED_ALLOCATED) {
596 /* Is there any real extent? - otherwise we overwrite 590 /* Is there any real extent? - otherwise we overwrite
597 * the fake one... */ 591 * the fake one... */
598 if (count) 592 if (count)
599 c = !c; 593 c = !c;
600 laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED | 594 laarr[c].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED |
601 inode->i_sb->s_blocksize; 595 inode->i_sb->s_blocksize;
602 memset(&laarr[c].extLocation, 0x00, 596 memset(&laarr[c].extLocation, 0x00, sizeof(kernel_lb_addr));
603 sizeof(kernel_lb_addr));
604 count++; 597 count++;
605 endnum++; 598 endnum++;
606 } 599 }
@@ -618,8 +611,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
618 } 611 }
619 612
620 /* if the current block is located in an extent, read the next extent */ 613 /* if the current block is located in an extent, read the next extent */
621 if ((etype = 614 if ((etype = udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1) {
622 udf_next_aext(inode, &next_epos, &eloc, &elen, 0)) != -1) {
623 laarr[c + 1].extLength = (etype << 30) | elen; 615 laarr[c + 1].extLength = (etype << 30) | elen;
624 laarr[c + 1].extLocation = eloc; 616 laarr[c + 1].extLocation = eloc;
625 count++; 617 count++;
@@ -631,24 +623,21 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
631 } 623 }
632 624
633 /* if the current extent is not recorded but allocated, get the 625 /* if the current extent is not recorded but allocated, get the
634 block in the extent corresponding to the requested block */ 626 * block in the extent corresponding to the requested block */
635 if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) 627 if ((laarr[c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
636 newblocknum = laarr[c].extLocation.logicalBlockNum + offset; 628 newblocknum = laarr[c].extLocation.logicalBlockNum + offset;
637 else { /* otherwise, allocate a new block */ 629 } else { /* otherwise, allocate a new block */
638
639 if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block) 630 if (UDF_I_NEXT_ALLOC_BLOCK(inode) == block)
640 goal = UDF_I_NEXT_ALLOC_GOAL(inode); 631 goal = UDF_I_NEXT_ALLOC_GOAL(inode);
641 632
642 if (!goal) { 633 if (!goal) {
643 if (!(goal = pgoal)) 634 if (!(goal = pgoal))
644 goal = 635 goal = UDF_I_LOCATION(inode).logicalBlockNum + 1;
645 UDF_I_LOCATION(inode).logicalBlockNum + 1;
646 } 636 }
647 637
648 if (!(newblocknum = udf_new_block(inode->i_sb, inode, 638 if (!(newblocknum = udf_new_block(inode->i_sb, inode,
649 UDF_I_LOCATION(inode). 639 UDF_I_LOCATION(inode).partitionReferenceNum,
650 partitionReferenceNum, goal, 640 goal, err))) {
651 err))) {
652 brelse(prev_epos.bh); 641 brelse(prev_epos.bh);
653 *err = -ENOSPC; 642 *err = -ENOSPC;
654 return NULL; 643 return NULL;
@@ -657,8 +646,8 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
657 } 646 }
658 647
659 /* if the extent the requsted block is located in contains multiple blocks, 648 /* if the extent the requsted block is located in contains multiple blocks,
660 split the extent into at most three extents. blocks prior to requested 649 * split the extent into at most three extents. blocks prior to requested
661 block, requested block, and blocks after requested block */ 650 * block, requested block, and blocks after requested block */
662 udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum); 651 udf_split_extents(inode, &c, offset, newblocknum, laarr, &endnum);
663 652
664#ifdef UDF_PREALLOCATE 653#ifdef UDF_PREALLOCATE
@@ -670,15 +659,14 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
670 udf_merge_extents(inode, laarr, &endnum); 659 udf_merge_extents(inode, laarr, &endnum);
671 660
672 /* write back the new extents, inserting new extents if the new number 661 /* write back the new extents, inserting new extents if the new number
673 of extents is greater than the old number, and deleting extents if 662 * of extents is greater than the old number, and deleting extents if
674 the new number of extents is less than the old number */ 663 * the new number of extents is less than the old number */
675 udf_update_extents(inode, laarr, startnum, endnum, &prev_epos); 664 udf_update_extents(inode, laarr, startnum, endnum, &prev_epos);
676 665
677 brelse(prev_epos.bh); 666 brelse(prev_epos.bh);
678 667
679 if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum, 668 if (!(newblock = udf_get_pblock(inode->i_sb, newblocknum,
680 UDF_I_LOCATION(inode). 669 UDF_I_LOCATION(inode).partitionReferenceNum, 0))) {
681 partitionReferenceNum, 0))) {
682 return NULL; 670 return NULL;
683 } 671 }
684 *phys = newblock; 672 *phys = newblock;
@@ -692,6 +680,7 @@ static struct buffer_head *inode_getblk(struct inode *inode, sector_t block,
692 udf_sync_inode(inode); 680 udf_sync_inode(inode);
693 else 681 else
694 mark_inode_dirty(inode); 682 mark_inode_dirty(inode);
683
695 return result; 684 return result;
696} 685}
697 686
@@ -701,16 +690,15 @@ static void udf_split_extents(struct inode *inode, int *c, int offset,
701 int *endnum) 690 int *endnum)
702{ 691{
703 if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) || 692 if ((laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30) ||
704 (laarr[*c].extLength >> 30) == 693 (laarr[*c].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) {
705 (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) {
706 int curr = *c; 694 int curr = *c;
707 int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) + 695 int blen = ((laarr[curr].extLength & UDF_EXTENT_LENGTH_MASK) +
708 inode->i_sb->s_blocksize - 696 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
709 1) >> inode->i_sb->s_blocksize_bits;
710 int8_t etype = (laarr[curr].extLength >> 30); 697 int8_t etype = (laarr[curr].extLength >> 30);
711 698
712 if (blen == 1) ; 699 if (blen == 1) {
713 else if (!offset || blen == offset + 1) { 700 ;
701 } else if (!offset || blen == offset + 1) {
714 laarr[curr + 2] = laarr[curr + 1]; 702 laarr[curr + 2] = laarr[curr + 1];
715 laarr[curr + 1] = laarr[curr]; 703 laarr[curr + 1] = laarr[curr];
716 } else { 704 } else {
@@ -720,20 +708,15 @@ static void udf_split_extents(struct inode *inode, int *c, int offset,
720 708
721 if (offset) { 709 if (offset) {
722 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { 710 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
723 udf_free_blocks(inode->i_sb, inode, 711 udf_free_blocks(inode->i_sb, inode, laarr[curr].extLocation, 0, offset);
724 laarr[curr].extLocation, 0, 712 laarr[curr].extLength = EXT_NOT_RECORDED_NOT_ALLOCATED |
725 offset); 713 (offset << inode->i_sb->s_blocksize_bits);
726 laarr[curr].extLength =
727 EXT_NOT_RECORDED_NOT_ALLOCATED | (offset <<
728 inode->
729 i_sb->
730 s_blocksize_bits);
731 laarr[curr].extLocation.logicalBlockNum = 0; 714 laarr[curr].extLocation.logicalBlockNum = 0;
732 laarr[curr].extLocation.partitionReferenceNum = 715 laarr[curr].extLocation.partitionReferenceNum = 0;
733 0; 716 } else {
734 } else
735 laarr[curr].extLength = (etype << 30) | 717 laarr[curr].extLength = (etype << 30) |
736 (offset << inode->i_sb->s_blocksize_bits); 718 (offset << inode->i_sb->s_blocksize_bits);
719 }
737 curr++; 720 curr++;
738 (*c)++; 721 (*c)++;
739 (*endnum)++; 722 (*endnum)++;
@@ -742,18 +725,16 @@ static void udf_split_extents(struct inode *inode, int *c, int offset,
742 laarr[curr].extLocation.logicalBlockNum = newblocknum; 725 laarr[curr].extLocation.logicalBlockNum = newblocknum;
743 if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) 726 if (etype == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
744 laarr[curr].extLocation.partitionReferenceNum = 727 laarr[curr].extLocation.partitionReferenceNum =
745 UDF_I_LOCATION(inode).partitionReferenceNum; 728 UDF_I_LOCATION(inode).partitionReferenceNum;
746 laarr[curr].extLength = EXT_RECORDED_ALLOCATED | 729 laarr[curr].extLength = EXT_RECORDED_ALLOCATED |
747 inode->i_sb->s_blocksize; 730 inode->i_sb->s_blocksize;
748 curr++; 731 curr++;
749 732
750 if (blen != offset + 1) { 733 if (blen != offset + 1) {
751 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) 734 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30))
752 laarr[curr].extLocation.logicalBlockNum += 735 laarr[curr].extLocation.logicalBlockNum += (offset + 1);
753 (offset + 1); 736 laarr[curr].extLength = (etype << 30) |
754 laarr[curr].extLength = 737 ((blen - (offset + 1)) << inode->i_sb->s_blocksize_bits);
755 (etype << 30) | ((blen - (offset + 1)) << inode->
756 i_sb->s_blocksize_bits);
757 curr++; 738 curr++;
758 (*endnum)++; 739 (*endnum)++;
759 } 740 }
@@ -772,90 +753,69 @@ static void udf_prealloc_extents(struct inode *inode, int c, int lastblock,
772 else 753 else
773 start = c; 754 start = c;
774 } else { 755 } else {
775 if ((laarr[c + 1].extLength >> 30) == 756 if ((laarr[c + 1].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
776 (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
777 start = c + 1; 757 start = c + 1;
778 length = currlength = 758 length = currlength = (((laarr[c + 1].extLength & UDF_EXTENT_LENGTH_MASK) +
779 (((laarr[c + 1]. 759 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits);
780 extLength & UDF_EXTENT_LENGTH_MASK) + 760 } else {
781 inode->i_sb->s_blocksize -
782 1) >> inode->i_sb->s_blocksize_bits);
783 } else
784 start = c; 761 start = c;
762 }
785 } 763 }
786 764
787 for (i = start + 1; i <= *endnum; i++) { 765 for (i = start + 1; i <= *endnum; i++) {
788 if (i == *endnum) { 766 if (i == *endnum) {
789 if (lastblock) 767 if (lastblock)
790 length += UDF_DEFAULT_PREALLOC_BLOCKS; 768 length += UDF_DEFAULT_PREALLOC_BLOCKS;
791 } else if ((laarr[i].extLength >> 30) == 769 } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) {
792 (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) 770 length += (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
793 length += 771 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits);
794 (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + 772 } else {
795 inode->i_sb->s_blocksize -
796 1) >> inode->i_sb->s_blocksize_bits);
797 else
798 break; 773 break;
774 }
799 } 775 }
800 776
801 if (length) { 777 if (length) {
802 int next = laarr[start].extLocation.logicalBlockNum + 778 int next = laarr[start].extLocation.logicalBlockNum +
803 (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) + 779 (((laarr[start].extLength & UDF_EXTENT_LENGTH_MASK) +
804 inode->i_sb->s_blocksize - 780 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits);
805 1) >> inode->i_sb->s_blocksize_bits);
806 int numalloc = udf_prealloc_blocks(inode->i_sb, inode, 781 int numalloc = udf_prealloc_blocks(inode->i_sb, inode,
807 laarr[start].extLocation. 782 laarr[start].extLocation.partitionReferenceNum,
808 partitionReferenceNum, 783 next, (UDF_DEFAULT_PREALLOC_BLOCKS > length ? length :
809 next, 784 UDF_DEFAULT_PREALLOC_BLOCKS) - currlength);
810 (UDF_DEFAULT_PREALLOC_BLOCKS 785 if (numalloc) {
811 > 786 if (start == (c + 1)) {
812 length ? length :
813 UDF_DEFAULT_PREALLOC_BLOCKS)
814 - currlength);
815
816 if (numalloc) {
817 if (start == (c + 1))
818 laarr[start].extLength += 787 laarr[start].extLength +=
819 (numalloc << inode->i_sb->s_blocksize_bits); 788 (numalloc << inode->i_sb->s_blocksize_bits);
820 else { 789 } else {
821 memmove(&laarr[c + 2], &laarr[c + 1], 790 memmove(&laarr[c + 2], &laarr[c + 1],
822 sizeof(long_ad) * (*endnum - (c + 1))); 791 sizeof(long_ad) * (*endnum - (c + 1)));
823 (*endnum)++; 792 (*endnum)++;
824 laarr[c + 1].extLocation.logicalBlockNum = next; 793 laarr[c + 1].extLocation.logicalBlockNum = next;
825 laarr[c + 1].extLocation.partitionReferenceNum = 794 laarr[c + 1].extLocation.partitionReferenceNum =
826 laarr[c].extLocation.partitionReferenceNum; 795 laarr[c].extLocation.partitionReferenceNum;
827 laarr[c + 1].extLength = 796 laarr[c + 1].extLength = EXT_NOT_RECORDED_ALLOCATED |
828 EXT_NOT_RECORDED_ALLOCATED | (numalloc << 797 (numalloc << inode->i_sb->s_blocksize_bits);
829 inode->i_sb->
830 s_blocksize_bits);
831 start = c + 1; 798 start = c + 1;
832 } 799 }
833 800
834 for (i = start + 1; numalloc && i < *endnum; i++) { 801 for (i = start + 1; numalloc && i < *endnum; i++) {
835 int elen = 802 int elen = ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
836 ((laarr[i]. 803 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits;
837 extLength & UDF_EXTENT_LENGTH_MASK) +
838 inode->i_sb->s_blocksize -
839 1) >> inode->i_sb->s_blocksize_bits;
840 804
841 if (elen > numalloc) { 805 if (elen > numalloc) {
842 laarr[i].extLength -= 806 laarr[i].extLength -=
843 (numalloc << inode->i_sb-> 807 (numalloc << inode->i_sb->s_blocksize_bits);
844 s_blocksize_bits);
845 numalloc = 0; 808 numalloc = 0;
846 } else { 809 } else {
847 numalloc -= elen; 810 numalloc -= elen;
848 if (*endnum > (i + 1)) 811 if (*endnum > (i + 1))
849 memmove(&laarr[i], 812 memmove(&laarr[i], &laarr[i + 1],
850 &laarr[i + 1], 813 sizeof(long_ad) * (*endnum - (i + 1)));
851 sizeof(long_ad) *
852 (*endnum - (i + 1)));
853 i--; 814 i--;
854 (*endnum)--; 815 (*endnum)--;
855 } 816 }
856 } 817 }
857 UDF_I_LENEXTENTS(inode) += 818 UDF_I_LENEXTENTS(inode) += numalloc << inode->i_sb->s_blocksize_bits;
858 numalloc << inode->i_sb->s_blocksize_bits;
859 } 819 }
860 } 820 }
861} 821}
@@ -867,119 +827,68 @@ static void udf_merge_extents(struct inode *inode,
867 int i; 827 int i;
868 828
869 for (i = 0; i < (*endnum - 1); i++) { 829 for (i = 0; i < (*endnum - 1); i++) {
870 if ((laarr[i].extLength >> 30) == 830 if ((laarr[i].extLength >> 30) == (laarr[i + 1].extLength >> 30)) {
871 (laarr[i + 1].extLength >> 30)) { 831 if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30)) ||
872 if (((laarr[i].extLength >> 30) == 832 ((laarr[i + 1].extLocation.logicalBlockNum - laarr[i].extLocation.logicalBlockNum) ==
873 (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))
874 ||
875 ((laarr[i + 1].extLocation.logicalBlockNum -
876 laarr[i].extLocation.logicalBlockNum) ==
877 (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + 833 (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
878 inode->i_sb->s_blocksize - 834 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits))) {
879 1) >> inode->i_sb->s_blocksize_bits))) { 835 if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
880 if (((laarr[i]. 836 (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) +
881 extLength & UDF_EXTENT_LENGTH_MASK) + 837 inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) {
882 (laarr[i + 1]. 838 laarr[i + 1].extLength = (laarr[i + 1].extLength -
883 extLength & UDF_EXTENT_LENGTH_MASK) + 839 (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
884 inode->i_sb->s_blocksize - 840 UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1);
885 1) & ~UDF_EXTENT_LENGTH_MASK) { 841 laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) +
886 laarr[i + 1].extLength = 842 (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize;
887 (laarr[i + 1].extLength - 843 laarr[i + 1].extLocation.logicalBlockNum =
888 (laarr[i]. 844 laarr[i].extLocation.logicalBlockNum +
889 extLength & 845 ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) >>
890 UDF_EXTENT_LENGTH_MASK) + 846 inode->i_sb->s_blocksize_bits);
891 UDF_EXTENT_LENGTH_MASK) & ~(inode->
892 i_sb->
893 s_blocksize
894 - 1);
895 laarr[i].extLength =
896 (laarr[i].
897 extLength & UDF_EXTENT_FLAG_MASK) +
898 (UDF_EXTENT_LENGTH_MASK + 1) -
899 inode->i_sb->s_blocksize;
900 laarr[i +
901 1].extLocation.logicalBlockNum =
902 laarr[i].extLocation.
903 logicalBlockNum +
904 ((laarr[i].
905 extLength &
906 UDF_EXTENT_LENGTH_MASK) >> inode->
907 i_sb->s_blocksize_bits);
908 } else { 847 } else {
909 laarr[i].extLength = 848 laarr[i].extLength = laarr[i + 1].extLength +
910 laarr[i + 1].extLength + 849 (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
911 (((laarr[i]. 850 inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1));
912 extLength &
913 UDF_EXTENT_LENGTH_MASK) +
914 inode->i_sb->s_blocksize -
915 1) & ~(inode->i_sb->s_blocksize -
916 1));
917 if (*endnum > (i + 2)) 851 if (*endnum > (i + 2))
918 memmove(&laarr[i + 1], 852 memmove(&laarr[i + 1], &laarr[i + 2],
919 &laarr[i + 2], 853 sizeof(long_ad) * (*endnum - (i + 2)));
920 sizeof(long_ad) *
921 (*endnum - (i + 2)));
922 i--; 854 i--;
923 (*endnum)--; 855 (*endnum)--;
924 } 856 }
925 } 857 }
926 } else 858 } else if (((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) &&
927 if (((laarr[i].extLength >> 30) == 859 ((laarr[i + 1].extLength >> 30) == (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) {
928 (EXT_NOT_RECORDED_ALLOCATED >> 30)) 860 udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0,
929 && ((laarr[i + 1].extLength >> 30) == 861 ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
930 (EXT_NOT_RECORDED_NOT_ALLOCATED >> 30))) { 862 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits);
931 udf_free_blocks(inode->i_sb, inode,
932 laarr[i].extLocation, 0,
933 ((laarr[i].
934 extLength & UDF_EXTENT_LENGTH_MASK) +
935 inode->i_sb->s_blocksize -
936 1) >> inode->i_sb->s_blocksize_bits);
937 laarr[i].extLocation.logicalBlockNum = 0; 863 laarr[i].extLocation.logicalBlockNum = 0;
938 laarr[i].extLocation.partitionReferenceNum = 0; 864 laarr[i].extLocation.partitionReferenceNum = 0;
939 865
940 if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) + 866 if (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
941 (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) + 867 (laarr[i + 1].extLength & UDF_EXTENT_LENGTH_MASK) +
942 inode->i_sb->s_blocksize - 868 inode->i_sb->s_blocksize - 1) & ~UDF_EXTENT_LENGTH_MASK) {
943 1) & ~UDF_EXTENT_LENGTH_MASK) { 869 laarr[i + 1].extLength = (laarr[i + 1].extLength -
944 laarr[i + 1].extLength = 870 (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
945 (laarr[i + 1].extLength - 871 UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->s_blocksize - 1);
946 (laarr[i]. 872 laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_FLAG_MASK) +
947 extLength & UDF_EXTENT_LENGTH_MASK) + 873 (UDF_EXTENT_LENGTH_MASK + 1) - inode->i_sb->s_blocksize;
948 UDF_EXTENT_LENGTH_MASK) & ~(inode->i_sb->
949 s_blocksize -
950 1);
951 laarr[i].extLength =
952 (laarr[i].
953 extLength & UDF_EXTENT_FLAG_MASK) +
954 (UDF_EXTENT_LENGTH_MASK + 1) -
955 inode->i_sb->s_blocksize;
956 } else { 874 } else {
957 laarr[i].extLength = laarr[i + 1].extLength + 875 laarr[i].extLength = laarr[i + 1].extLength +
958 (((laarr[i]. 876 (((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
959 extLength & UDF_EXTENT_LENGTH_MASK) + 877 inode->i_sb->s_blocksize - 1) & ~(inode->i_sb->s_blocksize - 1));
960 inode->i_sb->s_blocksize -
961 1) & ~(inode->i_sb->s_blocksize - 1));
962 if (*endnum > (i + 2)) 878 if (*endnum > (i + 2))
963 memmove(&laarr[i + 1], &laarr[i + 2], 879 memmove(&laarr[i + 1], &laarr[i + 2],
964 sizeof(long_ad) * (*endnum - 880 sizeof(long_ad) * (*endnum - (i + 2)));
965 (i + 2)));
966 i--; 881 i--;
967 (*endnum)--; 882 (*endnum)--;
968 } 883 }
969 } else if ((laarr[i].extLength >> 30) == 884 } else if ((laarr[i].extLength >> 30) == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
970 (EXT_NOT_RECORDED_ALLOCATED >> 30)) { 885 udf_free_blocks(inode->i_sb, inode, laarr[i].extLocation, 0,
971 udf_free_blocks(inode->i_sb, inode, 886 ((laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) +
972 laarr[i].extLocation, 0, 887 inode->i_sb->s_blocksize - 1) >> inode->i_sb->s_blocksize_bits);
973 ((laarr[i].
974 extLength & UDF_EXTENT_LENGTH_MASK) +
975 inode->i_sb->s_blocksize -
976 1) >> inode->i_sb->s_blocksize_bits);
977 laarr[i].extLocation.logicalBlockNum = 0; 888 laarr[i].extLocation.logicalBlockNum = 0;
978 laarr[i].extLocation.partitionReferenceNum = 0; 889 laarr[i].extLocation.partitionReferenceNum = 0;
979 laarr[i].extLength = 890 laarr[i].extLength = (laarr[i].extLength & UDF_EXTENT_LENGTH_MASK) |
980 (laarr[i]. 891 EXT_NOT_RECORDED_NOT_ALLOCATED;
981 extLength & UDF_EXTENT_LENGTH_MASK) |
982 EXT_NOT_RECORDED_NOT_ALLOCATED;
983 } 892 }
984 } 893 }
985} 894}
@@ -1025,10 +934,13 @@ struct buffer_head *udf_bread(struct inode *inode, int block,
1025 934
1026 if (buffer_uptodate(bh)) 935 if (buffer_uptodate(bh))
1027 return bh; 936 return bh;
937
1028 ll_rw_block(READ, 1, &bh); 938 ll_rw_block(READ, 1, &bh);
939
1029 wait_on_buffer(bh); 940 wait_on_buffer(bh);
1030 if (buffer_uptodate(bh)) 941 if (buffer_uptodate(bh))
1031 return bh; 942 return bh;
943
1032 brelse(bh); 944 brelse(bh);
1033 *err = -EIO; 945 *err = -EIO;
1034 return NULL; 946 return NULL;
@@ -1047,26 +959,24 @@ void udf_truncate(struct inode *inode)
1047 959
1048 lock_kernel(); 960 lock_kernel();
1049 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { 961 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
1050 if (inode->i_sb->s_blocksize < 962 if (inode->i_sb->s_blocksize < (udf_file_entry_alloc_offset(inode) +
1051 (udf_file_entry_alloc_offset(inode) + inode->i_size)) { 963 inode->i_size)) {
1052 udf_expand_file_adinicb(inode, inode->i_size, &err); 964 udf_expand_file_adinicb(inode, inode->i_size, &err);
1053 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) { 965 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
1054 inode->i_size = UDF_I_LENALLOC(inode); 966 inode->i_size = UDF_I_LENALLOC(inode);
1055 unlock_kernel(); 967 unlock_kernel();
1056 return; 968 return;
1057 } else 969 } else {
1058 udf_truncate_extents(inode); 970 udf_truncate_extents(inode);
971 }
1059 } else { 972 } else {
1060 offset = inode->i_size & (inode->i_sb->s_blocksize - 1); 973 offset = inode->i_size & (inode->i_sb->s_blocksize - 1);
1061 memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + 974 memset(UDF_I_DATA(inode) + UDF_I_LENEATTR(inode) + offset, 0x00,
1062 offset, 0x00, 975 inode->i_sb->s_blocksize - offset - udf_file_entry_alloc_offset(inode));
1063 inode->i_sb->s_blocksize - offset -
1064 udf_file_entry_alloc_offset(inode));
1065 UDF_I_LENALLOC(inode) = inode->i_size; 976 UDF_I_LENALLOC(inode) = inode->i_size;
1066 } 977 }
1067 } else { 978 } else {
1068 block_truncate_page(inode->i_mapping, inode->i_size, 979 block_truncate_page(inode->i_mapping, inode->i_size, udf_get_block);
1069 udf_get_block);
1070 udf_truncate_extents(inode); 980 udf_truncate_extents(inode);
1071 } 981 }
1072 982
@@ -1097,7 +1007,6 @@ static void __udf_read_inode(struct inode *inode)
1097 * i_op = NULL; 1007 * i_op = NULL;
1098 */ 1008 */
1099 bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident); 1009 bh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 0, &ident);
1100
1101 if (!bh) { 1010 if (!bh) {
1102 printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n", 1011 printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed !bh\n",
1103 inode->i_ino); 1012 inode->i_ino);
@@ -1107,8 +1016,7 @@ static void __udf_read_inode(struct inode *inode)
1107 1016
1108 if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE && 1017 if (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE &&
1109 ident != TAG_IDENT_USE) { 1018 ident != TAG_IDENT_USE) {
1110 printk(KERN_ERR 1019 printk(KERN_ERR "udf: udf_read_inode(ino %ld) failed ident=%d\n",
1111 "udf: udf_read_inode(ino %ld) failed ident=%d\n",
1112 inode->i_ino, ident); 1020 inode->i_ino, ident);
1113 brelse(bh); 1021 brelse(bh);
1114 make_bad_inode(inode); 1022 make_bad_inode(inode);
@@ -1121,9 +1029,7 @@ static void __udf_read_inode(struct inode *inode)
1121 struct buffer_head *ibh = NULL, *nbh = NULL; 1029 struct buffer_head *ibh = NULL, *nbh = NULL;
1122 struct indirectEntry *ie; 1030 struct indirectEntry *ie;
1123 1031
1124 ibh = 1032 ibh = udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1, &ident);
1125 udf_read_ptagged(inode->i_sb, UDF_I_LOCATION(inode), 1,
1126 &ident);
1127 if (ident == TAG_IDENT_IE) { 1033 if (ident == TAG_IDENT_IE) {
1128 if (ibh) { 1034 if (ibh) {
1129 kernel_lb_addr loc; 1035 kernel_lb_addr loc;
@@ -1132,13 +1038,10 @@ static void __udf_read_inode(struct inode *inode)
1132 loc = lelb_to_cpu(ie->indirectICB.extLocation); 1038 loc = lelb_to_cpu(ie->indirectICB.extLocation);
1133 1039
1134 if (ie->indirectICB.extLength && 1040 if (ie->indirectICB.extLength &&
1135 (nbh = 1041 (nbh = udf_read_ptagged(inode->i_sb, loc, 0, &ident))) {
1136 udf_read_ptagged(inode->i_sb, loc, 0, 1042 if (ident == TAG_IDENT_FE ||
1137 &ident))) { 1043 ident == TAG_IDENT_EFE) {
1138 if (ident == TAG_IDENT_FE 1044 memcpy(&UDF_I_LOCATION(inode), &loc,
1139 || ident == TAG_IDENT_EFE) {
1140 memcpy(&UDF_I_LOCATION(inode),
1141 &loc,
1142 sizeof(kernel_lb_addr)); 1045 sizeof(kernel_lb_addr));
1143 brelse(bh); 1046 brelse(bh);
1144 brelse(ibh); 1047 brelse(ibh);
@@ -1149,11 +1052,13 @@ static void __udf_read_inode(struct inode *inode)
1149 brelse(nbh); 1052 brelse(nbh);
1150 brelse(ibh); 1053 brelse(ibh);
1151 } 1054 }
1152 } else 1055 } else {
1153 brelse(ibh); 1056 brelse(ibh);
1057 }
1154 } 1058 }
1155 } else 1059 } else {
1156 brelse(ibh); 1060 brelse(ibh);
1061 }
1157 } else if (le16_to_cpu(fe->icbTag.strategyType) != 4) { 1062 } else if (le16_to_cpu(fe->icbTag.strategyType) != 4) {
1158 printk(KERN_ERR "udf: unsupported strategy type: %d\n", 1063 printk(KERN_ERR "udf: unsupported strategy type: %d\n",
1159 le16_to_cpu(fe->icbTag.strategyType)); 1064 le16_to_cpu(fe->icbTag.strategyType));
@@ -1179,11 +1084,10 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1179 1084
1180 if (le16_to_cpu(fe->icbTag.strategyType) == 4) 1085 if (le16_to_cpu(fe->icbTag.strategyType) == 4)
1181 UDF_I_STRAT4096(inode) = 0; 1086 UDF_I_STRAT4096(inode) = 0;
1182 else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */ 1087 else /* if (le16_to_cpu(fe->icbTag.strategyType) == 4096) */
1183 UDF_I_STRAT4096(inode) = 1; 1088 UDF_I_STRAT4096(inode) = 1;
1184 1089
1185 UDF_I_ALLOCTYPE(inode) = 1090 UDF_I_ALLOCTYPE(inode) = le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK;
1186 le16_to_cpu(fe->icbTag.flags) & ICBTAG_FLAG_AD_MASK;
1187 UDF_I_UNIQUE(inode) = 0; 1091 UDF_I_UNIQUE(inode) = 0;
1188 UDF_I_LENEATTR(inode) = 0; 1092 UDF_I_LENEATTR(inode) = 0;
1189 UDF_I_LENEXTENTS(inode) = 0; 1093 UDF_I_LENEXTENTS(inode) = 0;
@@ -1193,23 +1097,16 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1193 if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) { 1097 if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_EFE) {
1194 UDF_I_EFE(inode) = 1; 1098 UDF_I_EFE(inode) = 1;
1195 UDF_I_USE(inode) = 0; 1099 UDF_I_USE(inode) = 0;
1196 if (udf_alloc_i_data 1100 if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry))) {
1197 (inode,
1198 inode->i_sb->s_blocksize -
1199 sizeof(struct extendedFileEntry))) {
1200 make_bad_inode(inode); 1101 make_bad_inode(inode);
1201 return; 1102 return;
1202 } 1103 }
1203 memcpy(UDF_I_DATA(inode), 1104 memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct extendedFileEntry),
1204 bh->b_data + sizeof(struct extendedFileEntry), 1105 inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry));
1205 inode->i_sb->s_blocksize -
1206 sizeof(struct extendedFileEntry));
1207 } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) { 1106 } else if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_FE) {
1208 UDF_I_EFE(inode) = 0; 1107 UDF_I_EFE(inode) = 0;
1209 UDF_I_USE(inode) = 0; 1108 UDF_I_USE(inode) = 0;
1210 if (udf_alloc_i_data 1109 if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct fileEntry))) {
1211 (inode,
1212 inode->i_sb->s_blocksize - sizeof(struct fileEntry))) {
1213 make_bad_inode(inode); 1110 make_bad_inode(inode);
1214 return; 1111 return;
1215 } 1112 }
@@ -1219,19 +1116,13 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1219 UDF_I_EFE(inode) = 0; 1116 UDF_I_EFE(inode) = 0;
1220 UDF_I_USE(inode) = 1; 1117 UDF_I_USE(inode) = 1;
1221 UDF_I_LENALLOC(inode) = 1118 UDF_I_LENALLOC(inode) =
1222 le32_to_cpu(((struct unallocSpaceEntry *)bh->b_data)-> 1119 le32_to_cpu(((struct unallocSpaceEntry *)bh->b_data)->lengthAllocDescs);
1223 lengthAllocDescs); 1120 if (udf_alloc_i_data(inode, inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry))) {
1224 if (udf_alloc_i_data
1225 (inode,
1226 inode->i_sb->s_blocksize -
1227 sizeof(struct unallocSpaceEntry))) {
1228 make_bad_inode(inode); 1121 make_bad_inode(inode);
1229 return; 1122 return;
1230 } 1123 }
1231 memcpy(UDF_I_DATA(inode), 1124 memcpy(UDF_I_DATA(inode), bh->b_data + sizeof(struct unallocSpaceEntry),
1232 bh->b_data + sizeof(struct unallocSpaceEntry), 1125 inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry));
1233 inode->i_sb->s_blocksize -
1234 sizeof(struct unallocSpaceEntry));
1235 return; 1126 return;
1236 } 1127 }
1237 1128
@@ -1257,7 +1148,7 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1257 1148
1258 if (UDF_I_EFE(inode) == 0) { 1149 if (UDF_I_EFE(inode) == 0) {
1259 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) << 1150 inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
1260 (inode->i_sb->s_blocksize_bits - 9); 1151 (inode->i_sb->s_blocksize_bits - 9);
1261 1152
1262 if (udf_stamp_to_time(&convtime, &convtime_usec, 1153 if (udf_stamp_to_time(&convtime, &convtime_usec,
1263 lets_to_cpu(fe->accessTime))) { 1154 lets_to_cpu(fe->accessTime))) {
@@ -1326,78 +1217,56 @@ static void udf_fill_inode(struct inode *inode, struct buffer_head *bh)
1326 UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID); 1217 UDF_I_UNIQUE(inode) = le64_to_cpu(efe->uniqueID);
1327 UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr); 1218 UDF_I_LENEATTR(inode) = le32_to_cpu(efe->lengthExtendedAttr);
1328 UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs); 1219 UDF_I_LENALLOC(inode) = le32_to_cpu(efe->lengthAllocDescs);
1329 offset = 1220 offset = sizeof(struct extendedFileEntry) + UDF_I_LENEATTR(inode);
1330 sizeof(struct extendedFileEntry) + UDF_I_LENEATTR(inode);
1331 } 1221 }
1332 1222
1333 switch (fe->icbTag.fileType) { 1223 switch (fe->icbTag.fileType) {
1334 case ICBTAG_FILE_TYPE_DIRECTORY: 1224 case ICBTAG_FILE_TYPE_DIRECTORY:
1335 { 1225 inode->i_op = &udf_dir_inode_operations;
1336 inode->i_op = &udf_dir_inode_operations; 1226 inode->i_fop = &udf_dir_operations;
1337 inode->i_fop = &udf_dir_operations; 1227 inode->i_mode |= S_IFDIR;
1338 inode->i_mode |= S_IFDIR; 1228 inc_nlink(inode);
1339 inc_nlink(inode); 1229 break;
1340 break;
1341 }
1342 case ICBTAG_FILE_TYPE_REALTIME: 1230 case ICBTAG_FILE_TYPE_REALTIME:
1343 case ICBTAG_FILE_TYPE_REGULAR: 1231 case ICBTAG_FILE_TYPE_REGULAR:
1344 case ICBTAG_FILE_TYPE_UNDEF: 1232 case ICBTAG_FILE_TYPE_UNDEF:
1345 { 1233 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
1346 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) 1234 inode->i_data.a_ops = &udf_adinicb_aops;
1347 inode->i_data.a_ops = &udf_adinicb_aops; 1235 else
1348 else 1236 inode->i_data.a_ops = &udf_aops;
1349 inode->i_data.a_ops = &udf_aops; 1237 inode->i_op = &udf_file_inode_operations;
1350 inode->i_op = &udf_file_inode_operations; 1238 inode->i_fop = &udf_file_operations;
1351 inode->i_fop = &udf_file_operations; 1239 inode->i_mode |= S_IFREG;
1352 inode->i_mode |= S_IFREG; 1240 break;
1353 break;
1354 }
1355 case ICBTAG_FILE_TYPE_BLOCK: 1241 case ICBTAG_FILE_TYPE_BLOCK:
1356 { 1242 inode->i_mode |= S_IFBLK;
1357 inode->i_mode |= S_IFBLK; 1243 break;
1358 break;
1359 }
1360 case ICBTAG_FILE_TYPE_CHAR: 1244 case ICBTAG_FILE_TYPE_CHAR:
1361 { 1245 inode->i_mode |= S_IFCHR;
1362 inode->i_mode |= S_IFCHR; 1246 break;
1363 break;
1364 }
1365 case ICBTAG_FILE_TYPE_FIFO: 1247 case ICBTAG_FILE_TYPE_FIFO:
1366 { 1248 init_special_inode(inode, inode->i_mode | S_IFIFO, 0);
1367 init_special_inode(inode, inode->i_mode | S_IFIFO, 0); 1249 break;
1368 break;
1369 }
1370 case ICBTAG_FILE_TYPE_SOCKET: 1250 case ICBTAG_FILE_TYPE_SOCKET:
1371 { 1251 init_special_inode(inode, inode->i_mode | S_IFSOCK, 0);
1372 init_special_inode(inode, inode->i_mode | S_IFSOCK, 0); 1252 break;
1373 break;
1374 }
1375 case ICBTAG_FILE_TYPE_SYMLINK: 1253 case ICBTAG_FILE_TYPE_SYMLINK:
1376 { 1254 inode->i_data.a_ops = &udf_symlink_aops;
1377 inode->i_data.a_ops = &udf_symlink_aops; 1255 inode->i_op = &page_symlink_inode_operations;
1378 inode->i_op = &page_symlink_inode_operations; 1256 inode->i_mode = S_IFLNK | S_IRWXUGO;
1379 inode->i_mode = S_IFLNK | S_IRWXUGO; 1257 break;
1380 break;
1381 }
1382 default: 1258 default:
1383 { 1259 printk(KERN_ERR "udf: udf_fill_inode(ino %ld) failed unknown file type=%d\n",
1384 printk(KERN_ERR 1260 inode->i_ino, fe->icbTag.fileType);
1385 "udf: udf_fill_inode(ino %ld) failed unknown file type=%d\n", 1261 make_bad_inode(inode);
1386 inode->i_ino, fe->icbTag.fileType); 1262 return;
1387 make_bad_inode(inode);
1388 return;
1389 }
1390 } 1263 }
1391 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { 1264 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
1392 struct deviceSpec *dsea = (struct deviceSpec *) 1265 struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1);
1393 udf_get_extendedattr(inode, 12, 1);
1394
1395 if (dsea) { 1266 if (dsea) {
1396 init_special_inode(inode, inode->i_mode, 1267 init_special_inode(inode, inode->i_mode,
1397 MKDEV(le32_to_cpu 1268 MKDEV(le32_to_cpu(dsea->majorDeviceIdent),
1398 (dsea->majorDeviceIdent), 1269 le32_to_cpu(dsea->minorDeviceIdent)));
1399 le32_to_cpu(dsea->
1400 minorDeviceIdent)));
1401 /* Developer ID ??? */ 1270 /* Developer ID ??? */
1402 } else { 1271 } else {
1403 make_bad_inode(inode); 1272 make_bad_inode(inode);
@@ -1410,8 +1279,7 @@ static int udf_alloc_i_data(struct inode *inode, size_t size)
1410 UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL); 1279 UDF_I_DATA(inode) = kmalloc(size, GFP_KERNEL);
1411 1280
1412 if (!UDF_I_DATA(inode)) { 1281 if (!UDF_I_DATA(inode)) {
1413 printk(KERN_ERR 1282 printk(KERN_ERR "udf:udf_alloc_i_data (ino %ld) no free memory\n",
1414 "udf:udf_alloc_i_data (ino %ld) no free memory\n",
1415 inode->i_ino); 1283 inode->i_ino);
1416 return -ENOMEM; 1284 return -ENOMEM;
1417 } 1285 }
@@ -1428,12 +1296,12 @@ static mode_t udf_convert_permissions(struct fileEntry *fe)
1428 permissions = le32_to_cpu(fe->permissions); 1296 permissions = le32_to_cpu(fe->permissions);
1429 flags = le16_to_cpu(fe->icbTag.flags); 1297 flags = le16_to_cpu(fe->icbTag.flags);
1430 1298
1431 mode = ((permissions) & S_IRWXO) | 1299 mode = (( permissions ) & S_IRWXO) |
1432 ((permissions >> 2) & S_IRWXG) | 1300 (( permissions >> 2 ) & S_IRWXG) |
1433 ((permissions >> 4) & S_IRWXU) | 1301 (( permissions >> 4 ) & S_IRWXU) |
1434 ((flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) | 1302 (( flags & ICBTAG_FLAG_SETUID) ? S_ISUID : 0) |
1435 ((flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) | 1303 (( flags & ICBTAG_FLAG_SETGID) ? S_ISGID : 0) |
1436 ((flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0); 1304 (( flags & ICBTAG_FLAG_STICKY) ? S_ISVTX : 0);
1437 1305
1438 return mode; 1306 return mode;
1439} 1307}
@@ -1456,9 +1324,11 @@ static mode_t udf_convert_permissions(struct fileEntry *fe)
1456int udf_write_inode(struct inode *inode, int sync) 1324int udf_write_inode(struct inode *inode, int sync)
1457{ 1325{
1458 int ret; 1326 int ret;
1327
1459 lock_kernel(); 1328 lock_kernel();
1460 ret = udf_update_inode(inode, sync); 1329 ret = udf_update_inode(inode, sync);
1461 unlock_kernel(); 1330 unlock_kernel();
1331
1462 return ret; 1332 return ret;
1463} 1333}
1464 1334
@@ -1479,10 +1349,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1479 kernel_timestamp cpu_time; 1349 kernel_timestamp cpu_time;
1480 int err = 0; 1350 int err = 0;
1481 1351
1482 bh = udf_tread(inode->i_sb, 1352 bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode), 0));
1483 udf_get_lb_pblock(inode->i_sb, UDF_I_LOCATION(inode),
1484 0));
1485
1486 if (!bh) { 1353 if (!bh) {
1487 udf_debug("bread failure\n"); 1354 udf_debug("bread failure\n");
1488 return -EIO; 1355 return -EIO;
@@ -1495,27 +1362,21 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1495 1362
1496 if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) { 1363 if (le16_to_cpu(fe->descTag.tagIdent) == TAG_IDENT_USE) {
1497 struct unallocSpaceEntry *use = 1364 struct unallocSpaceEntry *use =
1498 (struct unallocSpaceEntry *)bh->b_data; 1365 (struct unallocSpaceEntry *)bh->b_data;
1499 1366
1500 use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode)); 1367 use->lengthAllocDescs = cpu_to_le32(UDF_I_LENALLOC(inode));
1501 memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), 1368 memcpy(bh->b_data + sizeof(struct unallocSpaceEntry), UDF_I_DATA(inode),
1502 UDF_I_DATA(inode), 1369 inode->i_sb->s_blocksize - sizeof(struct unallocSpaceEntry));
1503 inode->i_sb->s_blocksize - 1370 crclen = sizeof(struct unallocSpaceEntry) + UDF_I_LENALLOC(inode) - sizeof(tag);
1504 sizeof(struct unallocSpaceEntry)); 1371 use->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
1505 crclen =
1506 sizeof(struct unallocSpaceEntry) + UDF_I_LENALLOC(inode) -
1507 sizeof(tag);
1508 use->descTag.tagLocation =
1509 cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
1510 use->descTag.descCRCLength = cpu_to_le16(crclen); 1372 use->descTag.descCRCLength = cpu_to_le16(crclen);
1511 use->descTag.descCRC = 1373 use->descTag.descCRC = cpu_to_le16(udf_crc((char *)use + sizeof(tag), crclen, 0));
1512 cpu_to_le16(udf_crc((char *)use + sizeof(tag), crclen, 0));
1513 1374
1514 use->descTag.tagChecksum = 0; 1375 use->descTag.tagChecksum = 0;
1515 for (i = 0; i < 16; i++) 1376 for (i = 0; i < 16; i++) {
1516 if (i != 4) 1377 if (i != 4)
1517 use->descTag.tagChecksum += 1378 use->descTag.tagChecksum += ((uint8_t *)&(use->descTag))[i];
1518 ((uint8_t *) & (use->descTag))[i]; 1379 }
1519 1380
1520 mark_buffer_dirty(bh); 1381 mark_buffer_dirty(bh);
1521 brelse(bh); 1382 brelse(bh);
@@ -1532,13 +1393,14 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1532 else 1393 else
1533 fe->gid = cpu_to_le32(inode->i_gid); 1394 fe->gid = cpu_to_le32(inode->i_gid);
1534 1395
1535 udfperms = ((inode->i_mode & S_IRWXO)) | 1396 udfperms = ((inode->i_mode & S_IRWXO) ) |
1536 ((inode->i_mode & S_IRWXG) << 2) | ((inode->i_mode & S_IRWXU) << 4); 1397 ((inode->i_mode & S_IRWXG) << 2) |
1398 ((inode->i_mode & S_IRWXU) << 4);
1537 1399
1538 udfperms |= (le32_to_cpu(fe->permissions) & 1400 udfperms |= (le32_to_cpu(fe->permissions) &
1539 (FE_PERM_O_DELETE | FE_PERM_O_CHATTR | 1401 (FE_PERM_O_DELETE | FE_PERM_O_CHATTR |
1540 FE_PERM_G_DELETE | FE_PERM_G_CHATTR | 1402 FE_PERM_G_DELETE | FE_PERM_G_CHATTR |
1541 FE_PERM_U_DELETE | FE_PERM_U_CHATTR)); 1403 FE_PERM_U_DELETE | FE_PERM_U_CHATTR));
1542 fe->permissions = cpu_to_le32(udfperms); 1404 fe->permissions = cpu_to_le32(udfperms);
1543 1405
1544 if (S_ISDIR(inode->i_mode)) 1406 if (S_ISDIR(inode->i_mode))
@@ -1550,22 +1412,20 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1550 1412
1551 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) { 1413 if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode)) {
1552 regid *eid; 1414 regid *eid;
1553 struct deviceSpec *dsea = (struct deviceSpec *) 1415 struct deviceSpec *dsea =
1554 udf_get_extendedattr(inode, 12, 1); 1416 (struct deviceSpec *)udf_get_extendedattr(inode, 12, 1);
1555
1556 if (!dsea) { 1417 if (!dsea) {
1557 dsea = (struct deviceSpec *) 1418 dsea = (struct deviceSpec *)
1558 udf_add_extendedattr(inode, 1419 udf_add_extendedattr(inode,
1559 sizeof(struct deviceSpec) + 1420 sizeof(struct deviceSpec) +
1560 sizeof(regid), 12, 0x3); 1421 sizeof(regid), 12, 0x3);
1561 dsea->attrType = cpu_to_le32(12); 1422 dsea->attrType = cpu_to_le32(12);
1562 dsea->attrSubtype = 1; 1423 dsea->attrSubtype = 1;
1563 dsea->attrLength = 1424 dsea->attrLength = cpu_to_le32(sizeof(struct deviceSpec) +
1564 cpu_to_le32(sizeof(struct deviceSpec) + 1425 sizeof(regid));
1565 sizeof(regid));
1566 dsea->impUseLength = cpu_to_le32(sizeof(regid)); 1426 dsea->impUseLength = cpu_to_le32(sizeof(regid));
1567 } 1427 }
1568 eid = (regid *) dsea->impUse; 1428 eid = (regid *)dsea->impUse;
1569 memset(eid, 0, sizeof(regid)); 1429 memset(eid, 0, sizeof(regid));
1570 strcpy(eid->ident, UDF_ID_DEVELOPER); 1430 strcpy(eid->ident, UDF_ID_DEVELOPER);
1571 eid->identSuffix[0] = UDF_OS_CLASS_UNIX; 1431 eid->identSuffix[0] = UDF_OS_CLASS_UNIX;
@@ -1577,10 +1437,9 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1577 if (UDF_I_EFE(inode) == 0) { 1437 if (UDF_I_EFE(inode) == 0) {
1578 memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode), 1438 memcpy(bh->b_data + sizeof(struct fileEntry), UDF_I_DATA(inode),
1579 inode->i_sb->s_blocksize - sizeof(struct fileEntry)); 1439 inode->i_sb->s_blocksize - sizeof(struct fileEntry));
1580 fe->logicalBlocksRecorded = 1440 fe->logicalBlocksRecorded = cpu_to_le64(
1581 cpu_to_le64((inode->i_blocks + 1441 (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >>
1582 (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1442 (inode->i_sb->s_blocksize_bits - 9));
1583 1) >> (inode->i_sb->s_blocksize_bits - 9));
1584 1443
1585 if (udf_time_to_stamp(&cpu_time, inode->i_atime)) 1444 if (udf_time_to_stamp(&cpu_time, inode->i_atime))
1586 fe->accessTime = cpu_to_lets(cpu_time); 1445 fe->accessTime = cpu_to_lets(cpu_time);
@@ -1598,19 +1457,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1598 fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE); 1457 fe->descTag.tagIdent = cpu_to_le16(TAG_IDENT_FE);
1599 crclen = sizeof(struct fileEntry); 1458 crclen = sizeof(struct fileEntry);
1600 } else { 1459 } else {
1601 memcpy(bh->b_data + sizeof(struct extendedFileEntry), 1460 memcpy(bh->b_data + sizeof(struct extendedFileEntry), UDF_I_DATA(inode),
1602 UDF_I_DATA(inode), 1461 inode->i_sb->s_blocksize - sizeof(struct extendedFileEntry));
1603 inode->i_sb->s_blocksize -
1604 sizeof(struct extendedFileEntry));
1605 efe->objectSize = cpu_to_le64(inode->i_size); 1462 efe->objectSize = cpu_to_le64(inode->i_size);
1606 efe->logicalBlocksRecorded = cpu_to_le64((inode->i_blocks + 1463 efe->logicalBlocksRecorded = cpu_to_le64(
1607 (1 << 1464 (inode->i_blocks + (1 << (inode->i_sb->s_blocksize_bits - 9)) - 1) >>
1608 (inode->i_sb-> 1465 (inode->i_sb->s_blocksize_bits - 9));
1609 s_blocksize_bits -
1610 9)) -
1611 1) >> (inode->i_sb->
1612 s_blocksize_bits
1613 - 9));
1614 1466
1615 if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec || 1467 if (UDF_I_CRTIME(inode).tv_sec > inode->i_atime.tv_sec ||
1616 (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec && 1468 (UDF_I_CRTIME(inode).tv_sec == inode->i_atime.tv_sec &&
@@ -1671,13 +1523,13 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1671 else if (S_ISSOCK(inode->i_mode)) 1523 else if (S_ISSOCK(inode->i_mode))
1672 fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET; 1524 fe->icbTag.fileType = ICBTAG_FILE_TYPE_SOCKET;
1673 1525
1674 icbflags = UDF_I_ALLOCTYPE(inode) | 1526 icbflags = UDF_I_ALLOCTYPE(inode) |
1675 ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) | 1527 ((inode->i_mode & S_ISUID) ? ICBTAG_FLAG_SETUID : 0) |
1676 ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) | 1528 ((inode->i_mode & S_ISGID) ? ICBTAG_FLAG_SETGID : 0) |
1677 ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) | 1529 ((inode->i_mode & S_ISVTX) ? ICBTAG_FLAG_STICKY : 0) |
1678 (le16_to_cpu(fe->icbTag.flags) & 1530 (le16_to_cpu(fe->icbTag.flags) &
1679 ~(ICBTAG_FLAG_AD_MASK | ICBTAG_FLAG_SETUID | 1531 ~(ICBTAG_FLAG_AD_MASK | ICBTAG_FLAG_SETUID |
1680 ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY)); 1532 ICBTAG_FLAG_SETGID | ICBTAG_FLAG_STICKY));
1681 1533
1682 fe->icbTag.flags = cpu_to_le16(icbflags); 1534 fe->icbTag.flags = cpu_to_le16(icbflags);
1683 if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) 1535 if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
@@ -1685,18 +1537,16 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1685 else 1537 else
1686 fe->descTag.descVersion = cpu_to_le16(2); 1538 fe->descTag.descVersion = cpu_to_le16(2);
1687 fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); 1539 fe->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
1688 fe->descTag.tagLocation = 1540 fe->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
1689 cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
1690 crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag); 1541 crclen += UDF_I_LENEATTR(inode) + UDF_I_LENALLOC(inode) - sizeof(tag);
1691 fe->descTag.descCRCLength = cpu_to_le16(crclen); 1542 fe->descTag.descCRCLength = cpu_to_le16(crclen);
1692 fe->descTag.descCRC = 1543 fe->descTag.descCRC = cpu_to_le16(udf_crc((char *)fe + sizeof(tag), crclen, 0));
1693 cpu_to_le16(udf_crc((char *)fe + sizeof(tag), crclen, 0));
1694 1544
1695 fe->descTag.tagChecksum = 0; 1545 fe->descTag.tagChecksum = 0;
1696 for (i = 0; i < 16; i++) 1546 for (i = 0; i < 16; i++) {
1697 if (i != 4) 1547 if (i != 4)
1698 fe->descTag.tagChecksum += 1548 fe->descTag.tagChecksum += ((uint8_t *)&(fe->descTag))[i];
1699 ((uint8_t *) & (fe->descTag))[i]; 1549 }
1700 1550
1701 /* write the data blocks */ 1551 /* write the data blocks */
1702 mark_buffer_dirty(bh); 1552 mark_buffer_dirty(bh);
@@ -1709,6 +1559,7 @@ static int udf_update_inode(struct inode *inode, int do_sync)
1709 } 1559 }
1710 } 1560 }
1711 brelse(bh); 1561 brelse(bh);
1562
1712 return err; 1563 return err;
1713} 1564}
1714 1565
@@ -1729,8 +1580,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino)
1729 if (is_bad_inode(inode)) 1580 if (is_bad_inode(inode))
1730 goto out_iput; 1581 goto out_iput;
1731 1582
1732 if (ino.logicalBlockNum >= 1583 if (ino.logicalBlockNum >= UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) {
1733 UDF_SB_PARTLEN(sb, ino.partitionReferenceNum)) {
1734 udf_debug("block=%d, partition=%d out of range\n", 1584 udf_debug("block=%d, partition=%d out of range\n",
1735 ino.logicalBlockNum, ino.partitionReferenceNum); 1585 ino.logicalBlockNum, ino.partitionReferenceNum);
1736 make_bad_inode(inode); 1586 make_bad_inode(inode);
@@ -1739,7 +1589,7 @@ struct inode *udf_iget(struct super_block *sb, kernel_lb_addr ino)
1739 1589
1740 return inode; 1590 return inode;
1741 1591
1742 out_iput: 1592 out_iput:
1743 iput(inode); 1593 iput(inode);
1744 return NULL; 1594 return NULL;
1745} 1595}
@@ -1755,9 +1605,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
1755 uint8_t *ptr; 1605 uint8_t *ptr;
1756 1606
1757 if (!epos->bh) 1607 if (!epos->bh)
1758 ptr = 1608 ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1759 UDF_I_DATA(inode) + epos->offset -
1760 udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1761 else 1609 else
1762 ptr = epos->bh->b_data + epos->offset; 1610 ptr = epos->bh->b_data + epos->offset;
1763 1611
@@ -1774,18 +1622,13 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
1774 int err, loffset; 1622 int err, loffset;
1775 kernel_lb_addr obloc = epos->block; 1623 kernel_lb_addr obloc = epos->block;
1776 1624
1777 if (! 1625 if (!(epos->block.logicalBlockNum = udf_new_block(inode->i_sb, NULL,
1778 (epos->block.logicalBlockNum = 1626 obloc.partitionReferenceNum,
1779 udf_new_block(inode->i_sb, NULL, 1627 obloc.logicalBlockNum, &err))) {
1780 obloc.partitionReferenceNum,
1781 obloc.logicalBlockNum, &err))) {
1782 return -1; 1628 return -1;
1783 } 1629 }
1784 if (! 1630 if (!(nbh = udf_tgetblk(inode->i_sb, udf_get_lb_pblock(inode->i_sb,
1785 (nbh = 1631 epos->block, 0)))) {
1786 udf_tgetblk(inode->i_sb,
1787 udf_get_lb_pblock(inode->i_sb, epos->block,
1788 0)))) {
1789 return -1; 1632 return -1;
1790 } 1633 }
1791 lock_buffer(nbh); 1634 lock_buffer(nbh);
@@ -1796,8 +1639,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
1796 1639
1797 aed = (struct allocExtDesc *)(nbh->b_data); 1640 aed = (struct allocExtDesc *)(nbh->b_data);
1798 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) 1641 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT))
1799 aed->previousAllocExtLocation = 1642 aed->previousAllocExtLocation = cpu_to_le32(obloc.logicalBlockNum);
1800 cpu_to_le32(obloc.logicalBlockNum);
1801 if (epos->offset + adsize > inode->i_sb->s_blocksize) { 1643 if (epos->offset + adsize > inode->i_sb->s_blocksize) {
1802 loffset = epos->offset; 1644 loffset = epos->offset;
1803 aed->lengthAllocDescs = cpu_to_le32(adsize); 1645 aed->lengthAllocDescs = cpu_to_le32(adsize);
@@ -1814,9 +1656,7 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
1814 if (epos->bh) { 1656 if (epos->bh) {
1815 aed = (struct allocExtDesc *)epos->bh->b_data; 1657 aed = (struct allocExtDesc *)epos->bh->b_data;
1816 aed->lengthAllocDescs = 1658 aed->lengthAllocDescs =
1817 cpu_to_le32(le32_to_cpu 1659 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
1818 (aed->lengthAllocDescs) +
1819 adsize);
1820 } else { 1660 } else {
1821 UDF_I_LENALLOC(inode) += adsize; 1661 UDF_I_LENALLOC(inode) += adsize;
1822 mark_inode_dirty(inode); 1662 mark_inode_dirty(inode);
@@ -1830,37 +1670,30 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
1830 epos->block.logicalBlockNum, sizeof(tag)); 1670 epos->block.logicalBlockNum, sizeof(tag));
1831 switch (UDF_I_ALLOCTYPE(inode)) { 1671 switch (UDF_I_ALLOCTYPE(inode)) {
1832 case ICBTAG_FLAG_AD_SHORT: 1672 case ICBTAG_FLAG_AD_SHORT:
1833 { 1673 sad = (short_ad *)sptr;
1834 sad = (short_ad *) sptr; 1674 sad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS |
1835 sad->extLength = 1675 inode->i_sb->s_blocksize);
1836 cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | 1676 sad->extPosition = cpu_to_le32(epos->block.logicalBlockNum);
1837 inode->i_sb->s_blocksize); 1677 break;
1838 sad->extPosition =
1839 cpu_to_le32(epos->block.logicalBlockNum);
1840 break;
1841 }
1842 case ICBTAG_FLAG_AD_LONG: 1678 case ICBTAG_FLAG_AD_LONG:
1843 { 1679 lad = (long_ad *)sptr;
1844 lad = (long_ad *) sptr; 1680 lad->extLength = cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS |
1845 lad->extLength = 1681 inode->i_sb->s_blocksize);
1846 cpu_to_le32(EXT_NEXT_EXTENT_ALLOCDECS | 1682 lad->extLocation = cpu_to_lelb(epos->block);
1847 inode->i_sb->s_blocksize); 1683 memset(lad->impUse, 0x00, sizeof(lad->impUse));
1848 lad->extLocation = cpu_to_lelb(epos->block); 1684 break;
1849 memset(lad->impUse, 0x00, sizeof(lad->impUse));
1850 break;
1851 }
1852 } 1685 }
1853 if (epos->bh) { 1686 if (epos->bh) {
1854 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) 1687 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
1855 || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1688 UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
1856 udf_update_tag(epos->bh->b_data, loffset); 1689 udf_update_tag(epos->bh->b_data, loffset);
1857 else 1690 else
1858 udf_update_tag(epos->bh->b_data, 1691 udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc));
1859 sizeof(struct allocExtDesc));
1860 mark_buffer_dirty_inode(epos->bh, inode); 1692 mark_buffer_dirty_inode(epos->bh, inode);
1861 brelse(epos->bh); 1693 brelse(epos->bh);
1862 } else 1694 } else {
1863 mark_inode_dirty(inode); 1695 mark_inode_dirty(inode);
1696 }
1864 epos->bh = nbh; 1697 epos->bh = nbh;
1865 } 1698 }
1866 1699
@@ -1872,14 +1705,11 @@ int8_t udf_add_aext(struct inode * inode, struct extent_position * epos,
1872 } else { 1705 } else {
1873 aed = (struct allocExtDesc *)epos->bh->b_data; 1706 aed = (struct allocExtDesc *)epos->bh->b_data;
1874 aed->lengthAllocDescs = 1707 aed->lengthAllocDescs =
1875 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize); 1708 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) + adsize);
1876 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) 1709 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) || UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
1877 || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1710 udf_update_tag(epos->bh->b_data, epos->offset + (inc ? 0 : adsize));
1878 udf_update_tag(epos->bh->b_data,
1879 epos->offset + (inc ? 0 : adsize));
1880 else 1711 else
1881 udf_update_tag(epos->bh->b_data, 1712 udf_update_tag(epos->bh->b_data, sizeof(struct allocExtDesc));
1882 sizeof(struct allocExtDesc));
1883 mark_buffer_dirty_inode(epos->bh, inode); 1713 mark_buffer_dirty_inode(epos->bh, inode);
1884 } 1714 }
1885 1715
@@ -1891,51 +1721,47 @@ int8_t udf_write_aext(struct inode * inode, struct extent_position * epos,
1891{ 1721{
1892 int adsize; 1722 int adsize;
1893 uint8_t *ptr; 1723 uint8_t *ptr;
1724 short_ad *sad;
1725 long_ad *lad;
1894 1726
1895 if (!epos->bh) 1727 if (!epos->bh)
1896 ptr = 1728 ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1897 UDF_I_DATA(inode) + epos->offset -
1898 udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1899 else 1729 else
1900 ptr = epos->bh->b_data + epos->offset; 1730 ptr = epos->bh->b_data + epos->offset;
1901 1731
1902 switch (UDF_I_ALLOCTYPE(inode)) { 1732 switch (UDF_I_ALLOCTYPE(inode)) {
1903 case ICBTAG_FLAG_AD_SHORT: 1733 case ICBTAG_FLAG_AD_SHORT:
1904 { 1734 sad = (short_ad *)ptr;
1905 short_ad *sad = (short_ad *) ptr; 1735 sad->extLength = cpu_to_le32(elen);
1906 sad->extLength = cpu_to_le32(elen); 1736 sad->extPosition = cpu_to_le32(eloc.logicalBlockNum);
1907 sad->extPosition = cpu_to_le32(eloc.logicalBlockNum); 1737 adsize = sizeof(short_ad);
1908 adsize = sizeof(short_ad); 1738 break;
1909 break;
1910 }
1911 case ICBTAG_FLAG_AD_LONG: 1739 case ICBTAG_FLAG_AD_LONG:
1912 { 1740 lad = (long_ad *)ptr;
1913 long_ad *lad = (long_ad *) ptr; 1741 lad->extLength = cpu_to_le32(elen);
1914 lad->extLength = cpu_to_le32(elen); 1742 lad->extLocation = cpu_to_lelb(eloc);
1915 lad->extLocation = cpu_to_lelb(eloc); 1743 memset(lad->impUse, 0x00, sizeof(lad->impUse));
1916 memset(lad->impUse, 0x00, sizeof(lad->impUse)); 1744 adsize = sizeof(long_ad);
1917 adsize = sizeof(long_ad); 1745 break;
1918 break;
1919 }
1920 default: 1746 default:
1921 return -1; 1747 return -1;
1922 } 1748 }
1923 1749
1924 if (epos->bh) { 1750 if (epos->bh) {
1925 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) 1751 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
1926 || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) { 1752 UDF_SB_UDFREV(inode->i_sb) >= 0x0201) {
1927 struct allocExtDesc *aed = 1753 struct allocExtDesc *aed = (struct allocExtDesc *)epos->bh->b_data;
1928 (struct allocExtDesc *)epos->bh->b_data;
1929 udf_update_tag(epos->bh->b_data, 1754 udf_update_tag(epos->bh->b_data,
1930 le32_to_cpu(aed->lengthAllocDescs) + 1755 le32_to_cpu(aed->lengthAllocDescs) + sizeof(struct allocExtDesc));
1931 sizeof(struct allocExtDesc));
1932 } 1756 }
1933 mark_buffer_dirty_inode(epos->bh, inode); 1757 mark_buffer_dirty_inode(epos->bh, inode);
1934 } else 1758 } else {
1935 mark_inode_dirty(inode); 1759 mark_inode_dirty(inode);
1760 }
1936 1761
1937 if (inc) 1762 if (inc)
1938 epos->offset += adsize; 1763 epos->offset += adsize;
1764
1939 return (elen >> 30); 1765 return (elen >> 30);
1940} 1766}
1941 1767
@@ -1949,14 +1775,9 @@ int8_t udf_next_aext(struct inode * inode, struct extent_position * epos,
1949 epos->block = *eloc; 1775 epos->block = *eloc;
1950 epos->offset = sizeof(struct allocExtDesc); 1776 epos->offset = sizeof(struct allocExtDesc);
1951 brelse(epos->bh); 1777 brelse(epos->bh);
1952 if (! 1778 if (!(epos->bh = udf_tread(inode->i_sb, udf_get_lb_pblock(inode->i_sb, epos->block, 0)))) {
1953 (epos->bh =
1954 udf_tread(inode->i_sb,
1955 udf_get_lb_pblock(inode->i_sb, epos->block,
1956 0)))) {
1957 udf_debug("reading block %d failed!\n", 1779 udf_debug("reading block %d failed!\n",
1958 udf_get_lb_pblock(inode->i_sb, epos->block, 1780 udf_get_lb_pblock(inode->i_sb, epos->block, 0));
1959 0));
1960 return -1; 1781 return -1;
1961 } 1782 }
1962 } 1783 }
@@ -1970,75 +1791,49 @@ int8_t udf_current_aext(struct inode * inode, struct extent_position * epos,
1970 int alen; 1791 int alen;
1971 int8_t etype; 1792 int8_t etype;
1972 uint8_t *ptr; 1793 uint8_t *ptr;
1794 short_ad *sad;
1795 long_ad *lad;
1796
1973 1797
1974 if (!epos->bh) { 1798 if (!epos->bh) {
1975 if (!epos->offset) 1799 if (!epos->offset)
1976 epos->offset = udf_file_entry_alloc_offset(inode); 1800 epos->offset = udf_file_entry_alloc_offset(inode);
1977 ptr = 1801 ptr = UDF_I_DATA(inode) + epos->offset - udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1978 UDF_I_DATA(inode) + epos->offset - 1802 alen = udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode);
1979 udf_file_entry_alloc_offset(inode) + UDF_I_LENEATTR(inode);
1980 alen =
1981 udf_file_entry_alloc_offset(inode) + UDF_I_LENALLOC(inode);
1982 } else { 1803 } else {
1983 if (!epos->offset) 1804 if (!epos->offset)
1984 epos->offset = sizeof(struct allocExtDesc); 1805 epos->offset = sizeof(struct allocExtDesc);
1985 ptr = epos->bh->b_data + epos->offset; 1806 ptr = epos->bh->b_data + epos->offset;
1986 alen = 1807 alen = sizeof(struct allocExtDesc) +
1987 sizeof(struct allocExtDesc) + 1808 le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->lengthAllocDescs);
1988 le32_to_cpu(((struct allocExtDesc *)epos->bh->b_data)->
1989 lengthAllocDescs);
1990 } 1809 }
1991 1810
1992 switch (UDF_I_ALLOCTYPE(inode)) { 1811 switch (UDF_I_ALLOCTYPE(inode)) {
1993 case ICBTAG_FLAG_AD_SHORT: 1812 case ICBTAG_FLAG_AD_SHORT:
1994 { 1813 if (!(sad = udf_get_fileshortad(ptr, alen, &epos->offset, inc)))
1995 short_ad *sad; 1814 return -1;
1996 1815 etype = le32_to_cpu(sad->extLength) >> 30;
1997 if (! 1816 eloc->logicalBlockNum = le32_to_cpu(sad->extPosition);
1998 (sad = 1817 eloc->partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
1999 udf_get_fileshortad(ptr, alen, &epos->offset, 1818 *elen = le32_to_cpu(sad->extLength) & UDF_EXTENT_LENGTH_MASK;
2000 inc))) 1819 break;
2001 return -1;
2002
2003 etype = le32_to_cpu(sad->extLength) >> 30;
2004 eloc->logicalBlockNum = le32_to_cpu(sad->extPosition);
2005 eloc->partitionReferenceNum =
2006 UDF_I_LOCATION(inode).partitionReferenceNum;
2007 *elen =
2008 le32_to_cpu(sad->
2009 extLength) & UDF_EXTENT_LENGTH_MASK;
2010 break;
2011 }
2012 case ICBTAG_FLAG_AD_LONG: 1820 case ICBTAG_FLAG_AD_LONG:
2013 { 1821 if (!(lad = udf_get_filelongad(ptr, alen, &epos->offset, inc)))
2014 long_ad *lad;
2015
2016 if (!
2017 (lad =
2018 udf_get_filelongad(ptr, alen, &epos->offset, inc)))
2019 return -1;
2020
2021 etype = le32_to_cpu(lad->extLength) >> 30;
2022 *eloc = lelb_to_cpu(lad->extLocation);
2023 *elen =
2024 le32_to_cpu(lad->
2025 extLength) & UDF_EXTENT_LENGTH_MASK;
2026 break;
2027 }
2028 default:
2029 {
2030 udf_debug("alloc_type = %d unsupported\n",
2031 UDF_I_ALLOCTYPE(inode));
2032 return -1; 1822 return -1;
2033 } 1823 etype = le32_to_cpu(lad->extLength) >> 30;
1824 *eloc = lelb_to_cpu(lad->extLocation);
1825 *elen = le32_to_cpu(lad->extLength) & UDF_EXTENT_LENGTH_MASK;
1826 break;
1827 default:
1828 udf_debug("alloc_type = %d unsupported\n", UDF_I_ALLOCTYPE(inode));
1829 return -1;
2034 } 1830 }
2035 1831
2036 return etype; 1832 return etype;
2037} 1833}
2038 1834
2039static int8_t 1835static int8_t udf_insert_aext(struct inode *inode, struct extent_position epos,
2040udf_insert_aext(struct inode *inode, struct extent_position epos, 1836 kernel_lb_addr neloc, uint32_t nelen)
2041 kernel_lb_addr neloc, uint32_t nelen)
2042{ 1837{
2043 kernel_lb_addr oeloc; 1838 kernel_lb_addr oeloc;
2044 uint32_t oelen; 1839 uint32_t oelen;
@@ -2049,12 +1844,12 @@ udf_insert_aext(struct inode *inode, struct extent_position epos,
2049 1844
2050 while ((etype = udf_next_aext(inode, &epos, &oeloc, &oelen, 0)) != -1) { 1845 while ((etype = udf_next_aext(inode, &epos, &oeloc, &oelen, 0)) != -1) {
2051 udf_write_aext(inode, &epos, neloc, nelen, 1); 1846 udf_write_aext(inode, &epos, neloc, nelen, 1);
2052
2053 neloc = oeloc; 1847 neloc = oeloc;
2054 nelen = (etype << 30) | oelen; 1848 nelen = (etype << 30) | oelen;
2055 } 1849 }
2056 udf_add_aext(inode, &epos, neloc, nelen, 1); 1850 udf_add_aext(inode, &epos, neloc, nelen, 1);
2057 brelse(epos.bh); 1851 brelse(epos.bh);
1852
2058 return (nelen >> 30); 1853 return (nelen >> 30);
2059} 1854}
2060 1855
@@ -2105,15 +1900,12 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos,
2105 } else { 1900 } else {
2106 aed = (struct allocExtDesc *)oepos.bh->b_data; 1901 aed = (struct allocExtDesc *)oepos.bh->b_data;
2107 aed->lengthAllocDescs = 1902 aed->lengthAllocDescs =
2108 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - 1903 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - (2 * adsize));
2109 (2 * adsize)); 1904 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
2110 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) 1905 UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
2111 || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1906 udf_update_tag(oepos.bh->b_data, oepos.offset - (2 * adsize));
2112 udf_update_tag(oepos.bh->b_data,
2113 oepos.offset - (2 * adsize));
2114 else 1907 else
2115 udf_update_tag(oepos.bh->b_data, 1908 udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc));
2116 sizeof(struct allocExtDesc));
2117 mark_buffer_dirty_inode(oepos.bh, inode); 1909 mark_buffer_dirty_inode(oepos.bh, inode);
2118 } 1910 }
2119 } else { 1911 } else {
@@ -2124,21 +1916,19 @@ int8_t udf_delete_aext(struct inode * inode, struct extent_position epos,
2124 } else { 1916 } else {
2125 aed = (struct allocExtDesc *)oepos.bh->b_data; 1917 aed = (struct allocExtDesc *)oepos.bh->b_data;
2126 aed->lengthAllocDescs = 1918 aed->lengthAllocDescs =
2127 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - 1919 cpu_to_le32(le32_to_cpu(aed->lengthAllocDescs) - adsize);
2128 adsize); 1920 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
2129 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) 1921 UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
2130 || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 1922 udf_update_tag(oepos.bh->b_data, epos.offset - adsize);
2131 udf_update_tag(oepos.bh->b_data,
2132 epos.offset - adsize);
2133 else 1923 else
2134 udf_update_tag(oepos.bh->b_data, 1924 udf_update_tag(oepos.bh->b_data, sizeof(struct allocExtDesc));
2135 sizeof(struct allocExtDesc));
2136 mark_buffer_dirty_inode(oepos.bh, inode); 1925 mark_buffer_dirty_inode(oepos.bh, inode);
2137 } 1926 }
2138 } 1927 }
2139 1928
2140 brelse(epos.bh); 1929 brelse(epos.bh);
2141 brelse(oepos.bh); 1930 brelse(oepos.bh);
1931
2142 return (elen >> 30); 1932 return (elen >> 30);
2143} 1933}
2144 1934
@@ -2162,8 +1952,7 @@ int8_t inode_bmap(struct inode * inode, sector_t block,
2162 1952
2163 do { 1953 do {
2164 if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1) { 1954 if ((etype = udf_next_aext(inode, pos, eloc, elen, 1)) == -1) {
2165 *offset = 1955 *offset = (bcount - lbcount) >> inode->i_sb->s_blocksize_bits;
2166 (bcount - lbcount) >> inode->i_sb->s_blocksize_bits;
2167 UDF_I_LENEXTENTS(inode) = lbcount; 1956 UDF_I_LENEXTENTS(inode) = lbcount;
2168 return -1; 1957 return -1;
2169 } 1958 }
@@ -2180,13 +1969,12 @@ long udf_block_map(struct inode *inode, sector_t block)
2180 kernel_lb_addr eloc; 1969 kernel_lb_addr eloc;
2181 uint32_t elen; 1970 uint32_t elen;
2182 sector_t offset; 1971 sector_t offset;
2183 struct extent_position epos = { NULL, 0, {0, 0} }; 1972 struct extent_position epos = {};
2184 int ret; 1973 int ret;
2185 1974
2186 lock_kernel(); 1975 lock_kernel();
2187 1976
2188 if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == 1977 if (inode_bmap(inode, block, &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30))
2189 (EXT_RECORDED_ALLOCATED >> 30))
2190 ret = udf_get_lb_pblock(inode->i_sb, eloc, offset); 1978 ret = udf_get_lb_pblock(inode->i_sb, eloc, offset);
2191 else 1979 else
2192 ret = 0; 1980 ret = 0;
diff --git a/fs/udf/lowlevel.c b/fs/udf/lowlevel.c
index 4826c3616eef..579bae71e67e 100644
--- a/fs/udf/lowlevel.c
+++ b/fs/udf/lowlevel.c
@@ -43,7 +43,7 @@ unsigned int udf_get_last_session(struct super_block *sb)
43 udf_debug("XA disk: %s, vol_desc_start=%d\n", 43 udf_debug("XA disk: %s, vol_desc_start=%d\n",
44 (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba); 44 (ms_info.xa_flag ? "yes" : "no"), ms_info.addr.lba);
45#if WE_OBEY_THE_WRITTEN_STANDARDS 45#if WE_OBEY_THE_WRITTEN_STANDARDS
46 if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */ 46 if (ms_info.xa_flag) /* necessary for a valid ms_info.addr */
47#endif 47#endif
48 vol_desc_start = ms_info.addr.lba; 48 vol_desc_start = ms_info.addr.lba;
49 } else { 49 } else {
@@ -57,7 +57,7 @@ unsigned long udf_get_last_block(struct super_block *sb)
57 struct block_device *bdev = sb->s_bdev; 57 struct block_device *bdev = sb->s_bdev;
58 unsigned long lblock = 0; 58 unsigned long lblock = 0;
59 59
60 if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long)&lblock)) 60 if (ioctl_by_bdev(bdev, CDROM_LAST_WRITTEN, (unsigned long) &lblock))
61 lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits; 61 lblock = bdev->bd_inode->i_size >> sb->s_blocksize_bits;
62 62
63 if (lblock) 63 if (lblock)
diff --git a/fs/udf/misc.c b/fs/udf/misc.c
index a7f57277a96e..15297deb5051 100644
--- a/fs/udf/misc.c
+++ b/fs/udf/misc.c
@@ -54,15 +54,15 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
54 int i; 54 int i;
55 55
56 ea = UDF_I_DATA(inode); 56 ea = UDF_I_DATA(inode);
57 if (UDF_I_LENEATTR(inode)) 57 if (UDF_I_LENEATTR(inode)) {
58 ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); 58 ad = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
59 else { 59 } else {
60 ad = ea; 60 ad = ea;
61 size += sizeof(struct extendedAttrHeaderDesc); 61 size += sizeof(struct extendedAttrHeaderDesc);
62 } 62 }
63 63
64 offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) - 64 offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) -
65 UDF_I_LENALLOC(inode); 65 UDF_I_LENALLOC(inode);
66 66
67 /* TODO - Check for FreeEASpace */ 67 /* TODO - Check for FreeEASpace */
68 68
@@ -76,56 +76,45 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
76 76
77 if (UDF_I_LENEATTR(inode)) { 77 if (UDF_I_LENEATTR(inode)) {
78 /* check checksum/crc */ 78 /* check checksum/crc */
79 if (le16_to_cpu(eahd->descTag.tagIdent) != 79 if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
80 TAG_IDENT_EAHD 80 le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
81 || le32_to_cpu(eahd->descTag.tagLocation) !=
82 UDF_I_LOCATION(inode).logicalBlockNum) {
83 return NULL; 81 return NULL;
84 } 82 }
85 } else { 83 } else {
86 size -= sizeof(struct extendedAttrHeaderDesc); 84 size -= sizeof(struct extendedAttrHeaderDesc);
87 UDF_I_LENEATTR(inode) += 85 UDF_I_LENEATTR(inode) += sizeof(struct extendedAttrHeaderDesc);
88 sizeof(struct extendedAttrHeaderDesc);
89 eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); 86 eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD);
90 if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200) 87 if (UDF_SB_UDFREV(inode->i_sb) >= 0x0200)
91 eahd->descTag.descVersion = cpu_to_le16(3); 88 eahd->descTag.descVersion = cpu_to_le16(3);
92 else 89 else
93 eahd->descTag.descVersion = cpu_to_le16(2); 90 eahd->descTag.descVersion = cpu_to_le16(2);
94 eahd->descTag.tagSerialNum = 91 eahd->descTag.tagSerialNum = cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb));
95 cpu_to_le16(UDF_SB_SERIALNUM(inode->i_sb)); 92 eahd->descTag.tagLocation = cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
96 eahd->descTag.tagLocation =
97 cpu_to_le32(UDF_I_LOCATION(inode).logicalBlockNum);
98 eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); 93 eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF);
99 eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); 94 eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF);
100 } 95 }
101 96
102 offset = UDF_I_LENEATTR(inode); 97 offset = UDF_I_LENEATTR(inode);
103 if (type < 2048) { 98 if (type < 2048) {
104 if (le32_to_cpu(eahd->appAttrLocation) < 99 if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
105 UDF_I_LENEATTR(inode)) { 100 uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
106 uint32_t aal = 101 memmove(&ea[offset - aal + size],
107 le32_to_cpu(eahd->appAttrLocation); 102 &ea[aal], offset - aal);
108 memmove(&ea[offset - aal + size], &ea[aal],
109 offset - aal);
110 offset -= aal; 103 offset -= aal;
111 eahd->appAttrLocation = cpu_to_le32(aal + size); 104 eahd->appAttrLocation = cpu_to_le32(aal + size);
112 } 105 }
113 if (le32_to_cpu(eahd->impAttrLocation) < 106 if (le32_to_cpu(eahd->impAttrLocation) < UDF_I_LENEATTR(inode)) {
114 UDF_I_LENEATTR(inode)) { 107 uint32_t ial = le32_to_cpu(eahd->impAttrLocation);
115 uint32_t ial = 108 memmove(&ea[offset - ial + size],
116 le32_to_cpu(eahd->impAttrLocation); 109 &ea[ial], offset - ial);
117 memmove(&ea[offset - ial + size], &ea[ial],
118 offset - ial);
119 offset -= ial; 110 offset -= ial;
120 eahd->impAttrLocation = cpu_to_le32(ial + size); 111 eahd->impAttrLocation = cpu_to_le32(ial + size);
121 } 112 }
122 } else if (type < 65536) { 113 } else if (type < 65536) {
123 if (le32_to_cpu(eahd->appAttrLocation) < 114 if (le32_to_cpu(eahd->appAttrLocation) < UDF_I_LENEATTR(inode)) {
124 UDF_I_LENEATTR(inode)) { 115 uint32_t aal = le32_to_cpu(eahd->appAttrLocation);
125 uint32_t aal = 116 memmove(&ea[offset - aal + size],
126 le32_to_cpu(eahd->appAttrLocation); 117 &ea[aal], offset - aal);
127 memmove(&ea[offset - aal + size], &ea[aal],
128 offset - aal);
129 offset -= aal; 118 offset -= aal;
130 eahd->appAttrLocation = cpu_to_le32(aal + size); 119 eahd->appAttrLocation = cpu_to_le32(aal + size);
131 } 120 }
@@ -133,18 +122,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size,
133 /* rewrite CRC + checksum of eahd */ 122 /* rewrite CRC + checksum of eahd */
134 crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag); 123 crclen = sizeof(struct extendedAttrHeaderDesc) - sizeof(tag);
135 eahd->descTag.descCRCLength = cpu_to_le16(crclen); 124 eahd->descTag.descCRCLength = cpu_to_le16(crclen);
136 eahd->descTag.descCRC = 125 eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd +
137 cpu_to_le16(udf_crc((char *)eahd + sizeof(tag), crclen, 0)); 126 sizeof(tag), crclen, 0));
138 eahd->descTag.tagChecksum = 0; 127 eahd->descTag.tagChecksum = 0;
139 for (i = 0; i < 16; i++) 128 for (i = 0; i < 16; i++)
140 if (i != 4) 129 if (i != 4)
141 eahd->descTag.tagChecksum += 130 eahd->descTag.tagChecksum += ((uint8_t *)&(eahd->descTag))[i];
142 ((uint8_t *) & (eahd->descTag))[i];
143 UDF_I_LENEATTR(inode) += size; 131 UDF_I_LENEATTR(inode) += size;
144 return (struct genericFormat *)&ea[offset]; 132 return (struct genericFormat *)&ea[offset];
145 } 133 }
146 if (loc & 0x02) { 134 if (loc & 0x02) {
147 } 135 }
136
148 return NULL; 137 return NULL;
149} 138}
150 139
@@ -163,8 +152,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
163 152
164 /* check checksum/crc */ 153 /* check checksum/crc */
165 if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD || 154 if (le16_to_cpu(eahd->descTag.tagIdent) != TAG_IDENT_EAHD ||
166 le32_to_cpu(eahd->descTag.tagLocation) != 155 le32_to_cpu(eahd->descTag.tagLocation) != UDF_I_LOCATION(inode).logicalBlockNum) {
167 UDF_I_LOCATION(inode).logicalBlockNum) {
168 return NULL; 156 return NULL;
169 } 157 }
170 158
@@ -177,13 +165,13 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type,
177 165
178 while (offset < UDF_I_LENEATTR(inode)) { 166 while (offset < UDF_I_LENEATTR(inode)) {
179 gaf = (struct genericFormat *)&ea[offset]; 167 gaf = (struct genericFormat *)&ea[offset];
180 if (le32_to_cpu(gaf->attrType) == type 168 if (le32_to_cpu(gaf->attrType) == type && gaf->attrSubtype == subtype)
181 && gaf->attrSubtype == subtype)
182 return gaf; 169 return gaf;
183 else 170 else
184 offset += le32_to_cpu(gaf->attrLength); 171 offset += le32_to_cpu(gaf->attrLength);
185 } 172 }
186 } 173 }
174
187 return NULL; 175 return NULL;
188} 176}
189 177
@@ -216,23 +204,22 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
216 return NULL; 204 return NULL;
217 } 205 }
218 206
219 tag_p = (tag *) (bh->b_data); 207 tag_p = (tag *)(bh->b_data);
220 208
221 *ident = le16_to_cpu(tag_p->tagIdent); 209 *ident = le16_to_cpu(tag_p->tagIdent);
222 210
223 if (location != le32_to_cpu(tag_p->tagLocation)) { 211 if (location != le32_to_cpu(tag_p->tagLocation)) {
224 udf_debug("location mismatch block %u, tag %u != %u\n", 212 udf_debug("location mismatch block %u, tag %u != %u\n",
225 block + UDF_SB_SESSION(sb), 213 block + UDF_SB_SESSION(sb), le32_to_cpu(tag_p->tagLocation), location);
226 le32_to_cpu(tag_p->tagLocation), location);
227 goto error_out; 214 goto error_out;
228 } 215 }
229 216
230 /* Verify the tag checksum */ 217 /* Verify the tag checksum */
231 checksum = 0U; 218 checksum = 0U;
232 for (i = 0; i < 4; i++) 219 for (i = 0; i < 4; i++)
233 checksum += (uint8_t) (bh->b_data[i]); 220 checksum += (uint8_t)(bh->b_data[i]);
234 for (i = 5; i < 16; i++) 221 for (i = 5; i < 16; i++)
235 checksum += (uint8_t) (bh->b_data[i]); 222 checksum += (uint8_t)(bh->b_data[i]);
236 if (checksum != tag_p->tagChecksum) { 223 if (checksum != tag_p->tagChecksum) {
237 printk(KERN_ERR "udf: tag checksum failed block %d\n", block); 224 printk(KERN_ERR "udf: tag checksum failed block %d\n", block);
238 goto error_out; 225 goto error_out;
@@ -249,16 +236,14 @@ struct buffer_head *udf_read_tagged(struct super_block *sb, uint32_t block,
249 /* Verify the descriptor CRC */ 236 /* Verify the descriptor CRC */
250 if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize || 237 if (le16_to_cpu(tag_p->descCRCLength) + sizeof(tag) > sb->s_blocksize ||
251 le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag), 238 le16_to_cpu(tag_p->descCRC) == udf_crc(bh->b_data + sizeof(tag),
252 le16_to_cpu(tag_p-> 239 le16_to_cpu(tag_p->descCRCLength), 0)) {
253 descCRCLength),
254 0)) {
255 return bh; 240 return bh;
256 } 241 }
257 udf_debug("Crc failure block %d: crc = %d, crclen = %d\n", 242 udf_debug("Crc failure block %d: crc = %d, crclen = %d\n",
258 block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC), 243 block + UDF_SB_SESSION(sb), le16_to_cpu(tag_p->descCRC),
259 le16_to_cpu(tag_p->descCRCLength)); 244 le16_to_cpu(tag_p->descCRCLength));
260 245
261 error_out: 246error_out:
262 brelse(bh); 247 brelse(bh);
263 return NULL; 248 return NULL;
264} 249}
@@ -272,7 +257,7 @@ struct buffer_head *udf_read_ptagged(struct super_block *sb, kernel_lb_addr loc,
272 257
273void udf_update_tag(char *data, int length) 258void udf_update_tag(char *data, int length)
274{ 259{
275 tag *tptr = (tag *) data; 260 tag *tptr = (tag *)data;
276 int i; 261 int i;
277 262
278 length -= sizeof(tag); 263 length -= sizeof(tag);
@@ -283,13 +268,13 @@ void udf_update_tag(char *data, int length)
283 268
284 for (i = 0; i < 16; i++) 269 for (i = 0; i < 16; i++)
285 if (i != 4) 270 if (i != 4)
286 tptr->tagChecksum += (uint8_t) (data[i]); 271 tptr->tagChecksum += (uint8_t)(data[i]);
287} 272}
288 273
289void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum, 274void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
290 uint32_t loc, int length) 275 uint32_t loc, int length)
291{ 276{
292 tag *tptr = (tag *) data; 277 tag *tptr = (tag *)data;
293 tptr->tagIdent = cpu_to_le16(ident); 278 tptr->tagIdent = cpu_to_le16(ident);
294 tptr->descVersion = cpu_to_le16(version); 279 tptr->descVersion = cpu_to_le16(version);
295 tptr->tagSerialNum = cpu_to_le16(snum); 280 tptr->tagSerialNum = cpu_to_le16(snum);
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 334d363a0903..bec96a6b3343 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -37,6 +37,7 @@ static inline int udf_match(int len1, const char *name1, int len2,
37{ 37{
38 if (len1 != len2) 38 if (len1 != len2)
39 return 0; 39 return 0;
40
40 return !memcmp(name1, name2, len1); 41 return !memcmp(name1, name2, len1);
41} 42}
42 43
@@ -52,7 +53,7 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
52 uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse); 53 uint16_t liu = le16_to_cpu(cfi->lengthOfImpUse);
53 uint8_t lfi = cfi->lengthFileIdent; 54 uint8_t lfi = cfi->lengthFileIdent;
54 int padlen = fibh->eoffset - fibh->soffset - liu - lfi - 55 int padlen = fibh->eoffset - fibh->soffset - liu - lfi -
55 sizeof(struct fileIdentDesc); 56 sizeof(struct fileIdentDesc);
56 int adinicb = 0; 57 int adinicb = 0;
57 58
58 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) 59 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB)
@@ -61,85 +62,75 @@ int udf_write_fi(struct inode *inode, struct fileIdentDesc *cfi,
61 offset = fibh->soffset + sizeof(struct fileIdentDesc); 62 offset = fibh->soffset + sizeof(struct fileIdentDesc);
62 63
63 if (impuse) { 64 if (impuse) {
64 if (adinicb || (offset + liu < 0)) 65 if (adinicb || (offset + liu < 0)) {
65 memcpy((uint8_t *) sfi->impUse, impuse, liu); 66 memcpy((uint8_t *)sfi->impUse, impuse, liu);
66 else if (offset >= 0) 67 } else if (offset >= 0) {
67 memcpy(fibh->ebh->b_data + offset, impuse, liu); 68 memcpy(fibh->ebh->b_data + offset, impuse, liu);
68 else { 69 } else {
69 memcpy((uint8_t *) sfi->impUse, impuse, -offset); 70 memcpy((uint8_t *)sfi->impUse, impuse, -offset);
70 memcpy(fibh->ebh->b_data, impuse - offset, 71 memcpy(fibh->ebh->b_data, impuse - offset, liu + offset);
71 liu + offset);
72 } 72 }
73 } 73 }
74 74
75 offset += liu; 75 offset += liu;
76 76
77 if (fileident) { 77 if (fileident) {
78 if (adinicb || (offset + lfi < 0)) 78 if (adinicb || (offset + lfi < 0)) {
79 memcpy((uint8_t *) sfi->fileIdent + liu, fileident, 79 memcpy((uint8_t *)sfi->fileIdent + liu, fileident, lfi);
80 lfi); 80 } else if (offset >= 0) {
81 else if (offset >= 0)
82 memcpy(fibh->ebh->b_data + offset, fileident, lfi); 81 memcpy(fibh->ebh->b_data + offset, fileident, lfi);
83 else { 82 } else {
84 memcpy((uint8_t *) sfi->fileIdent + liu, fileident, 83 memcpy((uint8_t *)sfi->fileIdent + liu, fileident, -offset);
85 -offset); 84 memcpy(fibh->ebh->b_data, fileident - offset, lfi + offset);
86 memcpy(fibh->ebh->b_data, fileident - offset,
87 lfi + offset);
88 } 85 }
89 } 86 }
90 87
91 offset += lfi; 88 offset += lfi;
92 89
93 if (adinicb || (offset + padlen < 0)) 90 if (adinicb || (offset + padlen < 0)) {
94 memset((uint8_t *) sfi->padding + liu + lfi, 0x00, padlen); 91 memset((uint8_t *)sfi->padding + liu + lfi, 0x00, padlen);
95 else if (offset >= 0) 92 } else if (offset >= 0) {
96 memset(fibh->ebh->b_data + offset, 0x00, padlen); 93 memset(fibh->ebh->b_data + offset, 0x00, padlen);
97 else { 94 } else {
98 memset((uint8_t *) sfi->padding + liu + lfi, 0x00, -offset); 95 memset((uint8_t *)sfi->padding + liu + lfi, 0x00, -offset);
99 memset(fibh->ebh->b_data, 0x00, padlen + offset); 96 memset(fibh->ebh->b_data, 0x00, padlen + offset);
100 } 97 }
101 98
102 crc = 99 crc = udf_crc((uint8_t *)cfi + sizeof(tag),
103 udf_crc((uint8_t *) cfi + sizeof(tag), 100 sizeof(struct fileIdentDesc) - sizeof(tag), 0);
104 sizeof(struct fileIdentDesc) - sizeof(tag), 0); 101
105 102 if (fibh->sbh == fibh->ebh) {
106 if (fibh->sbh == fibh->ebh) 103 crc = udf_crc((uint8_t *)sfi->impUse,
107 crc = udf_crc((uint8_t *) sfi->impUse, 104 crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc);
108 crclen + sizeof(tag) - 105 } else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) {
109 sizeof(struct fileIdentDesc), crc); 106 crc = udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) + fibh->soffset,
110 else if (sizeof(struct fileIdentDesc) >= -fibh->soffset) 107 crclen + sizeof(tag) - sizeof(struct fileIdentDesc), crc);
111 crc = 108 } else {
112 udf_crc(fibh->ebh->b_data + sizeof(struct fileIdentDesc) + 109 crc = udf_crc((uint8_t *)sfi->impUse,
113 fibh->soffset, 110 -fibh->soffset - sizeof(struct fileIdentDesc), crc);
114 crclen + sizeof(tag) - sizeof(struct fileIdentDesc),
115 crc);
116 else {
117 crc = udf_crc((uint8_t *) sfi->impUse,
118 -fibh->soffset - sizeof(struct fileIdentDesc),
119 crc);
120 crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc); 111 crc = udf_crc(fibh->ebh->b_data, fibh->eoffset, crc);
121 } 112 }
122 113
123 cfi->descTag.descCRC = cpu_to_le16(crc); 114 cfi->descTag.descCRC = cpu_to_le16(crc);
124 cfi->descTag.descCRCLength = cpu_to_le16(crclen); 115 cfi->descTag.descCRCLength = cpu_to_le16(crclen);
125 116
126 for (i = 0; i < 16; i++) 117 for (i = 0; i < 16; i++) {
127 if (i != 4) 118 if (i != 4)
128 checksum += ((uint8_t *) & cfi->descTag)[i]; 119 checksum += ((uint8_t *)&cfi->descTag)[i];
120 }
129 121
130 cfi->descTag.tagChecksum = checksum; 122 cfi->descTag.tagChecksum = checksum;
131 if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) 123 if (adinicb || (sizeof(struct fileIdentDesc) <= -fibh->soffset)) {
132 memcpy((uint8_t *) sfi, (uint8_t *) cfi, 124 memcpy((uint8_t *)sfi, (uint8_t *)cfi, sizeof(struct fileIdentDesc));
133 sizeof(struct fileIdentDesc)); 125 } else {
134 else { 126 memcpy((uint8_t *)sfi, (uint8_t *)cfi, -fibh->soffset);
135 memcpy((uint8_t *) sfi, (uint8_t *) cfi, -fibh->soffset); 127 memcpy(fibh->ebh->b_data, (uint8_t *)cfi - fibh->soffset,
136 memcpy(fibh->ebh->b_data, (uint8_t *) cfi - fibh->soffset,
137 sizeof(struct fileIdentDesc) + fibh->soffset); 128 sizeof(struct fileIdentDesc) + fibh->soffset);
138 } 129 }
139 130
140 if (adinicb) 131 if (adinicb) {
141 mark_inode_dirty(inode); 132 mark_inode_dirty(inode);
142 else { 133 } else {
143 if (fibh->sbh != fibh->ebh) 134 if (fibh->sbh != fibh->ebh)
144 mark_buffer_dirty_inode(fibh->ebh, inode); 135 mark_buffer_dirty_inode(fibh->ebh, inode);
145 mark_buffer_dirty_inode(fibh->sbh, inode); 136 mark_buffer_dirty_inode(fibh->sbh, inode);
@@ -163,26 +154,25 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
163 kernel_lb_addr eloc; 154 kernel_lb_addr eloc;
164 uint32_t elen; 155 uint32_t elen;
165 sector_t offset; 156 sector_t offset;
166 struct extent_position epos = { NULL, 0, {0, 0} }; 157 struct extent_position epos = {};
167 158
168 size = (udf_ext0_offset(dir) + dir->i_size) >> 2; 159 size = (udf_ext0_offset(dir) + dir->i_size) >> 2;
169 f_pos = (udf_ext0_offset(dir) >> 2); 160 f_pos = (udf_ext0_offset(dir) >> 2);
170 161
171 fibh->soffset = fibh->eoffset = 162 fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
172 (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; 163 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
173 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
174 fibh->sbh = fibh->ebh = NULL; 164 fibh->sbh = fibh->ebh = NULL;
175 else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 165 } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
176 &epos, &eloc, &elen, 166 &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
177 &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
178 block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 167 block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
179 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 168 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
180 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 169 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
181 epos.offset -= sizeof(short_ad); 170 epos.offset -= sizeof(short_ad);
182 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) 171 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
183 epos.offset -= sizeof(long_ad); 172 epos.offset -= sizeof(long_ad);
184 } else 173 } else {
185 offset = 0; 174 offset = 0;
175 }
186 176
187 if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { 177 if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) {
188 brelse(epos.bh); 178 brelse(epos.bh);
@@ -196,7 +186,6 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
196 while ((f_pos < size)) { 186 while ((f_pos < size)) {
197 fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc, 187 fi = udf_fileident_read(dir, &f_pos, fibh, cfi, &epos, &eloc,
198 &elen, &offset); 188 &elen, &offset);
199
200 if (!fi) { 189 if (!fi) {
201 if (fibh->sbh != fibh->ebh) 190 if (fibh->sbh != fibh->ebh)
202 brelse(fibh->ebh); 191 brelse(fibh->ebh);
@@ -213,20 +202,14 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
213 } else { 202 } else {
214 int poffset; /* Unpaded ending offset */ 203 int poffset; /* Unpaded ending offset */
215 204
216 poffset = 205 poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi;
217 fibh->soffset + sizeof(struct fileIdentDesc) + liu +
218 lfi;
219 206
220 if (poffset >= lfi) 207 if (poffset >= lfi) {
221 nameptr = 208 nameptr = (uint8_t *)(fibh->ebh->b_data + poffset - lfi);
222 (uint8_t *) (fibh->ebh->b_data + poffset - 209 } else {
223 lfi);
224 else {
225 nameptr = fname; 210 nameptr = fname;
226 memcpy(nameptr, fi->fileIdent + liu, 211 memcpy(nameptr, fi->fileIdent + liu, lfi - poffset);
227 lfi - poffset); 212 memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset);
228 memcpy(nameptr + lfi - poffset,
229 fibh->ebh->b_data, poffset);
230 } 213 }
231 } 214 }
232 215
@@ -244,18 +227,18 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir,
244 continue; 227 continue;
245 228
246 if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) { 229 if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi))) {
247 if (udf_match 230 if (udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) {
248 (flen, fname, dentry->d_name.len,
249 dentry->d_name.name)) {
250 brelse(epos.bh); 231 brelse(epos.bh);
251 return fi; 232 return fi;
252 } 233 }
253 } 234 }
254 } 235 }
236
255 if (fibh->sbh != fibh->ebh) 237 if (fibh->sbh != fibh->ebh)
256 brelse(fibh->ebh); 238 brelse(fibh->ebh);
257 brelse(fibh->sbh); 239 brelse(fibh->sbh);
258 brelse(epos.bh); 240 brelse(epos.bh);
241
259 return NULL; 242 return NULL;
260} 243}
261 244
@@ -306,15 +289,19 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
306#ifdef UDF_RECOVERY 289#ifdef UDF_RECOVERY
307 /* temporary shorthand for specifying files by inode number */ 290 /* temporary shorthand for specifying files by inode number */
308 if (!strncmp(dentry->d_name.name, ".B=", 3)) { 291 if (!strncmp(dentry->d_name.name, ".B=", 3)) {
309 kernel_lb_addr lb = 292 kernel_lb_addr lb = {
310 { 0, simple_strtoul(dentry->d_name.name + 3, NULL, 0) }; 293 .logicalBlockNum = 0,
294 .partitionReferenceNum = simple_strtoul(dentry->d_name.name + 3,
295 NULL, 0),
296 };
311 inode = udf_iget(dir->i_sb, lb); 297 inode = udf_iget(dir->i_sb, lb);
312 if (!inode) { 298 if (!inode) {
313 unlock_kernel(); 299 unlock_kernel();
314 return ERR_PTR(-EACCES); 300 return ERR_PTR(-EACCES);
315 } 301 }
316 } else 302 }
317#endif /* UDF_RECOVERY */ 303 else
304#endif /* UDF_RECOVERY */
318 305
319 if (udf_find_entry(dir, dentry, &fibh, &cfi)) { 306 if (udf_find_entry(dir, dentry, &fibh, &cfi)) {
320 if (fibh.sbh != fibh.ebh) 307 if (fibh.sbh != fibh.ebh)
@@ -329,6 +316,7 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry,
329 } 316 }
330 unlock_kernel(); 317 unlock_kernel();
331 d_add(dentry, inode); 318 d_add(dentry, inode);
319
332 return NULL; 320 return NULL;
333} 321}
334 322
@@ -352,7 +340,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
352 kernel_lb_addr eloc; 340 kernel_lb_addr eloc;
353 uint32_t elen; 341 uint32_t elen;
354 sector_t offset; 342 sector_t offset;
355 struct extent_position epos = { NULL, 0, {0, 0} }; 343 struct extent_position epos = {};
356 344
357 sb = dir->i_sb; 345 sb = dir->i_sb;
358 346
@@ -361,36 +349,33 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
361 *err = -EINVAL; 349 *err = -EINVAL;
362 return NULL; 350 return NULL;
363 } 351 }
364 352 if (!(namelen = udf_put_filename(sb, dentry->d_name.name, name,
365 if (! 353 dentry->d_name.len))) {
366 (namelen =
367 udf_put_filename(sb, dentry->d_name.name, name,
368 dentry->d_name.len))) {
369 *err = -ENAMETOOLONG; 354 *err = -ENAMETOOLONG;
370 return NULL; 355 return NULL;
371 } 356 }
372 } else 357 } else {
373 namelen = 0; 358 namelen = 0;
359 }
374 360
375 nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3; 361 nfidlen = (sizeof(struct fileIdentDesc) + namelen + 3) & ~3;
376 362
377 f_pos = (udf_ext0_offset(dir) >> 2); 363 f_pos = (udf_ext0_offset(dir) >> 2);
378 364
379 fibh->soffset = fibh->eoffset = 365 fibh->soffset = fibh->eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
380 (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2; 366 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
381 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB)
382 fibh->sbh = fibh->ebh = NULL; 367 fibh->sbh = fibh->ebh = NULL;
383 else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 368 } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
384 &epos, &eloc, &elen, 369 &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
385 &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
386 block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 370 block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
387 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 371 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
388 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 372 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
389 epos.offset -= sizeof(short_ad); 373 epos.offset -= sizeof(short_ad);
390 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) 374 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
391 epos.offset -= sizeof(long_ad); 375 epos.offset -= sizeof(long_ad);
392 } else 376 } else {
393 offset = 0; 377 offset = 0;
378 }
394 379
395 if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) { 380 if (!(fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block))) {
396 brelse(epos.bh); 381 brelse(epos.bh);
@@ -423,40 +408,33 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
423 liu = le16_to_cpu(cfi->lengthOfImpUse); 408 liu = le16_to_cpu(cfi->lengthOfImpUse);
424 lfi = cfi->lengthFileIdent; 409 lfi = cfi->lengthFileIdent;
425 410
426 if (fibh->sbh == fibh->ebh) 411 if (fibh->sbh == fibh->ebh) {
427 nameptr = fi->fileIdent + liu; 412 nameptr = fi->fileIdent + liu;
428 else { 413 } else {
429 int poffset; /* Unpaded ending offset */ 414 int poffset; /* Unpaded ending offset */
430 415
431 poffset = 416 poffset = fibh->soffset + sizeof(struct fileIdentDesc) + liu + lfi;
432 fibh->soffset + sizeof(struct fileIdentDesc) + liu +
433 lfi;
434 417
435 if (poffset >= lfi) 418 if (poffset >= lfi) {
436 nameptr = 419 nameptr = (char *)(fibh->ebh->b_data + poffset - lfi);
437 (char *)(fibh->ebh->b_data + poffset - lfi); 420 } else {
438 else {
439 nameptr = fname; 421 nameptr = fname;
440 memcpy(nameptr, fi->fileIdent + liu, 422 memcpy(nameptr, fi->fileIdent + liu, lfi - poffset);
441 lfi - poffset); 423 memcpy(nameptr + lfi - poffset, fibh->ebh->b_data, poffset);
442 memcpy(nameptr + lfi - poffset,
443 fibh->ebh->b_data, poffset);
444 } 424 }
445 } 425 }
446 426
447 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) { 427 if ((cfi->fileCharacteristics & FID_FILE_CHAR_DELETED) != 0) {
448 if (((sizeof(struct fileIdentDesc) + liu + lfi + 428 if (((sizeof(struct fileIdentDesc) + liu + lfi + 3) & ~3) == nfidlen) {
449 3) & ~3) == nfidlen) {
450 brelse(epos.bh); 429 brelse(epos.bh);
451 cfi->descTag.tagSerialNum = cpu_to_le16(1); 430 cfi->descTag.tagSerialNum = cpu_to_le16(1);
452 cfi->fileVersionNum = cpu_to_le16(1); 431 cfi->fileVersionNum = cpu_to_le16(1);
453 cfi->fileCharacteristics = 0; 432 cfi->fileCharacteristics = 0;
454 cfi->lengthFileIdent = namelen; 433 cfi->lengthFileIdent = namelen;
455 cfi->lengthOfImpUse = cpu_to_le16(0); 434 cfi->lengthOfImpUse = cpu_to_le16(0);
456 if (!udf_write_fi 435 if (!udf_write_fi(dir, cfi, fi, fibh, NULL, name)) {
457 (dir, cfi, fi, fibh, NULL, name))
458 return fi; 436 return fi;
459 else { 437 } else {
460 *err = -EIO; 438 *err = -EIO;
461 return NULL; 439 return NULL;
462 } 440 }
@@ -467,8 +445,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
467 continue; 445 continue;
468 446
469 if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) && 447 if ((flen = udf_get_filename(dir->i_sb, nameptr, fname, lfi)) &&
470 udf_match(flen, fname, dentry->d_name.len, 448 udf_match(flen, fname, dentry->d_name.len, dentry->d_name.name)) {
471 dentry->d_name.name)) {
472 if (fibh->sbh != fibh->ebh) 449 if (fibh->sbh != fibh->ebh)
473 brelse(fibh->ebh); 450 brelse(fibh->ebh);
474 brelse(fibh->sbh); 451 brelse(fibh->sbh);
@@ -478,7 +455,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
478 } 455 }
479 } 456 }
480 457
481 add: 458add:
482 f_pos += nfidlen; 459 f_pos += nfidlen;
483 460
484 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB && 461 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB &&
@@ -491,14 +468,11 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
491 if (fibh->sbh != fibh->ebh) 468 if (fibh->sbh != fibh->ebh)
492 brelse(fibh->ebh); 469 brelse(fibh->ebh);
493 brelse(fibh->sbh); 470 brelse(fibh->sbh);
494 if (! 471 if (!(fibh->sbh = fibh->ebh = udf_expand_dir_adinicb(dir, &block, err)))
495 (fibh->sbh = fibh->ebh =
496 udf_expand_dir_adinicb(dir, &block, err)))
497 return NULL; 472 return NULL;
498 epos.block = UDF_I_LOCATION(dir); 473 epos.block = UDF_I_LOCATION(dir);
499 eloc.logicalBlockNum = block; 474 eloc.logicalBlockNum = block;
500 eloc.partitionReferenceNum = 475 eloc.partitionReferenceNum = UDF_I_LOCATION(dir).partitionReferenceNum;
501 UDF_I_LOCATION(dir).partitionReferenceNum;
502 elen = dir->i_sb->s_blocksize; 476 elen = dir->i_sb->s_blocksize;
503 epos.offset = udf_file_entry_alloc_offset(dir); 477 epos.offset = udf_file_entry_alloc_offset(dir);
504 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 478 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
@@ -517,16 +491,13 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
517 491
518 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 492 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
519 block = UDF_I_LOCATION(dir).logicalBlockNum; 493 block = UDF_I_LOCATION(dir).logicalBlockNum;
520 fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) + 494 fi = (struct fileIdentDesc *)(UDF_I_DATA(dir) + fibh->soffset -
521 fibh->soffset -
522 udf_ext0_offset(dir) + 495 udf_ext0_offset(dir) +
523 UDF_I_LENEATTR(dir)); 496 UDF_I_LENEATTR(dir));
524 } else { 497 } else {
525 block = eloc.logicalBlockNum + ((elen - 1) >> 498 block = eloc.logicalBlockNum + ((elen - 1) >>
526 dir->i_sb-> 499 dir->i_sb->s_blocksize_bits);
527 s_blocksize_bits); 500 fi = (struct fileIdentDesc *)(fibh->sbh->b_data + fibh->soffset);
528 fi = (struct fileIdentDesc *)(fibh->sbh->b_data +
529 fibh->soffset);
530 } 501 }
531 } else { 502 } else {
532 fibh->soffset = fibh->eoffset - sb->s_blocksize; 503 fibh->soffset = fibh->eoffset - sb->s_blocksize;
@@ -538,42 +509,36 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir,
538 509
539 block = eloc.logicalBlockNum + ((elen - 1) >> 510 block = eloc.logicalBlockNum + ((elen - 1) >>
540 dir->i_sb->s_blocksize_bits); 511 dir->i_sb->s_blocksize_bits);
541 512 fibh->ebh = udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 1, err);
542 if (! 513 if (!fibh->ebh) {
543 (fibh->ebh =
544 udf_bread(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
545 1, err))) {
546 brelse(epos.bh); 514 brelse(epos.bh);
547 brelse(fibh->sbh); 515 brelse(fibh->sbh);
548 return NULL; 516 return NULL;
549 } 517 }
550 518
551 if (!(fibh->soffset)) { 519 if (!fibh->soffset) {
552 if (udf_next_aext(dir, &epos, &eloc, &elen, 1) == 520 if (udf_next_aext(dir, &epos, &eloc, &elen, 1) ==
553 (EXT_RECORDED_ALLOCATED >> 30)) { 521 (EXT_RECORDED_ALLOCATED >> 30)) {
554 block = eloc.logicalBlockNum + ((elen - 1) >> 522 block = eloc.logicalBlockNum + ((elen - 1) >>
555 dir->i_sb-> 523 dir->i_sb->s_blocksize_bits);
556 s_blocksize_bits); 524 } else {
557 } else
558 block++; 525 block++;
526 }
559 527
560 brelse(fibh->sbh); 528 brelse(fibh->sbh);
561 fibh->sbh = fibh->ebh; 529 fibh->sbh = fibh->ebh;
562 fi = (struct fileIdentDesc *)(fibh->sbh->b_data); 530 fi = (struct fileIdentDesc *)(fibh->sbh->b_data);
563 } else { 531 } else {
564 fi = (struct fileIdentDesc *) 532 fi = (struct fileIdentDesc *)
565 (fibh->sbh->b_data + sb->s_blocksize + 533 (fibh->sbh->b_data + sb->s_blocksize + fibh->soffset);
566 fibh->soffset);
567 } 534 }
568 } 535 }
569 536
570 memset(cfi, 0, sizeof(struct fileIdentDesc)); 537 memset(cfi, 0, sizeof(struct fileIdentDesc));
571 if (UDF_SB_UDFREV(sb) >= 0x0200) 538 if (UDF_SB_UDFREV(sb) >= 0x0200)
572 udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, 539 udf_new_tag((char *)cfi, TAG_IDENT_FID, 3, 1, block, sizeof(tag));
573 sizeof(tag));
574 else 540 else
575 udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, 541 udf_new_tag((char *)cfi, TAG_IDENT_FID, 2, 1, block, sizeof(tag));
576 sizeof(tag));
577 cfi->fileVersionNum = cpu_to_le16(1); 542 cfi->fileVersionNum = cpu_to_le16(1);
578 cfi->lengthFileIdent = namelen; 543 cfi->lengthFileIdent = namelen;
579 cfi->lengthOfImpUse = cpu_to_le16(0); 544 cfi->lengthOfImpUse = cpu_to_le16(0);
@@ -599,8 +564,10 @@ static int udf_delete_entry(struct inode *inode, struct fileIdentDesc *fi,
599 struct fileIdentDesc *cfi) 564 struct fileIdentDesc *cfi)
600{ 565{
601 cfi->fileCharacteristics |= FID_FILE_CHAR_DELETED; 566 cfi->fileCharacteristics |= FID_FILE_CHAR_DELETED;
567
602 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT)) 568 if (UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT))
603 memset(&(cfi->icb), 0x00, sizeof(long_ad)); 569 memset(&(cfi->icb), 0x00, sizeof(long_ad));
570
604 return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL); 571 return udf_write_fi(inode, cfi, fi, fibh, NULL, NULL);
605} 572}
606 573
@@ -637,8 +604,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
637 } 604 }
638 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); 605 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
639 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); 606 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
640 *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 607 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
641 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); 608 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
642 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); 609 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
643 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 610 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
644 mark_inode_dirty(dir); 611 mark_inode_dirty(dir);
@@ -648,6 +615,7 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
648 brelse(fibh.sbh); 615 brelse(fibh.sbh);
649 unlock_kernel(); 616 unlock_kernel();
650 d_instantiate(dentry, inode); 617 d_instantiate(dentry, inode);
618
651 return 0; 619 return 0;
652} 620}
653 621
@@ -679,8 +647,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
679 } 647 }
680 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); 648 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
681 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); 649 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
682 *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 650 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
683 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); 651 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
684 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); 652 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
685 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 653 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
686 mark_inode_dirty(dir); 654 mark_inode_dirty(dir);
@@ -692,7 +660,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
692 brelse(fibh.sbh); 660 brelse(fibh.sbh);
693 d_instantiate(dentry, inode); 661 d_instantiate(dentry, inode);
694 err = 0; 662 err = 0;
695 out: 663
664out:
696 unlock_kernel(); 665 unlock_kernel();
697 return err; 666 return err;
698} 667}
@@ -725,10 +694,9 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
725 inode->i_nlink = 2; 694 inode->i_nlink = 2;
726 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); 695 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
727 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir)); 696 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(dir));
728 *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 697 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
729 cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL); 698 cpu_to_le32(UDF_I_UNIQUE(dir) & 0x00000000FFFFFFFFUL);
730 cfi.fileCharacteristics = 699 cfi.fileCharacteristics = FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
731 FID_FILE_CHAR_DIRECTORY | FID_FILE_CHAR_PARENT;
732 udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL); 700 udf_write_fi(inode, &cfi, fi, &fibh, NULL, NULL);
733 brelse(fibh.sbh); 701 brelse(fibh.sbh);
734 inode->i_mode = S_IFDIR | mode; 702 inode->i_mode = S_IFDIR | mode;
@@ -744,8 +712,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
744 } 712 }
745 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize); 713 cfi.icb.extLength = cpu_to_le32(inode->i_sb->s_blocksize);
746 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode)); 714 cfi.icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(inode));
747 *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 715 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
748 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL); 716 cpu_to_le32(UDF_I_UNIQUE(inode) & 0x00000000FFFFFFFFUL);
749 cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY; 717 cfi.fileCharacteristics |= FID_FILE_CHAR_DIRECTORY;
750 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL); 718 udf_write_fi(dir, &cfi, fi, &fibh, NULL, NULL);
751 inc_nlink(dir); 719 inc_nlink(dir);
@@ -755,7 +723,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
755 brelse(fibh.ebh); 723 brelse(fibh.ebh);
756 brelse(fibh.sbh); 724 brelse(fibh.sbh);
757 err = 0; 725 err = 0;
758 out: 726
727out:
759 unlock_kernel(); 728 unlock_kernel();
760 return err; 729 return err;
761} 730}
@@ -770,26 +739,25 @@ static int empty_dir(struct inode *dir)
770 kernel_lb_addr eloc; 739 kernel_lb_addr eloc;
771 uint32_t elen; 740 uint32_t elen;
772 sector_t offset; 741 sector_t offset;
773 struct extent_position epos = { NULL, 0, {0, 0} }; 742 struct extent_position epos = {};
774 743
775 f_pos = (udf_ext0_offset(dir) >> 2); 744 f_pos = (udf_ext0_offset(dir) >> 2);
776 745
777 fibh.soffset = fibh.eoffset = 746 fibh.soffset = fibh.eoffset = (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
778 (f_pos & ((dir->i_sb->s_blocksize - 1) >> 2)) << 2;
779 747
780 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) 748 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
781 fibh.sbh = fibh.ebh = NULL; 749 fibh.sbh = fibh.ebh = NULL;
782 else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2), 750 } else if (inode_bmap(dir, f_pos >> (dir->i_sb->s_blocksize_bits - 2),
783 &epos, &eloc, &elen, 751 &epos, &eloc, &elen, &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
784 &offset) == (EXT_RECORDED_ALLOCATED >> 30)) {
785 block = udf_get_lb_pblock(dir->i_sb, eloc, offset); 752 block = udf_get_lb_pblock(dir->i_sb, eloc, offset);
786 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) { 753 if ((++offset << dir->i_sb->s_blocksize_bits) < elen) {
787 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT) 754 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_SHORT)
788 epos.offset -= sizeof(short_ad); 755 epos.offset -= sizeof(short_ad);
789 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG) 756 else if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_LONG)
790 epos.offset -= sizeof(long_ad); 757 epos.offset -= sizeof(long_ad);
791 } else 758 } else {
792 offset = 0; 759 offset = 0;
760 }
793 761
794 if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) { 762 if (!(fibh.sbh = fibh.ebh = udf_tread(dir->i_sb, block))) {
795 brelse(epos.bh); 763 brelse(epos.bh);
@@ -803,7 +771,6 @@ static int empty_dir(struct inode *dir)
803 while ((f_pos < size)) { 771 while ((f_pos < size)) {
804 fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc, 772 fi = udf_fileident_read(dir, &f_pos, &fibh, &cfi, &epos, &eloc,
805 &elen, &offset); 773 &elen, &offset);
806
807 if (!fi) { 774 if (!fi) {
808 if (fibh.sbh != fibh.ebh) 775 if (fibh.sbh != fibh.ebh)
809 brelse(fibh.ebh); 776 brelse(fibh.ebh);
@@ -812,8 +779,8 @@ static int empty_dir(struct inode *dir)
812 return 0; 779 return 0;
813 } 780 }
814 781
815 if (cfi.lengthFileIdent 782 if (cfi.lengthFileIdent &&
816 && (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) { 783 (cfi.fileCharacteristics & FID_FILE_CHAR_DELETED) == 0) {
817 if (fibh.sbh != fibh.ebh) 784 if (fibh.sbh != fibh.ebh)
818 brelse(fibh.ebh); 785 brelse(fibh.ebh);
819 brelse(fibh.sbh); 786 brelse(fibh.sbh);
@@ -821,10 +788,12 @@ static int empty_dir(struct inode *dir)
821 return 0; 788 return 0;
822 } 789 }
823 } 790 }
791
824 if (fibh.sbh != fibh.ebh) 792 if (fibh.sbh != fibh.ebh)
825 brelse(fibh.ebh); 793 brelse(fibh.ebh);
826 brelse(fibh.sbh); 794 brelse(fibh.sbh);
827 brelse(epos.bh); 795 brelse(epos.bh);
796
828 return 1; 797 return 1;
829} 798}
830 799
@@ -859,15 +828,15 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
859 clear_nlink(inode); 828 clear_nlink(inode);
860 inode->i_size = 0; 829 inode->i_size = 0;
861 inode_dec_link_count(dir); 830 inode_dec_link_count(dir);
862 inode->i_ctime = dir->i_ctime = dir->i_mtime = 831 inode->i_ctime = dir->i_ctime = dir->i_mtime = current_fs_time(dir->i_sb);
863 current_fs_time(dir->i_sb);
864 mark_inode_dirty(dir); 832 mark_inode_dirty(dir);
865 833
866 end_rmdir: 834end_rmdir:
867 if (fibh.sbh != fibh.ebh) 835 if (fibh.sbh != fibh.ebh)
868 brelse(fibh.ebh); 836 brelse(fibh.ebh);
869 brelse(fibh.sbh); 837 brelse(fibh.sbh);
870 out: 838
839out:
871 unlock_kernel(); 840 unlock_kernel();
872 return retval; 841 return retval;
873} 842}
@@ -906,11 +875,12 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
906 inode->i_ctime = dir->i_ctime; 875 inode->i_ctime = dir->i_ctime;
907 retval = 0; 876 retval = 0;
908 877
909 end_unlink: 878end_unlink:
910 if (fibh.sbh != fibh.ebh) 879 if (fibh.sbh != fibh.ebh)
911 brelse(fibh.ebh); 880 brelse(fibh.ebh);
912 brelse(fibh.sbh); 881 brelse(fibh.sbh);
913 out: 882
883out:
914 unlock_kernel(); 884 unlock_kernel();
915 return retval; 885 return retval;
916} 886}
@@ -922,7 +892,7 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
922 struct pathComponent *pc; 892 struct pathComponent *pc;
923 char *compstart; 893 char *compstart;
924 struct udf_fileident_bh fibh; 894 struct udf_fileident_bh fibh;
925 struct extent_position epos = { NULL, 0, {0, 0} }; 895 struct extent_position epos = {};
926 int eoffset, elen = 0; 896 int eoffset, elen = 0;
927 struct fileIdentDesc *fi; 897 struct fileIdentDesc *fi;
928 struct fileIdentDesc cfi; 898 struct fileIdentDesc cfi;
@@ -945,26 +915,22 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
945 uint32_t elen; 915 uint32_t elen;
946 916
947 block = udf_new_block(inode->i_sb, inode, 917 block = udf_new_block(inode->i_sb, inode,
948 UDF_I_LOCATION(inode). 918 UDF_I_LOCATION(inode).partitionReferenceNum,
949 partitionReferenceNum, 919 UDF_I_LOCATION(inode).logicalBlockNum, &err);
950 UDF_I_LOCATION(inode).logicalBlockNum,
951 &err);
952 if (!block) 920 if (!block)
953 goto out_no_entry; 921 goto out_no_entry;
954 epos.block = UDF_I_LOCATION(inode); 922 epos.block = UDF_I_LOCATION(inode);
955 epos.offset = udf_file_entry_alloc_offset(inode); 923 epos.offset = udf_file_entry_alloc_offset(inode);
956 epos.bh = NULL; 924 epos.bh = NULL;
957 eloc.logicalBlockNum = block; 925 eloc.logicalBlockNum = block;
958 eloc.partitionReferenceNum = 926 eloc.partitionReferenceNum = UDF_I_LOCATION(inode).partitionReferenceNum;
959 UDF_I_LOCATION(inode).partitionReferenceNum;
960 elen = inode->i_sb->s_blocksize; 927 elen = inode->i_sb->s_blocksize;
961 UDF_I_LENEXTENTS(inode) = elen; 928 UDF_I_LENEXTENTS(inode) = elen;
962 udf_add_aext(inode, &epos, eloc, elen, 0); 929 udf_add_aext(inode, &epos, eloc, elen, 0);
963 brelse(epos.bh); 930 brelse(epos.bh);
964 931
965 block = udf_get_pblock(inode->i_sb, block, 932 block = udf_get_pblock(inode->i_sb, block,
966 UDF_I_LOCATION(inode). 933 UDF_I_LOCATION(inode).partitionReferenceNum, 0);
967 partitionReferenceNum, 0);
968 epos.bh = udf_tread(inode->i_sb, block); 934 epos.bh = udf_tread(inode->i_sb, block);
969 lock_buffer(epos.bh); 935 lock_buffer(epos.bh);
970 memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize); 936 memset(epos.bh->b_data, 0x00, inode->i_sb->s_blocksize);
@@ -972,8 +938,9 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
972 unlock_buffer(epos.bh); 938 unlock_buffer(epos.bh);
973 mark_buffer_dirty_inode(epos.bh, inode); 939 mark_buffer_dirty_inode(epos.bh, inode);
974 ea = epos.bh->b_data + udf_ext0_offset(inode); 940 ea = epos.bh->b_data + udf_ext0_offset(inode);
975 } else 941 } else {
976 ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); 942 ea = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
943 }
977 944
978 eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode); 945 eoffset = inode->i_sb->s_blocksize - udf_ext0_offset(inode);
979 pc = (struct pathComponent *)ea; 946 pc = (struct pathComponent *)ea;
@@ -1010,20 +977,17 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
1010 if (compstart[0] == '.') { 977 if (compstart[0] == '.') {
1011 if ((symname - compstart) == 1) 978 if ((symname - compstart) == 1)
1012 pc->componentType = 4; 979 pc->componentType = 4;
1013 else if ((symname - compstart) == 2 980 else if ((symname - compstart) == 2 && compstart[1] == '.')
1014 && compstart[1] == '.')
1015 pc->componentType = 3; 981 pc->componentType = 3;
1016 } 982 }
1017 983
1018 if (pc->componentType == 5) { 984 if (pc->componentType == 5) {
1019 if (! 985 namelen = udf_put_filename(inode->i_sb, compstart, name,
1020 (namelen = 986 symname - compstart);
1021 udf_put_filename(inode->i_sb, compstart, name, 987 if (!namelen)
1022 symname - compstart)))
1023 goto out_no_entry; 988 goto out_no_entry;
1024 989
1025 if (elen + sizeof(struct pathComponent) + namelen > 990 if (elen + sizeof(struct pathComponent) + namelen > eoffset)
1026 eoffset)
1027 goto out_no_entry; 991 goto out_no_entry;
1028 else 992 else
1029 pc->lengthComponentIdent = namelen; 993 pc->lengthComponentIdent = namelen;
@@ -1053,12 +1017,10 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
1053 if (UDF_SB_LVIDBH(inode->i_sb)) { 1017 if (UDF_SB_LVIDBH(inode->i_sb)) {
1054 struct logicalVolHeaderDesc *lvhd; 1018 struct logicalVolHeaderDesc *lvhd;
1055 uint64_t uniqueID; 1019 uint64_t uniqueID;
1056 lvhd = 1020 lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
1057 (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->
1058 logicalVolContentsUse);
1059 uniqueID = le64_to_cpu(lvhd->uniqueID); 1021 uniqueID = le64_to_cpu(lvhd->uniqueID);
1060 *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 1022 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
1061 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); 1023 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
1062 if (!(++uniqueID & 0x00000000FFFFFFFFUL)) 1024 if (!(++uniqueID & 0x00000000FFFFFFFFUL))
1063 uniqueID += 16; 1025 uniqueID += 16;
1064 lvhd->uniqueID = cpu_to_le64(uniqueID); 1026 lvhd->uniqueID = cpu_to_le64(uniqueID);
@@ -1074,11 +1036,11 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
1074 d_instantiate(dentry, inode); 1036 d_instantiate(dentry, inode);
1075 err = 0; 1037 err = 0;
1076 1038
1077 out: 1039out:
1078 unlock_kernel(); 1040 unlock_kernel();
1079 return err; 1041 return err;
1080 1042
1081 out_no_entry: 1043out_no_entry:
1082 inode_dec_link_count(inode); 1044 inode_dec_link_count(inode);
1083 iput(inode); 1045 iput(inode);
1084 goto out; 1046 goto out;
@@ -1107,12 +1069,10 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
1107 if (UDF_SB_LVIDBH(inode->i_sb)) { 1069 if (UDF_SB_LVIDBH(inode->i_sb)) {
1108 struct logicalVolHeaderDesc *lvhd; 1070 struct logicalVolHeaderDesc *lvhd;
1109 uint64_t uniqueID; 1071 uint64_t uniqueID;
1110 lvhd = 1072 lvhd = (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->logicalVolContentsUse);
1111 (struct logicalVolHeaderDesc *)(UDF_SB_LVID(inode->i_sb)->
1112 logicalVolContentsUse);
1113 uniqueID = le64_to_cpu(lvhd->uniqueID); 1073 uniqueID = le64_to_cpu(lvhd->uniqueID);
1114 *(__le32 *) ((struct allocDescImpUse *)cfi.icb.impUse)->impUse = 1074 *(__le32 *)((struct allocDescImpUse *)cfi.icb.impUse)->impUse =
1115 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL); 1075 cpu_to_le32(uniqueID & 0x00000000FFFFFFFFUL);
1116 if (!(++uniqueID & 0x00000000FFFFFFFFUL)) 1076 if (!(++uniqueID & 0x00000000FFFFFFFFUL))
1117 uniqueID += 16; 1077 uniqueID += 16;
1118 lvhd->uniqueID = cpu_to_le64(uniqueID); 1078 lvhd->uniqueID = cpu_to_le64(uniqueID);
@@ -1122,6 +1082,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
1122 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) { 1082 if (UDF_I_ALLOCTYPE(dir) == ICBTAG_FLAG_AD_IN_ICB) {
1123 mark_inode_dirty(dir); 1083 mark_inode_dirty(dir);
1124 } 1084 }
1085
1125 if (fibh.sbh != fibh.ebh) 1086 if (fibh.sbh != fibh.ebh)
1126 brelse(fibh.ebh); 1087 brelse(fibh.ebh);
1127 brelse(fibh.sbh); 1088 brelse(fibh.sbh);
@@ -1131,6 +1092,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
1131 atomic_inc(&inode->i_count); 1092 atomic_inc(&inode->i_count);
1132 d_instantiate(dentry, inode); 1093 d_instantiate(dentry, inode);
1133 unlock_kernel(); 1094 unlock_kernel();
1095
1134 return 0; 1096 return 0;
1135} 1097}
1136 1098
@@ -1143,8 +1105,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1143 struct inode *old_inode = old_dentry->d_inode; 1105 struct inode *old_inode = old_dentry->d_inode;
1144 struct inode *new_inode = new_dentry->d_inode; 1106 struct inode *new_inode = new_dentry->d_inode;
1145 struct udf_fileident_bh ofibh, nfibh; 1107 struct udf_fileident_bh ofibh, nfibh;
1146 struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = 1108 struct fileIdentDesc *ofi = NULL, *nfi = NULL, *dir_fi = NULL, ocfi, ncfi;
1147 NULL, ocfi, ncfi;
1148 struct buffer_head *dir_bh = NULL; 1109 struct buffer_head *dir_bh = NULL;
1149 int retval = -ENOENT; 1110 int retval = -ENOENT;
1150 kernel_lb_addr tloc; 1111 kernel_lb_addr tloc;
@@ -1181,36 +1142,27 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1181 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { 1142 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) {
1182 dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) - 1143 dir_fi = udf_get_fileident(UDF_I_DATA(old_inode) -
1183 (UDF_I_EFE(old_inode) ? 1144 (UDF_I_EFE(old_inode) ?
1184 sizeof(struct 1145 sizeof(struct extendedFileEntry) :
1185 extendedFileEntry) :
1186 sizeof(struct fileEntry)), 1146 sizeof(struct fileEntry)),
1187 old_inode->i_sb->s_blocksize, 1147 old_inode->i_sb->s_blocksize, &offset);
1188 &offset);
1189 } else { 1148 } else {
1190 dir_bh = udf_bread(old_inode, 0, 0, &retval); 1149 dir_bh = udf_bread(old_inode, 0, 0, &retval);
1191 if (!dir_bh) 1150 if (!dir_bh)
1192 goto end_rename; 1151 goto end_rename;
1193 dir_fi = 1152 dir_fi = udf_get_fileident(dir_bh->b_data, old_inode->i_sb->s_blocksize, &offset);
1194 udf_get_fileident(dir_bh->b_data,
1195 old_inode->i_sb->s_blocksize,
1196 &offset);
1197 } 1153 }
1198 if (!dir_fi) 1154 if (!dir_fi)
1199 goto end_rename; 1155 goto end_rename;
1200 tloc = lelb_to_cpu(dir_fi->icb.extLocation); 1156 tloc = lelb_to_cpu(dir_fi->icb.extLocation);
1201 if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) 1157 if (udf_get_lb_pblock(old_inode->i_sb, tloc, 0) != old_dir->i_ino)
1202 != old_dir->i_ino)
1203 goto end_rename; 1158 goto end_rename;
1204 1159
1205 retval = -EMLINK; 1160 retval = -EMLINK;
1206 if (!new_inode 1161 if (!new_inode && new_dir->i_nlink >= (256 << sizeof(new_dir->i_nlink)) - 1)
1207 && new_dir->i_nlink >=
1208 (256 << sizeof(new_dir->i_nlink)) - 1)
1209 goto end_rename; 1162 goto end_rename;
1210 } 1163 }
1211 if (!nfi) { 1164 if (!nfi) {
1212 nfi = 1165 nfi = udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval);
1213 udf_add_entry(new_dir, new_dentry, &nfibh, &ncfi, &retval);
1214 if (!nfi) 1166 if (!nfi)
1215 goto end_rename; 1167 goto end_rename;
1216 } 1168 }
@@ -1244,13 +1196,12 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1244 if (dir_fi) { 1196 if (dir_fi) {
1245 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir)); 1197 dir_fi->icb.extLocation = cpu_to_lelb(UDF_I_LOCATION(new_dir));
1246 udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) + 1198 udf_update_tag((char *)dir_fi, (sizeof(struct fileIdentDesc) +
1247 le16_to_cpu(dir_fi-> 1199 le16_to_cpu(dir_fi->lengthOfImpUse) + 3) & ~3);
1248 lengthOfImpUse) +
1249 3) & ~3);
1250 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) { 1200 if (UDF_I_ALLOCTYPE(old_inode) == ICBTAG_FLAG_AD_IN_ICB) {
1251 mark_inode_dirty(old_inode); 1201 mark_inode_dirty(old_inode);
1252 } else 1202 } else {
1253 mark_buffer_dirty_inode(dir_bh, old_inode); 1203 mark_buffer_dirty_inode(dir_bh, old_inode);
1204 }
1254 inode_dec_link_count(old_dir); 1205 inode_dec_link_count(old_dir);
1255 if (new_inode) { 1206 if (new_inode) {
1256 inode_dec_link_count(new_inode); 1207 inode_dec_link_count(new_inode);
@@ -1268,7 +1219,7 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1268 1219
1269 retval = 0; 1220 retval = 0;
1270 1221
1271 end_rename: 1222end_rename:
1272 brelse(dir_bh); 1223 brelse(dir_bh);
1273 if (nfi) { 1224 if (nfi) {
1274 if (nfibh.sbh != nfibh.ebh) 1225 if (nfibh.sbh != nfibh.ebh)
@@ -1276,17 +1227,18 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1276 brelse(nfibh.sbh); 1227 brelse(nfibh.sbh);
1277 } 1228 }
1278 unlock_kernel(); 1229 unlock_kernel();
1230
1279 return retval; 1231 return retval;
1280} 1232}
1281 1233
1282const struct inode_operations udf_dir_inode_operations = { 1234const struct inode_operations udf_dir_inode_operations = {
1283 .lookup = udf_lookup, 1235 .lookup = udf_lookup,
1284 .create = udf_create, 1236 .create = udf_create,
1285 .link = udf_link, 1237 .link = udf_link,
1286 .unlink = udf_unlink, 1238 .unlink = udf_unlink,
1287 .symlink = udf_symlink, 1239 .symlink = udf_symlink,
1288 .mkdir = udf_mkdir, 1240 .mkdir = udf_mkdir,
1289 .rmdir = udf_rmdir, 1241 .rmdir = udf_rmdir,
1290 .mknod = udf_mknod, 1242 .mknod = udf_mknod,
1291 .rename = udf_rename, 1243 .rename = udf_rename,
1292}; 1244};
diff --git a/fs/udf/osta_udf.h b/fs/udf/osta_udf.h
index bec5d340d8c5..65ff47902bd2 100644
--- a/fs/udf/osta_udf.h
+++ b/fs/udf/osta_udf.h
@@ -66,64 +66,64 @@
66#define IS_DF_SOFT_WRITE_PROTECT 0x02 66#define IS_DF_SOFT_WRITE_PROTECT 0x02
67 67
68struct UDFIdentSuffix { 68struct UDFIdentSuffix {
69 __le16 UDFRevision; 69 __le16 UDFRevision;
70 uint8_t OSClass; 70 uint8_t OSClass;
71 uint8_t OSIdentifier; 71 uint8_t OSIdentifier;
72 uint8_t reserved[4]; 72 uint8_t reserved[4];
73} __attribute__ ((packed)); 73} __attribute__ ((packed));
74 74
75struct impIdentSuffix { 75struct impIdentSuffix {
76 uint8_t OSClass; 76 uint8_t OSClass;
77 uint8_t OSIdentifier; 77 uint8_t OSIdentifier;
78 uint8_t reserved[6]; 78 uint8_t reserved[6];
79} __attribute__ ((packed)); 79} __attribute__ ((packed));
80 80
81struct appIdentSuffix { 81struct appIdentSuffix {
82 uint8_t impUse[8]; 82 uint8_t impUse[8];
83} __attribute__ ((packed)); 83} __attribute__ ((packed));
84 84
85/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */ 85/* Logical Volume Integrity Descriptor (UDF 2.50 2.2.6) */
86/* Implementation Use (UDF 2.50 2.2.6.4) */ 86/* Implementation Use (UDF 2.50 2.2.6.4) */
87struct logicalVolIntegrityDescImpUse { 87struct logicalVolIntegrityDescImpUse {
88 regid impIdent; 88 regid impIdent;
89 __le32 numFiles; 89 __le32 numFiles;
90 __le32 numDirs; 90 __le32 numDirs;
91 __le16 minUDFReadRev; 91 __le16 minUDFReadRev;
92 __le16 minUDFWriteRev; 92 __le16 minUDFWriteRev;
93 __le16 maxUDFWriteRev; 93 __le16 maxUDFWriteRev;
94 uint8_t impUse[0]; 94 uint8_t impUse[0];
95} __attribute__ ((packed)); 95} __attribute__ ((packed));
96 96
97/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */ 97/* Implementation Use Volume Descriptor (UDF 2.50 2.2.7) */
98/* Implementation Use (UDF 2.50 2.2.7.2) */ 98/* Implementation Use (UDF 2.50 2.2.7.2) */
99struct impUseVolDescImpUse { 99struct impUseVolDescImpUse {
100 charspec LVICharset; 100 charspec LVICharset;
101 dstring logicalVolIdent[128]; 101 dstring logicalVolIdent[128];
102 dstring LVInfo1[36]; 102 dstring LVInfo1[36];
103 dstring LVInfo2[36]; 103 dstring LVInfo2[36];
104 dstring LVInfo3[36]; 104 dstring LVInfo3[36];
105 regid impIdent; 105 regid impIdent;
106 uint8_t impUse[128]; 106 uint8_t impUse[128];
107} __attribute__ ((packed)); 107} __attribute__ ((packed));
108 108
109struct udfPartitionMap2 { 109struct udfPartitionMap2 {
110 uint8_t partitionMapType; 110 uint8_t partitionMapType;
111 uint8_t partitionMapLength; 111 uint8_t partitionMapLength;
112 uint8_t reserved1[2]; 112 uint8_t reserved1[2];
113 regid partIdent; 113 regid partIdent;
114 __le16 volSeqNum; 114 __le16 volSeqNum;
115 __le16 partitionNum; 115 __le16 partitionNum;
116} __attribute__ ((packed)); 116} __attribute__ ((packed));
117 117
118/* Virtual Partition Map (UDF 2.50 2.2.8) */ 118/* Virtual Partition Map (UDF 2.50 2.2.8) */
119struct virtualPartitionMap { 119struct virtualPartitionMap {
120 uint8_t partitionMapType; 120 uint8_t partitionMapType;
121 uint8_t partitionMapLength; 121 uint8_t partitionMapLength;
122 uint8_t reserved1[2]; 122 uint8_t reserved1[2];
123 regid partIdent; 123 regid partIdent;
124 __le16 volSeqNum; 124 __le16 volSeqNum;
125 __le16 partitionNum; 125 __le16 partitionNum;
126 uint8_t reserved2[24]; 126 uint8_t reserved2[24];
127} __attribute__ ((packed)); 127} __attribute__ ((packed));
128 128
129/* Sparable Partition Map (UDF 2.50 2.2.9) */ 129/* Sparable Partition Map (UDF 2.50 2.2.9) */
@@ -143,62 +143,62 @@ struct sparablePartitionMap {
143 143
144/* Metadata Partition Map (UDF 2.4.0 2.2.10) */ 144/* Metadata Partition Map (UDF 2.4.0 2.2.10) */
145struct metadataPartitionMap { 145struct metadataPartitionMap {
146 uint8_t partitionMapType; 146 uint8_t partitionMapType;
147 uint8_t partitionMapLength; 147 uint8_t partitionMapLength;
148 uint8_t reserved1[2]; 148 uint8_t reserved1[2];
149 regid partIdent; 149 regid partIdent;
150 __le16 volSeqNum; 150 __le16 volSeqNum;
151 __le16 partitionNum; 151 __le16 partitionNum;
152 __le32 metadataFileLoc; 152 __le32 metadataFileLoc;
153 __le32 metadataMirrorFileLoc; 153 __le32 metadataMirrorFileLoc;
154 __le32 metadataBitmapFileLoc; 154 __le32 metadataBitmapFileLoc;
155 __le32 allocUnitSize; 155 __le32 allocUnitSize;
156 __le16 alignUnitSize; 156 __le16 alignUnitSize;
157 uint8_t flags; 157 uint8_t flags;
158 uint8_t reserved2[5]; 158 uint8_t reserved2[5];
159} __attribute__ ((packed)); 159} __attribute__ ((packed));
160 160
161/* Virtual Allocation Table (UDF 1.5 2.2.10) */ 161/* Virtual Allocation Table (UDF 1.5 2.2.10) */
162struct virtualAllocationTable15 { 162struct virtualAllocationTable15 {
163 __le32 VirtualSector[0]; 163 __le32 VirtualSector[0];
164 regid vatIdent; 164 regid vatIdent;
165 __le32 previousVATICBLoc; 165 __le32 previousVATICBLoc;
166} __attribute__ ((packed)); 166} __attribute__ ((packed));
167 167
168#define ICBTAG_FILE_TYPE_VAT15 0x00U 168#define ICBTAG_FILE_TYPE_VAT15 0x00U
169 169
170/* Virtual Allocation Table (UDF 2.50 2.2.11) */ 170/* Virtual Allocation Table (UDF 2.50 2.2.11) */
171struct virtualAllocationTable20 { 171struct virtualAllocationTable20 {
172 __le16 lengthHeader; 172 __le16 lengthHeader;
173 __le16 lengthImpUse; 173 __le16 lengthImpUse;
174 dstring logicalVolIdent[128]; 174 dstring logicalVolIdent[128];
175 __le32 previousVATICBLoc; 175 __le32 previousVATICBLoc;
176 __le32 numFiles; 176 __le32 numFiles;
177 __le32 numDirs; 177 __le32 numDirs;
178 __le16 minReadRevision; 178 __le16 minReadRevision;
179 __le16 minWriteRevision; 179 __le16 minWriteRevision;
180 __le16 maxWriteRevision; 180 __le16 maxWriteRevision;
181 __le16 reserved; 181 __le16 reserved;
182 uint8_t impUse[0]; 182 uint8_t impUse[0];
183 __le32 vatEntry[0]; 183 __le32 vatEntry[0];
184} __attribute__ ((packed)); 184} __attribute__ ((packed));
185 185
186#define ICBTAG_FILE_TYPE_VAT20 0xF8U 186#define ICBTAG_FILE_TYPE_VAT20 0xF8U
187 187
188/* Sparing Table (UDF 2.50 2.2.12) */ 188/* Sparing Table (UDF 2.50 2.2.12) */
189struct sparingEntry { 189struct sparingEntry {
190 __le32 origLocation; 190 __le32 origLocation;
191 __le32 mappedLocation; 191 __le32 mappedLocation;
192} __attribute__ ((packed)); 192} __attribute__ ((packed));
193 193
194struct sparingTable { 194struct sparingTable {
195 tag descTag; 195 tag descTag;
196 regid sparingIdent; 196 regid sparingIdent;
197 __le16 reallocationTableLen; 197 __le16 reallocationTableLen;
198 __le16 reserved; 198 __le16 reserved;
199 __le32 sequenceNum; 199 __le32 sequenceNum;
200 struct sparingEntry 200 struct sparingEntry
201 mapEntry[0]; 201 mapEntry[0];
202} __attribute__ ((packed)); 202} __attribute__ ((packed));
203 203
204/* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */ 204/* Metadata File (and Metadata Mirror File) (UDF 2.50 2.2.13.1) */
@@ -208,8 +208,8 @@ struct sparingTable {
208 208
209/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */ 209/* struct long_ad ICB - ADImpUse (UDF 2.50 2.2.4.3) */
210struct allocDescImpUse { 210struct allocDescImpUse {
211 __le16 flags; 211 __le16 flags;
212 uint8_t impUse[4]; 212 uint8_t impUse[4];
213} __attribute__ ((packed)); 213} __attribute__ ((packed));
214 214
215#define AD_IU_EXT_ERASED 0x0001 215#define AD_IU_EXT_ERASED 0x0001
@@ -220,23 +220,23 @@ struct allocDescImpUse {
220/* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */ 220/* Implementation Use Extended Attribute (UDF 2.50 3.3.4.5) */
221/* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */ 221/* FreeEASpace (UDF 2.50 3.3.4.5.1.1) */
222struct freeEaSpace { 222struct freeEaSpace {
223 __le16 headerChecksum; 223 __le16 headerChecksum;
224 uint8_t freeEASpace[0]; 224 uint8_t freeEASpace[0];
225} __attribute__ ((packed)); 225} __attribute__ ((packed));
226 226
227/* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */ 227/* DVD Copyright Management Information (UDF 2.50 3.3.4.5.1.2) */
228struct DVDCopyrightImpUse { 228struct DVDCopyrightImpUse {
229 __le16 headerChecksum; 229 __le16 headerChecksum;
230 uint8_t CGMSInfo; 230 uint8_t CGMSInfo;
231 uint8_t dataType; 231 uint8_t dataType;
232 uint8_t protectionSystemInfo[4]; 232 uint8_t protectionSystemInfo[4];
233} __attribute__ ((packed)); 233} __attribute__ ((packed));
234 234
235/* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */ 235/* Application Use Extended Attribute (UDF 2.50 3.3.4.6) */
236/* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */ 236/* FreeAppEASpace (UDF 2.50 3.3.4.6.1) */
237struct freeAppEASpace { 237struct freeAppEASpace {
238 __le16 headerChecksum; 238 __le16 headerChecksum;
239 uint8_t freeEASpace[0]; 239 uint8_t freeEASpace[0];
240} __attribute__ ((packed)); 240} __attribute__ ((packed));
241 241
242/* UDF Defined System Stream (UDF 2.50 3.3.7) */ 242/* UDF Defined System Stream (UDF 2.50 3.3.7) */
@@ -276,4 +276,4 @@ struct freeAppEASpace {
276#define UDF_OS_ID_BEOS 0x00U 276#define UDF_OS_ID_BEOS 0x00U
277#define UDF_OS_ID_WINCE 0x00U 277#define UDF_OS_ID_WINCE 0x00U
278 278
279#endif /* _OSTA_UDF_H */ 279#endif /* _OSTA_UDF_H */
diff --git a/fs/udf/partition.c b/fs/udf/partition.c
index a95d830a674d..aaab24c8c498 100644
--- a/fs/udf/partition.c
+++ b/fs/udf/partition.c
@@ -14,7 +14,7 @@
14 * 14 *
15 * HISTORY 15 * HISTORY
16 * 16 *
17 * 12/06/98 blf Created file. 17 * 12/06/98 blf Created file.
18 * 18 *
19 */ 19 */
20 20
@@ -32,19 +32,17 @@ inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block,
32 uint16_t partition, uint32_t offset) 32 uint16_t partition, uint32_t offset)
33{ 33{
34 if (partition >= UDF_SB_NUMPARTS(sb)) { 34 if (partition >= UDF_SB_NUMPARTS(sb)) {
35 udf_debug 35 udf_debug("block=%d, partition=%d, offset=%d: invalid partition\n",
36 ("block=%d, partition=%d, offset=%d: invalid partition\n", 36 block, partition, offset);
37 block, partition, offset);
38 return 0xFFFFFFFF; 37 return 0xFFFFFFFF;
39 } 38 }
40 if (UDF_SB_PARTFUNC(sb, partition)) 39 if (UDF_SB_PARTFUNC(sb, partition))
41 return UDF_SB_PARTFUNC(sb, partition) (sb, block, partition, 40 return UDF_SB_PARTFUNC(sb, partition)(sb, block, partition, offset);
42 offset);
43 else 41 else
44 return UDF_SB_PARTROOT(sb, partition) + block + offset; 42 return UDF_SB_PARTROOT(sb, partition) + block + offset;
45} 43}
46 44
47uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block, 45uint32_t udf_get_pblock_virt15(struct super_block *sb, uint32_t block,
48 uint16_t partition, uint32_t offset) 46 uint16_t partition, uint32_t offset)
49{ 47{
50 struct buffer_head *bh = NULL; 48 struct buffer_head *bh = NULL;
@@ -52,14 +50,11 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
52 uint32_t index; 50 uint32_t index;
53 uint32_t loc; 51 uint32_t loc;
54 52
55 index = 53 index = (sb->s_blocksize - UDF_SB_TYPEVIRT(sb,partition).s_start_offset) / sizeof(uint32_t);
56 (sb->s_blocksize -
57 UDF_SB_TYPEVIRT(sb, partition).s_start_offset) / sizeof(uint32_t);
58 54
59 if (block > UDF_SB_TYPEVIRT(sb, partition).s_num_entries) { 55 if (block > UDF_SB_TYPEVIRT(sb,partition).s_num_entries) {
60 udf_debug 56 udf_debug("Trying to access block beyond end of VAT (%d max %d)\n",
61 ("Trying to access block beyond end of VAT (%d max %d)\n", 57 block, UDF_SB_TYPEVIRT(sb,partition).s_num_entries);
62 block, UDF_SB_TYPEVIRT(sb, partition).s_num_entries);
63 return 0xFFFFFFFF; 58 return 0xFFFFFFFF;
64 } 59 }
65 60
@@ -69,10 +64,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
69 index = block % (sb->s_blocksize / sizeof(uint32_t)); 64 index = block % (sb->s_blocksize / sizeof(uint32_t));
70 } else { 65 } else {
71 newblock = 0; 66 newblock = 0;
72 index = 67 index = UDF_SB_TYPEVIRT(sb,partition).s_start_offset / sizeof(uint32_t) + block;
73 UDF_SB_TYPEVIRT(sb,
74 partition).s_start_offset /
75 sizeof(uint32_t) + block;
76 } 68 }
77 69
78 loc = udf_block_map(UDF_SB_VAT(sb), newblock); 70 loc = udf_block_map(UDF_SB_VAT(sb), newblock);
@@ -83,7 +75,7 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
83 return 0xFFFFFFFF; 75 return 0xFFFFFFFF;
84 } 76 }
85 77
86 loc = le32_to_cpu(((__le32 *) bh->b_data)[index]); 78 loc = le32_to_cpu(((__le32 *)bh->b_data)[index]);
87 79
88 brelse(bh); 80 brelse(bh);
89 81
@@ -93,8 +85,8 @@ uint32_t udf_get_pblock_virt15(struct super_block * sb, uint32_t block,
93 } 85 }
94 86
95 return udf_get_pblock(sb, loc, 87 return udf_get_pblock(sb, loc,
96 UDF_I_LOCATION(UDF_SB_VAT(sb)). 88 UDF_I_LOCATION(UDF_SB_VAT(sb)).partitionReferenceNum,
97 partitionReferenceNum, offset); 89 offset);
98} 90}
99 91
100inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block, 92inline uint32_t udf_get_pblock_virt20(struct super_block * sb, uint32_t block,
@@ -108,40 +100,29 @@ uint32_t udf_get_pblock_spar15(struct super_block * sb, uint32_t block,
108{ 100{
109 int i; 101 int i;
110 struct sparingTable *st = NULL; 102 struct sparingTable *st = NULL;
111 uint32_t packet = 103 uint32_t packet = (block + offset) & ~(UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1);
112 (block + offset) & ~(UDF_SB_TYPESPAR(sb, partition).s_packet_len -
113 1);
114 104
115 for (i = 0; i < 4; i++) { 105 for (i = 0; i < 4; i++) {
116 if (UDF_SB_TYPESPAR(sb, partition).s_spar_map[i] != NULL) { 106 if (UDF_SB_TYPESPAR(sb,partition).s_spar_map[i] != NULL) {
117 st = (struct sparingTable *)UDF_SB_TYPESPAR(sb, 107 st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,partition).s_spar_map[i]->b_data;
118 partition).
119 s_spar_map[i]->b_data;
120 break; 108 break;
121 } 109 }
122 } 110 }
123 111
124 if (st) { 112 if (st) {
125 for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) { 113 for (i = 0; i < le16_to_cpu(st->reallocationTableLen); i++) {
126 if (le32_to_cpu(st->mapEntry[i].origLocation) >= 114 if (le32_to_cpu(st->mapEntry[i].origLocation) >= 0xFFFFFFF0) {
127 0xFFFFFFF0)
128 break; 115 break;
129 else if (le32_to_cpu(st->mapEntry[i].origLocation) == 116 } else if (le32_to_cpu(st->mapEntry[i].origLocation) == packet) {
130 packet) { 117 return le32_to_cpu(st->mapEntry[i].mappedLocation) +
131 return le32_to_cpu(st->mapEntry[i]. 118 ((block + offset) & (UDF_SB_TYPESPAR(sb,partition).s_packet_len - 1));
132 mappedLocation) + ((block + 119 } else if (le32_to_cpu(st->mapEntry[i].origLocation) > packet) {
133 offset) &
134 (UDF_SB_TYPESPAR
135 (sb,
136 partition).
137 s_packet_len
138 - 1));
139 } else if (le32_to_cpu(st->mapEntry[i].origLocation) >
140 packet)
141 break; 120 break;
121 }
142 } 122 }
143 } 123 }
144 return UDF_SB_PARTROOT(sb, partition) + block + offset; 124
125 return UDF_SB_PARTROOT(sb,partition) + block + offset;
145} 126}
146 127
147int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block) 128int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
@@ -153,20 +134,14 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
153 int i, j, k, l; 134 int i, j, k, l;
154 135
155 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { 136 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
156 if (old_block > UDF_SB_PARTROOT(sb, i) && 137 if (old_block > UDF_SB_PARTROOT(sb,i) &&
157 old_block < UDF_SB_PARTROOT(sb, i) + UDF_SB_PARTLEN(sb, i)) 138 old_block < UDF_SB_PARTROOT(sb,i) + UDF_SB_PARTLEN(sb,i)) {
158 { 139 sdata = &UDF_SB_TYPESPAR(sb,i);
159 sdata = &UDF_SB_TYPESPAR(sb, i); 140 packet = (old_block - UDF_SB_PARTROOT(sb,i)) & ~(sdata->s_packet_len - 1);
160 packet =
161 (old_block -
162 UDF_SB_PARTROOT(sb,
163 i)) & ~(sdata->s_packet_len - 1);
164 141
165 for (j = 0; j < 4; j++) { 142 for (j = 0; j < 4; j++) {
166 if (UDF_SB_TYPESPAR(sb, i).s_spar_map[j] != 143 if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
167 NULL) { 144 st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
168 st = (struct sparingTable *)sdata->
169 s_spar_map[j]->b_data;
170 break; 145 break;
171 } 146 }
172 } 147 }
@@ -174,122 +149,51 @@ int udf_relocate_blocks(struct super_block *sb, long old_block, long *new_block)
174 if (!st) 149 if (!st)
175 return 1; 150 return 1;
176 151
177 for (k = 0; k < le16_to_cpu(st->reallocationTableLen); 152 for (k = 0; k < le16_to_cpu(st->reallocationTableLen); k++) {
178 k++) { 153 if (le32_to_cpu(st->mapEntry[k].origLocation) == 0xFFFFFFFF) {
179 if (le32_to_cpu(st->mapEntry[k].origLocation) ==
180 0xFFFFFFFF) {
181 for (; j < 4; j++) { 154 for (; j < 4; j++) {
182 if (sdata->s_spar_map[j]) { 155 if (sdata->s_spar_map[j]) {
183 st = (struct 156 st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
184 sparingTable *) 157 st->mapEntry[k].origLocation = cpu_to_le32(packet);
185 sdata-> 158 udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
186 s_spar_map[j]-> 159 mark_buffer_dirty(sdata->s_spar_map[j]);
187 b_data;
188 st->mapEntry[k].
189 origLocation =
190 cpu_to_le32(packet);
191 udf_update_tag((char *)
192 st,
193 sizeof
194 (struct
195 sparingTable)
196 +
197 le16_to_cpu
198 (st->
199 reallocationTableLen)
200 *
201 sizeof
202 (struct
203 sparingEntry));
204 mark_buffer_dirty
205 (sdata->
206 s_spar_map[j]);
207 } 160 }
208 } 161 }
209 *new_block = 162 *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
210 le32_to_cpu(st->mapEntry[k]. 163 ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
211 mappedLocation) +
212 ((old_block -
213 UDF_SB_PARTROOT(sb,
214 i)) & (sdata->
215 s_packet_len
216 - 1));
217 return 0; 164 return 0;
218 } else 165 } else if (le32_to_cpu(st->mapEntry[k].origLocation) == packet) {
219 if (le32_to_cpu 166 *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
220 (st->mapEntry[k].origLocation) == 167 ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
221 packet) {
222 *new_block =
223 le32_to_cpu(st->mapEntry[k].
224 mappedLocation) +
225 ((old_block -
226 UDF_SB_PARTROOT(sb,
227 i)) & (sdata->
228 s_packet_len
229 - 1));
230 return 0; 168 return 0;
231 } else 169 } else if (le32_to_cpu(st->mapEntry[k].origLocation) > packet) {
232 if (le32_to_cpu
233 (st->mapEntry[k].origLocation) > packet)
234 break; 170 break;
171 }
235 } 172 }
236 for (l = k; l < le16_to_cpu(st->reallocationTableLen); 173
237 l++) { 174 for (l = k; l < le16_to_cpu(st->reallocationTableLen); l++) {
238 if (le32_to_cpu(st->mapEntry[l].origLocation) == 175 if (le32_to_cpu(st->mapEntry[l].origLocation) == 0xFFFFFFFF) {
239 0xFFFFFFFF) {
240 for (; j < 4; j++) { 176 for (; j < 4; j++) {
241 if (sdata->s_spar_map[j]) { 177 if (sdata->s_spar_map[j]) {
242 st = (struct 178 st = (struct sparingTable *)sdata->s_spar_map[j]->b_data;
243 sparingTable *) 179 mapEntry = st->mapEntry[l];
244 sdata-> 180 mapEntry.origLocation = cpu_to_le32(packet);
245 s_spar_map[j]-> 181 memmove(&st->mapEntry[k + 1], &st->mapEntry[k], (l - k) * sizeof(struct sparingEntry));
246 b_data; 182 st->mapEntry[k] = mapEntry;
247 mapEntry = 183 udf_update_tag((char *)st, sizeof(struct sparingTable) + le16_to_cpu(st->reallocationTableLen) * sizeof(struct sparingEntry));
248 st->mapEntry[l]; 184 mark_buffer_dirty(sdata->s_spar_map[j]);
249 mapEntry.origLocation =
250 cpu_to_le32(packet);
251 memmove(&st->
252 mapEntry[k + 1],
253 &st->
254 mapEntry[k],
255 (l -
256 k) *
257 sizeof(struct
258 sparingEntry));
259 st->mapEntry[k] =
260 mapEntry;
261 udf_update_tag((char *)
262 st,
263 sizeof
264 (struct
265 sparingTable)
266 +
267 le16_to_cpu
268 (st->
269 reallocationTableLen)
270 *
271 sizeof
272 (struct
273 sparingEntry));
274 mark_buffer_dirty
275 (sdata->
276 s_spar_map[j]);
277 } 185 }
278 } 186 }
279 *new_block = 187 *new_block = le32_to_cpu(st->mapEntry[k].mappedLocation) +
280 le32_to_cpu(st->mapEntry[k]. 188 ((old_block - UDF_SB_PARTROOT(sb,i)) & (sdata->s_packet_len - 1));
281 mappedLocation) +
282 ((old_block -
283 UDF_SB_PARTROOT(sb,
284 i)) & (sdata->
285 s_packet_len
286 - 1));
287 return 0; 189 return 0;
288 } 190 }
289 } 191 }
192
290 return 1; 193 return 1;
291 } 194 } /* if old_block */
292 } 195 }
196
293 if (i == UDF_SB_NUMPARTS(sb)) { 197 if (i == UDF_SB_NUMPARTS(sb)) {
294 /* outside of partitions */ 198 /* outside of partitions */
295 /* for now, fail =) */ 199 /* for now, fail =) */
diff --git a/fs/udf/super.c b/fs/udf/super.c
index 72097ee6b752..7b30964665db 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -104,11 +104,11 @@ static int udf_get_sb(struct file_system_type *fs_type,
104} 104}
105 105
106static struct file_system_type udf_fstype = { 106static struct file_system_type udf_fstype = {
107 .owner = THIS_MODULE, 107 .owner = THIS_MODULE,
108 .name = "udf", 108 .name = "udf",
109 .get_sb = udf_get_sb, 109 .get_sb = udf_get_sb,
110 .kill_sb = kill_block_super, 110 .kill_sb = kill_block_super,
111 .fs_flags = FS_REQUIRES_DEV, 111 .fs_flags = FS_REQUIRES_DEV,
112}; 112};
113 113
114static struct kmem_cache *udf_inode_cachep; 114static struct kmem_cache *udf_inode_cachep;
@@ -116,8 +116,7 @@ static struct kmem_cache *udf_inode_cachep;
116static struct inode *udf_alloc_inode(struct super_block *sb) 116static struct inode *udf_alloc_inode(struct super_block *sb)
117{ 117{
118 struct udf_inode_info *ei; 118 struct udf_inode_info *ei;
119 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, 119 ei = (struct udf_inode_info *)kmem_cache_alloc(udf_inode_cachep, GFP_KERNEL);
120 GFP_KERNEL);
121 if (!ei) 120 if (!ei)
122 return NULL; 121 return NULL;
123 122
@@ -150,7 +149,7 @@ static int init_inodecache(void)
150 0, (SLAB_RECLAIM_ACCOUNT | 149 0, (SLAB_RECLAIM_ACCOUNT |
151 SLAB_MEM_SPREAD), 150 SLAB_MEM_SPREAD),
152 init_once); 151 init_once);
153 if (udf_inode_cachep == NULL) 152 if (!udf_inode_cachep)
154 return -ENOMEM; 153 return -ENOMEM;
155 return 0; 154 return 0;
156} 155}
@@ -162,15 +161,15 @@ static void destroy_inodecache(void)
162 161
163/* Superblock operations */ 162/* Superblock operations */
164static const struct super_operations udf_sb_ops = { 163static const struct super_operations udf_sb_ops = {
165 .alloc_inode = udf_alloc_inode, 164 .alloc_inode = udf_alloc_inode,
166 .destroy_inode = udf_destroy_inode, 165 .destroy_inode = udf_destroy_inode,
167 .write_inode = udf_write_inode, 166 .write_inode = udf_write_inode,
168 .delete_inode = udf_delete_inode, 167 .delete_inode = udf_delete_inode,
169 .clear_inode = udf_clear_inode, 168 .clear_inode = udf_clear_inode,
170 .put_super = udf_put_super, 169 .put_super = udf_put_super,
171 .write_super = udf_write_super, 170 .write_super = udf_write_super,
172 .statfs = udf_statfs, 171 .statfs = udf_statfs,
173 .remount_fs = udf_remount_fs, 172 .remount_fs = udf_remount_fs,
174}; 173};
175 174
176struct udf_options { 175struct udf_options {
@@ -193,16 +192,20 @@ struct udf_options {
193static int __init init_udf_fs(void) 192static int __init init_udf_fs(void)
194{ 193{
195 int err; 194 int err;
195
196 err = init_inodecache(); 196 err = init_inodecache();
197 if (err) 197 if (err)
198 goto out1; 198 goto out1;
199 err = register_filesystem(&udf_fstype); 199 err = register_filesystem(&udf_fstype);
200 if (err) 200 if (err)
201 goto out; 201 goto out;
202
202 return 0; 203 return 0;
203 out: 204
205out:
204 destroy_inodecache(); 206 destroy_inodecache();
205 out1: 207
208out1:
206 return err; 209 return err;
207} 210}
208 211
@@ -213,7 +216,7 @@ static void __exit exit_udf_fs(void)
213} 216}
214 217
215module_init(init_udf_fs) 218module_init(init_udf_fs)
216 module_exit(exit_udf_fs) 219module_exit(exit_udf_fs)
217 220
218/* 221/*
219 * udf_parse_options 222 * udf_parse_options
@@ -239,7 +242,7 @@ module_init(init_udf_fs)
239 * 242 *
240 * The remaining are for debugging and disaster recovery: 243 * The remaining are for debugging and disaster recovery:
241 * 244 *
242 * novrs Skip volume sequence recognition 245 * novrs Skip volume sequence recognition
243 * 246 *
244 * The following expect a offset from 0. 247 * The following expect a offset from 0.
245 * 248 *
@@ -268,6 +271,7 @@ module_init(init_udf_fs)
268 * July 1, 1997 - Andrew E. Mileski 271 * July 1, 1997 - Andrew E. Mileski
269 * Written, tested, and released. 272 * Written, tested, and released.
270 */ 273 */
274
271enum { 275enum {
272 Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete, 276 Opt_novrs, Opt_nostrict, Opt_bs, Opt_unhide, Opt_undelete,
273 Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad, 277 Opt_noadinicb, Opt_adinicb, Opt_shortad, Opt_longad,
@@ -278,32 +282,32 @@ enum {
278}; 282};
279 283
280static match_table_t tokens = { 284static match_table_t tokens = {
281 {Opt_novrs, "novrs"}, 285 {Opt_novrs, "novrs"},
282 {Opt_nostrict, "nostrict"}, 286 {Opt_nostrict, "nostrict"},
283 {Opt_bs, "bs=%u"}, 287 {Opt_bs, "bs=%u"},
284 {Opt_unhide, "unhide"}, 288 {Opt_unhide, "unhide"},
285 {Opt_undelete, "undelete"}, 289 {Opt_undelete, "undelete"},
286 {Opt_noadinicb, "noadinicb"}, 290 {Opt_noadinicb, "noadinicb"},
287 {Opt_adinicb, "adinicb"}, 291 {Opt_adinicb, "adinicb"},
288 {Opt_shortad, "shortad"}, 292 {Opt_shortad, "shortad"},
289 {Opt_longad, "longad"}, 293 {Opt_longad, "longad"},
290 {Opt_uforget, "uid=forget"}, 294 {Opt_uforget, "uid=forget"},
291 {Opt_uignore, "uid=ignore"}, 295 {Opt_uignore, "uid=ignore"},
292 {Opt_gforget, "gid=forget"}, 296 {Opt_gforget, "gid=forget"},
293 {Opt_gignore, "gid=ignore"}, 297 {Opt_gignore, "gid=ignore"},
294 {Opt_gid, "gid=%u"}, 298 {Opt_gid, "gid=%u"},
295 {Opt_uid, "uid=%u"}, 299 {Opt_uid, "uid=%u"},
296 {Opt_umask, "umask=%o"}, 300 {Opt_umask, "umask=%o"},
297 {Opt_session, "session=%u"}, 301 {Opt_session, "session=%u"},
298 {Opt_lastblock, "lastblock=%u"}, 302 {Opt_lastblock, "lastblock=%u"},
299 {Opt_anchor, "anchor=%u"}, 303 {Opt_anchor, "anchor=%u"},
300 {Opt_volume, "volume=%u"}, 304 {Opt_volume, "volume=%u"},
301 {Opt_partition, "partition=%u"}, 305 {Opt_partition, "partition=%u"},
302 {Opt_fileset, "fileset=%u"}, 306 {Opt_fileset, "fileset=%u"},
303 {Opt_rootdir, "rootdir=%u"}, 307 {Opt_rootdir, "rootdir=%u"},
304 {Opt_utf8, "utf8"}, 308 {Opt_utf8, "utf8"},
305 {Opt_iocharset, "iocharset=%s"}, 309 {Opt_iocharset, "iocharset=%s"},
306 {Opt_err, NULL} 310 {Opt_err, NULL}
307}; 311};
308 312
309static int udf_parse_options(char *options, struct udf_options *uopt) 313static int udf_parse_options(char *options, struct udf_options *uopt)
@@ -444,9 +448,11 @@ static int udf_parse_options(char *options, struct udf_options *uopt)
444void udf_write_super(struct super_block *sb) 448void udf_write_super(struct super_block *sb)
445{ 449{
446 lock_kernel(); 450 lock_kernel();
451
447 if (!(sb->s_flags & MS_RDONLY)) 452 if (!(sb->s_flags & MS_RDONLY))
448 udf_open_lvid(sb); 453 udf_open_lvid(sb);
449 sb->s_dirt = 0; 454 sb->s_dirt = 0;
455
450 unlock_kernel(); 456 unlock_kernel();
451} 457}
452 458
@@ -455,16 +461,16 @@ static int udf_remount_fs(struct super_block *sb, int *flags, char *options)
455 struct udf_options uopt; 461 struct udf_options uopt;
456 462
457 uopt.flags = UDF_SB(sb)->s_flags; 463 uopt.flags = UDF_SB(sb)->s_flags;
458 uopt.uid = UDF_SB(sb)->s_uid; 464 uopt.uid = UDF_SB(sb)->s_uid;
459 uopt.gid = UDF_SB(sb)->s_gid; 465 uopt.gid = UDF_SB(sb)->s_gid;
460 uopt.umask = UDF_SB(sb)->s_umask; 466 uopt.umask = UDF_SB(sb)->s_umask;
461 467
462 if (!udf_parse_options(options, &uopt)) 468 if (!udf_parse_options(options, &uopt))
463 return -EINVAL; 469 return -EINVAL;
464 470
465 UDF_SB(sb)->s_flags = uopt.flags; 471 UDF_SB(sb)->s_flags = uopt.flags;
466 UDF_SB(sb)->s_uid = uopt.uid; 472 UDF_SB(sb)->s_uid = uopt.uid;
467 UDF_SB(sb)->s_gid = uopt.gid; 473 UDF_SB(sb)->s_gid = uopt.gid;
468 UDF_SB(sb)->s_umask = uopt.umask; 474 UDF_SB(sb)->s_umask = uopt.umask;
469 475
470 if (UDF_SB_LVIDBH(sb)) { 476 if (UDF_SB_LVIDBH(sb)) {
@@ -517,6 +523,7 @@ static int udf_set_blocksize(struct super_block *sb, int bsize)
517 printk(KERN_ERR "udf: bad block size (%d)\n", bsize); 523 printk(KERN_ERR "udf: bad block size (%d)\n", bsize);
518 return 0; 524 return 0;
519 } 525 }
526
520 return sb->s_blocksize; 527 return sb->s_blocksize;
521} 528}
522 529
@@ -552,15 +559,12 @@ static int udf_vrs(struct super_block *sb, int silent)
552 559
553 /* Look for ISO descriptors */ 560 /* Look for ISO descriptors */
554 vsd = (struct volStructDesc *)(bh->b_data + 561 vsd = (struct volStructDesc *)(bh->b_data +
555 (sector & 562 (sector & (sb->s_blocksize - 1)));
556 (sb->s_blocksize - 1)));
557 563
558 if (vsd->stdIdent[0] == 0) { 564 if (vsd->stdIdent[0] == 0) {
559 brelse(bh); 565 brelse(bh);
560 break; 566 break;
561 } else 567 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) {
562 if (!strncmp
563 (vsd->stdIdent, VSD_STD_ID_CD001, VSD_STD_ID_LEN)) {
564 iso9660 = sector; 568 iso9660 = sector;
565 switch (vsd->structType) { 569 switch (vsd->structType) {
566 case 0: 570 case 0:
@@ -587,21 +591,13 @@ static int udf_vrs(struct super_block *sb, int silent)
587 vsd->structType); 591 vsd->structType);
588 break; 592 break;
589 } 593 }
590 } else 594 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) {
591 if (!strncmp 595 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) {
592 (vsd->stdIdent, VSD_STD_ID_BEA01, VSD_STD_ID_LEN)) {
593 } else
594 if (!strncmp
595 (vsd->stdIdent, VSD_STD_ID_TEA01, VSD_STD_ID_LEN)) {
596 brelse(bh); 596 brelse(bh);
597 break; 597 break;
598 } else 598 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) {
599 if (!strncmp
600 (vsd->stdIdent, VSD_STD_ID_NSR02, VSD_STD_ID_LEN)) {
601 nsr02 = sector; 599 nsr02 = sector;
602 } else 600 } else if (!strncmp(vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) {
603 if (!strncmp
604 (vsd->stdIdent, VSD_STD_ID_NSR03, VSD_STD_ID_LEN)) {
605 nsr03 = sector; 601 nsr03 = sector;
606 } 602 }
607 brelse(bh); 603 brelse(bh);
@@ -644,11 +640,10 @@ static void udf_find_anchor(struct super_block *sb)
644 640
645 if (lastblock) { 641 if (lastblock) {
646 int varlastblock = udf_variable_to_fixed(lastblock); 642 int varlastblock = udf_variable_to_fixed(lastblock);
647 int last[] = { lastblock, lastblock - 2, 643 int last[] = { lastblock, lastblock - 2,
648 lastblock - 150, lastblock - 152, 644 lastblock - 150, lastblock - 152,
649 varlastblock, varlastblock - 2, 645 varlastblock, varlastblock - 2,
650 varlastblock - 150, varlastblock - 152 646 varlastblock - 150, varlastblock - 152 };
651 };
652 647
653 lastblock = 0; 648 lastblock = 0;
654 649
@@ -664,88 +659,54 @@ static void udf_find_anchor(struct super_block *sb)
664 if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) { 659 if (last[i] < 0 || !(bh = sb_bread(sb, last[i]))) {
665 ident = location = 0; 660 ident = location = 0;
666 } else { 661 } else {
667 ident = 662 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
668 le16_to_cpu(((tag *) bh->b_data)->tagIdent); 663 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
669 location =
670 le32_to_cpu(((tag *) bh->b_data)->
671 tagLocation);
672 brelse(bh); 664 brelse(bh);
673 } 665 }
674 666
675 if (ident == TAG_IDENT_AVDP) { 667 if (ident == TAG_IDENT_AVDP) {
676 if (location == last[i] - UDF_SB_SESSION(sb)) { 668 if (location == last[i] - UDF_SB_SESSION(sb)) {
677 lastblock = UDF_SB_ANCHOR(sb)[0] = 669 lastblock = UDF_SB_ANCHOR(sb)[0] = last[i] - UDF_SB_SESSION(sb);
678 last[i] - UDF_SB_SESSION(sb); 670 UDF_SB_ANCHOR(sb)[1] = last[i] - 256 - UDF_SB_SESSION(sb);
679 UDF_SB_ANCHOR(sb)[1] = 671 } else if (location == udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb)) {
680 last[i] - 256 - UDF_SB_SESSION(sb);
681 } else if (location ==
682 udf_variable_to_fixed(last[i]) -
683 UDF_SB_SESSION(sb)) {
684 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV); 672 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
685 lastblock = UDF_SB_ANCHOR(sb)[0] = 673 lastblock = UDF_SB_ANCHOR(sb)[0] = udf_variable_to_fixed(last[i]) - UDF_SB_SESSION(sb);
686 udf_variable_to_fixed(last[i]) - 674 UDF_SB_ANCHOR(sb)[1] = lastblock - 256 - UDF_SB_SESSION(sb);
687 UDF_SB_SESSION(sb); 675 } else {
688 UDF_SB_ANCHOR(sb)[1] = 676 udf_debug("Anchor found at block %d, location mismatch %d.\n",
689 lastblock - 256 - 677 last[i], location);
690 UDF_SB_SESSION(sb); 678 }
691 } else 679 } else if (ident == TAG_IDENT_FE || ident == TAG_IDENT_EFE) {
692 udf_debug
693 ("Anchor found at block %d, location mismatch %d.\n",
694 last[i], location);
695 } else if (ident == TAG_IDENT_FE
696 || ident == TAG_IDENT_EFE) {
697 lastblock = last[i]; 680 lastblock = last[i];
698 UDF_SB_ANCHOR(sb)[3] = 512; 681 UDF_SB_ANCHOR(sb)[3] = 512;
699 } else { 682 } else {
700 if (last[i] < 256 683 if (last[i] < 256 || !(bh = sb_bread(sb, last[i] - 256))) {
701 || !(bh = sb_bread(sb, last[i] - 256))) {
702 ident = location = 0; 684 ident = location = 0;
703 } else { 685 } else {
704 ident = 686 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
705 le16_to_cpu(((tag *) bh->b_data)-> 687 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
706 tagIdent);
707 location =
708 le32_to_cpu(((tag *) bh->b_data)->
709 tagLocation);
710 brelse(bh); 688 brelse(bh);
711 } 689 }
712 690
713 if (ident == TAG_IDENT_AVDP && 691 if (ident == TAG_IDENT_AVDP &&
714 location == 692 location == last[i] - 256 - UDF_SB_SESSION(sb)) {
715 last[i] - 256 - UDF_SB_SESSION(sb)) {
716 lastblock = last[i]; 693 lastblock = last[i];
717 UDF_SB_ANCHOR(sb)[1] = last[i] - 256; 694 UDF_SB_ANCHOR(sb)[1] = last[i] - 256;
718 } else { 695 } else {
719 if (last[i] < 312 + UDF_SB_SESSION(sb) 696 if (last[i] < 312 + UDF_SB_SESSION(sb) ||
720 || !(bh = 697 !(bh = sb_bread(sb, last[i] - 312 - UDF_SB_SESSION(sb)))) {
721 sb_bread(sb,
722 last[i] - 312 -
723 UDF_SB_SESSION(sb))))
724 {
725 ident = location = 0; 698 ident = location = 0;
726 } else { 699 } else {
727 ident = 700 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
728 le16_to_cpu(((tag *) bh-> 701 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
729 b_data)->
730 tagIdent);
731 location =
732 le32_to_cpu(((tag *) bh->
733 b_data)->
734 tagLocation);
735 brelse(bh); 702 brelse(bh);
736 } 703 }
737 704
738 if (ident == TAG_IDENT_AVDP && 705 if (ident == TAG_IDENT_AVDP &&
739 location == 706 location == udf_variable_to_fixed(last[i]) - 256) {
740 udf_variable_to_fixed(last[i]) - 707 UDF_SET_FLAG(sb, UDF_FLAG_VARCONV);
741 256) { 708 lastblock = udf_variable_to_fixed(last[i]);
742 UDF_SET_FLAG(sb, 709 UDF_SB_ANCHOR(sb)[1] = lastblock - 256;
743 UDF_FLAG_VARCONV);
744 lastblock =
745 udf_variable_to_fixed(last
746 [i]);
747 UDF_SB_ANCHOR(sb)[1] =
748 lastblock - 256;
749 } 710 }
750 } 711 }
751 } 712 }
@@ -755,9 +716,8 @@ static void udf_find_anchor(struct super_block *sb)
755 if (!lastblock) { 716 if (!lastblock) {
756 /* We havn't found the lastblock. check 312 */ 717 /* We havn't found the lastblock. check 312 */
757 if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) { 718 if ((bh = sb_bread(sb, 312 + UDF_SB_SESSION(sb)))) {
758 ident = le16_to_cpu(((tag *) bh->b_data)->tagIdent); 719 ident = le16_to_cpu(((tag *)bh->b_data)->tagIdent);
759 location = 720 location = le32_to_cpu(((tag *)bh->b_data)->tagLocation);
760 le32_to_cpu(((tag *) bh->b_data)->tagLocation);
761 brelse(bh); 721 brelse(bh);
762 722
763 if (ident == TAG_IDENT_AVDP && location == 256) 723 if (ident == TAG_IDENT_AVDP && location == 256)
@@ -767,19 +727,13 @@ static void udf_find_anchor(struct super_block *sb)
767 727
768 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { 728 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
769 if (UDF_SB_ANCHOR(sb)[i]) { 729 if (UDF_SB_ANCHOR(sb)[i]) {
770 if (!(bh = udf_read_tagged(sb, 730 if (!(bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
771 UDF_SB_ANCHOR(sb)[i], 731 UDF_SB_ANCHOR(sb)[i], &ident))) {
772 UDF_SB_ANCHOR(sb)[i],
773 &ident))) {
774 UDF_SB_ANCHOR(sb)[i] = 0; 732 UDF_SB_ANCHOR(sb)[i] = 0;
775 } else { 733 } else {
776 brelse(bh); 734 brelse(bh);
777 if ((ident != TAG_IDENT_AVDP) && (i || 735 if ((ident != TAG_IDENT_AVDP) &&
778 (ident != 736 (i || (ident != TAG_IDENT_FE && ident != TAG_IDENT_EFE))) {
779 TAG_IDENT_FE
780 && ident !=
781 TAG_IDENT_EFE)))
782 {
783 UDF_SB_ANCHOR(sb)[i] = 0; 737 UDF_SB_ANCHOR(sb)[i] = 0;
784 } 738 }
785 } 739 }
@@ -789,9 +743,7 @@ static void udf_find_anchor(struct super_block *sb)
789 UDF_SB_LASTBLOCK(sb) = lastblock; 743 UDF_SB_LASTBLOCK(sb) = lastblock;
790} 744}
791 745
792static int 746static int udf_find_fileset(struct super_block *sb, kernel_lb_addr *fileset, kernel_lb_addr *root)
793udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
794 kernel_lb_addr * root)
795{ 747{
796 struct buffer_head *bh = NULL; 748 struct buffer_head *bh = NULL;
797 long lastblock; 749 long lastblock;
@@ -801,18 +753,19 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
801 fileset->partitionReferenceNum != 0xFFFF) { 753 fileset->partitionReferenceNum != 0xFFFF) {
802 bh = udf_read_ptagged(sb, *fileset, 0, &ident); 754 bh = udf_read_ptagged(sb, *fileset, 0, &ident);
803 755
804 if (!bh) 756 if (!bh) {
805 return 1; 757 return 1;
806 else if (ident != TAG_IDENT_FSD) { 758 } else if (ident != TAG_IDENT_FSD) {
807 brelse(bh); 759 brelse(bh);
808 return 1; 760 return 1;
809 } 761 }
810 762
811 } 763 }
812 764
813 if (!bh) { /* Search backwards through the partitions */ 765 if (!bh) { /* Search backwards through the partitions */
814 kernel_lb_addr newfileset; 766 kernel_lb_addr newfileset;
815 767
768/* --> cvg: FIXME - is it reasonable? */
816 return 1; 769 return 1;
817 770
818 for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1; 771 for (newfileset.partitionReferenceNum = UDF_SB_NUMPARTS(sb) - 1;
@@ -820,14 +773,11 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
820 fileset->logicalBlockNum == 0xFFFFFFFF && 773 fileset->logicalBlockNum == 0xFFFFFFFF &&
821 fileset->partitionReferenceNum == 0xFFFF); 774 fileset->partitionReferenceNum == 0xFFFF);
822 newfileset.partitionReferenceNum--) { 775 newfileset.partitionReferenceNum--) {
823 lastblock = 776 lastblock = UDF_SB_PARTLEN(sb, newfileset.partitionReferenceNum);
824 UDF_SB_PARTLEN(sb,
825 newfileset.partitionReferenceNum);
826 newfileset.logicalBlockNum = 0; 777 newfileset.logicalBlockNum = 0;
827 778
828 do { 779 do {
829 bh = udf_read_ptagged(sb, newfileset, 0, 780 bh = udf_read_ptagged(sb, newfileset, 0, &ident);
830 &ident);
831 if (!bh) { 781 if (!bh) {
832 newfileset.logicalBlockNum++; 782 newfileset.logicalBlockNum++;
833 continue; 783 continue;
@@ -835,38 +785,28 @@ udf_find_fileset(struct super_block *sb, kernel_lb_addr * fileset,
835 785
836 switch (ident) { 786 switch (ident) {
837 case TAG_IDENT_SBD: 787 case TAG_IDENT_SBD:
838 { 788 {
839 struct spaceBitmapDesc *sp; 789 struct spaceBitmapDesc *sp;
840 sp = (struct spaceBitmapDesc *) 790 sp = (struct spaceBitmapDesc *)bh->b_data;
841 bh->b_data; 791 newfileset.logicalBlockNum += 1 +
842 newfileset.logicalBlockNum += 792 ((le32_to_cpu(sp->numOfBytes) +
843 1 + 793 sizeof(struct spaceBitmapDesc) - 1)
844 ((le32_to_cpu 794 >> sb->s_blocksize_bits);
845 (sp->numOfBytes) + 795 brelse(bh);
846 sizeof(struct 796 break;
847 spaceBitmapDesc) - 797 }
848 1)
849 >> sb->s_blocksize_bits);
850 brelse(bh);
851 break;
852 }
853 case TAG_IDENT_FSD: 798 case TAG_IDENT_FSD:
854 { 799 *fileset = newfileset;
855 *fileset = newfileset; 800 break;
856 break;
857 }
858 default: 801 default:
859 { 802 newfileset.logicalBlockNum++;
860 newfileset.logicalBlockNum++; 803 brelse(bh);
861 brelse(bh); 804 bh = NULL;
862 bh = NULL; 805 break;
863 break;
864 }
865 } 806 }
866 } 807 } while (newfileset.logicalBlockNum < lastblock &&
867 while (newfileset.logicalBlockNum < lastblock && 808 fileset->logicalBlockNum == 0xFFFFFFFF &&
868 fileset->logicalBlockNum == 0xFFFFFFFF && 809 fileset->partitionReferenceNum == 0xFFFF);
869 fileset->partitionReferenceNum == 0xFFFF);
870 } 810 }
871 } 811 }
872 812
@@ -898,10 +838,10 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
898 lets_to_cpu(pvoldesc->recordingDateAndTime))) { 838 lets_to_cpu(pvoldesc->recordingDateAndTime))) {
899 kernel_timestamp ts; 839 kernel_timestamp ts;
900 ts = lets_to_cpu(pvoldesc->recordingDateAndTime); 840 ts = lets_to_cpu(pvoldesc->recordingDateAndTime);
901 udf_debug 841 udf_debug("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n",
902 ("recording time %ld/%ld, %04u/%02u/%02u %02u:%02u (%x)\n", 842 recording, recording_usec,
903 recording, recording_usec, ts.year, ts.month, ts.day, 843 ts.year, ts.month, ts.day, ts.hour,
904 ts.hour, ts.minute, ts.typeAndTimezone); 844 ts.minute, ts.typeAndTimezone);
905 UDF_SB_RECORDTIME(sb).tv_sec = recording; 845 UDF_SB_RECORDTIME(sb).tv_sec = recording;
906 UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000; 846 UDF_SB_RECORDTIME(sb).tv_nsec = recording_usec * 1000;
907 } 847 }
@@ -920,9 +860,8 @@ static void udf_load_pvoldesc(struct super_block *sb, struct buffer_head *bh)
920 } 860 }
921} 861}
922 862
923static void 863static void udf_load_fileset(struct super_block *sb, struct buffer_head *bh,
924udf_load_fileset(struct super_block *sb, struct buffer_head *bh, 864 kernel_lb_addr *root)
925 kernel_lb_addr * root)
926{ 865{
927 struct fileSetDesc *fset; 866 struct fileSetDesc *fset;
928 867
@@ -945,121 +884,72 @@ static void udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
945 884
946 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { 885 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
947 udf_debug("Searching map: (%d == %d)\n", 886 udf_debug("Searching map: (%d == %d)\n",
948 UDF_SB_PARTMAPS(sb)[i].s_partition_num, 887 UDF_SB_PARTMAPS(sb)[i].s_partition_num, le16_to_cpu(p->partitionNumber));
949 le16_to_cpu(p->partitionNumber)); 888 if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == le16_to_cpu(p->partitionNumber)) {
950 if (UDF_SB_PARTMAPS(sb)[i].s_partition_num == 889 UDF_SB_PARTLEN(sb,i) = le32_to_cpu(p->partitionLength); /* blocks */
951 le16_to_cpu(p->partitionNumber)) { 890 UDF_SB_PARTROOT(sb,i) = le32_to_cpu(p->partitionStartingLocation);
952 UDF_SB_PARTLEN(sb, i) = le32_to_cpu(p->partitionLength); /* blocks */ 891 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_READ_ONLY)
953 UDF_SB_PARTROOT(sb, i) = 892 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_READ_ONLY;
954 le32_to_cpu(p->partitionStartingLocation); 893 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_WRITE_ONCE)
955 if (le32_to_cpu(p->accessType) == 894 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_WRITE_ONCE;
956 PD_ACCESS_TYPE_READ_ONLY) 895 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_REWRITABLE)
957 UDF_SB_PARTFLAGS(sb, i) |= 896 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_REWRITABLE;
958 UDF_PART_FLAG_READ_ONLY; 897 if (le32_to_cpu(p->accessType) == PD_ACCESS_TYPE_OVERWRITABLE)
959 if (le32_to_cpu(p->accessType) == 898 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_OVERWRITABLE;
960 PD_ACCESS_TYPE_WRITE_ONCE) 899
961 UDF_SB_PARTFLAGS(sb, i) |= 900 if (!strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR02) ||
962 UDF_PART_FLAG_WRITE_ONCE; 901 !strcmp(p->partitionContents.ident, PD_PARTITION_CONTENTS_NSR03)) {
963 if (le32_to_cpu(p->accessType) ==
964 PD_ACCESS_TYPE_REWRITABLE)
965 UDF_SB_PARTFLAGS(sb, i) |=
966 UDF_PART_FLAG_REWRITABLE;
967 if (le32_to_cpu(p->accessType) ==
968 PD_ACCESS_TYPE_OVERWRITABLE)
969 UDF_SB_PARTFLAGS(sb, i) |=
970 UDF_PART_FLAG_OVERWRITABLE;
971
972 if (!strcmp
973 (p->partitionContents.ident,
974 PD_PARTITION_CONTENTS_NSR02)
975 || !strcmp(p->partitionContents.ident,
976 PD_PARTITION_CONTENTS_NSR03)) {
977 struct partitionHeaderDesc *phd; 902 struct partitionHeaderDesc *phd;
978 903
979 phd = 904 phd = (struct partitionHeaderDesc *)(p->partitionContentsUse);
980 (struct partitionHeaderDesc *)(p->
981 partitionContentsUse);
982 if (phd->unallocSpaceTable.extLength) { 905 if (phd->unallocSpaceTable.extLength) {
983 kernel_lb_addr loc = 906 kernel_lb_addr loc = {
984 { le32_to_cpu(phd-> 907 .logicalBlockNum = le32_to_cpu(phd->unallocSpaceTable.extPosition),
985 unallocSpaceTable. 908 .partitionReferenceNum = i,
986 extPosition), i }; 909 };
987 910
988 UDF_SB_PARTMAPS(sb)[i].s_uspace. 911 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table =
989 s_table = udf_iget(sb, loc); 912 udf_iget(sb, loc);
990 UDF_SB_PARTFLAGS(sb, i) |= 913 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_TABLE;
991 UDF_PART_FLAG_UNALLOC_TABLE; 914 udf_debug("unallocSpaceTable (part %d) @ %ld\n",
992 udf_debug 915 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_table->i_ino);
993 ("unallocSpaceTable (part %d) @ %ld\n",
994 i,
995 UDF_SB_PARTMAPS(sb)[i].s_uspace.
996 s_table->i_ino);
997 } 916 }
998 if (phd->unallocSpaceBitmap.extLength) { 917 if (phd->unallocSpaceBitmap.extLength) {
999 UDF_SB_ALLOC_BITMAP(sb, i, s_uspace); 918 UDF_SB_ALLOC_BITMAP(sb, i, s_uspace);
1000 if (UDF_SB_PARTMAPS(sb)[i].s_uspace. 919 if (UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap != NULL) {
1001 s_bitmap != NULL) { 920 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extLength =
1002 UDF_SB_PARTMAPS(sb)[i].s_uspace. 921 le32_to_cpu(phd->unallocSpaceBitmap.extLength);
1003 s_bitmap->s_extLength = 922 UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition =
1004 le32_to_cpu(phd-> 923 le32_to_cpu(phd->unallocSpaceBitmap.extPosition);
1005 unallocSpaceBitmap. 924 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_UNALLOC_BITMAP;
1006 extLength); 925 udf_debug("unallocSpaceBitmap (part %d) @ %d\n",
1007 UDF_SB_PARTMAPS(sb)[i].s_uspace. 926 i, UDF_SB_PARTMAPS(sb)[i].s_uspace.s_bitmap->s_extPosition);
1008 s_bitmap->s_extPosition =
1009 le32_to_cpu(phd->
1010 unallocSpaceBitmap.
1011 extPosition);
1012 UDF_SB_PARTFLAGS(sb, i) |=
1013 UDF_PART_FLAG_UNALLOC_BITMAP;
1014 udf_debug
1015 ("unallocSpaceBitmap (part %d) @ %d\n",
1016 i,
1017 UDF_SB_PARTMAPS(sb)[i].
1018 s_uspace.s_bitmap->
1019 s_extPosition);
1020 } 927 }
1021 } 928 }
1022 if (phd->partitionIntegrityTable.extLength) 929 if (phd->partitionIntegrityTable.extLength)
1023 udf_debug 930 udf_debug("partitionIntegrityTable (part %d)\n", i);
1024 ("partitionIntegrityTable (part %d)\n",
1025 i);
1026 if (phd->freedSpaceTable.extLength) { 931 if (phd->freedSpaceTable.extLength) {
1027 kernel_lb_addr loc = 932 kernel_lb_addr loc = {
1028 { le32_to_cpu(phd->freedSpaceTable. 933 .logicalBlockNum = le32_to_cpu(phd->freedSpaceTable.extPosition),
1029 extPosition), i }; 934 .partitionReferenceNum = i,
1030 935 };
1031 UDF_SB_PARTMAPS(sb)[i].s_fspace. 936
1032 s_table = udf_iget(sb, loc); 937 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table =
1033 UDF_SB_PARTFLAGS(sb, i) |= 938 udf_iget(sb, loc);
1034 UDF_PART_FLAG_FREED_TABLE; 939 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_TABLE;
1035 udf_debug 940 udf_debug("freedSpaceTable (part %d) @ %ld\n",
1036 ("freedSpaceTable (part %d) @ %ld\n", 941 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_table->i_ino);
1037 i,
1038 UDF_SB_PARTMAPS(sb)[i].s_fspace.
1039 s_table->i_ino);
1040 } 942 }
1041 if (phd->freedSpaceBitmap.extLength) { 943 if (phd->freedSpaceBitmap.extLength) {
1042 UDF_SB_ALLOC_BITMAP(sb, i, s_fspace); 944 UDF_SB_ALLOC_BITMAP(sb, i, s_fspace);
1043 if (UDF_SB_PARTMAPS(sb)[i].s_fspace. 945 if (UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap != NULL) {
1044 s_bitmap != NULL) { 946 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extLength =
1045 UDF_SB_PARTMAPS(sb)[i].s_fspace. 947 le32_to_cpu(phd->freedSpaceBitmap.extLength);
1046 s_bitmap->s_extLength = 948 UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition =
1047 le32_to_cpu(phd-> 949 le32_to_cpu(phd->freedSpaceBitmap.extPosition);
1048 freedSpaceBitmap. 950 UDF_SB_PARTFLAGS(sb,i) |= UDF_PART_FLAG_FREED_BITMAP;
1049 extLength); 951 udf_debug("freedSpaceBitmap (part %d) @ %d\n",
1050 UDF_SB_PARTMAPS(sb)[i].s_fspace. 952 i, UDF_SB_PARTMAPS(sb)[i].s_fspace.s_bitmap->s_extPosition);
1051 s_bitmap->s_extPosition =
1052 le32_to_cpu(phd->
1053 freedSpaceBitmap.
1054 extPosition);
1055 UDF_SB_PARTFLAGS(sb, i) |=
1056 UDF_PART_FLAG_FREED_BITMAP;
1057 udf_debug
1058 ("freedSpaceBitmap (part %d) @ %d\n",
1059 i,
1060 UDF_SB_PARTMAPS(sb)[i].
1061 s_fspace.s_bitmap->
1062 s_extPosition);
1063 } 953 }
1064 } 954 }
1065 } 955 }
@@ -1070,16 +960,14 @@ static void udf_load_partdesc(struct super_block *sb, struct buffer_head *bh)
1070 udf_debug("Partition (%d) not found in partition map\n", 960 udf_debug("Partition (%d) not found in partition map\n",
1071 le16_to_cpu(p->partitionNumber)); 961 le16_to_cpu(p->partitionNumber));
1072 } else { 962 } else {
1073 udf_debug 963 udf_debug("Partition (%d:%d type %x) starts at physical %d, block length %d\n",
1074 ("Partition (%d:%d type %x) starts at physical %d, block length %d\n", 964 le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb,i),
1075 le16_to_cpu(p->partitionNumber), i, UDF_SB_PARTTYPE(sb, i), 965 UDF_SB_PARTROOT(sb,i), UDF_SB_PARTLEN(sb,i));
1076 UDF_SB_PARTROOT(sb, i), UDF_SB_PARTLEN(sb, i));
1077 } 966 }
1078} 967}
1079 968
1080static int 969static int udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
1081udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh, 970 kernel_lb_addr *fileset)
1082 kernel_lb_addr * fileset)
1083{ 971{
1084 struct logicalVolDesc *lvd; 972 struct logicalVolDesc *lvd;
1085 int i, j, offset; 973 int i, j, offset;
@@ -1090,116 +978,69 @@ udf_load_logicalvol(struct super_block *sb, struct buffer_head *bh,
1090 UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps)); 978 UDF_SB_ALLOC_PARTMAPS(sb, le32_to_cpu(lvd->numPartitionMaps));
1091 979
1092 for (i = 0, offset = 0; 980 for (i = 0, offset = 0;
1093 i < UDF_SB_NUMPARTS(sb) 981 i < UDF_SB_NUMPARTS(sb) && offset < le32_to_cpu(lvd->mapTableLength);
1094 && offset < le32_to_cpu(lvd->mapTableLength); 982 i++, offset += ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapLength) {
1095 i++, offset += 983 type = ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->partitionMapType;
1096 ((struct genericPartitionMap *)&(lvd->partitionMaps[offset]))->
1097 partitionMapLength) {
1098 type =
1099 ((struct genericPartitionMap *)
1100 &(lvd->partitionMaps[offset]))->partitionMapType;
1101 if (type == 1) { 984 if (type == 1) {
1102 struct genericPartitionMap1 *gpm1 = 985 struct genericPartitionMap1 *gpm1 = (struct genericPartitionMap1 *)&(lvd->partitionMaps[offset]);
1103 (struct genericPartitionMap1 *)&(lvd-> 986 UDF_SB_PARTTYPE(sb,i) = UDF_TYPE1_MAP15;
1104 partitionMaps 987 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(gpm1->volSeqNum);
1105 [offset]); 988 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(gpm1->partitionNum);
1106 UDF_SB_PARTTYPE(sb, i) = UDF_TYPE1_MAP15; 989 UDF_SB_PARTFUNC(sb,i) = NULL;
1107 UDF_SB_PARTVSN(sb, i) = le16_to_cpu(gpm1->volSeqNum);
1108 UDF_SB_PARTNUM(sb, i) = le16_to_cpu(gpm1->partitionNum);
1109 UDF_SB_PARTFUNC(sb, i) = NULL;
1110 } else if (type == 2) { 990 } else if (type == 2) {
1111 struct udfPartitionMap2 *upm2 = 991 struct udfPartitionMap2 *upm2 = (struct udfPartitionMap2 *)&(lvd->partitionMaps[offset]);
1112 (struct udfPartitionMap2 *)&(lvd-> 992 if (!strncmp(upm2->partIdent.ident, UDF_ID_VIRTUAL, strlen(UDF_ID_VIRTUAL))) {
1113 partitionMaps[offset]); 993 if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0150) {
1114 if (!strncmp 994 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP15;
1115 (upm2->partIdent.ident, UDF_ID_VIRTUAL, 995 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt15;
1116 strlen(UDF_ID_VIRTUAL))) { 996 } else if (le16_to_cpu(((__le16 *)upm2->partIdent.identSuffix)[0]) == 0x0200) {
1117 if (le16_to_cpu 997 UDF_SB_PARTTYPE(sb,i) = UDF_VIRTUAL_MAP20;
1118 (((__le16 *) upm2->partIdent. 998 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_virt20;
1119 identSuffix)[0]) == 0x0150) {
1120 UDF_SB_PARTTYPE(sb, i) =
1121 UDF_VIRTUAL_MAP15;
1122 UDF_SB_PARTFUNC(sb, i) =
1123 udf_get_pblock_virt15;
1124 } else
1125 if (le16_to_cpu
1126 (((__le16 *) upm2->partIdent.
1127 identSuffix)[0]) == 0x0200) {
1128 UDF_SB_PARTTYPE(sb, i) =
1129 UDF_VIRTUAL_MAP20;
1130 UDF_SB_PARTFUNC(sb, i) =
1131 udf_get_pblock_virt20;
1132 } 999 }
1133 } else 1000 } else if (!strncmp(upm2->partIdent.ident, UDF_ID_SPARABLE, strlen(UDF_ID_SPARABLE))) {
1134 if (!strncmp
1135 (upm2->partIdent.ident, UDF_ID_SPARABLE,
1136 strlen(UDF_ID_SPARABLE))) {
1137 uint32_t loc; 1001 uint32_t loc;
1138 uint16_t ident; 1002 uint16_t ident;
1139 struct sparingTable *st; 1003 struct sparingTable *st;
1140 struct sparablePartitionMap *spm = 1004 struct sparablePartitionMap *spm = (struct sparablePartitionMap *)&(lvd->partitionMaps[offset]);
1141 (struct sparablePartitionMap *)&(lvd-> 1005
1142 partitionMaps 1006 UDF_SB_PARTTYPE(sb,i) = UDF_SPARABLE_MAP15;
1143 [offset]); 1007 UDF_SB_TYPESPAR(sb,i).s_packet_len = le16_to_cpu(spm->packetLength);
1144
1145 UDF_SB_PARTTYPE(sb, i) = UDF_SPARABLE_MAP15;
1146 UDF_SB_TYPESPAR(sb, i).s_packet_len =
1147 le16_to_cpu(spm->packetLength);
1148 for (j = 0; j < spm->numSparingTables; j++) { 1008 for (j = 0; j < spm->numSparingTables; j++) {
1149 loc = 1009 loc = le32_to_cpu(spm->locSparingTable[j]);
1150 le32_to_cpu(spm-> 1010 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] =
1151 locSparingTable[j]); 1011 udf_read_tagged(sb, loc, loc, &ident);
1152 UDF_SB_TYPESPAR(sb, i).s_spar_map[j] = 1012 if (UDF_SB_TYPESPAR(sb,i).s_spar_map[j] != NULL) {
1153 udf_read_tagged(sb, loc, loc, 1013 st = (struct sparingTable *)UDF_SB_TYPESPAR(sb,i).s_spar_map[j]->b_data;
1154 &ident); 1014 if (ident != 0 ||
1155 if (UDF_SB_TYPESPAR(sb, i). 1015 strncmp(st->sparingIdent.ident, UDF_ID_SPARING, strlen(UDF_ID_SPARING))) {
1156 s_spar_map[j] != NULL) { 1016 brelse(UDF_SB_TYPESPAR(sb,i).s_spar_map[j]);
1157 st = (struct sparingTable *) 1017 UDF_SB_TYPESPAR(sb,i).s_spar_map[j] = NULL;
1158 UDF_SB_TYPESPAR(sb,
1159 i).
1160 s_spar_map[j]->b_data;
1161 if (ident != 0
1162 || strncmp(st->sparingIdent.
1163 ident,
1164 UDF_ID_SPARING,
1165 strlen
1166 (UDF_ID_SPARING)))
1167 {
1168 brelse(UDF_SB_TYPESPAR
1169 (sb,
1170 i).
1171 s_spar_map[j]);
1172 UDF_SB_TYPESPAR(sb,
1173 i).
1174 s_spar_map[j] =
1175 NULL;
1176 } 1018 }
1177 } 1019 }
1178 } 1020 }
1179 UDF_SB_PARTFUNC(sb, i) = udf_get_pblock_spar15; 1021 UDF_SB_PARTFUNC(sb,i) = udf_get_pblock_spar15;
1180 } else { 1022 } else {
1181 udf_debug("Unknown ident: %s\n", 1023 udf_debug("Unknown ident: %s\n", upm2->partIdent.ident);
1182 upm2->partIdent.ident);
1183 continue; 1024 continue;
1184 } 1025 }
1185 UDF_SB_PARTVSN(sb, i) = le16_to_cpu(upm2->volSeqNum); 1026 UDF_SB_PARTVSN(sb,i) = le16_to_cpu(upm2->volSeqNum);
1186 UDF_SB_PARTNUM(sb, i) = le16_to_cpu(upm2->partitionNum); 1027 UDF_SB_PARTNUM(sb,i) = le16_to_cpu(upm2->partitionNum);
1187 } 1028 }
1188 udf_debug("Partition (%d:%d) type %d on volume %d\n", 1029 udf_debug("Partition (%d:%d) type %d on volume %d\n",
1189 i, UDF_SB_PARTNUM(sb, i), type, UDF_SB_PARTVSN(sb, 1030 i, UDF_SB_PARTNUM(sb,i), type, UDF_SB_PARTVSN(sb,i));
1190 i));
1191 } 1031 }
1192 1032
1193 if (fileset) { 1033 if (fileset) {
1194 long_ad *la = (long_ad *) & (lvd->logicalVolContentsUse[0]); 1034 long_ad *la = (long_ad *)&(lvd->logicalVolContentsUse[0]);
1195 1035
1196 *fileset = lelb_to_cpu(la->extLocation); 1036 *fileset = lelb_to_cpu(la->extLocation);
1197 udf_debug 1037 udf_debug("FileSet found in LogicalVolDesc at block=%d, partition=%d\n",
1198 ("FileSet found in LogicalVolDesc at block=%d, partition=%d\n", 1038 fileset->logicalBlockNum,
1199 fileset->logicalBlockNum, fileset->partitionReferenceNum); 1039 fileset->partitionReferenceNum);
1200 } 1040 }
1201 if (lvd->integritySeqExt.extLength) 1041 if (lvd->integritySeqExt.extLength)
1202 udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt)); 1042 udf_load_logicalvolint(sb, leea_to_cpu(lvd->integritySeqExt));
1043
1203 return 0; 1044 return 0;
1204} 1045}
1205 1046
@@ -1219,9 +1060,7 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
1219 UDF_SB_LVIDBH(sb) = bh; 1060 UDF_SB_LVIDBH(sb) = bh;
1220 1061
1221 if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength) 1062 if (UDF_SB_LVID(sb)->nextIntegrityExt.extLength)
1222 udf_load_logicalvolint(sb, 1063 udf_load_logicalvolint(sb, leea_to_cpu(UDF_SB_LVID(sb)->nextIntegrityExt));
1223 leea_to_cpu(UDF_SB_LVID(sb)->
1224 nextIntegrityExt));
1225 1064
1226 if (UDF_SB_LVIDBH(sb) != bh) 1065 if (UDF_SB_LVIDBH(sb) != bh)
1227 brelse(bh); 1066 brelse(bh);
@@ -1247,9 +1086,8 @@ static void udf_load_logicalvolint(struct super_block *sb, kernel_extent_ad loc)
1247 * July 1, 1997 - Andrew E. Mileski 1086 * July 1, 1997 - Andrew E. Mileski
1248 * Written, tested, and released. 1087 * Written, tested, and released.
1249 */ 1088 */
1250static int 1089static int udf_process_sequence(struct super_block *sb, long block, long lastblock,
1251udf_process_sequence(struct super_block *sb, long block, long lastblock, 1090 kernel_lb_addr *fileset)
1252 kernel_lb_addr * fileset)
1253{ 1091{
1254 struct buffer_head *bh = NULL; 1092 struct buffer_head *bh = NULL;
1255 struct udf_vds_record vds[VDS_POS_LENGTH]; 1093 struct udf_vds_record vds[VDS_POS_LENGTH];
@@ -1274,82 +1112,71 @@ udf_process_sequence(struct super_block *sb, long block, long lastblock,
1274 gd = (struct generic_desc *)bh->b_data; 1112 gd = (struct generic_desc *)bh->b_data;
1275 vdsn = le32_to_cpu(gd->volDescSeqNum); 1113 vdsn = le32_to_cpu(gd->volDescSeqNum);
1276 switch (ident) { 1114 switch (ident) {
1277 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */ 1115 case TAG_IDENT_PVD: /* ISO 13346 3/10.1 */
1278 if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) { 1116 if (vdsn >= vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum) {
1279 vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = 1117 vds[VDS_POS_PRIMARY_VOL_DESC].volDescSeqNum = vdsn;
1280 vdsn;
1281 vds[VDS_POS_PRIMARY_VOL_DESC].block = block; 1118 vds[VDS_POS_PRIMARY_VOL_DESC].block = block;
1282 } 1119 }
1283 break; 1120 break;
1284 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */ 1121 case TAG_IDENT_VDP: /* ISO 13346 3/10.3 */
1285 if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) { 1122 if (vdsn >= vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum) {
1286 vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn; 1123 vds[VDS_POS_VOL_DESC_PTR].volDescSeqNum = vdsn;
1287 vds[VDS_POS_VOL_DESC_PTR].block = block; 1124 vds[VDS_POS_VOL_DESC_PTR].block = block;
1288 1125
1289 vdp = (struct volDescPtr *)bh->b_data; 1126 vdp = (struct volDescPtr *)bh->b_data;
1290 next_s = 1127 next_s = le32_to_cpu(vdp->nextVolDescSeqExt.extLocation);
1291 le32_to_cpu(vdp->nextVolDescSeqExt. 1128 next_e = le32_to_cpu(vdp->nextVolDescSeqExt.extLength);
1292 extLocation);
1293 next_e =
1294 le32_to_cpu(vdp->nextVolDescSeqExt.
1295 extLength);
1296 next_e = next_e >> sb->s_blocksize_bits; 1129 next_e = next_e >> sb->s_blocksize_bits;
1297 next_e += next_s; 1130 next_e += next_s;
1298 } 1131 }
1299 break; 1132 break;
1300 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */ 1133 case TAG_IDENT_IUVD: /* ISO 13346 3/10.4 */
1301 if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) { 1134 if (vdsn >= vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum) {
1302 vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = 1135 vds[VDS_POS_IMP_USE_VOL_DESC].volDescSeqNum = vdsn;
1303 vdsn;
1304 vds[VDS_POS_IMP_USE_VOL_DESC].block = block; 1136 vds[VDS_POS_IMP_USE_VOL_DESC].block = block;
1305 } 1137 }
1306 break; 1138 break;
1307 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */ 1139 case TAG_IDENT_PD: /* ISO 13346 3/10.5 */
1308 if (!vds[VDS_POS_PARTITION_DESC].block) 1140 if (!vds[VDS_POS_PARTITION_DESC].block)
1309 vds[VDS_POS_PARTITION_DESC].block = block; 1141 vds[VDS_POS_PARTITION_DESC].block = block;
1310 break; 1142 break;
1311 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */ 1143 case TAG_IDENT_LVD: /* ISO 13346 3/10.6 */
1312 if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) { 1144 if (vdsn >= vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum) {
1313 vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = 1145 vds[VDS_POS_LOGICAL_VOL_DESC].volDescSeqNum = vdsn;
1314 vdsn;
1315 vds[VDS_POS_LOGICAL_VOL_DESC].block = block; 1146 vds[VDS_POS_LOGICAL_VOL_DESC].block = block;
1316 } 1147 }
1317 break; 1148 break;
1318 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */ 1149 case TAG_IDENT_USD: /* ISO 13346 3/10.8 */
1319 if (vdsn >= 1150 if (vdsn >= vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) {
1320 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum) { 1151 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum = vdsn;
1321 vds[VDS_POS_UNALLOC_SPACE_DESC].volDescSeqNum =
1322 vdsn;
1323 vds[VDS_POS_UNALLOC_SPACE_DESC].block = block; 1152 vds[VDS_POS_UNALLOC_SPACE_DESC].block = block;
1324 } 1153 }
1325 break; 1154 break;
1326 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */ 1155 case TAG_IDENT_TD: /* ISO 13346 3/10.9 */
1327 vds[VDS_POS_TERMINATING_DESC].block = block; 1156 vds[VDS_POS_TERMINATING_DESC].block = block;
1328 if (next_e) { 1157 if (next_e) {
1329 block = next_s; 1158 block = next_s;
1330 lastblock = next_e; 1159 lastblock = next_e;
1331 next_s = next_e = 0; 1160 next_s = next_e = 0;
1332 } else 1161 } else {
1333 done = 1; 1162 done = 1;
1163 }
1334 break; 1164 break;
1335 } 1165 }
1336 brelse(bh); 1166 brelse(bh);
1337 } 1167 }
1338 for (i = 0; i < VDS_POS_LENGTH; i++) { 1168 for (i = 0; i < VDS_POS_LENGTH; i++) {
1339 if (vds[i].block) { 1169 if (vds[i].block) {
1340 bh = udf_read_tagged(sb, vds[i].block, vds[i].block, 1170 bh = udf_read_tagged(sb, vds[i].block, vds[i].block, &ident);
1341 &ident);
1342 1171
1343 if (i == VDS_POS_PRIMARY_VOL_DESC) 1172 if (i == VDS_POS_PRIMARY_VOL_DESC) {
1344 udf_load_pvoldesc(sb, bh); 1173 udf_load_pvoldesc(sb, bh);
1345 else if (i == VDS_POS_LOGICAL_VOL_DESC) 1174 } else if (i == VDS_POS_LOGICAL_VOL_DESC) {
1346 udf_load_logicalvol(sb, bh, fileset); 1175 udf_load_logicalvol(sb, bh, fileset);
1347 else if (i == VDS_POS_PARTITION_DESC) { 1176 } else if (i == VDS_POS_PARTITION_DESC) {
1348 struct buffer_head *bh2 = NULL; 1177 struct buffer_head *bh2 = NULL;
1349 udf_load_partdesc(sb, bh); 1178 udf_load_partdesc(sb, bh);
1350 for (j = vds[i].block + 1; 1179 for (j = vds[i].block + 1; j < vds[VDS_POS_TERMINATING_DESC].block; j++) {
1351 j < vds[VDS_POS_TERMINATING_DESC].block;
1352 j++) {
1353 bh2 = udf_read_tagged(sb, j, j, &ident); 1180 bh2 = udf_read_tagged(sb, j, j, &ident);
1354 gd = (struct generic_desc *)bh2->b_data; 1181 gd = (struct generic_desc *)bh2->b_data;
1355 if (ident == TAG_IDENT_PD) 1182 if (ident == TAG_IDENT_PD)
@@ -1378,16 +1205,17 @@ static int udf_check_valid(struct super_block *sb, int novrs, int silent)
1378 /* Check that it is NSR02 compliant */ 1205 /* Check that it is NSR02 compliant */
1379 /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */ 1206 /* Process any "CD-ROM Volume Descriptor Set" (ECMA 167 2/8.3.1) */
1380 else if ((block = udf_vrs(sb, silent)) == -1) { 1207 else if ((block = udf_vrs(sb, silent)) == -1) {
1381 udf_debug 1208 udf_debug("Failed to read byte 32768. Assuming open disc. "
1382 ("Failed to read byte 32768. Assuming open disc. Skipping validity check\n"); 1209 "Skipping validity check\n");
1383 if (!UDF_SB_LASTBLOCK(sb)) 1210 if (!UDF_SB_LASTBLOCK(sb))
1384 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb); 1211 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1385 return 0; 1212 return 0;
1386 } else 1213 } else {
1387 return !block; 1214 return !block;
1215 }
1388} 1216}
1389 1217
1390static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset) 1218static int udf_load_partition(struct super_block *sb, kernel_lb_addr *fileset)
1391{ 1219{
1392 struct anchorVolDescPtr *anchor; 1220 struct anchorVolDescPtr *anchor;
1393 uint16_t ident; 1221 uint16_t ident;
@@ -1399,28 +1227,20 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset)
1399 return 1; 1227 return 1;
1400 1228
1401 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) { 1229 for (i = 0; i < ARRAY_SIZE(UDF_SB_ANCHOR(sb)); i++) {
1402 if (UDF_SB_ANCHOR(sb)[i] && (bh = udf_read_tagged(sb, 1230 if (UDF_SB_ANCHOR(sb)[i] &&
1403 UDF_SB_ANCHOR 1231 (bh = udf_read_tagged(sb, UDF_SB_ANCHOR(sb)[i],
1404 (sb)[i], 1232 UDF_SB_ANCHOR(sb)[i], &ident))) {
1405 UDF_SB_ANCHOR
1406 (sb)[i],
1407 &ident))) {
1408 anchor = (struct anchorVolDescPtr *)bh->b_data; 1233 anchor = (struct anchorVolDescPtr *)bh->b_data;
1409 1234
1410 /* Locate the main sequence */ 1235 /* Locate the main sequence */
1411 main_s = 1236 main_s = le32_to_cpu(anchor->mainVolDescSeqExt.extLocation);
1412 le32_to_cpu(anchor->mainVolDescSeqExt.extLocation); 1237 main_e = le32_to_cpu(anchor->mainVolDescSeqExt.extLength );
1413 main_e =
1414 le32_to_cpu(anchor->mainVolDescSeqExt.extLength);
1415 main_e = main_e >> sb->s_blocksize_bits; 1238 main_e = main_e >> sb->s_blocksize_bits;
1416 main_e += main_s; 1239 main_e += main_s;
1417 1240
1418 /* Locate the reserve sequence */ 1241 /* Locate the reserve sequence */
1419 reserve_s = 1242 reserve_s = le32_to_cpu(anchor->reserveVolDescSeqExt.extLocation);
1420 le32_to_cpu(anchor->reserveVolDescSeqExt. 1243 reserve_e = le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
1421 extLocation);
1422 reserve_e =
1423 le32_to_cpu(anchor->reserveVolDescSeqExt.extLength);
1424 reserve_e = reserve_e >> sb->s_blocksize_bits; 1244 reserve_e = reserve_e >> sb->s_blocksize_bits;
1425 reserve_e += reserve_s; 1245 reserve_e += reserve_s;
1426 1246
@@ -1428,10 +1248,8 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset)
1428 1248
1429 /* Process the main & reserve sequences */ 1249 /* Process the main & reserve sequences */
1430 /* responsible for finding the PartitionDesc(s) */ 1250 /* responsible for finding the PartitionDesc(s) */
1431 if (! 1251 if (!(udf_process_sequence(sb, main_s, main_e, fileset) &&
1432 (udf_process_sequence(sb, main_s, main_e, fileset) 1252 udf_process_sequence(sb, reserve_s, reserve_e, fileset))) {
1433 && udf_process_sequence(sb, reserve_s, reserve_e,
1434 fileset))) {
1435 break; 1253 break;
1436 } 1254 }
1437 } 1255 }
@@ -1444,81 +1262,67 @@ static int udf_load_partition(struct super_block *sb, kernel_lb_addr * fileset)
1444 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]); 1262 udf_debug("Using anchor in block %d\n", UDF_SB_ANCHOR(sb)[i]);
1445 1263
1446 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) { 1264 for (i = 0; i < UDF_SB_NUMPARTS(sb); i++) {
1265 kernel_lb_addr uninitialized_var(ino);
1447 switch (UDF_SB_PARTTYPE(sb, i)) { 1266 switch (UDF_SB_PARTTYPE(sb, i)) {
1448 case UDF_VIRTUAL_MAP15: 1267 case UDF_VIRTUAL_MAP15:
1449 case UDF_VIRTUAL_MAP20: 1268 case UDF_VIRTUAL_MAP20:
1450 { 1269 if (!UDF_SB_LASTBLOCK(sb)) {
1451 kernel_lb_addr uninitialized_var(ino); 1270 UDF_SB_LASTBLOCK(sb) = udf_get_last_block(sb);
1271 udf_find_anchor(sb);
1272 }
1452 1273
1453 if (!UDF_SB_LASTBLOCK(sb)) { 1274 if (!UDF_SB_LASTBLOCK(sb)) {
1454 UDF_SB_LASTBLOCK(sb) = 1275 udf_debug("Unable to determine Lastblock (For "
1455 udf_get_last_block(sb); 1276 "Virtual Partition)\n");
1456 udf_find_anchor(sb); 1277 return 1;
1457 } 1278 }
1458 1279
1459 if (!UDF_SB_LASTBLOCK(sb)) { 1280 for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) {
1460 udf_debug 1281 if (j != i && UDF_SB_PARTVSN(sb, i) ==
1461 ("Unable to determine Lastblock (For Virtual Partition)\n"); 1282 UDF_SB_PARTVSN(sb, j) &&
1462 return 1; 1283 UDF_SB_PARTNUM(sb, i) ==
1284 UDF_SB_PARTNUM(sb, j)) {
1285 ino.partitionReferenceNum = j;
1286 ino.logicalBlockNum =
1287 UDF_SB_LASTBLOCK(sb) -
1288 UDF_SB_PARTROOT(sb, j);
1289 break;
1463 } 1290 }
1291 }
1464 1292
1465 for (j = 0; j < UDF_SB_NUMPARTS(sb); j++) { 1293 if (j == UDF_SB_NUMPARTS(sb))
1466 if (j != i && 1294 return 1;
1467 UDF_SB_PARTVSN(sb,
1468 i) ==
1469 UDF_SB_PARTVSN(sb, j)
1470 && UDF_SB_PARTNUM(sb,
1471 i) ==
1472 UDF_SB_PARTNUM(sb, j)) {
1473 ino.partitionReferenceNum = j;
1474 ino.logicalBlockNum =
1475 UDF_SB_LASTBLOCK(sb) -
1476 UDF_SB_PARTROOT(sb, j);
1477 break;
1478 }
1479 }
1480 1295
1481 if (j == UDF_SB_NUMPARTS(sb)) 1296 if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino)))
1482 return 1; 1297 return 1;
1483 1298
1484 if (!(UDF_SB_VAT(sb) = udf_iget(sb, ino))) 1299 if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) {
1485 return 1; 1300 UDF_SB_TYPEVIRT(sb, i).s_start_offset =
1301 udf_ext0_offset(UDF_SB_VAT(sb));
1302 UDF_SB_TYPEVIRT(sb, i).s_num_entries =
1303 (UDF_SB_VAT(sb)->i_size - 36) >> 2;
1304 } else if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP20) {
1305 struct buffer_head *bh = NULL;
1306 uint32_t pos;
1486 1307
1487 if (UDF_SB_PARTTYPE(sb, i) == UDF_VIRTUAL_MAP15) { 1308 pos = udf_block_map(UDF_SB_VAT(sb), 0);
1488 UDF_SB_TYPEVIRT(sb, i).s_start_offset = 1309 bh = sb_bread(sb, pos);
1489 udf_ext0_offset(UDF_SB_VAT(sb)); 1310 if (!bh)
1490 UDF_SB_TYPEVIRT(sb, i).s_num_entries = 1311 return 1;
1491 (UDF_SB_VAT(sb)->i_size - 36) >> 2; 1312 UDF_SB_TYPEVIRT(sb, i).s_start_offset =
1492 } else if (UDF_SB_PARTTYPE(sb, i) == 1313 le16_to_cpu(((struct
1493 UDF_VIRTUAL_MAP20) { 1314 virtualAllocationTable20 *)bh->b_data +
1494 struct buffer_head *bh = NULL; 1315 udf_ext0_offset(UDF_SB_VAT(sb)))->
1495 uint32_t pos; 1316 lengthHeader) +
1496 1317 udf_ext0_offset(UDF_SB_VAT(sb));
1497 pos = udf_block_map(UDF_SB_VAT(sb), 0); 1318 UDF_SB_TYPEVIRT(sb, i).s_num_entries =
1498 bh = sb_bread(sb, pos); 1319 (UDF_SB_VAT(sb)->i_size -
1499 if (!bh) 1320 UDF_SB_TYPEVIRT(sb, i).s_start_offset) >> 2;
1500 return 1; 1321 brelse(bh);
1501 UDF_SB_TYPEVIRT(sb, i).s_start_offset =
1502 le16_to_cpu(((struct
1503 virtualAllocationTable20
1504 *)bh->b_data +
1505 udf_ext0_offset
1506 (UDF_SB_VAT(sb)))->
1507 lengthHeader) +
1508 udf_ext0_offset(UDF_SB_VAT(sb));
1509 UDF_SB_TYPEVIRT(sb, i).s_num_entries =
1510 (UDF_SB_VAT(sb)->i_size -
1511 UDF_SB_TYPEVIRT(sb,
1512 i).
1513 s_start_offset) >> 2;
1514 brelse(bh);
1515 }
1516 UDF_SB_PARTROOT(sb, i) =
1517 udf_get_pblock(sb, 0, i, 0);
1518 UDF_SB_PARTLEN(sb, i) =
1519 UDF_SB_PARTLEN(sb,
1520 ino.partitionReferenceNum);
1521 } 1322 }
1323 UDF_SB_PARTROOT(sb, i) = udf_get_pblock(sb, 0, i, 0);
1324 UDF_SB_PARTLEN(sb, i) = UDF_SB_PARTLEN(sb,
1325 ino.partitionReferenceNum);
1522 } 1326 }
1523 } 1327 }
1524 return 0; 1328 return 0;
@@ -1555,42 +1359,32 @@ static void udf_open_lvid(struct super_block *sb)
1555 1359
1556static void udf_close_lvid(struct super_block *sb) 1360static void udf_close_lvid(struct super_block *sb)
1557{ 1361{
1362 kernel_timestamp cpu_time;
1363 int i;
1364
1558 if (UDF_SB_LVIDBH(sb) && 1365 if (UDF_SB_LVIDBH(sb) &&
1559 UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) { 1366 UDF_SB_LVID(sb)->integrityType == LVID_INTEGRITY_TYPE_OPEN) {
1560 int i;
1561 kernel_timestamp cpu_time;
1562
1563 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; 1367 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
1564 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; 1368 UDF_SB_LVIDIU(sb)->impIdent.identSuffix[1] = UDF_OS_ID_LINUX;
1565 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME)) 1369 if (udf_time_to_stamp(&cpu_time, CURRENT_TIME))
1566 UDF_SB_LVID(sb)->recordingDateAndTime = 1370 UDF_SB_LVID(sb)->recordingDateAndTime = cpu_to_lets(cpu_time);
1567 cpu_to_lets(cpu_time); 1371 if (UDF_MAX_WRITE_VERSION > le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev))
1568 if (UDF_MAX_WRITE_VERSION > 1372 UDF_SB_LVIDIU(sb)->maxUDFWriteRev = cpu_to_le16(UDF_MAX_WRITE_VERSION);
1569 le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev)) 1373 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev))
1570 UDF_SB_LVIDIU(sb)->maxUDFWriteRev = 1374 UDF_SB_LVIDIU(sb)->minUDFReadRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1571 cpu_to_le16(UDF_MAX_WRITE_VERSION); 1375 if (UDF_SB_UDFREV(sb) > le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
1572 if (UDF_SB_UDFREV(sb) > 1376 UDF_SB_LVIDIU(sb)->minUDFWriteRev = cpu_to_le16(UDF_SB_UDFREV(sb));
1573 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev)) 1377 UDF_SB_LVID(sb)->integrityType = cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
1574 UDF_SB_LVIDIU(sb)->minUDFReadRev =
1575 cpu_to_le16(UDF_SB_UDFREV(sb));
1576 if (UDF_SB_UDFREV(sb) >
1577 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev))
1578 UDF_SB_LVIDIU(sb)->minUDFWriteRev =
1579 cpu_to_le16(UDF_SB_UDFREV(sb));
1580 UDF_SB_LVID(sb)->integrityType =
1581 cpu_to_le32(LVID_INTEGRITY_TYPE_CLOSE);
1582 1378
1583 UDF_SB_LVID(sb)->descTag.descCRC = 1379 UDF_SB_LVID(sb)->descTag.descCRC =
1584 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag), 1380 cpu_to_le16(udf_crc((char *)UDF_SB_LVID(sb) + sizeof(tag),
1585 le16_to_cpu(UDF_SB_LVID(sb)->descTag. 1381 le16_to_cpu(UDF_SB_LVID(sb)->descTag.descCRCLength), 0));
1586 descCRCLength), 0));
1587 1382
1588 UDF_SB_LVID(sb)->descTag.tagChecksum = 0; 1383 UDF_SB_LVID(sb)->descTag.tagChecksum = 0;
1589 for (i = 0; i < 16; i++) 1384 for (i = 0; i < 16; i++)
1590 if (i != 4) 1385 if (i != 4)
1591 UDF_SB_LVID(sb)->descTag.tagChecksum += 1386 UDF_SB_LVID(sb)->descTag.tagChecksum +=
1592 ((uint8_t *) & 1387 ((uint8_t *)&(UDF_SB_LVID(sb)->descTag))[i];
1593 (UDF_SB_LVID(sb)->descTag))[i];
1594 1388
1595 mark_buffer_dirty(UDF_SB_LVIDBH(sb)); 1389 mark_buffer_dirty(UDF_SB_LVIDBH(sb));
1596 } 1390 }
@@ -1628,6 +1422,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1628 sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL); 1422 sbi = kmalloc(sizeof(struct udf_sb_info), GFP_KERNEL);
1629 if (!sbi) 1423 if (!sbi)
1630 return -ENOMEM; 1424 return -ENOMEM;
1425
1631 sb->s_fs_info = sbi; 1426 sb->s_fs_info = sbi;
1632 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info)); 1427 memset(UDF_SB(sb), 0x00, sizeof(struct udf_sb_info));
1633 1428
@@ -1679,7 +1474,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1679 UDF_SB_ANCHOR(sb)[2] = uopt.anchor; 1474 UDF_SB_ANCHOR(sb)[2] = uopt.anchor;
1680 UDF_SB_ANCHOR(sb)[3] = 256; 1475 UDF_SB_ANCHOR(sb)[3] = 256;
1681 1476
1682 if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */ 1477 if (udf_check_valid(sb, uopt.novrs, silent)) { /* read volume recognition sequences */
1683 printk("UDF-fs: No VRS found\n"); 1478 printk("UDF-fs: No VRS found\n");
1684 goto error_out; 1479 goto error_out;
1685 } 1480 }
@@ -1701,10 +1496,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1701 udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb)); 1496 udf_debug("Lastblock=%d\n", UDF_SB_LASTBLOCK(sb));
1702 1497
1703 if (UDF_SB_LVIDBH(sb)) { 1498 if (UDF_SB_LVIDBH(sb)) {
1704 uint16_t minUDFReadRev = 1499 uint16_t minUDFReadRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev);
1705 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFReadRev); 1500 uint16_t minUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
1706 uint16_t minUDFWriteRev =
1707 le16_to_cpu(UDF_SB_LVIDIU(sb)->minUDFWriteRev);
1708 /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */ 1501 /* uint16_t maxUDFWriteRev = le16_to_cpu(UDF_SB_LVIDIU(sb)->maxUDFWriteRev); */
1709 1502
1710 if (minUDFReadRev > UDF_MAX_READ_VERSION) { 1503 if (minUDFReadRev > UDF_MAX_READ_VERSION) {
@@ -1729,10 +1522,8 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1729 goto error_out; 1522 goto error_out;
1730 } 1523 }
1731 1524
1732 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1525 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_READ_ONLY) {
1733 UDF_PART_FLAG_READ_ONLY) { 1526 printk("UDF-fs: Partition marked readonly; forcing readonly mount\n");
1734 printk
1735 ("UDF-fs: Partition marked readonly; forcing readonly mount\n");
1736 sb->s_flags |= MS_RDONLY; 1527 sb->s_flags |= MS_RDONLY;
1737 } 1528 }
1738 1529
@@ -1744,10 +1535,11 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1744 if (!silent) { 1535 if (!silent) {
1745 kernel_timestamp ts; 1536 kernel_timestamp ts;
1746 udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb)); 1537 udf_time_to_stamp(&ts, UDF_SB_RECORDTIME(sb));
1747 udf_info 1538 udf_info("UDF %s (%s) Mounting volume '%s', "
1748 ("UDF %s (%s) Mounting volume '%s', timestamp %04u/%02u/%02u %02u:%02u (%x)\n", 1539 "timestamp %04u/%02u/%02u %02u:%02u (%x)\n",
1749 UDFFS_VERSION, UDFFS_DATE, UDF_SB_VOLIDENT(sb), ts.year, 1540 UDFFS_VERSION, UDFFS_DATE,
1750 ts.month, ts.day, ts.hour, ts.minute, ts.typeAndTimezone); 1541 UDF_SB_VOLIDENT(sb), ts.year, ts.month, ts.day, ts.hour, ts.minute,
1542 ts.typeAndTimezone);
1751 } 1543 }
1752 if (!(sb->s_flags & MS_RDONLY)) 1544 if (!(sb->s_flags & MS_RDONLY))
1753 udf_open_lvid(sb); 1545 udf_open_lvid(sb);
@@ -1772,30 +1564,21 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1772 sb->s_maxbytes = MAX_LFS_FILESIZE; 1564 sb->s_maxbytes = MAX_LFS_FILESIZE;
1773 return 0; 1565 return 0;
1774 1566
1775 error_out: 1567error_out:
1776 if (UDF_SB_VAT(sb)) 1568 if (UDF_SB_VAT(sb))
1777 iput(UDF_SB_VAT(sb)); 1569 iput(UDF_SB_VAT(sb));
1778 if (UDF_SB_NUMPARTS(sb)) { 1570 if (UDF_SB_NUMPARTS(sb)) {
1779 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1571 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1780 UDF_PART_FLAG_UNALLOC_TABLE) 1572 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1781 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace. 1573 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1782 s_table); 1574 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1783 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1575 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1784 UDF_PART_FLAG_FREED_TABLE) 1576 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
1785 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace. 1577 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1786 s_table); 1578 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
1787 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1579 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
1788 UDF_PART_FLAG_UNALLOC_BITMAP)
1789 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
1790 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) &
1791 UDF_PART_FLAG_FREED_BITMAP)
1792 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
1793 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) ==
1794 UDF_SPARABLE_MAP15) {
1795 for (i = 0; i < 4; i++) 1580 for (i = 0; i < 4; i++)
1796 brelse(UDF_SB_TYPESPAR 1581 brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1797 (sb,
1798 UDF_SB_PARTITION(sb)).s_spar_map[i]);
1799 } 1582 }
1800 } 1583 }
1801#ifdef CONFIG_UDF_NLS 1584#ifdef CONFIG_UDF_NLS
@@ -1808,6 +1591,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
1808 UDF_SB_FREE(sb); 1591 UDF_SB_FREE(sb);
1809 kfree(sbi); 1592 kfree(sbi);
1810 sb->s_fs_info = NULL; 1593 sb->s_fs_info = NULL;
1594
1811 return -EINVAL; 1595 return -EINVAL;
1812} 1596}
1813 1597
@@ -1823,8 +1607,8 @@ void udf_error(struct super_block *sb, const char *function,
1823 va_start(args, fmt); 1607 va_start(args, fmt);
1824 vsnprintf(error_buf, sizeof(error_buf), fmt, args); 1608 vsnprintf(error_buf, sizeof(error_buf), fmt, args);
1825 va_end(args); 1609 va_end(args);
1826 printk(KERN_CRIT "UDF-fs error (device %s): %s: %s\n", 1610 printk (KERN_CRIT "UDF-fs error (device %s): %s: %s\n",
1827 sb->s_id, function, error_buf); 1611 sb->s_id, function, error_buf);
1828} 1612}
1829 1613
1830void udf_warning(struct super_block *sb, const char *function, 1614void udf_warning(struct super_block *sb, const char *function,
@@ -1859,26 +1643,17 @@ static void udf_put_super(struct super_block *sb)
1859 if (UDF_SB_VAT(sb)) 1643 if (UDF_SB_VAT(sb))
1860 iput(UDF_SB_VAT(sb)); 1644 iput(UDF_SB_VAT(sb));
1861 if (UDF_SB_NUMPARTS(sb)) { 1645 if (UDF_SB_NUMPARTS(sb)) {
1862 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1646 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE)
1863 UDF_PART_FLAG_UNALLOC_TABLE) 1647 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
1864 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace. 1648 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE)
1865 s_table); 1649 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
1866 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1650 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP)
1867 UDF_PART_FLAG_FREED_TABLE) 1651 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_uspace);
1868 iput(UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace. 1652 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP)
1869 s_table); 1653 UDF_SB_FREE_BITMAP(sb,UDF_SB_PARTITION(sb), s_fspace);
1870 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1654 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) == UDF_SPARABLE_MAP15) {
1871 UDF_PART_FLAG_UNALLOC_BITMAP)
1872 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_uspace);
1873 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) &
1874 UDF_PART_FLAG_FREED_BITMAP)
1875 UDF_SB_FREE_BITMAP(sb, UDF_SB_PARTITION(sb), s_fspace);
1876 if (UDF_SB_PARTTYPE(sb, UDF_SB_PARTITION(sb)) ==
1877 UDF_SPARABLE_MAP15) {
1878 for (i = 0; i < 4; i++) 1655 for (i = 0; i < 4; i++)
1879 brelse(UDF_SB_TYPESPAR 1656 brelse(UDF_SB_TYPESPAR(sb, UDF_SB_PARTITION(sb)).s_spar_map[i]);
1880 (sb,
1881 UDF_SB_PARTITION(sb)).s_spar_map[i]);
1882 } 1657 }
1883 } 1658 }
1884#ifdef CONFIG_UDF_NLS 1659#ifdef CONFIG_UDF_NLS
@@ -1917,8 +1692,7 @@ static int udf_statfs(struct dentry *dentry, struct kstatfs *buf)
1917 buf->f_bavail = buf->f_bfree; 1692 buf->f_bavail = buf->f_bfree;
1918 buf->f_files = (UDF_SB_LVIDBH(sb) ? 1693 buf->f_files = (UDF_SB_LVIDBH(sb) ?
1919 (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) + 1694 (le32_to_cpu(UDF_SB_LVIDIU(sb)->numFiles) +
1920 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + 1695 le32_to_cpu(UDF_SB_LVIDIU(sb)->numDirs)) : 0) + buf->f_bfree;
1921 buf->f_bfree;
1922 buf->f_ffree = buf->f_bfree; 1696 buf->f_ffree = buf->f_bfree;
1923 /* __kernel_fsid_t f_fsid */ 1697 /* __kernel_fsid_t f_fsid */
1924 buf->f_namelen = UDF_NAME_LEN - 2; 1698 buf->f_namelen = UDF_NAME_LEN - 2;
@@ -1930,8 +1704,7 @@ static unsigned char udf_bitmap_lookup[16] = {
1930 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 1704 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
1931}; 1705};
1932 1706
1933static unsigned int 1707static unsigned int udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1934udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1935{ 1708{
1936 struct buffer_head *bh = NULL; 1709 struct buffer_head *bh = NULL;
1937 unsigned int accum = 0; 1710 unsigned int accum = 0;
@@ -1961,8 +1734,8 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1961 1734
1962 bm = (struct spaceBitmapDesc *)bh->b_data; 1735 bm = (struct spaceBitmapDesc *)bh->b_data;
1963 bytes = le32_to_cpu(bm->numOfBytes); 1736 bytes = le32_to_cpu(bm->numOfBytes);
1964 index = sizeof(struct spaceBitmapDesc); /* offset in first block only */ 1737 index = sizeof(struct spaceBitmapDesc); /* offset in first block only */
1965 ptr = (uint8_t *) bh->b_data; 1738 ptr = (uint8_t *)bh->b_data;
1966 1739
1967 while (bytes > 0) { 1740 while (bytes > 0) {
1968 while ((bytes > 0) && (index < sb->s_blocksize)) { 1741 while ((bytes > 0) && (index < sb->s_blocksize)) {
@@ -1981,19 +1754,18 @@ udf_count_free_bitmap(struct super_block *sb, struct udf_bitmap *bitmap)
1981 goto out; 1754 goto out;
1982 } 1755 }
1983 index = 0; 1756 index = 0;
1984 ptr = (uint8_t *) bh->b_data; 1757 ptr = (uint8_t *)bh->b_data;
1985 } 1758 }
1986 } 1759 }
1987 brelse(bh); 1760 brelse(bh);
1988 1761
1989 out: 1762out:
1990 unlock_kernel(); 1763 unlock_kernel();
1991 1764
1992 return accum; 1765 return accum;
1993} 1766}
1994 1767
1995static unsigned int 1768static unsigned int udf_count_free_table(struct super_block *sb, struct inode *table)
1996udf_count_free_table(struct super_block *sb, struct inode *table)
1997{ 1769{
1998 unsigned int accum = 0; 1770 unsigned int accum = 0;
1999 uint32_t elen; 1771 uint32_t elen;
@@ -2007,8 +1779,9 @@ udf_count_free_table(struct super_block *sb, struct inode *table)
2007 epos.offset = sizeof(struct unallocSpaceEntry); 1779 epos.offset = sizeof(struct unallocSpaceEntry);
2008 epos.bh = NULL; 1780 epos.bh = NULL;
2009 1781
2010 while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) 1782 while ((etype = udf_next_aext(table, &epos, &eloc, &elen, 1)) != -1) {
2011 accum += (elen >> table->i_sb->s_blocksize_bits); 1783 accum += (elen >> table->i_sb->s_blocksize_bits);
1784 }
2012 brelse(epos.bh); 1785 brelse(epos.bh);
2013 1786
2014 unlock_kernel(); 1787 unlock_kernel();
@@ -2021,12 +1794,8 @@ static unsigned int udf_count_free(struct super_block *sb)
2021 unsigned int accum = 0; 1794 unsigned int accum = 0;
2022 1795
2023 if (UDF_SB_LVIDBH(sb)) { 1796 if (UDF_SB_LVIDBH(sb)) {
2024 if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > 1797 if (le32_to_cpu(UDF_SB_LVID(sb)->numOfPartitions) > UDF_SB_PARTITION(sb)) {
2025 UDF_SB_PARTITION(sb)) { 1798 accum = le32_to_cpu(UDF_SB_LVID(sb)->freeSpaceTable[UDF_SB_PARTITION(sb)]);
2026 accum =
2027 le32_to_cpu(UDF_SB_LVID(sb)->
2028 freeSpaceTable[UDF_SB_PARTITION(sb)]);
2029
2030 if (accum == 0xFFFFFFFF) 1799 if (accum == 0xFFFFFFFF)
2031 accum = 0; 1800 accum = 0;
2032 } 1801 }
@@ -2035,40 +1804,24 @@ static unsigned int udf_count_free(struct super_block *sb)
2035 if (accum) 1804 if (accum)
2036 return accum; 1805 return accum;
2037 1806
2038 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1807 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_BITMAP) {
2039 UDF_PART_FLAG_UNALLOC_BITMAP) { 1808 accum += udf_count_free_bitmap(sb,
2040 accum += 1809 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_bitmap);
2041 udf_count_free_bitmap(sb,
2042 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2043 (sb)].s_uspace.
2044 s_bitmap);
2045 } 1810 }
2046 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1811 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_BITMAP) {
2047 UDF_PART_FLAG_FREED_BITMAP) { 1812 accum += udf_count_free_bitmap(sb,
2048 accum += 1813 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_bitmap);
2049 udf_count_free_bitmap(sb,
2050 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2051 (sb)].s_fspace.
2052 s_bitmap);
2053 } 1814 }
2054 if (accum) 1815 if (accum)
2055 return accum; 1816 return accum;
2056 1817
2057 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1818 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_UNALLOC_TABLE) {
2058 UDF_PART_FLAG_UNALLOC_TABLE) { 1819 accum += udf_count_free_table(sb,
2059 accum += 1820 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_uspace.s_table);
2060 udf_count_free_table(sb,
2061 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2062 (sb)].s_uspace.
2063 s_table);
2064 } 1821 }
2065 if (UDF_SB_PARTFLAGS(sb, UDF_SB_PARTITION(sb)) & 1822 if (UDF_SB_PARTFLAGS(sb,UDF_SB_PARTITION(sb)) & UDF_PART_FLAG_FREED_TABLE) {
2066 UDF_PART_FLAG_FREED_TABLE) { 1823 accum += udf_count_free_table(sb,
2067 accum += 1824 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION(sb)].s_fspace.s_table);
2068 udf_count_free_table(sb,
2069 UDF_SB_PARTMAPS(sb)[UDF_SB_PARTITION
2070 (sb)].s_fspace.
2071 s_table);
2072 } 1825 }
2073 1826
2074 return accum; 1827 return accum;
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index c4b82a920082..e6f933dd6a7b 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -11,7 +11,7 @@
11 * Each contributing author retains all rights to their own work. 11 * Each contributing author retains all rights to their own work.
12 * 12 *
13 * (C) 1998-2001 Ben Fennema 13 * (C) 1998-2001 Ben Fennema
14 * (C) 1999 Stelias Computing Inc 14 * (C) 1999 Stelias Computing Inc
15 * 15 *
16 * HISTORY 16 * HISTORY
17 * 17 *
@@ -33,8 +33,7 @@
33#include <linux/buffer_head.h> 33#include <linux/buffer_head.h>
34#include "udf_i.h" 34#include "udf_i.h"
35 35
36static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, 36static void udf_pc_to_char(struct super_block *sb, char *from, int fromlen, char *to)
37 char *to)
38{ 37{
39 struct pathComponent *pc; 38 struct pathComponent *pc;
40 int elen = 0; 39 int elen = 0;
@@ -81,9 +80,9 @@ static int udf_symlink_filler(struct file *file, struct page *page)
81 char *p = kmap(page); 80 char *p = kmap(page);
82 81
83 lock_kernel(); 82 lock_kernel();
84 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) 83 if (UDF_I_ALLOCTYPE(inode) == ICBTAG_FLAG_AD_IN_ICB) {
85 symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode); 84 symlink = UDF_I_DATA(inode) + UDF_I_LENEATTR(inode);
86 else { 85 } else {
87 bh = sb_bread(inode->i_sb, udf_block_map(inode, 0)); 86 bh = sb_bread(inode->i_sb, udf_block_map(inode, 0));
88 87
89 if (!bh) 88 if (!bh)
@@ -100,7 +99,8 @@ static int udf_symlink_filler(struct file *file, struct page *page)
100 kunmap(page); 99 kunmap(page);
101 unlock_page(page); 100 unlock_page(page);
102 return 0; 101 return 0;
103 out: 102
103out:
104 unlock_kernel(); 104 unlock_kernel();
105 SetPageError(page); 105 SetPageError(page);
106 kunmap(page); 106 kunmap(page);
@@ -112,5 +112,5 @@ static int udf_symlink_filler(struct file *file, struct page *page)
112 * symlinks can't do much... 112 * symlinks can't do much...
113 */ 113 */
114const struct address_space_operations udf_symlink_aops = { 114const struct address_space_operations udf_symlink_aops = {
115 .readpage = udf_symlink_filler, 115 .readpage = udf_symlink_filler,
116}; 116};
diff --git a/fs/udf/truncate.c b/fs/udf/truncate.c
index b2002da0a5c0..7fc3912885a5 100644
--- a/fs/udf/truncate.c
+++ b/fs/udf/truncate.c
@@ -32,13 +32,11 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
32 kernel_lb_addr eloc, int8_t etype, uint32_t elen, 32 kernel_lb_addr eloc, int8_t etype, uint32_t elen,
33 uint32_t nelen) 33 uint32_t nelen)
34{ 34{
35 kernel_lb_addr neloc = { 0, 0 }; 35 kernel_lb_addr neloc = {};
36 int last_block = 36 int last_block = (elen + inode->i_sb->s_blocksize - 1) >>
37 (elen + inode->i_sb->s_blocksize - 37 inode->i_sb->s_blocksize_bits;
38 1) >> inode->i_sb->s_blocksize_bits; 38 int first_block = (nelen + inode->i_sb->s_blocksize - 1) >>
39 int first_block = 39 inode->i_sb->s_blocksize_bits;
40 (nelen + inode->i_sb->s_blocksize -
41 1) >> inode->i_sb->s_blocksize_bits;
42 40
43 if (nelen) { 41 if (nelen) {
44 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) { 42 if (etype == (EXT_NOT_RECORDED_ALLOCATED >> 30)) {
@@ -70,7 +68,7 @@ static void extent_trunc(struct inode *inode, struct extent_position *epos,
70 */ 68 */
71void udf_truncate_tail_extent(struct inode *inode) 69void udf_truncate_tail_extent(struct inode *inode)
72{ 70{
73 struct extent_position epos = { NULL, 0, {0, 0} }; 71 struct extent_position epos = {};
74 kernel_lb_addr eloc; 72 kernel_lb_addr eloc;
75 uint32_t elen, nelen; 73 uint32_t elen, nelen;
76 uint64_t lbcount = 0; 74 uint64_t lbcount = 0;
@@ -156,16 +154,16 @@ void udf_discard_prealloc(struct inode *inode)
156 extent_trunc(inode, &epos, eloc, etype, elen, 0); 154 extent_trunc(inode, &epos, eloc, etype, elen, 0);
157 if (!epos.bh) { 155 if (!epos.bh) {
158 UDF_I_LENALLOC(inode) = 156 UDF_I_LENALLOC(inode) =
159 epos.offset - udf_file_entry_alloc_offset(inode); 157 epos.offset - udf_file_entry_alloc_offset(inode);
160 mark_inode_dirty(inode); 158 mark_inode_dirty(inode);
161 } else { 159 } else {
162 struct allocExtDesc *aed = 160 struct allocExtDesc *aed =
163 (struct allocExtDesc *)(epos.bh->b_data); 161 (struct allocExtDesc *)(epos.bh->b_data);
164 aed->lengthAllocDescs = 162 aed->lengthAllocDescs =
165 cpu_to_le32(epos.offset - 163 cpu_to_le32(epos.offset -
166 sizeof(struct allocExtDesc)); 164 sizeof(struct allocExtDesc));
167 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) 165 if (!UDF_QUERY_FLAG(inode->i_sb, UDF_FLAG_STRICT) ||
168 || UDF_SB_UDFREV(inode->i_sb) >= 0x0201) 166 UDF_SB_UDFREV(inode->i_sb) >= 0x0201)
169 udf_update_tag(epos.bh->b_data, epos.offset); 167 udf_update_tag(epos.bh->b_data, epos.offset);
170 else 168 else
171 udf_update_tag(epos.bh->b_data, 169 udf_update_tag(epos.bh->b_data,
@@ -182,7 +180,7 @@ void udf_discard_prealloc(struct inode *inode)
182void udf_truncate_extents(struct inode *inode) 180void udf_truncate_extents(struct inode *inode)
183{ 181{
184 struct extent_position epos; 182 struct extent_position epos;
185 kernel_lb_addr eloc, neloc = { 0, 0 }; 183 kernel_lb_addr eloc, neloc = {};
186 uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc; 184 uint32_t elen, nelen = 0, indirect_ext_len = 0, lenalloc;
187 int8_t etype; 185 int8_t etype;
188 struct super_block *sb = inode->i_sb; 186 struct super_block *sb = inode->i_sb;
@@ -198,9 +196,8 @@ void udf_truncate_extents(struct inode *inode)
198 BUG(); 196 BUG();
199 197
200 etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset); 198 etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset);
201 byte_offset = 199 byte_offset = (offset << sb->s_blocksize_bits) +
202 (offset << sb->s_blocksize_bits) + 200 (inode->i_size & (sb->s_blocksize - 1));
203 (inode->i_size & (sb->s_blocksize - 1));
204 if (etype != -1) { 201 if (etype != -1) {
205 epos.offset -= adsize; 202 epos.offset -= adsize;
206 extent_trunc(inode, &epos, eloc, etype, elen, byte_offset); 203 extent_trunc(inode, &epos, eloc, etype, elen, byte_offset);
@@ -215,9 +212,7 @@ void udf_truncate_extents(struct inode *inode)
215 else 212 else
216 lenalloc -= sizeof(struct allocExtDesc); 213 lenalloc -= sizeof(struct allocExtDesc);
217 214
218 while ((etype = 215 while ((etype = udf_current_aext(inode, &epos, &eloc, &elen, 0)) != -1) {
219 udf_current_aext(inode, &epos, &eloc, &elen,
220 0)) != -1) {
221 if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) { 216 if (etype == (EXT_NEXT_EXTENT_ALLOCDECS >> 30)) {
222 udf_write_aext(inode, &epos, neloc, nelen, 0); 217 udf_write_aext(inode, &epos, neloc, nelen, 0);
223 if (indirect_ext_len) { 218 if (indirect_ext_len) {
@@ -229,52 +224,35 @@ void udf_truncate_extents(struct inode *inode)
229 0, indirect_ext_len); 224 0, indirect_ext_len);
230 } else { 225 } else {
231 if (!epos.bh) { 226 if (!epos.bh) {
232 UDF_I_LENALLOC(inode) = 227 UDF_I_LENALLOC(inode) = lenalloc;
233 lenalloc;
234 mark_inode_dirty(inode); 228 mark_inode_dirty(inode);
235 } else { 229 } else {
236 struct allocExtDesc *aed = 230 struct allocExtDesc *aed =
237 (struct allocExtDesc 231 (struct allocExtDesc *)(epos.bh->b_data);
238 *)(epos.bh->b_data);
239 aed->lengthAllocDescs = 232 aed->lengthAllocDescs =
240 cpu_to_le32(lenalloc); 233 cpu_to_le32(lenalloc);
241 if (!UDF_QUERY_FLAG 234 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
242 (sb, UDF_FLAG_STRICT) 235 UDF_SB_UDFREV(sb) >= 0x0201)
243 || UDF_SB_UDFREV(sb) >= 236 udf_update_tag(epos.bh->b_data,
244 0x0201) 237 lenalloc +
245 udf_update_tag(epos.bh-> 238 sizeof(struct allocExtDesc));
246 b_data,
247 lenalloc
248 +
249 sizeof
250 (struct
251 allocExtDesc));
252 else 239 else
253 udf_update_tag(epos.bh-> 240 udf_update_tag(epos.bh->b_data,
254 b_data, 241 sizeof(struct allocExtDesc));
255 sizeof 242 mark_buffer_dirty_inode(epos.bh, inode);
256 (struct
257 allocExtDesc));
258 mark_buffer_dirty_inode(epos.bh,
259 inode);
260 } 243 }
261 } 244 }
262 brelse(epos.bh); 245 brelse(epos.bh);
263 epos.offset = sizeof(struct allocExtDesc); 246 epos.offset = sizeof(struct allocExtDesc);
264 epos.block = eloc; 247 epos.block = eloc;
265 epos.bh = 248 epos.bh = udf_tread(sb, udf_get_lb_pblock(sb, eloc, 0));
266 udf_tread(sb,
267 udf_get_lb_pblock(sb, eloc, 0));
268 if (elen) 249 if (elen)
269 indirect_ext_len = (elen + 250 indirect_ext_len = (elen + sb->s_blocksize -1) >>
270 sb->s_blocksize - 251 sb->s_blocksize_bits;
271 1) >> sb->
272 s_blocksize_bits;
273 else 252 else
274 indirect_ext_len = 1; 253 indirect_ext_len = 1;
275 } else { 254 } else {
276 extent_trunc(inode, &epos, eloc, etype, elen, 255 extent_trunc(inode, &epos, eloc, etype, elen, 0);
277 0);
278 epos.offset += adsize; 256 epos.offset += adsize;
279 } 257 }
280 } 258 }
@@ -292,16 +270,13 @@ void udf_truncate_extents(struct inode *inode)
292 struct allocExtDesc *aed = 270 struct allocExtDesc *aed =
293 (struct allocExtDesc *)(epos.bh->b_data); 271 (struct allocExtDesc *)(epos.bh->b_data);
294 aed->lengthAllocDescs = cpu_to_le32(lenalloc); 272 aed->lengthAllocDescs = cpu_to_le32(lenalloc);
295 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) 273 if (!UDF_QUERY_FLAG(sb, UDF_FLAG_STRICT) ||
296 || UDF_SB_UDFREV(sb) >= 0x0201) 274 UDF_SB_UDFREV(sb) >= 0x0201)
297 udf_update_tag(epos.bh->b_data, 275 udf_update_tag(epos.bh->b_data,
298 lenalloc + 276 lenalloc + sizeof(struct allocExtDesc));
299 sizeof(struct
300 allocExtDesc));
301 else 277 else
302 udf_update_tag(epos.bh->b_data, 278 udf_update_tag(epos.bh->b_data,
303 sizeof(struct 279 sizeof(struct allocExtDesc));
304 allocExtDesc));
305 mark_buffer_dirty_inode(epos.bh, inode); 280 mark_buffer_dirty_inode(epos.bh, inode);
306 } 281 }
307 } 282 }
@@ -314,21 +289,14 @@ void udf_truncate_extents(struct inode *inode)
314 * no extent above inode->i_size => truncate is 289 * no extent above inode->i_size => truncate is
315 * extending the file by 'offset' blocks. 290 * extending the file by 'offset' blocks.
316 */ 291 */
317 if ((!epos.bh 292 if ((!epos.bh &&
318 && epos.offset == 293 epos.offset == udf_file_entry_alloc_offset(inode)) ||
319 udf_file_entry_alloc_offset(inode)) || (epos.bh 294 (epos.bh && epos.offset == sizeof(struct allocExtDesc))) {
320 && epos.
321 offset ==
322 sizeof
323 (struct
324 allocExtDesc)))
325 {
326 /* File has no extents at all or has empty last 295 /* File has no extents at all or has empty last
327 * indirect extent! Create a fake extent... */ 296 * indirect extent! Create a fake extent... */
328 extent.extLocation.logicalBlockNum = 0; 297 extent.extLocation.logicalBlockNum = 0;
329 extent.extLocation.partitionReferenceNum = 0; 298 extent.extLocation.partitionReferenceNum = 0;
330 extent.extLength = 299 extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED;
331 EXT_NOT_RECORDED_NOT_ALLOCATED;
332 } else { 300 } else {
333 epos.offset -= adsize; 301 epos.offset -= adsize;
334 etype = udf_next_aext(inode, &epos, 302 etype = udf_next_aext(inode, &epos,
@@ -337,10 +305,7 @@ void udf_truncate_extents(struct inode *inode)
337 extent.extLength |= etype << 30; 305 extent.extLength |= etype << 30;
338 } 306 }
339 udf_extend_file(inode, &epos, &extent, 307 udf_extend_file(inode, &epos, &extent,
340 offset + 308 offset + ((inode->i_size & (sb->s_blocksize - 1)) != 0));
341 ((inode->
342 i_size & (sb->s_blocksize - 1)) !=
343 0));
344 } 309 }
345 } 310 }
346 UDF_I_LENEXTENTS(inode) = inode->i_size; 311 UDF_I_LENEXTENTS(inode) = inode->i_size;
diff --git a/fs/udf/udf_i.h b/fs/udf/udf_i.h
index bee4308a8113..d7dbe6f3ba0c 100644
--- a/fs/udf/udf_i.h
+++ b/fs/udf/udf_i.h
@@ -23,4 +23,4 @@ static inline struct udf_inode_info *UDF_I(struct inode *inode)
23#define UDF_I_LAD(X) ( UDF_I(X)->i_ext.i_lad ) 23#define UDF_I_LAD(X) ( UDF_I(X)->i_ext.i_lad )
24#define UDF_I_DATA(X) ( UDF_I(X)->i_ext.i_data ) 24#define UDF_I_DATA(X) ( UDF_I(X)->i_ext.i_data )
25 25
26#endif /* !defined(_LINUX_UDF_I_H) */ 26#endif /* !defined(_LINUX_UDF_I_H) */
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 60f31d8cebee..3e937d3fb8f9 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -20,8 +20,8 @@
20#define UDF_FLAG_VARCONV 8 20#define UDF_FLAG_VARCONV 8
21#define UDF_FLAG_NLS_MAP 9 21#define UDF_FLAG_NLS_MAP 9
22#define UDF_FLAG_UTF8 10 22#define UDF_FLAG_UTF8 10
23#define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */ 23#define UDF_FLAG_UID_FORGET 11 /* save -1 for uid to disk */
24#define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */ 24#define UDF_FLAG_UID_IGNORE 12 /* use sb uid instead of on disk uid */
25#define UDF_FLAG_GID_FORGET 13 25#define UDF_FLAG_GID_FORGET 13
26#define UDF_FLAG_GID_IGNORE 14 26#define UDF_FLAG_GID_IGNORE 14
27 27
@@ -41,8 +41,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
41 41
42#define UDF_SB_FREE(X)\ 42#define UDF_SB_FREE(X)\
43{\ 43{\
44 if (UDF_SB(X))\ 44 if (UDF_SB(X)) {\
45 {\
46 kfree(UDF_SB_PARTMAPS(X));\ 45 kfree(UDF_SB_PARTMAPS(X));\
47 UDF_SB_PARTMAPS(X) = NULL;\ 46 UDF_SB_PARTMAPS(X) = NULL;\
48 }\ 47 }\
@@ -51,13 +50,10 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
51#define UDF_SB_ALLOC_PARTMAPS(X,Y)\ 50#define UDF_SB_ALLOC_PARTMAPS(X,Y)\
52{\ 51{\
53 UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\ 52 UDF_SB_PARTMAPS(X) = kmalloc(sizeof(struct udf_part_map) * Y, GFP_KERNEL);\
54 if (UDF_SB_PARTMAPS(X) != NULL)\ 53 if (UDF_SB_PARTMAPS(X) != NULL) {\
55 {\
56 UDF_SB_NUMPARTS(X) = Y;\ 54 UDF_SB_NUMPARTS(X) = Y;\
57 memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\ 55 memset(UDF_SB_PARTMAPS(X), 0x00, sizeof(struct udf_part_map) * Y);\
58 }\ 56 } else {\
59 else\
60 {\
61 UDF_SB_NUMPARTS(X) = 0;\ 57 UDF_SB_NUMPARTS(X) = 0;\
62 udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\ 58 udf_error(X, __FUNCTION__, "Unable to allocate space for %d partition maps", Y);\
63 }\ 59 }\
@@ -72,15 +68,12 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
72 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\ 68 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = kmalloc(size, GFP_KERNEL);\
73 else\ 69 else\
74 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\ 70 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap = vmalloc(size);\
75 if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL)\ 71 if (UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap != NULL) {\
76 {\
77 memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\ 72 memset(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap, 0x00, size);\
78 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\ 73 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_block_bitmap =\
79 (struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\ 74 (struct buffer_head **)(UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap + 1);\
80 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\ 75 UDF_SB_PARTMAPS(X)[(Y)].Z.s_bitmap->s_nr_groups = nr_groups;\
81 }\ 76 } else {\
82 else\
83 {\
84 udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\ 77 udf_error(X, __FUNCTION__, "Unable to allocate space for bitmap and %d buffer_head pointers", nr_groups);\
85 }\ 78 }\
86} 79}
@@ -90,8 +83,7 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
90 int i;\ 83 int i;\
91 int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\ 84 int nr_groups = UDF_SB_BITMAP_NR_GROUPS(X,Y,Z);\
92 int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\ 85 int size = sizeof(struct udf_bitmap) + (sizeof(struct buffer_head *) * nr_groups);\
93 for (i=0; i<nr_groups; i++)\ 86 for (i = 0; i < nr_groups; i++) {\
94 {\
95 if (UDF_SB_BITMAP(X,Y,Z,i))\ 87 if (UDF_SB_BITMAP(X,Y,Z,i))\
96 brelse(UDF_SB_BITMAP(X,Y,Z,i));\ 88 brelse(UDF_SB_BITMAP(X,Y,Z,i));\
97 }\ 89 }\
@@ -139,4 +131,4 @@ static inline struct udf_sb_info *UDF_SB(struct super_block *sb)
139#define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags ) 131#define UDF_SB_FLAGS(X) ( UDF_SB(X)->s_flags )
140#define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat ) 132#define UDF_SB_VAT(X) ( UDF_SB(X)->s_vat )
141 133
142#endif /* __LINUX_UDF_SB_H */ 134#endif /* __LINUX_UDF_SB_H */
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h
index 76f2b82a39dc..c8016cc9e7e6 100644
--- a/fs/udf/udfdecl.h
+++ b/fs/udf/udfdecl.h
@@ -63,8 +63,8 @@ struct udf_vds_record {
63}; 63};
64 64
65struct generic_desc { 65struct generic_desc {
66 tag descTag; 66 tag descTag;
67 __le32 volDescSeqNum; 67 __le32 volDescSeqNum;
68}; 68};
69 69
70struct ustr { 70struct ustr {
diff --git a/fs/udf/udfend.h b/fs/udf/udfend.h
index 450daab35a13..c4bd1203f857 100644
--- a/fs/udf/udfend.h
+++ b/fs/udf/udfend.h
@@ -7,75 +7,93 @@
7static inline kernel_lb_addr lelb_to_cpu(lb_addr in) 7static inline kernel_lb_addr lelb_to_cpu(lb_addr in)
8{ 8{
9 kernel_lb_addr out; 9 kernel_lb_addr out;
10
10 out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum); 11 out.logicalBlockNum = le32_to_cpu(in.logicalBlockNum);
11 out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum); 12 out.partitionReferenceNum = le16_to_cpu(in.partitionReferenceNum);
13
12 return out; 14 return out;
13} 15}
14 16
15static inline lb_addr cpu_to_lelb(kernel_lb_addr in) 17static inline lb_addr cpu_to_lelb(kernel_lb_addr in)
16{ 18{
17 lb_addr out; 19 lb_addr out;
20
18 out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum); 21 out.logicalBlockNum = cpu_to_le32(in.logicalBlockNum);
19 out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum); 22 out.partitionReferenceNum = cpu_to_le16(in.partitionReferenceNum);
23
20 return out; 24 return out;
21} 25}
22 26
23static inline kernel_timestamp lets_to_cpu(timestamp in) 27static inline kernel_timestamp lets_to_cpu(timestamp in)
24{ 28{
25 kernel_timestamp out; 29 kernel_timestamp out;
30
26 memcpy(&out, &in, sizeof(timestamp)); 31 memcpy(&out, &in, sizeof(timestamp));
27 out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone); 32 out.typeAndTimezone = le16_to_cpu(in.typeAndTimezone);
28 out.year = le16_to_cpu(in.year); 33 out.year = le16_to_cpu(in.year);
34
29 return out; 35 return out;
30} 36}
31 37
32static inline short_ad lesa_to_cpu(short_ad in) 38static inline short_ad lesa_to_cpu(short_ad in)
33{ 39{
34 short_ad out; 40 short_ad out;
41
35 out.extLength = le32_to_cpu(in.extLength); 42 out.extLength = le32_to_cpu(in.extLength);
36 out.extPosition = le32_to_cpu(in.extPosition); 43 out.extPosition = le32_to_cpu(in.extPosition);
44
37 return out; 45 return out;
38} 46}
39 47
40static inline short_ad cpu_to_lesa(short_ad in) 48static inline short_ad cpu_to_lesa(short_ad in)
41{ 49{
42 short_ad out; 50 short_ad out;
51
43 out.extLength = cpu_to_le32(in.extLength); 52 out.extLength = cpu_to_le32(in.extLength);
44 out.extPosition = cpu_to_le32(in.extPosition); 53 out.extPosition = cpu_to_le32(in.extPosition);
54
45 return out; 55 return out;
46} 56}
47 57
48static inline kernel_long_ad lela_to_cpu(long_ad in) 58static inline kernel_long_ad lela_to_cpu(long_ad in)
49{ 59{
50 kernel_long_ad out; 60 kernel_long_ad out;
61
51 out.extLength = le32_to_cpu(in.extLength); 62 out.extLength = le32_to_cpu(in.extLength);
52 out.extLocation = lelb_to_cpu(in.extLocation); 63 out.extLocation = lelb_to_cpu(in.extLocation);
64
53 return out; 65 return out;
54} 66}
55 67
56static inline long_ad cpu_to_lela(kernel_long_ad in) 68static inline long_ad cpu_to_lela(kernel_long_ad in)
57{ 69{
58 long_ad out; 70 long_ad out;
71
59 out.extLength = cpu_to_le32(in.extLength); 72 out.extLength = cpu_to_le32(in.extLength);
60 out.extLocation = cpu_to_lelb(in.extLocation); 73 out.extLocation = cpu_to_lelb(in.extLocation);
74
61 return out; 75 return out;
62} 76}
63 77
64static inline kernel_extent_ad leea_to_cpu(extent_ad in) 78static inline kernel_extent_ad leea_to_cpu(extent_ad in)
65{ 79{
66 kernel_extent_ad out; 80 kernel_extent_ad out;
81
67 out.extLength = le32_to_cpu(in.extLength); 82 out.extLength = le32_to_cpu(in.extLength);
68 out.extLocation = le32_to_cpu(in.extLocation); 83 out.extLocation = le32_to_cpu(in.extLocation);
84
69 return out; 85 return out;
70} 86}
71 87
72static inline timestamp cpu_to_lets(kernel_timestamp in) 88static inline timestamp cpu_to_lets(kernel_timestamp in)
73{ 89{
74 timestamp out; 90 timestamp out;
91
75 memcpy(&out, &in, sizeof(timestamp)); 92 memcpy(&out, &in, sizeof(timestamp));
76 out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone); 93 out.typeAndTimezone = cpu_to_le16(in.typeAndTimezone);
77 out.year = cpu_to_le16(in.year); 94 out.year = cpu_to_le16(in.year);
95
78 return out; 96 return out;
79} 97}
80 98
81#endif /* __UDF_ENDIAN_H */ 99#endif /* __UDF_ENDIAN_H */
diff --git a/fs/udf/udftime.c b/fs/udf/udftime.c
index b9f3198080e9..3fd80eb66af3 100644
--- a/fs/udf/udftime.c
+++ b/fs/udf/udftime.c
@@ -18,18 +18,18 @@
18 Boston, MA 02111-1307, USA. */ 18 Boston, MA 02111-1307, USA. */
19 19
20/* 20/*
21 * dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time 21 * dgb 10/02/98: ripped this from glibc source to help convert timestamps to unix time
22 * 10/04/98: added new table-based lookup after seeing how ugly the gnu code is 22 * 10/04/98: added new table-based lookup after seeing how ugly the gnu code is
23 * blf 09/27/99: ripped out all the old code and inserted new table from 23 * blf 09/27/99: ripped out all the old code and inserted new table from
24 * John Brockmeyer (without leap second corrections) 24 * John Brockmeyer (without leap second corrections)
25 * rewrote udf_stamp_to_time and fixed timezone accounting in 25 * rewrote udf_stamp_to_time and fixed timezone accounting in
26 udf_time_to_stamp. 26 * udf_time_to_stamp.
27 */ 27 */
28 28
29/* 29/*
30 * We don't take into account leap seconds. This may be correct or incorrect. 30 * We don't take into account leap seconds. This may be correct or incorrect.
31 * For more NIST information (especially dealing with leap seconds), see: 31 * For more NIST information (especially dealing with leap seconds), see:
32 * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm 32 * http://www.boulder.nist.gov/timefreq/pubs/bulletin/leapsecond.htm
33 */ 33 */
34 34
35#include <linux/types.h> 35#include <linux/types.h>
@@ -54,28 +54,28 @@ static const unsigned short int __mon_yday[2][13] = {
54}; 54};
55 55
56#define MAX_YEAR_SECONDS 69 56#define MAX_YEAR_SECONDS 69
57#define SPD 0x15180 /*3600*24 */ 57#define SPD 0x15180 /*3600*24 */
58#define SPY(y,l,s) (SPD * (365*y+l)+s) 58#define SPY(y,l,s) (SPD * (365*y+l)+s)
59 59
60static time_t year_seconds[MAX_YEAR_SECONDS] = { 60static time_t year_seconds[MAX_YEAR_SECONDS]= {
61/*1970*/ SPY(0, 0, 0), SPY(1, 0, 0), SPY(2, 0, 0), SPY(3, 1, 0), 61/*1970*/ SPY( 0, 0,0), SPY( 1, 0,0), SPY( 2, 0,0), SPY( 3, 1,0),
62/*1974*/ SPY(4, 1, 0), SPY(5, 1, 0), SPY(6, 1, 0), SPY(7, 2, 0), 62/*1974*/ SPY( 4, 1,0), SPY( 5, 1,0), SPY( 6, 1,0), SPY( 7, 2,0),
63/*1978*/ SPY(8, 2, 0), SPY(9, 2, 0), SPY(10, 2, 0), SPY(11, 3, 0), 63/*1978*/ SPY( 8, 2,0), SPY( 9, 2,0), SPY(10, 2,0), SPY(11, 3,0),
64/*1982*/ SPY(12, 3, 0), SPY(13, 3, 0), SPY(14, 3, 0), SPY(15, 4, 0), 64/*1982*/ SPY(12, 3,0), SPY(13, 3,0), SPY(14, 3,0), SPY(15, 4,0),
65/*1986*/ SPY(16, 4, 0), SPY(17, 4, 0), SPY(18, 4, 0), SPY(19, 5, 0), 65/*1986*/ SPY(16, 4,0), SPY(17, 4,0), SPY(18, 4,0), SPY(19, 5,0),
66/*1990*/ SPY(20, 5, 0), SPY(21, 5, 0), SPY(22, 5, 0), SPY(23, 6, 0), 66/*1990*/ SPY(20, 5,0), SPY(21, 5,0), SPY(22, 5,0), SPY(23, 6,0),
67/*1994*/ SPY(24, 6, 0), SPY(25, 6, 0), SPY(26, 6, 0), SPY(27, 7, 0), 67/*1994*/ SPY(24, 6,0), SPY(25, 6,0), SPY(26, 6,0), SPY(27, 7,0),
68/*1998*/ SPY(28, 7, 0), SPY(29, 7, 0), SPY(30, 7, 0), SPY(31, 8, 0), 68/*1998*/ SPY(28, 7,0), SPY(29, 7,0), SPY(30, 7,0), SPY(31, 8,0),
69/*2002*/ SPY(32, 8, 0), SPY(33, 8, 0), SPY(34, 8, 0), SPY(35, 9, 0), 69/*2002*/ SPY(32, 8,0), SPY(33, 8,0), SPY(34, 8,0), SPY(35, 9,0),
70/*2006*/ SPY(36, 9, 0), SPY(37, 9, 0), SPY(38, 9, 0), SPY(39, 10, 0), 70/*2006*/ SPY(36, 9,0), SPY(37, 9,0), SPY(38, 9,0), SPY(39,10,0),
71/*2010*/ SPY(40, 10, 0), SPY(41, 10, 0), SPY(42, 10, 0), SPY(43, 11, 0), 71/*2010*/ SPY(40,10,0), SPY(41,10,0), SPY(42,10,0), SPY(43,11,0),
72/*2014*/ SPY(44, 11, 0), SPY(45, 11, 0), SPY(46, 11, 0), SPY(47, 12, 0), 72/*2014*/ SPY(44,11,0), SPY(45,11,0), SPY(46,11,0), SPY(47,12,0),
73/*2018*/ SPY(48, 12, 0), SPY(49, 12, 0), SPY(50, 12, 0), SPY(51, 13, 0), 73/*2018*/ SPY(48,12,0), SPY(49,12,0), SPY(50,12,0), SPY(51,13,0),
74/*2022*/ SPY(52, 13, 0), SPY(53, 13, 0), SPY(54, 13, 0), SPY(55, 14, 0), 74/*2022*/ SPY(52,13,0), SPY(53,13,0), SPY(54,13,0), SPY(55,14,0),
75/*2026*/ SPY(56, 14, 0), SPY(57, 14, 0), SPY(58, 14, 0), SPY(59, 15, 0), 75/*2026*/ SPY(56,14,0), SPY(57,14,0), SPY(58,14,0), SPY(59,15,0),
76/*2030*/ SPY(60, 15, 0), SPY(61, 15, 0), SPY(62, 15, 0), SPY(63, 16, 0), 76/*2030*/ SPY(60,15,0), SPY(61,15,0), SPY(62,15,0), SPY(63,16,0),
77/*2034*/ SPY(64, 16, 0), SPY(65, 16, 0), SPY(66, 16, 0), SPY(67, 17, 0), 77/*2034*/ SPY(64,16,0), SPY(65,16,0), SPY(66,16,0), SPY(67,17,0),
78/*2038*/ SPY(68, 17, 0) 78/*2038*/ SPY(68,17,0)
79}; 79};
80 80
81extern struct timezone sys_tz; 81extern struct timezone sys_tz;
@@ -83,7 +83,7 @@ extern struct timezone sys_tz;
83#define SECS_PER_HOUR (60 * 60) 83#define SECS_PER_HOUR (60 * 60)
84#define SECS_PER_DAY (SECS_PER_HOUR * 24) 84#define SECS_PER_DAY (SECS_PER_HOUR * 24)
85 85
86time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src) 86time_t *udf_stamp_to_time(time_t *dest, long *dest_usec, kernel_timestamp src)
87{ 87{
88 int yday; 88 int yday;
89 uint8_t type = src.typeAndTimezone >> 12; 89 uint8_t type = src.typeAndTimezone >> 12;
@@ -93,10 +93,11 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
93 offset = src.typeAndTimezone << 4; 93 offset = src.typeAndTimezone << 4;
94 /* sign extent offset */ 94 /* sign extent offset */
95 offset = (offset >> 4); 95 offset = (offset >> 4);
96 if (offset == -2047) /* unspecified offset */ 96 if (offset == -2047) /* unspecified offset */
97 offset = 0; 97 offset = 0;
98 } else 98 } else {
99 offset = 0; 99 offset = 0;
100 }
100 101
101 if ((src.year < EPOCH_YEAR) || 102 if ((src.year < EPOCH_YEAR) ||
102 (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) { 103 (src.year >= EPOCH_YEAR + MAX_YEAR_SECONDS)) {
@@ -107,12 +108,10 @@ time_t *udf_stamp_to_time(time_t * dest, long *dest_usec, kernel_timestamp src)
107 *dest = year_seconds[src.year - EPOCH_YEAR]; 108 *dest = year_seconds[src.year - EPOCH_YEAR];
108 *dest -= offset * 60; 109 *dest -= offset * 60;
109 110
110 yday = ((__mon_yday[__isleap(src.year)] 111 yday = ((__mon_yday[__isleap (src.year)]
111 [src.month - 1]) + (src.day - 1)); 112 [src.month - 1]) + (src.day - 1));
112 *dest += (((yday * 24) + src.hour) * 60 + src.minute) * 60 + src.second; 113 *dest += ( ( (yday * 24) + src.hour ) * 60 + src.minute ) * 60 + src.second;
113 *dest_usec = 114 *dest_usec = src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 + src.microseconds;
114 src.centiseconds * 10000 + src.hundredsOfMicroseconds * 100 +
115 src.microseconds;
116 return dest; 115 return dest;
117} 116}
118 117
@@ -145,8 +144,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
145 long int yg = y + days / 365 - (days % 365 < 0); 144 long int yg = y + days / 365 - (days % 365 < 0);
146 145
147 /* Adjust DAYS and Y to match the guessed year. */ 146 /* Adjust DAYS and Y to match the guessed year. */
148 days -= ((yg - y) * 365 + LEAPS_THRU_END_OF(yg - 1) 147 days -= ((yg - y) * 365
149 - LEAPS_THRU_END_OF(y - 1)); 148 + LEAPS_THRU_END_OF (yg - 1)
149 - LEAPS_THRU_END_OF (y - 1));
150 y = yg; 150 y = yg;
151 } 151 }
152 dest->year = y; 152 dest->year = y;
@@ -158,11 +158,9 @@ kernel_timestamp *udf_time_to_stamp(kernel_timestamp * dest, struct timespec ts)
158 dest->day = days + 1; 158 dest->day = days + 1;
159 159
160 dest->centiseconds = ts.tv_nsec / 10000000; 160 dest->centiseconds = ts.tv_nsec / 10000000;
161 dest->hundredsOfMicroseconds = 161 dest->hundredsOfMicroseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100;
162 (ts.tv_nsec / 1000 - dest->centiseconds * 10000) / 100; 162 dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
163 dest->microseconds = 163 dest->hundredsOfMicroseconds * 100);
164 (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
165 dest->hundredsOfMicroseconds * 100);
166 return dest; 164 return dest;
167} 165}
168 166
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 46835240275c..9e6099c26c27 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -29,21 +29,23 @@
29 29
30static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int); 30static int udf_translate_to_linux(uint8_t *, uint8_t *, int, uint8_t *, int);
31 31
32static int udf_char_to_ustr(struct ustr *dest, const uint8_t * src, int strlen) 32static int udf_char_to_ustr(struct ustr *dest, const uint8_t *src, int strlen)
33{ 33{
34 if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2)) 34 if ((!dest) || (!src) || (!strlen) || (strlen > UDF_NAME_LEN - 2))
35 return 0; 35 return 0;
36
36 memset(dest, 0, sizeof(struct ustr)); 37 memset(dest, 0, sizeof(struct ustr));
37 memcpy(dest->u_name, src, strlen); 38 memcpy(dest->u_name, src, strlen);
38 dest->u_cmpID = 0x08; 39 dest->u_cmpID = 0x08;
39 dest->u_len = strlen; 40 dest->u_len = strlen;
41
40 return strlen; 42 return strlen;
41} 43}
42 44
43/* 45/*
44 * udf_build_ustr 46 * udf_build_ustr
45 */ 47 */
46int udf_build_ustr(struct ustr *dest, dstring * ptr, int size) 48int udf_build_ustr(struct ustr *dest, dstring *ptr, int size)
47{ 49{
48 int usesize; 50 int usesize;
49 51
@@ -55,13 +57,14 @@ int udf_build_ustr(struct ustr *dest, dstring * ptr, int size)
55 dest->u_cmpID = ptr[0]; 57 dest->u_cmpID = ptr[0];
56 dest->u_len = ptr[size - 1]; 58 dest->u_len = ptr[size - 1];
57 memcpy(dest->u_name, ptr + 1, usesize - 1); 59 memcpy(dest->u_name, ptr + 1, usesize - 1);
60
58 return 0; 61 return 0;
59} 62}
60 63
61/* 64/*
62 * udf_build_ustr_exact 65 * udf_build_ustr_exact
63 */ 66 */
64static int udf_build_ustr_exact(struct ustr *dest, dstring * ptr, int exactsize) 67static int udf_build_ustr_exact(struct ustr *dest, dstring *ptr, int exactsize)
65{ 68{
66 if ((!dest) || (!ptr) || (!exactsize)) 69 if ((!dest) || (!ptr) || (!exactsize))
67 return -1; 70 return -1;
@@ -70,6 +73,7 @@ static int udf_build_ustr_exact(struct ustr *dest, dstring * ptr, int exactsize)
70 dest->u_cmpID = ptr[0]; 73 dest->u_cmpID = ptr[0];
71 dest->u_len = exactsize - 1; 74 dest->u_len = exactsize - 1;
72 memcpy(dest->u_name, ptr + 1, exactsize - 1); 75 memcpy(dest->u_name, ptr + 1, exactsize - 1);
76
73 return 0; 77 return 0;
74} 78}
75 79
@@ -129,20 +133,15 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
129 c = (c << 8) | ocu[i++]; 133 c = (c << 8) | ocu[i++];
130 134
131 /* Compress Unicode to UTF-8 */ 135 /* Compress Unicode to UTF-8 */
132 if (c < 0x80U) 136 if (c < 0x80U) {
133 utf_o->u_name[utf_o->u_len++] = (uint8_t) c; 137 utf_o->u_name[utf_o->u_len++] = (uint8_t)c;
134 else if (c < 0x800U) { 138 } else if (c < 0x800U) {
135 utf_o->u_name[utf_o->u_len++] = 139 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xc0 | (c >> 6));
136 (uint8_t) (0xc0 | (c >> 6)); 140 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f));
137 utf_o->u_name[utf_o->u_len++] =
138 (uint8_t) (0x80 | (c & 0x3f));
139 } else { 141 } else {
140 utf_o->u_name[utf_o->u_len++] = 142 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0xe0 | (c >> 12));
141 (uint8_t) (0xe0 | (c >> 12)); 143 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | ((c >> 6) & 0x3f));
142 utf_o->u_name[utf_o->u_len++] = 144 utf_o->u_name[utf_o->u_len++] = (uint8_t)(0x80 | (c & 0x3f));
143 (uint8_t) (0x80 | ((c >> 6) & 0x3f));
144 utf_o->u_name[utf_o->u_len++] =
145 (uint8_t) (0x80 | (c & 0x3f));
146 } 145 }
147 } 146 }
148 utf_o->u_cmpID = 8; 147 utf_o->u_cmpID = 8;
@@ -173,7 +172,7 @@ int udf_CS0toUTF8(struct ustr *utf_o, struct ustr *ocu_i)
173 * November 12, 1997 - Andrew E. Mileski 172 * November 12, 1997 - Andrew E. Mileski
174 * Written, tested, and released. 173 * Written, tested, and released.
175 */ 174 */
176static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length) 175static int udf_UTF8toCS0(dstring *ocu, struct ustr *utf, int length)
177{ 176{
178 unsigned c, i, max_val, utf_char; 177 unsigned c, i, max_val, utf_char;
179 int utf_cnt, u_len; 178 int utf_cnt, u_len;
@@ -182,12 +181,12 @@ static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length)
182 ocu[0] = 8; 181 ocu[0] = 8;
183 max_val = 0xffU; 182 max_val = 0xffU;
184 183
185 try_again: 184try_again:
186 u_len = 0U; 185 u_len = 0U;
187 utf_char = 0U; 186 utf_char = 0U;
188 utf_cnt = 0U; 187 utf_cnt = 0U;
189 for (i = 0U; i < utf->u_len; i++) { 188 for (i = 0U; i < utf->u_len; i++) {
190 c = (uint8_t) utf->u_name[i]; 189 c = (uint8_t)utf->u_name[i];
191 190
192 /* Complete a multi-byte UTF-8 character */ 191 /* Complete a multi-byte UTF-8 character */
193 if (utf_cnt) { 192 if (utf_cnt) {
@@ -213,37 +212,40 @@ static int udf_UTF8toCS0(dstring * ocu, struct ustr *utf, int length)
213 } else if ((c & 0xfeU) == 0xfcU) { 212 } else if ((c & 0xfeU) == 0xfcU) {
214 utf_char = c & 0x01U; 213 utf_char = c & 0x01U;
215 utf_cnt = 5; 214 utf_cnt = 5;
216 } else 215 } else {
217 goto error_out; 216 goto error_out;
217 }
218 continue; 218 continue;
219 } else 219 } else {
220 /* Single byte UTF-8 character (most common) */ 220 /* Single byte UTF-8 character (most common) */
221 utf_char = c; 221 utf_char = c;
222 }
222 } 223 }
223 224
224 /* Choose no compression if necessary */ 225 /* Choose no compression if necessary */
225 if (utf_char > max_val) { 226 if (utf_char > max_val) {
226 if (0xffU == max_val) { 227 if (max_val == 0xffU) {
227 max_val = 0xffffU; 228 max_val = 0xffffU;
228 ocu[0] = (uint8_t) 0x10U; 229 ocu[0] = (uint8_t)0x10U;
229 goto try_again; 230 goto try_again;
230 } 231 }
231 goto error_out; 232 goto error_out;
232 } 233 }
233 234
234 if (max_val == 0xffffU) { 235 if (max_val == 0xffffU) {
235 ocu[++u_len] = (uint8_t) (utf_char >> 8); 236 ocu[++u_len] = (uint8_t)(utf_char >> 8);
236 } 237 }
237 ocu[++u_len] = (uint8_t) (utf_char & 0xffU); 238 ocu[++u_len] = (uint8_t)(utf_char & 0xffU);
238 } 239 }
239 240
240 if (utf_cnt) { 241 if (utf_cnt) {
241 error_out: 242error_out:
242 ocu[++u_len] = '?'; 243 ocu[++u_len] = '?';
243 printk(KERN_DEBUG "udf: bad UTF-8 character\n"); 244 printk(KERN_DEBUG "udf: bad UTF-8 character\n");
244 } 245 }
245 246
246 ocu[length - 1] = (uint8_t) u_len + 1; 247 ocu[length - 1] = (uint8_t)u_len + 1;
248
247 return u_len + 1; 249 return u_len + 1;
248} 250}
249 251
@@ -288,7 +290,7 @@ static int udf_CS0toNLS(struct nls_table *nls, struct ustr *utf_o,
288 return utf_o->u_len; 290 return utf_o->u_len;
289} 291}
290 292
291static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni, 293static int udf_NLStoCS0(struct nls_table *nls, dstring *ocu, struct ustr *uni,
292 int length) 294 int length)
293{ 295{
294 unsigned len, i, max_val; 296 unsigned len, i, max_val;
@@ -299,7 +301,7 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni,
299 ocu[0] = 8; 301 ocu[0] = 8;
300 max_val = 0xffU; 302 max_val = 0xffU;
301 303
302 try_again: 304try_again:
303 u_len = 0U; 305 u_len = 0U;
304 for (i = 0U; i < uni->u_len; i++) { 306 for (i = 0U; i < uni->u_len; i++) {
305 len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char); 307 len = nls->char2uni(&uni->u_name[i], uni->u_len - i, &uni_char);
@@ -308,21 +310,21 @@ static int udf_NLStoCS0(struct nls_table *nls, dstring * ocu, struct ustr *uni,
308 310
309 if (uni_char > max_val) { 311 if (uni_char > max_val) {
310 max_val = 0xffffU; 312 max_val = 0xffffU;
311 ocu[0] = (uint8_t) 0x10U; 313 ocu[0] = (uint8_t)0x10U;
312 goto try_again; 314 goto try_again;
313 } 315 }
314 316
315 if (max_val == 0xffffU) 317 if (max_val == 0xffffU)
316 ocu[++u_len] = (uint8_t) (uni_char >> 8); 318 ocu[++u_len] = (uint8_t)(uni_char >> 8);
317 ocu[++u_len] = (uint8_t) (uni_char & 0xffU); 319 ocu[++u_len] = (uint8_t)(uni_char & 0xffU);
318 i += len - 1; 320 i += len - 1;
319 } 321 }
320 322
321 ocu[length - 1] = (uint8_t) u_len + 1; 323 ocu[length - 1] = (uint8_t)u_len + 1;
322 return u_len + 1; 324 return u_len + 1;
323} 325}
324 326
325int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname, 327int udf_get_filename(struct super_block *sb, uint8_t *sname, uint8_t *dname,
326 int flen) 328 int flen)
327{ 329{
328 struct ustr filename, unifilename; 330 struct ustr filename, unifilename;
@@ -334,30 +336,29 @@ int udf_get_filename(struct super_block *sb, uint8_t * sname, uint8_t * dname,
334 336
335 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { 337 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
336 if (!udf_CS0toUTF8(&filename, &unifilename)) { 338 if (!udf_CS0toUTF8(&filename, &unifilename)) {
337 udf_debug("Failed in udf_get_filename: sname = %s\n", 339 udf_debug("Failed in udf_get_filename: sname = %s\n", sname);
338 sname);
339 return 0; 340 return 0;
340 } 341 }
341 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { 342 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
342 if (!udf_CS0toNLS 343 if (!udf_CS0toNLS(UDF_SB(sb)->s_nls_map, &filename, &unifilename)) {
343 (UDF_SB(sb)->s_nls_map, &filename, &unifilename)) { 344 udf_debug("Failed in udf_get_filename: sname = %s\n", sname);
344 udf_debug("Failed in udf_get_filename: sname = %s\n",
345 sname);
346 return 0; 345 return 0;
347 } 346 }
348 } else 347 } else {
349 return 0; 348 return 0;
349 }
350 350
351 if ((len = 351 len = udf_translate_to_linux(dname, filename.u_name, filename.u_len,
352 udf_translate_to_linux(dname, filename.u_name, filename.u_len, 352 unifilename.u_name, unifilename.u_len);
353 unifilename.u_name, unifilename.u_len))) { 353 if (len) {
354 return len; 354 return len;
355 } 355 }
356
356 return 0; 357 return 0;
357} 358}
358 359
359int udf_put_filename(struct super_block *sb, const uint8_t * sname, 360int udf_put_filename(struct super_block *sb, const uint8_t *sname,
360 uint8_t * dname, int flen) 361 uint8_t *dname, int flen)
361{ 362{
362 struct ustr unifilename; 363 struct ustr unifilename;
363 int namelen; 364 int namelen;
@@ -367,31 +368,29 @@ int udf_put_filename(struct super_block *sb, const uint8_t * sname,
367 } 368 }
368 369
369 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) { 370 if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8)) {
370 if (! 371 namelen = udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN);
371 (namelen = 372 if (!namelen) {
372 udf_UTF8toCS0(dname, &unifilename, UDF_NAME_LEN))) {
373 return 0; 373 return 0;
374 } 374 }
375 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) { 375 } else if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP)) {
376 if (! 376 namelen = udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename, UDF_NAME_LEN);
377 (namelen = 377 if (!namelen) {
378 udf_NLStoCS0(UDF_SB(sb)->s_nls_map, dname, &unifilename,
379 UDF_NAME_LEN))) {
380 return 0; 378 return 0;
381 } 379 }
382 } else 380 } else {
383 return 0; 381 return 0;
382 }
384 383
385 return namelen; 384 return namelen;
386} 385}
387 386
388#define ILLEGAL_CHAR_MARK '_' 387#define ILLEGAL_CHAR_MARK '_'
389#define EXT_MARK '.' 388#define EXT_MARK '.'
390#define CRC_MARK '#' 389#define CRC_MARK '#'
391#define EXT_SIZE 5 390#define EXT_SIZE 5
392 391
393static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName, 392static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, int udfLen,
394 int udfLen, uint8_t * fidName, int fidNameLen) 393 uint8_t *fidName, int fidNameLen)
395{ 394{
396 int index, newIndex = 0, needsCRC = 0; 395 int index, newIndex = 0, needsCRC = 0;
397 int extIndex = 0, newExtIndex = 0, hasExt = 0; 396 int extIndex = 0, newExtIndex = 0, hasExt = 0;
@@ -399,8 +398,8 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
399 uint8_t curr; 398 uint8_t curr;
400 const uint8_t hexChar[] = "0123456789ABCDEF"; 399 const uint8_t hexChar[] = "0123456789ABCDEF";
401 400
402 if (udfName[0] == '.' && (udfLen == 1 || 401 if (udfName[0] == '.' &&
403 (udfLen == 2 && udfName[1] == '.'))) { 402 (udfLen == 1 || (udfLen == 2 && udfName[1] == '.'))) {
404 needsCRC = 1; 403 needsCRC = 1;
405 newIndex = udfLen; 404 newIndex = udfLen;
406 memcpy(newName, udfName, udfLen); 405 memcpy(newName, udfName, udfLen);
@@ -410,16 +409,13 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
410 if (curr == '/' || curr == 0) { 409 if (curr == '/' || curr == 0) {
411 needsCRC = 1; 410 needsCRC = 1;
412 curr = ILLEGAL_CHAR_MARK; 411 curr = ILLEGAL_CHAR_MARK;
413 while (index + 1 < udfLen 412 while (index + 1 < udfLen && (udfName[index + 1] == '/' ||
414 && (udfName[index + 1] == '/' 413 udfName[index + 1] == 0))
415 || udfName[index + 1] == 0))
416 index++; 414 index++;
417 } 415 } if (curr == EXT_MARK && (udfLen - index - 1) <= EXT_SIZE) {
418 if (curr == EXT_MARK 416 if (udfLen == index + 1) {
419 && (udfLen - index - 1) <= EXT_SIZE) {
420 if (udfLen == index + 1)
421 hasExt = 0; 417 hasExt = 0;
422 else { 418 } else {
423 hasExt = 1; 419 hasExt = 1;
424 extIndex = index; 420 extIndex = index;
425 newExtIndex = newIndex; 421 newExtIndex = newIndex;
@@ -437,23 +433,16 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
437 433
438 if (hasExt) { 434 if (hasExt) {
439 int maxFilenameLen; 435 int maxFilenameLen;
440 for (index = 0; 436 for(index = 0; index < EXT_SIZE && extIndex + index + 1 < udfLen; index++) {
441 index < EXT_SIZE && extIndex + index + 1 < udfLen;
442 index++) {
443 curr = udfName[extIndex + index + 1]; 437 curr = udfName[extIndex + index + 1];
444 438
445 if (curr == '/' || curr == 0) { 439 if (curr == '/' || curr == 0) {
446 needsCRC = 1; 440 needsCRC = 1;
447 curr = ILLEGAL_CHAR_MARK; 441 curr = ILLEGAL_CHAR_MARK;
448 while (extIndex + index + 2 < udfLen 442 while(extIndex + index + 2 < udfLen &&
449 && (index + 1 < EXT_SIZE 443 (index + 1 < EXT_SIZE
450 && 444 && (udfName[extIndex + index + 2] == '/' ||
451 (udfName 445 udfName[extIndex + index + 2] == 0)))
452 [extIndex + index + 2] ==
453 '/'
454 || udfName[extIndex +
455 index + 2] ==
456 0)))
457 index++; 446 index++;
458 } 447 }
459 ext[localExtIndex++] = curr; 448 ext[localExtIndex++] = curr;
@@ -463,8 +452,9 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
463 newIndex = maxFilenameLen; 452 newIndex = maxFilenameLen;
464 else 453 else
465 newIndex = newExtIndex; 454 newIndex = newExtIndex;
466 } else if (newIndex > 250) 455 } else if (newIndex > 250) {
467 newIndex = 250; 456 newIndex = 250;
457 }
468 newName[newIndex++] = CRC_MARK; 458 newName[newIndex++] = CRC_MARK;
469 valueCRC = udf_crc(fidName, fidNameLen, 0); 459 valueCRC = udf_crc(fidName, fidNameLen, 0);
470 newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12]; 460 newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12];
@@ -478,5 +468,6 @@ static int udf_translate_to_linux(uint8_t * newName, uint8_t * udfName,
478 newName[newIndex++] = ext[index]; 468 newName[newIndex++] = ext[index];
479 } 469 }
480 } 470 }
471
481 return newIndex; 472 return newIndex;
482} 473}
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h
index 8948a6461834..45662f6dbdb6 100644
--- a/include/acpi/acmacros.h
+++ b/include/acpi/acmacros.h
@@ -486,6 +486,8 @@
486#define ACPI_FUNCTION_NAME(name) 486#define ACPI_FUNCTION_NAME(name)
487#endif 487#endif
488 488
489#ifdef DEBUG_FUNC_TRACE
490
489#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \ 491#define ACPI_FUNCTION_TRACE(a) ACPI_FUNCTION_NAME(a) \
490 acpi_ut_trace(ACPI_DEBUG_PARAMETERS) 492 acpi_ut_trace(ACPI_DEBUG_PARAMETERS)
491#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \ 493#define ACPI_FUNCTION_TRACE_PTR(a,b) ACPI_FUNCTION_NAME(a) \
@@ -563,6 +565,27 @@
563 565
564#endif /* ACPI_SIMPLE_RETURN_MACROS */ 566#endif /* ACPI_SIMPLE_RETURN_MACROS */
565 567
568#else /* !DEBUG_FUNC_TRACE */
569
570#define ACPI_FUNCTION_TRACE(a)
571#define ACPI_FUNCTION_TRACE_PTR(a,b)
572#define ACPI_FUNCTION_TRACE_U32(a,b)
573#define ACPI_FUNCTION_TRACE_STR(a,b)
574#define ACPI_FUNCTION_EXIT
575#define ACPI_FUNCTION_STATUS_EXIT(s)
576#define ACPI_FUNCTION_VALUE_EXIT(s)
577#define ACPI_FUNCTION_TRACE(a)
578#define ACPI_FUNCTION_ENTRY()
579
580#define return_VOID return
581#define return_ACPI_STATUS(s) return(s)
582#define return_VALUE(s) return(s)
583#define return_UINT8(s) return(s)
584#define return_UINT32(s) return(s)
585#define return_PTR(s) return(s)
586
587#endif /* DEBUG_FUNC_TRACE */
588
566/* Conditional execution */ 589/* Conditional execution */
567 590
568#define ACPI_DEBUG_EXEC(a) a 591#define ACPI_DEBUG_EXEC(a) a
@@ -599,26 +622,26 @@
599#define ACPI_DEBUG_EXEC(a) 622#define ACPI_DEBUG_EXEC(a)
600#define ACPI_NORMAL_EXEC(a) a; 623#define ACPI_NORMAL_EXEC(a) a;
601 624
602#define ACPI_DEBUG_DEFINE(a) 625#define ACPI_DEBUG_DEFINE(a) do { } while(0)
603#define ACPI_DEBUG_ONLY_MEMBERS(a) 626#define ACPI_DEBUG_ONLY_MEMBERS(a) do { } while(0)
604#define ACPI_FUNCTION_NAME(a) 627#define ACPI_FUNCTION_NAME(a) do { } while(0)
605#define ACPI_FUNCTION_TRACE(a) 628#define ACPI_FUNCTION_TRACE(a) do { } while(0)
606#define ACPI_FUNCTION_TRACE_PTR(a,b) 629#define ACPI_FUNCTION_TRACE_PTR(a,b) do { } while(0)
607#define ACPI_FUNCTION_TRACE_U32(a,b) 630#define ACPI_FUNCTION_TRACE_U32(a,b) do { } while(0)
608#define ACPI_FUNCTION_TRACE_STR(a,b) 631#define ACPI_FUNCTION_TRACE_STR(a,b) do { } while(0)
609#define ACPI_FUNCTION_EXIT 632#define ACPI_FUNCTION_EXIT do { } while(0)
610#define ACPI_FUNCTION_STATUS_EXIT(s) 633#define ACPI_FUNCTION_STATUS_EXIT(s) do { } while(0)
611#define ACPI_FUNCTION_VALUE_EXIT(s) 634#define ACPI_FUNCTION_VALUE_EXIT(s) do { } while(0)
612#define ACPI_FUNCTION_ENTRY() 635#define ACPI_FUNCTION_ENTRY() do { } while(0)
613#define ACPI_DUMP_STACK_ENTRY(a) 636#define ACPI_DUMP_STACK_ENTRY(a) do { } while(0)
614#define ACPI_DUMP_OPERANDS(a,b,c,d,e) 637#define ACPI_DUMP_OPERANDS(a,b,c,d,e) do { } while(0)
615#define ACPI_DUMP_ENTRY(a,b) 638#define ACPI_DUMP_ENTRY(a,b) do { } while(0)
616#define ACPI_DUMP_TABLES(a,b) 639#define ACPI_DUMP_TABLES(a,b) do { } while(0)
617#define ACPI_DUMP_PATHNAME(a,b,c,d) 640#define ACPI_DUMP_PATHNAME(a,b,c,d) do { } while(0)
618#define ACPI_DUMP_RESOURCE_LIST(a) 641#define ACPI_DUMP_RESOURCE_LIST(a) do { } while(0)
619#define ACPI_DUMP_BUFFER(a,b) 642#define ACPI_DUMP_BUFFER(a,b) do { } while(0)
620#define ACPI_DEBUG_PRINT(pl) 643#define ACPI_DEBUG_PRINT(pl) do { } while(0)
621#define ACPI_DEBUG_PRINT_RAW(pl) 644#define ACPI_DEBUG_PRINT_RAW(pl) do { } while(0)
622 645
623#define return_VOID return 646#define return_VOID return
624#define return_ACPI_STATUS(s) return(s) 647#define return_ACPI_STATUS(s) return(s)
diff --git a/include/acpi/acoutput.h b/include/acpi/acoutput.h
index 7812267b577f..c090a8b0bc99 100644
--- a/include/acpi/acoutput.h
+++ b/include/acpi/acoutput.h
@@ -178,8 +178,8 @@
178 178
179/* Defaults for debug_level, debug and normal */ 179/* Defaults for debug_level, debug and normal */
180 180
181#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) 181#define ACPI_DEBUG_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR)
182#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR | ACPI_LV_DEBUG_OBJECT) 182#define ACPI_NORMAL_DEFAULT (ACPI_LV_INIT | ACPI_LV_WARN | ACPI_LV_ERROR)
183#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL) 183#define ACPI_DEBUG_ALL (ACPI_LV_AML_DISASSEMBLE | ACPI_LV_ALL_EXCEPTIONS | ACPI_LV_ALL)
184 184
185#endif /* __ACOUTPUT_H__ */ 185#endif /* __ACOUTPUT_H__ */
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h
index c6fa5e023bc7..5e3dcf3299bf 100644
--- a/include/acpi/acpi_bus.h
+++ b/include/acpi/acpi_bus.h
@@ -321,7 +321,8 @@ struct acpi_bus_event {
321}; 321};
322 322
323extern struct kset acpi_subsys; 323extern struct kset acpi_subsys;
324 324extern int acpi_bus_generate_genetlink_event(struct acpi_device *device,
325 u8 type, int data);
325/* 326/*
326 * External Functions 327 * External Functions
327 */ 328 */
diff --git a/include/acpi/acpi_numa.h b/include/acpi/acpi_numa.h
index e2fcee2b340d..62c5ee4311da 100644
--- a/include/acpi/acpi_numa.h
+++ b/include/acpi/acpi_numa.h
@@ -13,6 +13,7 @@
13 13
14extern int pxm_to_node(int); 14extern int pxm_to_node(int);
15extern int node_to_pxm(int); 15extern int node_to_pxm(int);
16extern void __acpi_map_pxm_to_node(int, int);
16extern int acpi_map_pxm_to_node(int); 17extern int acpi_map_pxm_to_node(int);
17extern void __cpuinit acpi_unmap_pxm_to_node(int); 18extern void __cpuinit acpi_unmap_pxm_to_node(int);
18 19
diff --git a/include/acpi/platform/acenv.h b/include/acpi/platform/acenv.h
index dab2ec59a3b0..c785485e62a6 100644
--- a/include/acpi/platform/acenv.h
+++ b/include/acpi/platform/acenv.h
@@ -136,7 +136,7 @@
136 136
137/*! [Begin] no source code translation */ 137/*! [Begin] no source code translation */
138 138
139#if defined(__linux__) 139#if defined(_LINUX) || defined(__linux__)
140#include "aclinux.h" 140#include "aclinux.h"
141 141
142#elif defined(_AED_EFI) 142#elif defined(_AED_EFI)
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index a568717f98c6..6ed15a0978eb 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -91,7 +91,10 @@
91#define ACPI_USE_NATIVE_DIVIDE 91#define ACPI_USE_NATIVE_DIVIDE
92#endif 92#endif
93 93
94#ifndef __cdecl
94#define __cdecl 95#define __cdecl
96#endif
97
95#define ACPI_FLUSH_CPU_CACHE() 98#define ACPI_FLUSH_CPU_CACHE()
96#endif /* __KERNEL__ */ 99#endif /* __KERNEL__ */
97 100
diff --git a/include/acpi/processor.h b/include/acpi/processor.h
index b4b0ffdab098..f9f987f8e661 100644
--- a/include/acpi/processor.h
+++ b/include/acpi/processor.h
@@ -21,6 +21,8 @@
21#define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */ 21#define ACPI_PSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
22#define ACPI_PSD_REV0_ENTRIES 5 22#define ACPI_PSD_REV0_ENTRIES 5
23 23
24#define ACPI_TSD_REV0_REVISION 0 /* Support for _PSD as in ACPI 3.0 */
25#define ACPI_TSD_REV0_ENTRIES 5
24/* 26/*
25 * Types of coordination defined in ACPI 3.0. Same macros can be used across 27 * Types of coordination defined in ACPI 3.0. Same macros can be used across
26 * P, C and T states 28 * P, C and T states
@@ -125,17 +127,53 @@ struct acpi_processor_performance {
125 127
126/* Throttling Control */ 128/* Throttling Control */
127 129
130struct acpi_tsd_package {
131 acpi_integer num_entries;
132 acpi_integer revision;
133 acpi_integer domain;
134 acpi_integer coord_type;
135 acpi_integer num_processors;
136} __attribute__ ((packed));
137
138struct acpi_ptc_register {
139 u8 descriptor;
140 u16 length;
141 u8 space_id;
142 u8 bit_width;
143 u8 bit_offset;
144 u8 reserved;
145 u64 address;
146} __attribute__ ((packed));
147
148struct acpi_processor_tx_tss {
149 acpi_integer freqpercentage; /* */
150 acpi_integer power; /* milliWatts */
151 acpi_integer transition_latency; /* microseconds */
152 acpi_integer control; /* control value */
153 acpi_integer status; /* success indicator */
154};
128struct acpi_processor_tx { 155struct acpi_processor_tx {
129 u16 power; 156 u16 power;
130 u16 performance; 157 u16 performance;
131}; 158};
132 159
160struct acpi_processor;
133struct acpi_processor_throttling { 161struct acpi_processor_throttling {
134 int state; 162 unsigned int state;
163 unsigned int platform_limit;
164 struct acpi_pct_register control_register;
165 struct acpi_pct_register status_register;
166 unsigned int state_count;
167 struct acpi_processor_tx_tss *states_tss;
168 struct acpi_tsd_package domain_info;
169 cpumask_t shared_cpu_map;
170 int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
171 int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
172 int state);
173
135 u32 address; 174 u32 address;
136 u8 duty_offset; 175 u8 duty_offset;
137 u8 duty_width; 176 u8 duty_width;
138 int state_count;
139 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING]; 177 struct acpi_processor_tx states[ACPI_PROCESSOR_MAX_THROTTLING];
140}; 178};
141 179
@@ -169,6 +207,9 @@ struct acpi_processor {
169 u32 id; 207 u32 id;
170 u32 pblk; 208 u32 pblk;
171 int performance_platform_limit; 209 int performance_platform_limit;
210 int throttling_platform_limit;
211 /* 0 - states 0..n-th state available */
212
172 struct acpi_processor_flags flags; 213 struct acpi_processor_flags flags;
173 struct acpi_processor_power power; 214 struct acpi_processor_power power;
174 struct acpi_processor_performance *performance; 215 struct acpi_processor_performance *performance;
@@ -270,7 +311,7 @@ static inline int acpi_processor_ppc_has_changed(struct acpi_processor *pr)
270 311
271/* in processor_throttling.c */ 312/* in processor_throttling.c */
272int acpi_processor_get_throttling_info(struct acpi_processor *pr); 313int acpi_processor_get_throttling_info(struct acpi_processor *pr);
273int acpi_processor_set_throttling(struct acpi_processor *pr, int state); 314extern int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
274extern struct file_operations acpi_processor_throttling_fops; 315extern struct file_operations acpi_processor_throttling_fops;
275 316
276/* in processor_idle.c */ 317/* in processor_idle.c */
diff --git a/include/asm-alpha/irq.h b/include/asm-alpha/irq.h
index 917b9fe372cf..06377400dc09 100644
--- a/include/asm-alpha/irq.h
+++ b/include/asm-alpha/irq.h
@@ -85,10 +85,6 @@ static __inline__ int irq_canonicalize(int irq)
85 return ((irq == 2) ? 9 : irq); 85 return ((irq == 2) ? 9 : irq);
86} 86}
87 87
88extern void disable_irq(unsigned int);
89extern void disable_irq_nosync(unsigned int);
90extern void enable_irq(unsigned int);
91
92struct pt_regs; 88struct pt_regs;
93extern void (*perf_irq)(unsigned long, struct pt_regs *); 89extern void (*perf_irq)(unsigned long, struct pt_regs *);
94 90
diff --git a/include/asm-arm/arch-at91/at91_mci.h b/include/asm-arm/arch-at91/at91_mci.h
index 40a9876b661a..c2e11cc374ba 100644
--- a/include/asm-arm/arch-at91/at91_mci.h
+++ b/include/asm-arm/arch-at91/at91_mci.h
@@ -26,6 +26,9 @@
26#define AT91_MCI_MR 0x04 /* Mode Register */ 26#define AT91_MCI_MR 0x04 /* Mode Register */
27#define AT91_MCI_CLKDIV (0xff << 0) /* Clock Divider */ 27#define AT91_MCI_CLKDIV (0xff << 0) /* Clock Divider */
28#define AT91_MCI_PWSDIV (7 << 8) /* Power Saving Divider */ 28#define AT91_MCI_PWSDIV (7 << 8) /* Power Saving Divider */
29#define AT91_MCI_RDPROOF (1 << 11) /* Read Proof Enable [SAM926[03] only] */
30#define AT91_MCI_WRPROOF (1 << 12) /* Write Proof Enable [SAM926[03] only] */
31#define AT91_MCI_PDCFBYTE (1 << 13) /* PDC Force Byte Transfer [SAM926[03] only] */
29#define AT91_MCI_PDCPADV (1 << 14) /* PDC Padding Value */ 32#define AT91_MCI_PDCPADV (1 << 14) /* PDC Padding Value */
30#define AT91_MCI_PDCMODE (1 << 15) /* PDC-orientated Mode */ 33#define AT91_MCI_PDCMODE (1 << 15) /* PDC-orientated Mode */
31#define AT91_MCI_BLKLEN (0xfff << 18) /* Data Block Length */ 34#define AT91_MCI_BLKLEN (0xfff << 18) /* Data Block Length */
diff --git a/include/asm-arm/arch-iop13xx/iop13xx.h b/include/asm-arm/arch-iop13xx/iop13xx.h
index d4e4f828577c..52b7fab7ef60 100644
--- a/include/asm-arm/arch-iop13xx/iop13xx.h
+++ b/include/asm-arm/arch-iop13xx/iop13xx.h
@@ -19,6 +19,39 @@ static inline int iop13xx_cpu_id(void)
19 return id; 19 return id;
20} 20}
21 21
22/* WDTCR CP6 R7 Page 9 */
23static inline u32 read_wdtcr(void)
24{
25 u32 val;
26 asm volatile("mrc p6, 0, %0, c7, c9, 0":"=r" (val));
27 return val;
28}
29static inline void write_wdtcr(u32 val)
30{
31 asm volatile("mcr p6, 0, %0, c7, c9, 0"::"r" (val));
32}
33
34/* WDTSR CP6 R8 Page 9 */
35static inline u32 read_wdtsr(void)
36{
37 u32 val;
38 asm volatile("mrc p6, 0, %0, c8, c9, 0":"=r" (val));
39 return val;
40}
41static inline void write_wdtsr(u32 val)
42{
43 asm volatile("mcr p6, 0, %0, c8, c9, 0"::"r" (val));
44}
45
46/* RCSR - Reset Cause Status Register */
47static inline u32 read_rcsr(void)
48{
49 u32 val;
50 asm volatile("mrc p6, 0, %0, c0, c1, 0":"=r" (val));
51 return val;
52}
53
54extern unsigned long get_iop_tick_rate(void);
22#endif 55#endif
23 56
24/* 57/*
@@ -480,4 +513,14 @@ static inline int iop13xx_cpu_id(void)
480#define IOP13XX_PBI_LR1 IOP13XX_PBI_OFFSET(0x14) 513#define IOP13XX_PBI_LR1 IOP13XX_PBI_OFFSET(0x14)
481 514
482#define IOP13XX_PROCESSOR_FREQ IOP13XX_REG_ADDR32(0x2180) 515#define IOP13XX_PROCESSOR_FREQ IOP13XX_REG_ADDR32(0x2180)
516
517/* Watchdog timer definitions */
518#define IOP_WDTCR_EN_ARM 0x1e1e1e1e
519#define IOP_WDTCR_EN 0xe1e1e1e1
520#define IOP_WDTCR_DIS_ARM 0x1f1f1f1f
521#define IOP_WDTCR_DIS 0xf1f1f1f1
522#define IOP_RCSR_WDT (1 << 5) /* reset caused by watchdog timer */
523#define IOP13XX_WDTSR_WRITE_EN (1 << 31) /* used to speed up reset requests */
524#define IOP13XX_WDTCR_IB_RESET (1 << 0)
525
483#endif /* _IOP13XX_HW_H_ */ 526#endif /* _IOP13XX_HW_H_ */
diff --git a/include/asm-arm/arch-iop13xx/system.h b/include/asm-arm/arch-iop13xx/system.h
index 127827058e1f..8575af8db78c 100644
--- a/include/asm-arm/arch-iop13xx/system.h
+++ b/include/asm-arm/arch-iop13xx/system.h
@@ -13,43 +13,13 @@ static inline void arch_idle(void)
13 cpu_do_idle(); 13 cpu_do_idle();
14} 14}
15 15
16/* WDTCR CP6 R7 Page 9 */
17static inline u32 read_wdtcr(void)
18{
19 u32 val;
20 asm volatile("mrc p6, 0, %0, c7, c9, 0":"=r" (val));
21 return val;
22}
23static inline void write_wdtcr(u32 val)
24{
25 asm volatile("mcr p6, 0, %0, c7, c9, 0"::"r" (val));
26}
27
28/* WDTSR CP6 R8 Page 9 */
29static inline u32 read_wdtsr(void)
30{
31 u32 val;
32 asm volatile("mrc p6, 0, %0, c8, c9, 0":"=r" (val));
33 return val;
34}
35static inline void write_wdtsr(u32 val)
36{
37 asm volatile("mcr p6, 0, %0, c8, c9, 0"::"r" (val));
38}
39
40#define IOP13XX_WDTCR_EN_ARM 0x1e1e1e1e
41#define IOP13XX_WDTCR_EN 0xe1e1e1e1
42#define IOP13XX_WDTCR_DIS_ARM 0x1f1f1f1f
43#define IOP13XX_WDTCR_DIS 0xf1f1f1f1
44#define IOP13XX_WDTSR_WRITE_EN (1 << 31)
45#define IOP13XX_WDTCR_IB_RESET (1 << 0)
46static inline void arch_reset(char mode) 16static inline void arch_reset(char mode)
47{ 17{
48 /* 18 /*
49 * Reset the internal bus (warning both cores are reset) 19 * Reset the internal bus (warning both cores are reset)
50 */ 20 */
51 write_wdtcr(IOP13XX_WDTCR_EN_ARM); 21 write_wdtcr(IOP_WDTCR_EN_ARM);
52 write_wdtcr(IOP13XX_WDTCR_EN); 22 write_wdtcr(IOP_WDTCR_EN);
53 write_wdtsr(IOP13XX_WDTSR_WRITE_EN | IOP13XX_WDTCR_IB_RESET); 23 write_wdtsr(IOP13XX_WDTSR_WRITE_EN | IOP13XX_WDTCR_IB_RESET);
54 write_wdtcr(0x1000); 24 write_wdtcr(0x1000);
55 25
diff --git a/include/asm-arm/arch-iop13xx/uncompress.h b/include/asm-arm/arch-iop13xx/uncompress.h
index b9525d59b7ad..dd9c2934190e 100644
--- a/include/asm-arm/arch-iop13xx/uncompress.h
+++ b/include/asm-arm/arch-iop13xx/uncompress.h
@@ -1,7 +1,6 @@
1#include <asm/types.h> 1#include <asm/types.h>
2#include <linux/serial_reg.h> 2#include <linux/serial_reg.h>
3#include <asm/hardware.h> 3#include <asm/hardware.h>
4#include <asm/processor.h>
5 4
6#define UART_BASE ((volatile u32 *)IOP13XX_UART1_PHYS) 5#define UART_BASE ((volatile u32 *)IOP13XX_UART1_PHYS)
7#define TX_DONE (UART_LSR_TEMT | UART_LSR_THRE) 6#define TX_DONE (UART_LSR_TEMT | UART_LSR_THRE)
@@ -9,7 +8,7 @@
9static inline void putc(char c) 8static inline void putc(char c)
10{ 9{
11 while ((UART_BASE[UART_LSR] & TX_DONE) != TX_DONE) 10 while ((UART_BASE[UART_LSR] & TX_DONE) != TX_DONE)
12 cpu_relax(); 11 barrier();
13 UART_BASE[UART_TX] = c; 12 UART_BASE[UART_TX] = c;
14} 13}
15 14
diff --git a/include/asm-arm/arch-iop32x/uncompress.h b/include/asm-arm/arch-iop32x/uncompress.h
index e64f52bf2bce..070f15818fe7 100644
--- a/include/asm-arm/arch-iop32x/uncompress.h
+++ b/include/asm-arm/arch-iop32x/uncompress.h
@@ -26,7 +26,7 @@ static __inline__ void __arch_decomp_setup(unsigned long arch_id)
26{ 26{
27 if (machine_is_iq80321()) 27 if (machine_is_iq80321())
28 uart_base = (volatile u8 *)IQ80321_UART; 28 uart_base = (volatile u8 *)IQ80321_UART;
29 else if (machine_is_iq31244()) 29 else if (machine_is_iq31244() || machine_is_em7210())
30 uart_base = (volatile u8 *)IQ31244_UART; 30 uart_base = (volatile u8 *)IQ31244_UART;
31 else 31 else
32 uart_base = (volatile u8 *)0xfe800000; 32 uart_base = (volatile u8 *)0xfe800000;
diff --git a/include/asm-arm/arch-mxc/board-mx31ads.h b/include/asm-arm/arch-mxc/board-mx31ads.h
new file mode 100644
index 000000000000..be29b83ad4ae
--- /dev/null
+++ b/include/asm-arm/arch-mxc/board-mx31ads.h
@@ -0,0 +1,142 @@
1/*
2 * Copyright 2005-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_BOARD_MX31ADS_H__
12#define __ASM_ARCH_MXC_BOARD_MX31ADS_H__
13
14/*!
15 * @name PBC Controller parameters
16 */
17/*! @{ */
18/*!
19 * Base address of PBC controller
20 */
21#define PBC_BASE_ADDRESS IO_ADDRESS(CS4_BASE_ADDR)
22/* Offsets for the PBC Controller register */
23/*!
24 * PBC Board status register offset
25 */
26#define PBC_BSTAT 0x000002
27/*!
28 * PBC Board control register 1 set address.
29 */
30#define PBC_BCTRL1_SET 0x000004
31/*!
32 * PBC Board control register 1 clear address.
33 */
34#define PBC_BCTRL1_CLEAR 0x000006
35/*!
36 * PBC Board control register 2 set address.
37 */
38#define PBC_BCTRL2_SET 0x000008
39/*!
40 * PBC Board control register 2 clear address.
41 */
42#define PBC_BCTRL2_CLEAR 0x00000A
43/*!
44 * PBC Board control register 3 set address.
45 */
46#define PBC_BCTRL3_SET 0x00000C
47/*!
48 * PBC Board control register 3 clear address.
49 */
50#define PBC_BCTRL3_CLEAR 0x00000E
51/*!
52 * PBC Board control register 4 set address.
53 */
54#define PBC_BCTRL4_SET 0x000010
55/*!
56 * PBC Board control register 4 clear address.
57 */
58#define PBC_BCTRL4_CLEAR 0x000012
59/*!
60 * PBC Board status register 1.
61 */
62#define PBC_BSTAT1 0x000014
63/*!
64 * PBC Board interrupt status register.
65 */
66#define PBC_INTSTATUS 0x000016
67/*!
68 * PBC Board interrupt current status register.
69 */
70#define PBC_INTCURR_STATUS 0x000018
71/*!
72 * PBC Interrupt mask register set address.
73 */
74#define PBC_INTMASK_SET 0x00001A
75/*!
76 * PBC Interrupt mask register clear address.
77 */
78#define PBC_INTMASK_CLEAR 0x00001C
79
80/*!
81 * External UART A.
82 */
83#define PBC_SC16C652_UARTA 0x010000
84/*!
85 * External UART B.
86 */
87#define PBC_SC16C652_UARTB 0x010010
88/*!
89 * Ethernet Controller IO base address.
90 */
91#define PBC_CS8900A_IOBASE 0x020000
92/*!
93 * Ethernet Controller Memory base address.
94 */
95#define PBC_CS8900A_MEMBASE 0x021000
96/*!
97 * Ethernet Controller DMA base address.
98 */
99#define PBC_CS8900A_DMABASE 0x022000
100/*!
101 * External chip select 0.
102 */
103#define PBC_XCS0 0x040000
104/*!
105 * LCD Display enable.
106 */
107#define PBC_LCD_EN_B 0x060000
108/*!
109 * Code test debug enable.
110 */
111#define PBC_CODE_B 0x070000
112/*!
113 * PSRAM memory select.
114 */
115#define PBC_PSRAM_B 0x5000000
116
117#define PBC_INTSTATUS_REG (PBC_INTSTATUS + PBC_BASE_ADDRESS)
118#define PBC_INTCURR_STATUS_REG (PBC_INTCURR_STATUS + PBC_BASE_ADDRESS)
119#define PBC_INTMASK_SET_REG (PBC_INTMASK_SET + PBC_BASE_ADDRESS)
120#define PBC_INTMASK_CLEAR_REG (PBC_INTMASK_CLEAR + PBC_BASE_ADDRESS)
121#define EXPIO_PARENT_INT IOMUX_TO_IRQ(MX31_PIN_GPIO1_4)
122
123#define EXPIO_INT_LOW_BAT (MXC_EXP_IO_BASE + 0)
124#define EXPIO_INT_PB_IRQ (MXC_EXP_IO_BASE + 1)
125#define EXPIO_INT_OTG_FS_OVR (MXC_EXP_IO_BASE + 2)
126#define EXPIO_INT_FSH_OVR (MXC_EXP_IO_BASE + 3)
127#define EXPIO_INT_RES4 (MXC_EXP_IO_BASE + 4)
128#define EXPIO_INT_RES5 (MXC_EXP_IO_BASE + 5)
129#define EXPIO_INT_RES6 (MXC_EXP_IO_BASE + 6)
130#define EXPIO_INT_RES7 (MXC_EXP_IO_BASE + 7)
131#define EXPIO_INT_ENET_INT (MXC_EXP_IO_BASE + 8)
132#define EXPIO_INT_OTG_FS_INT (MXC_EXP_IO_BASE + 9)
133#define EXPIO_INT_XUART_INTA (MXC_EXP_IO_BASE + 10)
134#define EXPIO_INT_XUART_INTB (MXC_EXP_IO_BASE + 11)
135#define EXPIO_INT_SYNTH_IRQ (MXC_EXP_IO_BASE + 12)
136#define EXPIO_INT_CE_INT1 (MXC_EXP_IO_BASE + 13)
137#define EXPIO_INT_CE_INT2 (MXC_EXP_IO_BASE + 14)
138#define EXPIO_INT_RES15 (MXC_EXP_IO_BASE + 15)
139
140#define MXC_MAX_EXP_IO_LINES 16
141
142#endif /* __ASM_ARCH_MXC_BOARD_MX31ADS_H__ */
diff --git a/include/asm-arm/arch-mxc/common.h b/include/asm-arm/arch-mxc/common.h
new file mode 100644
index 000000000000..23b4350edbd6
--- /dev/null
+++ b/include/asm-arm/arch-mxc/common.h
@@ -0,0 +1,20 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_COMMON_H__
12#define __ASM_ARCH_MXC_COMMON_H__
13
14struct sys_timer;
15
16extern void mxc_map_io(void);
17extern void mxc_init_irq(void);
18extern struct sys_timer mxc_timer;
19
20#endif
diff --git a/include/asm-arm/arch-mxc/dma.h b/include/asm-arm/arch-mxc/dma.h
new file mode 100644
index 000000000000..65e639d51d2b
--- /dev/null
+++ b/include/asm-arm/arch-mxc/dma.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_DMA_H__
12#define __ASM_ARCH_MXC_DMA_H__
13
14/*!
15 * @file dma.h
16 * @brief This file contains Unified DMA API for all MXC platforms.
17 * The API is platform independent.
18 *
19 * @ingroup SDMA
20 */
21#endif
diff --git a/include/asm-arm/arch-mxc/entry-macro.S b/include/asm-arm/arch-mxc/entry-macro.S
new file mode 100644
index 000000000000..b542433afb1b
--- /dev/null
+++ b/include/asm-arm/arch-mxc/entry-macro.S
@@ -0,0 +1,39 @@
1/*
2 * Copyright (C) 2007 Lennert Buytenhek <buytenh@wantstofly.org>
3 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
4 */
5
6/*
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12 @ this macro disables fast irq (not implemented)
13 .macro disable_fiq
14 .endm
15
16 .macro get_irqnr_preamble, base, tmp
17 .endm
18
19 .macro arch_ret_to_user, tmp1, tmp2
20 .endm
21
22 @ this macro checks which interrupt occured
23 @ and returns its number in irqnr
24 @ and returns if an interrupt occured in irqstat
25 .macro get_irqnr_and_base, irqnr, irqstat, base, tmp
26 ldr \base, =AVIC_IO_ADDRESS(AVIC_BASE_ADDR)
27 @ Load offset & priority of the highest priority
28 @ interrupt pending from AVIC_NIVECSR
29 ldr \irqstat, [\base, #0x40]
30 @ Shift to get the decoded IRQ number, using ASR so
31 @ 'no interrupt pending' becomes 0xffffffff
32 mov \irqnr, \irqstat, asr #16
33 @ set zero flag if IRQ + 1 == 0
34 adds \tmp, \irqnr, #1
35 .endm
36
37 @ irq priority table (not used)
38 .macro irq_prio_table
39 .endm
diff --git a/include/asm-arm/arch-mxc/hardware.h b/include/asm-arm/arch-mxc/hardware.h
new file mode 100644
index 000000000000..3c09b92fef0d
--- /dev/null
+++ b/include/asm-arm/arch-mxc/hardware.h
@@ -0,0 +1,52 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11/*!
12 * @file hardware.h
13 * @brief This file contains the hardware definitions of the board.
14 *
15 * @ingroup System
16 */
17#ifndef __ASM_ARCH_MXC_HARDWARE_H__
18#define __ASM_ARCH_MXC_HARDWARE_H__
19
20#include <asm/sizes.h>
21
22#include <asm/arch/mx31.h>
23
24#include <asm/arch/mxc.h>
25
26#define MXC_MAX_GPIO_LINES (GPIO_NUM_PIN * GPIO_PORT_NUM)
27
28/*
29 * ---------------------------------------------------------------------------
30 * Board specific defines
31 * ---------------------------------------------------------------------------
32 */
33#define MXC_EXP_IO_BASE (MXC_GPIO_INT_BASE + MXC_MAX_GPIO_LINES)
34
35#include <asm/arch/board-mx31ads.h>
36
37#ifndef MXC_MAX_EXP_IO_LINES
38#define MXC_MAX_EXP_IO_LINES 0
39#endif
40
41#define MXC_MAX_VIRTUAL_INTS 16
42#define MXC_VIRTUAL_INTS_BASE (MXC_EXP_IO_BASE + MXC_MAX_EXP_IO_LINES)
43#define MXC_SDIO1_CARD_IRQ MXC_VIRTUAL_INTS_BASE
44#define MXC_SDIO2_CARD_IRQ (MXC_VIRTUAL_INTS_BASE + 1)
45#define MXC_SDIO3_CARD_IRQ (MXC_VIRTUAL_INTS_BASE + 2)
46
47#define MXC_MAX_INTS (MXC_MAX_INT_LINES + \
48 MXC_MAX_GPIO_LINES + \
49 MXC_MAX_EXP_IO_LINES + \
50 MXC_MAX_VIRTUAL_INTS)
51
52#endif /* __ASM_ARCH_MXC_HARDWARE_H__ */
diff --git a/include/asm-arm/arch-mxc/io.h b/include/asm-arm/arch-mxc/io.h
new file mode 100644
index 000000000000..cf6c83a4b9f7
--- /dev/null
+++ b/include/asm-arm/arch-mxc/io.h
@@ -0,0 +1,33 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11/*!
12 * @file io.h
13 * @brief This file contains some memory mapping macros.
14 * @note There is no real ISA or PCI buses. But have to define these macros
15 * for some drivers to compile.
16 *
17 * @ingroup System
18 */
19
20#ifndef __ASM_ARCH_MXC_IO_H__
21#define __ASM_ARCH_MXC_IO_H__
22
23/*! Allow IO space to be anywhere in the memory */
24#define IO_SPACE_LIMIT 0xffffffff
25
26/*!
27 * io address mapping macro
28 */
29#define __io(a) ((void __iomem *)(a))
30
31#define __mem_pci(a) (a)
32
33#endif
diff --git a/include/asm-arm/arch-mxc/irqs.h b/include/asm-arm/arch-mxc/irqs.h
new file mode 100644
index 000000000000..e4686c6bc4bf
--- /dev/null
+++ b/include/asm-arm/arch-mxc/irqs.h
@@ -0,0 +1,38 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_IRQS_H__
12#define __ASM_ARCH_MXC_IRQS_H__
13
14#include <asm/hardware.h>
15
16/*!
17 * @file irqs.h
18 * @brief This file defines the number of normal interrupts and fast interrupts
19 *
20 * @ingroup Interrupt
21 */
22
23#define MXC_IRQ_TO_EXPIO(irq) ((irq) - MXC_EXP_IO_BASE)
24
25#define MXC_IRQ_TO_GPIO(irq) ((irq) - MXC_GPIO_INT_BASE)
26#define MXC_GPIO_TO_IRQ(x) (MXC_GPIO_INT_BASE + x)
27
28/*!
29 * Number of normal interrupts
30 */
31#define NR_IRQS MXC_MAX_INTS
32
33/*!
34 * Number of fast interrupts
35 */
36#define NR_FIQS MXC_MAX_INTS
37
38#endif /* __ASM_ARCH_MXC_IRQS_H__ */
diff --git a/include/asm-arm/arch-mxc/memory.h b/include/asm-arm/arch-mxc/memory.h
new file mode 100644
index 000000000000..c89aac83a407
--- /dev/null
+++ b/include/asm-arm/arch-mxc/memory.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_MEMORY_H__
12#define __ASM_ARCH_MXC_MEMORY_H__
13
14#include <asm/hardware.h>
15
16/*!
17 * @file memory.h
18 * @brief This file contains macros needed by the Linux kernel and drivers.
19 *
20 * @ingroup Memory
21 */
22
23/*!
24 * Virtual view <-> DMA view memory address translations
25 * This macro is used to translate the virtual address to an address
26 * suitable to be passed to set_dma_addr()
27 */
28#define __virt_to_bus(a) __virt_to_phys(a)
29
30/*!
31 * Used to convert an address for DMA operations to an address that the
32 * kernel can use.
33 */
34#define __bus_to_virt(a) __phys_to_virt(a)
35
36#endif /* __ASM_ARCH_MXC_MEMORY_H__ */
diff --git a/include/asm-arm/arch-mxc/mx31.h b/include/asm-arm/arch-mxc/mx31.h
new file mode 100644
index 000000000000..85c49c9e5d15
--- /dev/null
+++ b/include/asm-arm/arch-mxc/mx31.h
@@ -0,0 +1,335 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_MX31_H__
12#define __ASM_ARCH_MXC_MX31_H__
13
14#ifndef __ASM_ARCH_MXC_HARDWARE_H__
15#error "Do not include directly."
16#endif
17
18/*!
19 * defines the hardware clock tick rate
20 */
21#define CLOCK_TICK_RATE 16625000
22
23/*
24 * MX31 memory map:
25 *
26 * Virt Phys Size What
27 * ---------------------------------------------------------------------------
28 * F8000000 1FFC0000 16K IRAM
29 * F9000000 30000000 256M L2CC
30 * FC000000 43F00000 1M AIPS 1
31 * FC100000 50000000 1M SPBA
32 * FC200000 53F00000 1M AIPS 2
33 * FC500000 60000000 128M ROMPATCH
34 * FC400000 68000000 128M AVIC
35 * 70000000 256M IPU (MAX M2)
36 * 80000000 256M CSD0 SDRAM/DDR
37 * 90000000 256M CSD1 SDRAM/DDR
38 * A0000000 128M CS0 Flash
39 * A8000000 128M CS1 Flash
40 * B0000000 32M CS2
41 * B2000000 32M CS3
42 * F4000000 B4000000 32M CS4
43 * B6000000 32M CS5
44 * FC320000 B8000000 64K NAND, SDRAM, WEIM, M3IF, EMI controllers
45 * C0000000 64M PCMCIA/CF
46 */
47
48#define CS0_BASE_ADDR 0xA0000000
49#define CS1_BASE_ADDR 0xA8000000
50#define CS2_BASE_ADDR 0xB0000000
51#define CS3_BASE_ADDR 0xB2000000
52
53#define CS4_BASE_ADDR 0xB4000000
54#define CS4_BASE_ADDR_VIRT 0xF4000000
55#define CS4_SIZE SZ_32M
56
57#define CS5_BASE_ADDR 0xB6000000
58#define PCMCIA_MEM_BASE_ADDR 0xBC000000
59
60/*
61 * IRAM
62 */
63#define IRAM_BASE_ADDR 0x1FFC0000 /* internal ram */
64#define IRAM_BASE_ADDR_VIRT 0xF8000000
65#define IRAM_SIZE SZ_16K
66
67/*
68 * L2CC
69 */
70#define L2CC_BASE_ADDR 0x30000000
71#define L2CC_BASE_ADDR_VIRT 0xF9000000
72#define L2CC_SIZE SZ_1M
73
74/*
75 * AIPS 1
76 */
77#define AIPS1_BASE_ADDR 0x43F00000
78#define AIPS1_BASE_ADDR_VIRT 0xFC000000
79#define AIPS1_SIZE SZ_1M
80
81#define MAX_BASE_ADDR (AIPS1_BASE_ADDR + 0x00004000)
82#define EVTMON_BASE_ADDR (AIPS1_BASE_ADDR + 0x00008000)
83#define CLKCTL_BASE_ADDR (AIPS1_BASE_ADDR + 0x0000C000)
84#define ETB_SLOT4_BASE_ADDR (AIPS1_BASE_ADDR + 0x00010000)
85#define ETB_SLOT5_BASE_ADDR (AIPS1_BASE_ADDR + 0x00014000)
86#define ECT_CTIO_BASE_ADDR (AIPS1_BASE_ADDR + 0x00018000)
87#define I2C_BASE_ADDR (AIPS1_BASE_ADDR + 0x00080000)
88#define I2C3_BASE_ADDR (AIPS1_BASE_ADDR + 0x00084000)
89#define OTG_BASE_ADDR (AIPS1_BASE_ADDR + 0x00088000)
90#define ATA_BASE_ADDR (AIPS1_BASE_ADDR + 0x0008C000)
91#define UART1_BASE_ADDR (AIPS1_BASE_ADDR + 0x00090000)
92#define UART2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00094000)
93#define I2C2_BASE_ADDR (AIPS1_BASE_ADDR + 0x00098000)
94#define OWIRE_BASE_ADDR (AIPS1_BASE_ADDR + 0x0009C000)
95#define SSI1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A0000)
96#define CSPI1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A4000)
97#define KPP_BASE_ADDR (AIPS1_BASE_ADDR + 0x000A8000)
98#define IOMUXC_BASE_ADDR (AIPS1_BASE_ADDR + 0x000AC000)
99#define UART4_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B0000)
100#define UART5_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B4000)
101#define ECT_IP1_BASE_ADDR (AIPS1_BASE_ADDR + 0x000B8000)
102#define ECT_IP2_BASE_ADDR (AIPS1_BASE_ADDR + 0x000BC000)
103
104/*
105 * SPBA global module enabled #0
106 */
107#define SPBA0_BASE_ADDR 0x50000000
108#define SPBA0_BASE_ADDR_VIRT 0xFC100000
109#define SPBA0_SIZE SZ_1M
110
111#define MMC_SDHC1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00004000)
112#define MMC_SDHC2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00008000)
113#define UART3_BASE_ADDR (SPBA0_BASE_ADDR + 0x0000C000)
114#define CSPI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00010000)
115#define SSI2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00014000)
116#define SIM1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00018000)
117#define IIM_BASE_ADDR (SPBA0_BASE_ADDR + 0x0001C000)
118#define ATA_DMA_BASE_ADDR (SPBA0_BASE_ADDR + 0x00020000)
119#define MSHC1_BASE_ADDR (SPBA0_BASE_ADDR + 0x00024000)
120#define MSHC2_BASE_ADDR (SPBA0_BASE_ADDR + 0x00024000)
121#define SPBA_CTRL_BASE_ADDR (SPBA0_BASE_ADDR + 0x0003C000)
122
123/*
124 * AIPS 2
125 */
126#define AIPS2_BASE_ADDR 0x53F00000
127#define AIPS2_BASE_ADDR_VIRT 0xFC200000
128#define AIPS2_SIZE SZ_1M
129#define CCM_BASE_ADDR (AIPS2_BASE_ADDR + 0x00080000)
130#define CSPI3_BASE_ADDR (AIPS2_BASE_ADDR + 0x00084000)
131#define FIRI_BASE_ADDR (AIPS2_BASE_ADDR + 0x0008C000)
132#define GPT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00090000)
133#define EPIT1_BASE_ADDR (AIPS2_BASE_ADDR + 0x00094000)
134#define EPIT2_BASE_ADDR (AIPS2_BASE_ADDR + 0x00098000)
135#define GPIO3_BASE_ADDR (AIPS2_BASE_ADDR + 0x000A4000)
136#define SCC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AC000)
137#define SCM_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AE000)
138#define SMN_BASE_ADDR (AIPS2_BASE_ADDR + 0x000AF000)
139#define RNGA_BASE_ADDR (AIPS2_BASE_ADDR + 0x000B0000)
140#define IPU_CTRL_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C0000)
141#define AUDMUX_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C4000)
142#define MPEG4_ENC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000C8000)
143#define GPIO1_BASE_ADDR (AIPS2_BASE_ADDR + 0x000CC000)
144#define GPIO2_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D0000)
145#define SDMA_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D4000)
146#define RTC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000D8000)
147#define WDOG_BASE_ADDR (AIPS2_BASE_ADDR + 0x000DC000)
148#define PWM_BASE_ADDR (AIPS2_BASE_ADDR + 0x000E0000)
149#define RTIC_BASE_ADDR (AIPS2_BASE_ADDR + 0x000EC000)
150
151/*
152 * ROMP and AVIC
153 */
154#define ROMP_BASE_ADDR 0x60000000
155#define ROMP_BASE_ADDR_VIRT 0xFC500000
156#define ROMP_SIZE SZ_1M
157
158#define AVIC_BASE_ADDR 0x68000000
159#define AVIC_BASE_ADDR_VIRT 0xFC400000
160#define AVIC_SIZE SZ_1M
161
162/*
163 * NAND, SDRAM, WEIM, M3IF, EMI controllers
164 */
165#define X_MEMC_BASE_ADDR 0xB8000000
166#define X_MEMC_BASE_ADDR_VIRT 0xFC320000
167#define X_MEMC_SIZE SZ_64K
168
169#define NFC_BASE_ADDR (X_MEMC_BASE_ADDR + 0x0000)
170#define ESDCTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x1000)
171#define WEIM_BASE_ADDR (X_MEMC_BASE_ADDR + 0x2000)
172#define M3IF_BASE_ADDR (X_MEMC_BASE_ADDR + 0x3000)
173#define EMI_CTL_BASE_ADDR (X_MEMC_BASE_ADDR + 0x4000)
174#define PCMCIA_CTL_BASE_ADDR EMI_CTL_BASE_ADDR
175
176/*
177 * Memory regions and CS
178 */
179#define IPU_MEM_BASE_ADDR 0x70000000
180#define CSD0_BASE_ADDR 0x80000000
181#define CSD1_BASE_ADDR 0x90000000
182#define CS0_BASE_ADDR 0xA0000000
183#define CS1_BASE_ADDR 0xA8000000
184#define CS2_BASE_ADDR 0xB0000000
185#define CS3_BASE_ADDR 0xB2000000
186
187#define CS4_BASE_ADDR 0xB4000000
188#define CS4_BASE_ADDR_VIRT 0xF4000000
189#define CS4_SIZE SZ_32M
190
191#define CS5_BASE_ADDR 0xB6000000
192#define PCMCIA_MEM_BASE_ADDR 0xBC000000
193
194/*!
195 * This macro defines the physical to virtual address mapping for all the
196 * peripheral modules. It is used by passing in the physical address as x
197 * and returning the virtual address. If the physical address is not mapped,
198 * it returns 0xDEADBEEF
199 */
200#define IO_ADDRESS(x) \
201 (((x >= IRAM_BASE_ADDR) && (x < (IRAM_BASE_ADDR + IRAM_SIZE))) ? IRAM_IO_ADDRESS(x):\
202 ((x >= L2CC_BASE_ADDR) && (x < (L2CC_BASE_ADDR + L2CC_SIZE))) ? L2CC_IO_ADDRESS(x):\
203 ((x >= AIPS1_BASE_ADDR) && (x < (AIPS1_BASE_ADDR + AIPS1_SIZE))) ? AIPS1_IO_ADDRESS(x):\
204 ((x >= SPBA0_BASE_ADDR) && (x < (SPBA0_BASE_ADDR + SPBA0_SIZE))) ? SPBA0_IO_ADDRESS(x):\
205 ((x >= AIPS2_BASE_ADDR) && (x < (AIPS2_BASE_ADDR + AIPS2_SIZE))) ? AIPS2_IO_ADDRESS(x):\
206 ((x >= ROMP_BASE_ADDR) && (x < (ROMP_BASE_ADDR + ROMP_SIZE))) ? ROMP_IO_ADDRESS(x):\
207 ((x >= AVIC_BASE_ADDR) && (x < (AVIC_BASE_ADDR + AVIC_SIZE))) ? AVIC_IO_ADDRESS(x):\
208 ((x >= CS4_BASE_ADDR) && (x < (CS4_BASE_ADDR + CS4_SIZE))) ? CS4_IO_ADDRESS(x):\
209 ((x >= X_MEMC_BASE_ADDR) && (x < (X_MEMC_BASE_ADDR + X_MEMC_SIZE))) ? X_MEMC_IO_ADDRESS(x):\
210 0xDEADBEEF)
211
212/*
213 * define the address mapping macros: in physical address order
214 */
215
216#define IRAM_IO_ADDRESS(x) \
217 (((x) - IRAM_BASE_ADDR) + IRAM_BASE_ADDR_VIRT)
218
219#define L2CC_IO_ADDRESS(x) \
220 (((x) - L2CC_BASE_ADDR) + L2CC_BASE_ADDR_VIRT)
221
222#define AIPS1_IO_ADDRESS(x) \
223 (((x) - AIPS1_BASE_ADDR) + AIPS1_BASE_ADDR_VIRT)
224
225#define SPBA0_IO_ADDRESS(x) \
226 (((x) - SPBA0_BASE_ADDR) + SPBA0_BASE_ADDR_VIRT)
227
228#define AIPS2_IO_ADDRESS(x) \
229 (((x) - AIPS2_BASE_ADDR) + AIPS2_BASE_ADDR_VIRT)
230
231#define ROMP_IO_ADDRESS(x) \
232 (((x) - ROMP_BASE_ADDR) + ROMP_BASE_ADDR_VIRT)
233
234#define AVIC_IO_ADDRESS(x) \
235 (((x) - AVIC_BASE_ADDR) + AVIC_BASE_ADDR_VIRT)
236
237#define CS4_IO_ADDRESS(x) \
238 (((x) - CS4_BASE_ADDR) + CS4_BASE_ADDR_VIRT)
239
240#define X_MEMC_IO_ADDRESS(x) \
241 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
242
243#define PCMCIA_IO_ADDRESS(x) \
244 (((x) - X_MEMC_BASE_ADDR) + X_MEMC_BASE_ADDR_VIRT)
245
246/* Start of physical RAM - On many MX31 platforms, this is the first SDRAM bank (CSD0) */
247#define PHYS_OFFSET CSD0_BASE_ADDR
248
249/*
250 * Interrupt numbers
251 */
252#define MXC_INT_PEN_ADS7843 0
253#define MXC_INT_RESV1 1
254#define MXC_INT_CS8900A 2
255#define MXC_INT_I2C3 3
256#define MXC_INT_I2C2 4
257#define MXC_INT_MPEG4_ENCODER 5
258#define MXC_INT_RTIC 6
259#define MXC_INT_FIRI 7
260#define MXC_INT_MMC_SDHC2 8
261#define MXC_INT_MMC_SDHC1 9
262#define MXC_INT_I2C 10
263#define MXC_INT_SSI2 11
264#define MXC_INT_SSI1 12
265#define MXC_INT_CSPI2 13
266#define MXC_INT_CSPI1 14
267#define MXC_INT_ATA 15
268#define MXC_INT_MBX 16
269#define MXC_INT_CSPI3 17
270#define MXC_INT_UART3 18
271#define MXC_INT_IIM 19
272#define MXC_INT_SIM2 20
273#define MXC_INT_SIM1 21
274#define MXC_INT_RNGA 22
275#define MXC_INT_EVTMON 23
276#define MXC_INT_KPP 24
277#define MXC_INT_RTC 25
278#define MXC_INT_PWM 26
279#define MXC_INT_EPIT2 27
280#define MXC_INT_EPIT1 28
281#define MXC_INT_GPT 29
282#define MXC_INT_RESV30 30
283#define MXC_INT_RESV31 31
284#define MXC_INT_UART2 32
285#define MXC_INT_NANDFC 33
286#define MXC_INT_SDMA 34
287#define MXC_INT_USB1 35
288#define MXC_INT_USB2 36
289#define MXC_INT_USB3 37
290#define MXC_INT_USB4 38
291#define MXC_INT_MSHC1 39
292#define MXC_INT_MSHC2 40
293#define MXC_INT_IPU_ERR 41
294#define MXC_INT_IPU_SYN 42
295#define MXC_INT_RESV43 43
296#define MXC_INT_RESV44 44
297#define MXC_INT_UART1 45
298#define MXC_INT_UART4 46
299#define MXC_INT_UART5 47
300#define MXC_INT_ECT 48
301#define MXC_INT_SCC_SCM 49
302#define MXC_INT_SCC_SMN 50
303#define MXC_INT_GPIO2 51
304#define MXC_INT_GPIO1 52
305#define MXC_INT_CCM 53
306#define MXC_INT_PCMCIA 54
307#define MXC_INT_WDOG 55
308#define MXC_INT_GPIO3 56
309#define MXC_INT_RESV57 57
310#define MXC_INT_EXT_POWER 58
311#define MXC_INT_EXT_TEMPER 59
312#define MXC_INT_EXT_SENSOR60 60
313#define MXC_INT_EXT_SENSOR61 61
314#define MXC_INT_EXT_WDOG 62
315#define MXC_INT_EXT_TV 63
316
317#define MXC_MAX_INT_LINES 64
318
319#define MXC_GPIO_INT_BASE MXC_MAX_INT_LINES
320
321/*!
322 * Number of GPIO port as defined in the IC Spec
323 */
324#define GPIO_PORT_NUM 3
325/*!
326 * Number of GPIO pins per port
327 */
328#define GPIO_NUM_PIN 32
329
330#define PROD_SIGNATURE 0x1 /* For MX31 */
331
332#define SYSTEM_REV_MIN CHIP_REV_1_0
333#define SYSTEM_REV_NUM 3
334
335#endif /* __ASM_ARCH_MXC_MX31_H__ */
diff --git a/include/asm-arm/arch-mxc/mxc.h b/include/asm-arm/arch-mxc/mxc.h
new file mode 100644
index 000000000000..0837f1f9ca31
--- /dev/null
+++ b/include/asm-arm/arch-mxc/mxc.h
@@ -0,0 +1,149 @@
1/*
2 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
3 */
4
5/*
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10
11#ifndef __ASM_ARCH_MXC_H__
12#define __ASM_ARCH_MXC_H__
13
14#ifndef __ASM_ARCH_MXC_HARDWARE_H__
15#error "Do not include directly."
16#endif
17
18/*
19 *****************************************
20 * GPT Register definitions *
21 *****************************************
22 */
23#define MXC_GPT_GPTCR IO_ADDRESS(GPT1_BASE_ADDR + 0x00)
24#define MXC_GPT_GPTPR IO_ADDRESS(GPT1_BASE_ADDR + 0x04)
25#define MXC_GPT_GPTSR IO_ADDRESS(GPT1_BASE_ADDR + 0x08)
26#define MXC_GPT_GPTIR IO_ADDRESS(GPT1_BASE_ADDR + 0x0C)
27#define MXC_GPT_GPTOCR1 IO_ADDRESS(GPT1_BASE_ADDR + 0x10)
28#define MXC_GPT_GPTOCR2 IO_ADDRESS(GPT1_BASE_ADDR + 0x14)
29#define MXC_GPT_GPTOCR3 IO_ADDRESS(GPT1_BASE_ADDR + 0x18)
30#define MXC_GPT_GPTICR1 IO_ADDRESS(GPT1_BASE_ADDR + 0x1C)
31#define MXC_GPT_GPTICR2 IO_ADDRESS(GPT1_BASE_ADDR + 0x20)
32#define MXC_GPT_GPTCNT IO_ADDRESS(GPT1_BASE_ADDR + 0x24)
33
34/*!
35 * GPT Control register bit definitions
36 */
37#define GPTCR_FO3 (1 << 31)
38#define GPTCR_FO2 (1 << 30)
39#define GPTCR_FO1 (1 << 29)
40
41#define GPTCR_OM3_SHIFT 26
42#define GPTCR_OM3_MASK (7 << GPTCR_OM3_SHIFT)
43#define GPTCR_OM3_DISCONNECTED (0 << GPTCR_OM3_SHIFT)
44#define GPTCR_OM3_TOGGLE (1 << GPTCR_OM3_SHIFT)
45#define GPTCR_OM3_CLEAR (2 << GPTCR_OM3_SHIFT)
46#define GPTCR_OM3_SET (3 << GPTCR_OM3_SHIFT)
47#define GPTCR_OM3_GENERATE_LOW (7 << GPTCR_OM3_SHIFT)
48
49#define GPTCR_OM2_SHIFT 23
50#define GPTCR_OM2_MASK (7 << GPTCR_OM2_SHIFT)
51#define GPTCR_OM2_DISCONNECTED (0 << GPTCR_OM2_SHIFT)
52#define GPTCR_OM2_TOGGLE (1 << GPTCR_OM2_SHIFT)
53#define GPTCR_OM2_CLEAR (2 << GPTCR_OM2_SHIFT)
54#define GPTCR_OM2_SET (3 << GPTCR_OM2_SHIFT)
55#define GPTCR_OM2_GENERATE_LOW (7 << GPTCR_OM2_SHIFT)
56
57#define GPTCR_OM1_SHIFT 20
58#define GPTCR_OM1_MASK (7 << GPTCR_OM1_SHIFT)
59#define GPTCR_OM1_DISCONNECTED (0 << GPTCR_OM1_SHIFT)
60#define GPTCR_OM1_TOGGLE (1 << GPTCR_OM1_SHIFT)
61#define GPTCR_OM1_CLEAR (2 << GPTCR_OM1_SHIFT)
62#define GPTCR_OM1_SET (3 << GPTCR_OM1_SHIFT)
63#define GPTCR_OM1_GENERATE_LOW (7 << GPTCR_OM1_SHIFT)
64
65#define GPTCR_IM2_SHIFT 18
66#define GPTCR_IM2_MASK (3 << GPTCR_IM2_SHIFT)
67#define GPTCR_IM2_CAPTURE_DISABLE (0 << GPTCR_IM2_SHIFT)
68#define GPTCR_IM2_CAPTURE_RISING (1 << GPTCR_IM2_SHIFT)
69#define GPTCR_IM2_CAPTURE_FALLING (2 << GPTCR_IM2_SHIFT)
70#define GPTCR_IM2_CAPTURE_BOTH (3 << GPTCR_IM2_SHIFT)
71
72#define GPTCR_IM1_SHIFT 16
73#define GPTCR_IM1_MASK (3 << GPTCR_IM1_SHIFT)
74#define GPTCR_IM1_CAPTURE_DISABLE (0 << GPTCR_IM1_SHIFT)
75#define GPTCR_IM1_CAPTURE_RISING (1 << GPTCR_IM1_SHIFT)
76#define GPTCR_IM1_CAPTURE_FALLING (2 << GPTCR_IM1_SHIFT)
77#define GPTCR_IM1_CAPTURE_BOTH (3 << GPTCR_IM1_SHIFT)
78
79#define GPTCR_SWR (1 << 15)
80#define GPTCR_FRR (1 << 9)
81
82#define GPTCR_CLKSRC_SHIFT 6
83#define GPTCR_CLKSRC_MASK (7 << GPTCR_CLKSRC_SHIFT)
84#define GPTCR_CLKSRC_NOCLOCK (0 << GPTCR_CLKSRC_SHIFT)
85#define GPTCR_CLKSRC_HIGHFREQ (2 << GPTCR_CLKSRC_SHIFT)
86#define GPTCR_CLKSRC_CLKIN (3 << GPTCR_CLKSRC_SHIFT)
87#define GPTCR_CLKSRC_CLK32K (7 << GPTCR_CLKSRC_SHIFT)
88
89#define GPTCR_STOPEN (1 << 5)
90#define GPTCR_DOZEN (1 << 4)
91#define GPTCR_WAITEN (1 << 3)
92#define GPTCR_DBGEN (1 << 2)
93
94#define GPTCR_ENMOD (1 << 1)
95#define GPTCR_ENABLE (1 << 0)
96
97#define GPTSR_OF1 (1 << 0)
98#define GPTSR_OF2 (1 << 1)
99#define GPTSR_OF3 (1 << 2)
100#define GPTSR_IF1 (1 << 3)
101#define GPTSR_IF2 (1 << 4)
102#define GPTSR_ROV (1 << 5)
103
104#define GPTIR_OF1IE GPTSR_OF1
105#define GPTIR_OF2IE GPTSR_OF2
106#define GPTIR_OF3IE GPTSR_OF3
107#define GPTIR_IF1IE GPTSR_IF1
108#define GPTIR_IF2IE GPTSR_IF2
109#define GPTIR_ROVIE GPTSR_ROV
110
111/*
112 *****************************************
113 * AVIC Registers *
114 *****************************************
115 */
116#define AVIC_BASE IO_ADDRESS(AVIC_BASE_ADDR)
117#define AVIC_INTCNTL (AVIC_BASE + 0x00) /* int control reg */
118#define AVIC_NIMASK (AVIC_BASE + 0x04) /* int mask reg */
119#define AVIC_INTENNUM (AVIC_BASE + 0x08) /* int enable number reg */
120#define AVIC_INTDISNUM (AVIC_BASE + 0x0C) /* int disable number reg */
121#define AVIC_INTENABLEH (AVIC_BASE + 0x10) /* int enable reg high */
122#define AVIC_INTENABLEL (AVIC_BASE + 0x14) /* int enable reg low */
123#define AVIC_INTTYPEH (AVIC_BASE + 0x18) /* int type reg high */
124#define AVIC_INTTYPEL (AVIC_BASE + 0x1C) /* int type reg low */
125#define AVIC_NIPRIORITY7 (AVIC_BASE + 0x20) /* norm int priority lvl7 */
126#define AVIC_NIPRIORITY6 (AVIC_BASE + 0x24) /* norm int priority lvl6 */
127#define AVIC_NIPRIORITY5 (AVIC_BASE + 0x28) /* norm int priority lvl5 */
128#define AVIC_NIPRIORITY4 (AVIC_BASE + 0x2C) /* norm int priority lvl4 */
129#define AVIC_NIPRIORITY3 (AVIC_BASE + 0x30) /* norm int priority lvl3 */
130#define AVIC_NIPRIORITY2 (AVIC_BASE + 0x34) /* norm int priority lvl2 */
131#define AVIC_NIPRIORITY1 (AVIC_BASE + 0x38) /* norm int priority lvl1 */
132#define AVIC_NIPRIORITY0 (AVIC_BASE + 0x3C) /* norm int priority lvl0 */
133#define AVIC_NIVECSR (AVIC_BASE + 0x40) /* norm int vector/status */
134#define AVIC_FIVECSR (AVIC_BASE + 0x44) /* fast int vector/status */
135#define AVIC_INTSRCH (AVIC_BASE + 0x48) /* int source reg high */
136#define AVIC_INTSRCL (AVIC_BASE + 0x4C) /* int source reg low */
137#define AVIC_INTFRCH (AVIC_BASE + 0x50) /* int force reg high */
138#define AVIC_INTFRCL (AVIC_BASE + 0x54) /* int force reg low */
139#define AVIC_NIPNDH (AVIC_BASE + 0x58) /* norm int pending high */
140#define AVIC_NIPNDL (AVIC_BASE + 0x5C) /* norm int pending low */
141#define AVIC_FIPNDH (AVIC_BASE + 0x60) /* fast int pending high */
142#define AVIC_FIPNDL (AVIC_BASE + 0x64) /* fast int pending low */
143
144#define SYSTEM_PREV_REG IO_ADDRESS(IIM_BASE_ADDR + 0x20)
145#define SYSTEM_SREV_REG IO_ADDRESS(IIM_BASE_ADDR + 0x24)
146#define IIM_PROD_REV_SH 3
147#define IIM_PROD_REV_LEN 5
148
149#endif /* __ASM_ARCH_MXC_H__ */
diff --git a/include/asm-arm/arch-mxc/system.h b/include/asm-arm/arch-mxc/system.h
new file mode 100644
index 000000000000..109956b41aca
--- /dev/null
+++ b/include/asm-arm/arch-mxc/system.h
@@ -0,0 +1,50 @@
1/*
2 * Copyright (C) 1999 ARM Limited
3 * Copyright (C) 2000 Deep Blue Solutions Ltd
4 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef __ASM_ARCH_MXC_SYSTEM_H__
22#define __ASM_ARCH_MXC_SYSTEM_H__
23
24/*!
25 * @file system.h
26 * @brief This file contains idle and reset functions.
27 *
28 * @ingroup System
29 */
30
31/*!
32 * This function puts the CPU into idle mode. It is called by default_idle()
33 * in process.c file.
34 */
35static inline void arch_idle(void)
36{
37 cpu_do_idle();
38}
39
40/*
41 * This function resets the system. It is called by machine_restart().
42 *
43 * @param mode indicates different kinds of resets
44 */
45static inline void arch_reset(char mode)
46{
47 cpu_reset(0);
48}
49
50#endif /* __ASM_ARCH_MXC_SYSTEM_H__ */
diff --git a/include/asm-arm/arch-mxc/timex.h b/include/asm-arm/arch-mxc/timex.h
new file mode 100644
index 000000000000..59019fa58f82
--- /dev/null
+++ b/include/asm-arm/arch-mxc/timex.h
@@ -0,0 +1,25 @@
1/*
2 * Copyright (C) 1999 ARM Limited
3 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef __ASM_ARCH_MXC_TIMEX_H__
21#define __ASM_ARCH_MXC_TIMEX_H__
22
23#include <asm/hardware.h> /* for CLOCK_TICK_RATE */
24
25#endif /* __ASM_ARCH_MXC_TIMEX_H__ */
diff --git a/include/asm-arm/arch-mxc/uncompress.h b/include/asm-arm/arch-mxc/uncompress.h
new file mode 100644
index 000000000000..ec5787d0e78c
--- /dev/null
+++ b/include/asm-arm/arch-mxc/uncompress.h
@@ -0,0 +1,79 @@
1/*
2 * include/asm-arm/arch-mxc/uncompress.h
3 *
4 *
5 *
6 * Copyright (C) 1999 ARM Limited
7 * Copyright (C) Shane Nay (shane@minirl.com)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23#ifndef __ASM_ARCH_MXC_UNCOMPRESS_H__
24#define __ASM_ARCH_MXC_UNCOMPRESS_H__
25
26#define __MXC_BOOT_UNCOMPRESS
27
28#include <asm/hardware.h>
29#include <asm/processor.h>
30
31#define UART(x) (*(volatile unsigned long *)(serial_port + (x)))
32
33#define USR2 0x98
34#define USR2_TXFE (1<<14)
35#define TXR 0x40
36#define UCR1 0x80
37#define UCR1_UARTEN 1
38
39/*
40 * The following code assumes the serial port has already been
41 * initialized by the bootloader. We search for the first enabled
42 * port in the most probable order. If you didn't setup a port in
43 * your bootloader then nothing will appear (which might be desired).
44 *
45 * This does not append a newline
46 */
47
48static void putc(int ch)
49{
50 static unsigned long serial_port = 0;
51
52 if (unlikely(serial_port == 0)) {
53 do {
54 serial_port = UART1_BASE_ADDR;
55 if (UART(UCR1) & UCR1_UARTEN)
56 break;
57 serial_port = UART2_BASE_ADDR;
58 if (UART(UCR1) & UCR1_UARTEN)
59 break;
60 return;
61 } while (0);
62 }
63
64 while (!(UART(USR2) & USR2_TXFE))
65 cpu_relax();
66
67 UART(TXR) = ch;
68}
69
70#define flush() do { } while (0)
71
72/*
73 * nothing to do
74 */
75#define arch_decomp_setup()
76
77#define arch_decomp_wdog()
78
79#endif /* __ASM_ARCH_MXC_UNCOMPRESS_H__ */
diff --git a/include/asm-arm/arch-mxc/vmalloc.h b/include/asm-arm/arch-mxc/vmalloc.h
new file mode 100644
index 000000000000..83a73da895eb
--- /dev/null
+++ b/include/asm-arm/arch-mxc/vmalloc.h
@@ -0,0 +1,36 @@
1/*
2 * Copyright (C) 2000 Russell King.
3 * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19
20#ifndef __ASM_ARCH_MXC_VMALLOC_H__
21#define __ASM_ARCH_MXC_VMALLOC_H__
22
23/*!
24 * @file vmalloc.h
25 *
26 * @brief This file contains platform specific macros for vmalloc.
27 *
28 * @ingroup System
29 */
30
31/*!
32 * vmalloc ending address
33 */
34#define VMALLOC_END 0xF4000000
35
36#endif /* __ASM_ARCH_MXC_VMALLOC_H__ */
diff --git a/include/asm-arm/arch-ns9xxx/regs-bbu.h b/include/asm-arm/arch-ns9xxx/regs-bbu.h
index e26269546240..7ee194dc6354 100644
--- a/include/asm-arm/arch-ns9xxx/regs-bbu.h
+++ b/include/asm-arm/arch-ns9xxx/regs-bbu.h
@@ -15,7 +15,31 @@
15 15
16/* BBus Utility */ 16/* BBus Utility */
17 17
18/* GPIO Configuration Register */ 18/* GPIO Configuration Registers block 1 */
19#define BBU_GC(x) __REG2(0x9060000c, (x)) 19/* NOTE: the HRM starts counting at 1 for the GPIO registers, here the start is
20 * at 0 for each block. That is, BBU_GCONFb1(0) is GPIO Configuration Register
21 * #1, BBU_GCONFb2(0) is GPIO Configuration Register #8. */
22#define BBU_GCONFb1(x) __REG2(0x90600010, (x))
23#define BBU_GCONFb2(x) __REG2(0x90600100, (x))
24
25#define BBU_GCONFx_DIR(m) __REGBIT(3 + (((m) & 7) << 2))
26#define BBU_GCONFx_DIR_INPUT(m) __REGVAL(BBU_GCONFx_DIR(m), 0)
27#define BBU_GCONFx_DIR_OUTPUT(m) __REGVAL(BBU_GCONFx_DIR(m), 1)
28#define BBU_GCONFx_INV(m) __REGBIT(2 + (((m) & 7) << 2))
29#define BBU_GCONFx_INV_NO(m) __REGVAL(BBU_GCONFx_INV(m), 0)
30#define BBU_GCONFx_INV_YES(m) __REGVAL(BBU_GCONFx_INV(m), 1)
31#define BBU_GCONFx_FUNC(m) __REGBITS(1 + (((m) & 7) << 2), ((m) & 7) << 2)
32#define BBU_GCONFx_FUNC_0(m) __REGVAL(BBU_GCONFx_FUNC(m), 0)
33#define BBU_GCONFx_FUNC_1(m) __REGVAL(BBU_GCONFx_FUNC(m), 1)
34#define BBU_GCONFx_FUNC_2(m) __REGVAL(BBU_GCONFx_FUNC(m), 2)
35#define BBU_GCONFx_FUNC_3(m) __REGVAL(BBU_GCONFx_FUNC(m), 3)
36
37#define BBU_GCTRL1 __REG(0x90600030)
38#define BBU_GCTRL2 __REG(0x90600034)
39#define BBU_GCTRL3 __REG(0x90600120)
40
41#define BBU_GSTAT1 __REG(0x90600040)
42#define BBU_GSTAT2 __REG(0x90600044)
43#define BBU_GSTAT3 __REG(0x90600130)
20 44
21#endif /* ifndef __ASM_ARCH_REGSBBU_H */ 45#endif /* ifndef __ASM_ARCH_REGSBBU_H */
diff --git a/include/asm-arm/arch-ns9xxx/regs-mem.h b/include/asm-arm/arch-ns9xxx/regs-mem.h
index 8ed8448767b9..fb455a0ed845 100644
--- a/include/asm-arm/arch-ns9xxx/regs-mem.h
+++ b/include/asm-arm/arch-ns9xxx/regs-mem.h
@@ -79,9 +79,9 @@
79#define MEM_SMC(x) __REG2(0xa0700200, (x) << 3) 79#define MEM_SMC(x) __REG2(0xa0700200, (x) << 3)
80 80
81/* Static Memory Configuration Register x: Write protect */ 81/* Static Memory Configuration Register x: Write protect */
82#define MEM_SMC_WSMC __REGBIT(20) 82#define MEM_SMC_PSMC __REGBIT(20)
83#define MEM_SMC_WSMC_OFF __REGVAL(MEM_SMC_WSMC, 0) 83#define MEM_SMC_PSMC_OFF __REGVAL(MEM_SMC_PSMC, 0)
84#define MEM_SMC_WSMC_ON __REGVAL(MEM_SMC_WSMC, 1) 84#define MEM_SMC_PSMC_ON __REGVAL(MEM_SMC_PSMC, 1)
85 85
86/* Static Memory Configuration Register x: Buffer enable */ 86/* Static Memory Configuration Register x: Buffer enable */
87#define MEM_SMC_BSMC __REGBIT(19) 87#define MEM_SMC_BSMC __REGBIT(19)
diff --git a/include/asm-arm/arch-ns9xxx/regs-sys.h b/include/asm-arm/arch-ns9xxx/regs-sys.h
index a42546aeb92a..749262f86204 100644
--- a/include/asm-arm/arch-ns9xxx/regs-sys.h
+++ b/include/asm-arm/arch-ns9xxx/regs-sys.h
@@ -64,7 +64,7 @@
64 64
65/* Timer x Control register: Timer enable */ 65/* Timer x Control register: Timer enable */
66#define SYS_TCx_TEN __REGBIT(15) 66#define SYS_TCx_TEN __REGBIT(15)
67#define SYS_TCx_TEN_DIS __REGVAL(SYS_TCx_TEN, 1) 67#define SYS_TCx_TEN_DIS __REGVAL(SYS_TCx_TEN, 0)
68#define SYS_TCx_TEN_EN __REGVAL(SYS_TCx_TEN, 1) 68#define SYS_TCx_TEN_EN __REGVAL(SYS_TCx_TEN, 1)
69 69
70/* Timer x Control register: CPU debug mode */ 70/* Timer x Control register: CPU debug mode */
diff --git a/include/asm-arm/arch-pxa/pm.h b/include/asm-arm/arch-pxa/pm.h
index 52243a62c4e7..6903db7fae15 100644
--- a/include/asm-arm/arch-pxa/pm.h
+++ b/include/asm-arm/arch-pxa/pm.h
@@ -7,5 +7,19 @@
7 * 7 *
8 */ 8 */
9 9
10extern int pxa_pm_prepare(suspend_state_t state); 10struct pxa_cpu_pm_fns {
11 int save_size;
12 void (*save)(unsigned long *);
13 void (*restore)(unsigned long *);
14 int (*valid)(suspend_state_t state);
15 void (*enter)(suspend_state_t state);
16};
17
18extern struct pxa_cpu_pm_fns *pxa_cpu_pm_fns;
19
20/* sleep.S */
21extern void pxa25x_cpu_suspend(unsigned int);
22extern void pxa27x_cpu_suspend(unsigned int);
23extern void pxa_cpu_resume(void);
24
11extern int pxa_pm_enter(suspend_state_t state); 25extern int pxa_pm_enter(suspend_state_t state);
diff --git a/include/asm-arm/arch-s3c2400/map.h b/include/asm-arm/arch-s3c2400/map.h
new file mode 100644
index 000000000000..1184d907b31e
--- /dev/null
+++ b/include/asm-arm/arch-s3c2400/map.h
@@ -0,0 +1,66 @@
1/* linux/include/asm-arm/arch-s3c2400/map.h
2 *
3 * Copyright 2003,2007 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * Copyright 2003, Lucas Correia Villa Real
8 *
9 * S3C2400 - Memory map definitions
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
14*/
15
16#define S3C2400_PA_MEMCTRL (0x14000000)
17#define S3C2400_PA_USBHOST (0x14200000)
18#define S3C2400_PA_IRQ (0x14400000)
19#define S3C2400_PA_DMA (0x14600000)
20#define S3C2400_PA_CLKPWR (0x14800000)
21#define S3C2400_PA_LCD (0x14A00000)
22#define S3C2400_PA_UART (0x15000000)
23#define S3C2400_PA_TIMER (0x15100000)
24#define S3C2400_PA_USBDEV (0x15200140)
25#define S3C2400_PA_WATCHDOG (0x15300000)
26#define S3C2400_PA_IIC (0x15400000)
27#define S3C2400_PA_IIS (0x15508000)
28#define S3C2400_PA_GPIO (0x15600000)
29#define S3C2400_PA_RTC (0x15700040)
30#define S3C2400_PA_ADC (0x15800000)
31#define S3C2400_PA_SPI (0x15900000)
32
33#define S3C2400_PA_MMC (0x15A00000)
34#define S3C2400_SZ_MMC SZ_1M
35
36/* physical addresses of all the chip-select areas */
37
38#define S3C2400_CS0 (0x00000000)
39#define S3C2400_CS1 (0x02000000)
40#define S3C2400_CS2 (0x04000000)
41#define S3C2400_CS3 (0x06000000)
42#define S3C2400_CS4 (0x08000000)
43#define S3C2400_CS5 (0x0A000000)
44#define S3C2400_CS6 (0x0C000000)
45#define S3C2400_CS7 (0x0E000000)
46
47#define S3C2400_SDRAM_PA (S3C2400_CS6)
48
49/* Use a single interface for common resources between S3C24XX cpus */
50
51#define S3C24XX_PA_IRQ S3C2400_PA_IRQ
52#define S3C24XX_PA_MEMCTRL S3C2400_PA_MEMCTRL
53#define S3C24XX_PA_USBHOST S3C2400_PA_USBHOST
54#define S3C24XX_PA_DMA S3C2400_PA_DMA
55#define S3C24XX_PA_CLKPWR S3C2400_PA_CLKPWR
56#define S3C24XX_PA_LCD S3C2400_PA_LCD
57#define S3C24XX_PA_UART S3C2400_PA_UART
58#define S3C24XX_PA_TIMER S3C2400_PA_TIMER
59#define S3C24XX_PA_USBDEV S3C2400_PA_USBDEV
60#define S3C24XX_PA_WATCHDOG S3C2400_PA_WATCHDOG
61#define S3C24XX_PA_IIC S3C2400_PA_IIC
62#define S3C24XX_PA_IIS S3C2400_PA_IIS
63#define S3C24XX_PA_GPIO S3C2400_PA_GPIO
64#define S3C24XX_PA_RTC S3C2400_PA_RTC
65#define S3C24XX_PA_ADC S3C2400_PA_ADC
66#define S3C24XX_PA_SPI S3C2400_PA_SPI
diff --git a/include/asm-arm/arch-s3c2400/memory.h b/include/asm-arm/arch-s3c2400/memory.h
new file mode 100644
index 000000000000..fb0381dde704
--- /dev/null
+++ b/include/asm-arm/arch-s3c2400/memory.h
@@ -0,0 +1,23 @@
1/* linux/include/asm-arm/arch-s3c2400/memory.h
2 * from linux/include/asm-arm/arch-rpc/memory.h
3 *
4 * Copyright 2007 Simtec Electronics
5 * http://armlinux.simtec.co.uk/
6 * Ben Dooks <ben@simtec.co.uk>
7 *
8 * Copyright (C) 1996,1997,1998 Russell King.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13*/
14
15#ifndef __ASM_ARCH_MEMORY_H
16#define __ASM_ARCH_MEMORY_H
17
18#define PHYS_OFFSET UL(0x0C000000)
19
20#define __virt_to_bus(x) __virt_to_phys(x)
21#define __bus_to_virt(x) __phys_to_virt(x)
22
23#endif
diff --git a/include/asm-arm/arch-s3c2410/debug-macro.S b/include/asm-arm/arch-s3c2410/debug-macro.S
index 93064860e0e5..9c8cd9abb82b 100644
--- a/include/asm-arm/arch-s3c2410/debug-macro.S
+++ b/include/asm-arm/arch-s3c2410/debug-macro.S
@@ -13,32 +13,23 @@
13*/ 13*/
14 14
15#include <asm/arch/map.h> 15#include <asm/arch/map.h>
16#include <asm/arch/regs-serial.h>
17#include <asm/arch/regs-gpio.h> 16#include <asm/arch/regs-gpio.h>
17#include <asm/plat-s3c/regs-serial.h>
18 18
19#define S3C2410_UART1_OFF (0x4000) 19#define S3C2410_UART1_OFF (0x4000)
20#define SHIFT_2440TXF (14-9) 20#define SHIFT_2440TXF (14-9)
21 21
22 .macro addruart, rx 22 .macro addruart, rx
23 mrc p15, 0, \rx, c1, c0 23 mrc p15, 0, \rx, c1, c0
24 tst \rx, #1 24 tst \rx, #1
25 ldreq \rx, = S3C24XX_PA_UART 25 ldreq \rx, = S3C24XX_PA_UART
26 ldrne \rx, = S3C24XX_VA_UART 26 ldrne \rx, = S3C24XX_VA_UART
27#if CONFIG_DEBUG_S3C2410_UART != 0 27#if CONFIG_DEBUG_S3C_UART != 0
28 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C2410_UART) 28 add \rx, \rx, #(S3C2410_UART1_OFF * CONFIG_DEBUG_S3C_UART)
29#endif 29#endif
30 .endm 30 .endm
31 31
32 .macro senduart,rd,rx 32 .macro fifo_full_s3c24xx rd, rx
33 strb \rd, [\rx, # S3C2410_UTXH ]
34 .endm
35
36 .macro busyuart, rd, rx
37 ldr \rd, [ \rx, # S3C2410_UFCON ]
38 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled?
39 beq 1001f @
40 @ FIFO enabled...
411003:
42 @ check for arm920 vs arm926. currently assume all arm926 33 @ check for arm920 vs arm926. currently assume all arm926
43 @ devices have an 64 byte FIFO identical to the s3c2440 34 @ devices have an 64 byte FIFO identical to the s3c2440
44 mrc p15, 0, \rd, c0, c0 35 mrc p15, 0, \rd, c0, c0
@@ -57,25 +48,22 @@
57 ldr \rd, [ \rx, # S3C2410_UFSTAT ] 48 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
58 moveq \rd, \rd, lsr #SHIFT_2440TXF 49 moveq \rd, \rd, lsr #SHIFT_2440TXF
59 tst \rd, #S3C2410_UFSTAT_TXFULL 50 tst \rd, #S3C2410_UFSTAT_TXFULL
60 bne 1003b 51 .endm
61 b 1002f
62
631001:
64 @ busy waiting for non fifo
65 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
66 tst \rd, #S3C2410_UTRSTAT_TXFE
67 beq 1001b
68 52
691002: @ exit busyuart 53 .macro fifo_full_s3c2410 rd, rx
70 .endm 54 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
55 tst \rd, #S3C2410_UFSTAT_TXFULL
56 .endm
71 57
72 .macro waituart,rd,rx 58/* fifo level reading */
73 59
74 ldr \rd, [ \rx, # S3C2410_UFCON ] 60 .macro fifo_level_s3c24xx rd, rx
75 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled? 61 @ check for arm920 vs arm926. currently assume all arm926
76 beq 1001f @ 62 @ devices have an 64 byte FIFO identical to the s3c2440
77 @ FIFO enabled... 63 mrc p15, 0, \rd, c0, c0
781003: 64 and \rd, \rd, #0xff0
65 teq \rd, #0x260
66 beq 10000f
79 mrc p15, 0, \rd, c1, c0 67 mrc p15, 0, \rd, c1, c0
80 tst \rd, #1 68 tst \rd, #1
81 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART) 69 addeq \rd, \rx, #(S3C24XX_PA_GPIO - S3C24XX_PA_UART)
@@ -85,18 +73,32 @@
85 and \rd, \rd, #0x00ff0000 73 and \rd, \rd, #0x00ff0000
86 teq \rd, #0x00440000 @ is it 2440? 74 teq \rd, #0x00440000 @ is it 2440?
87 75
7610000:
88 ldr \rd, [ \rx, # S3C2410_UFSTAT ] 77 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
89 andne \rd, \rd, #S3C2410_UFSTAT_TXMASK 78 andne \rd, \rd, #S3C2410_UFSTAT_TXMASK
90 andeq \rd, \rd, #S3C2440_UFSTAT_TXMASK 79 andeq \rd, \rd, #S3C2440_UFSTAT_TXMASK
91 teq \rd, #0 80 .endm
92 bne 1003b 81
93 b 1002f 82 .macro fifo_level_s3c2410 rd, rx
83 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
84 and \rd, \rd, #S3C2410_UFSTAT_TXMASK
85 .endm
86
87/* Select the correct implementation depending on the configuration. The
88 * S3C2440 will get selected by default, as these are the most widely
89 * used variants of these
90*/
91
92#if defined(CONFIG_CPU_LLSERIAL_S3C2410_ONLY)
93#define fifo_full fifo_full_s3c2410
94#define fifo_level fifo_level_s3c2410
95#warning 2410only
96#elif !defined(CONFIG_CPU_LLSERIAL_S3C2440_ONLY)
97#define fifo_full fifo_full_s3c24xx
98#define fifo_level fifo_level_s3c24xx
99#warning generic
100#endif
94 101
951001: 102/* include the reset of the code which will do the work */
96 @ idle waiting for non fifo
97 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
98 tst \rd, #S3C2410_UTRSTAT_TXFE
99 beq 1001b
100 103
1011002: @ exit busyuart 104#include <asm/plat-s3c/debug-macro.S>
102 .endm
diff --git a/include/asm-arm/arch-s3c2410/map.h b/include/asm-arm/arch-s3c2410/map.h
index 19e77f038042..b33ed3b05ef5 100644
--- a/include/asm-arm/arch-s3c2410/map.h
+++ b/include/asm-arm/arch-s3c2410/map.h
@@ -13,58 +13,36 @@
13#ifndef __ASM_ARCH_MAP_H 13#ifndef __ASM_ARCH_MAP_H
14#define __ASM_ARCH_MAP_H 14#define __ASM_ARCH_MAP_H
15 15
16/* we have a bit of a tight squeeze to fit all our registers from 16#include <asm/plat-s3c/map.h>
17 * 0xF00000000 upwards, since we use all of the nGCS space in some
18 * capacity, and also need to fit the S3C2410 registers in as well...
19 *
20 * we try to ensure stuff like the IRQ registers are available for
21 * an single MOVS instruction (ie, only 8 bits of set data)
22 *
23 * Note, we are trying to remove some of these from the implementation
24 * as they are only useful to certain drivers...
25 */
26
27#ifndef __ASSEMBLY__
28#define S3C2410_ADDR(x) ((void __iomem __force *)0xF0000000 + (x))
29#else
30#define S3C2410_ADDR(x) (0xF0000000 + (x))
31#endif
32 17
33#define S3C2400_ADDR(x) S3C2410_ADDR(x) 18#define S3C2410_ADDR(x) S3C_ADDR(x)
34 19
35/* interrupt controller is the first thing we put in, to make 20/* interrupt controller is the first thing we put in, to make
36 * the assembly code for the irq detection easier 21 * the assembly code for the irq detection easier
37 */ 22 */
38#define S3C24XX_VA_IRQ S3C2410_ADDR(0x00000000) 23#define S3C24XX_VA_IRQ S3C_VA_IRQ
39#define S3C2400_PA_IRQ (0x14400000)
40#define S3C2410_PA_IRQ (0x4A000000) 24#define S3C2410_PA_IRQ (0x4A000000)
41#define S3C24XX_SZ_IRQ SZ_1M 25#define S3C24XX_SZ_IRQ SZ_1M
42 26
43/* memory controller registers */ 27/* memory controller registers */
44#define S3C24XX_VA_MEMCTRL S3C2410_ADDR(0x00100000) 28#define S3C24XX_VA_MEMCTRL S3C_VA_MEM
45#define S3C2400_PA_MEMCTRL (0x14000000)
46#define S3C2410_PA_MEMCTRL (0x48000000) 29#define S3C2410_PA_MEMCTRL (0x48000000)
47#define S3C24XX_SZ_MEMCTRL SZ_1M 30#define S3C24XX_SZ_MEMCTRL SZ_1M
48 31
49/* USB host controller */ 32/* USB host controller */
50#define S3C2400_PA_USBHOST (0x14200000)
51#define S3C2410_PA_USBHOST (0x49000000) 33#define S3C2410_PA_USBHOST (0x49000000)
52#define S3C24XX_SZ_USBHOST SZ_1M 34#define S3C24XX_SZ_USBHOST SZ_1M
53 35
54/* DMA controller */ 36/* DMA controller */
55#define S3C2400_PA_DMA (0x14600000)
56#define S3C2410_PA_DMA (0x4B000000) 37#define S3C2410_PA_DMA (0x4B000000)
57#define S3C24XX_SZ_DMA SZ_1M 38#define S3C24XX_SZ_DMA SZ_1M
58 39
59/* Clock and Power management */ 40/* Clock and Power management */
60#define S3C24XX_VA_CLKPWR S3C2410_ADDR(0x00200000) 41#define S3C24XX_VA_CLKPWR S3C_VA_SYS
61#define S3C2400_PA_CLKPWR (0x14800000)
62#define S3C2410_PA_CLKPWR (0x4C000000) 42#define S3C2410_PA_CLKPWR (0x4C000000)
63#define S3C24XX_SZ_CLKPWR SZ_1M 43#define S3C24XX_SZ_CLKPWR SZ_1M
64 44
65/* LCD controller */ 45/* LCD controller */
66#define S3C24XX_VA_LCD S3C2410_ADDR(0x00300000)
67#define S3C2400_PA_LCD (0x14A00000)
68#define S3C2410_PA_LCD (0x4D000000) 46#define S3C2410_PA_LCD (0x4D000000)
69#define S3C24XX_SZ_LCD SZ_1M 47#define S3C24XX_SZ_LCD SZ_1M
70 48
@@ -72,41 +50,30 @@
72#define S3C2410_PA_NAND (0x4E000000) 50#define S3C2410_PA_NAND (0x4E000000)
73#define S3C24XX_SZ_NAND SZ_1M 51#define S3C24XX_SZ_NAND SZ_1M
74 52
75/* MMC controller - available on the S3C2400 */
76#define S3C2400_PA_MMC (0x15A00000)
77#define S3C2400_SZ_MMC SZ_1M
78
79/* UARTs */ 53/* UARTs */
80#define S3C24XX_VA_UART S3C2410_ADDR(0x00400000) 54#define S3C24XX_VA_UART S3C_VA_UART
81#define S3C2400_PA_UART (0x15000000)
82#define S3C2410_PA_UART (0x50000000) 55#define S3C2410_PA_UART (0x50000000)
83#define S3C24XX_SZ_UART SZ_1M 56#define S3C24XX_SZ_UART SZ_1M
84 57
85/* Timers */ 58/* Timers */
86#define S3C24XX_VA_TIMER S3C2410_ADDR(0x00500000) 59#define S3C24XX_VA_TIMER S3C_VA_TIMER
87#define S3C2400_PA_TIMER (0x15100000)
88#define S3C2410_PA_TIMER (0x51000000) 60#define S3C2410_PA_TIMER (0x51000000)
89#define S3C24XX_SZ_TIMER SZ_1M 61#define S3C24XX_SZ_TIMER SZ_1M
90 62
91/* USB Device port */ 63/* USB Device port */
92#define S3C24XX_VA_USBDEV S3C2410_ADDR(0x00600000)
93#define S3C2400_PA_USBDEV (0x15200140)
94#define S3C2410_PA_USBDEV (0x52000000) 64#define S3C2410_PA_USBDEV (0x52000000)
95#define S3C24XX_SZ_USBDEV SZ_1M 65#define S3C24XX_SZ_USBDEV SZ_1M
96 66
97/* Watchdog */ 67/* Watchdog */
98#define S3C24XX_VA_WATCHDOG S3C2410_ADDR(0x00700000) 68#define S3C24XX_VA_WATCHDOG S3C_VA_WATCHDOG
99#define S3C2400_PA_WATCHDOG (0x15300000)
100#define S3C2410_PA_WATCHDOG (0x53000000) 69#define S3C2410_PA_WATCHDOG (0x53000000)
101#define S3C24XX_SZ_WATCHDOG SZ_1M 70#define S3C24XX_SZ_WATCHDOG SZ_1M
102 71
103/* IIC hardware controller */ 72/* IIC hardware controller */
104#define S3C2400_PA_IIC (0x15400000)
105#define S3C2410_PA_IIC (0x54000000) 73#define S3C2410_PA_IIC (0x54000000)
106#define S3C24XX_SZ_IIC SZ_1M 74#define S3C24XX_SZ_IIC SZ_1M
107 75
108/* IIS controller */ 76/* IIS controller */
109#define S3C2400_PA_IIS (0x15508000)
110#define S3C2410_PA_IIS (0x55000000) 77#define S3C2410_PA_IIS (0x55000000)
111#define S3C24XX_SZ_IIS SZ_1M 78#define S3C24XX_SZ_IIS SZ_1M
112 79
@@ -116,27 +83,23 @@
116 * it is the same distance apart from the UART in the 83 * it is the same distance apart from the UART in the
117 * phsyical address space, as the initial mapping for the IO 84 * phsyical address space, as the initial mapping for the IO
118 * is done as a 1:1 maping. This puts it (currently) at 85 * is done as a 1:1 maping. This puts it (currently) at
119 * 0xF6800000, which is not in the way of any current mapping 86 * 0xFA800000, which is not in the way of any current mapping
120 * by the base system. 87 * by the base system.
121*/ 88*/
122 89
123#define S3C2400_PA_GPIO (0x15600000)
124#define S3C2410_PA_GPIO (0x56000000) 90#define S3C2410_PA_GPIO (0x56000000)
125#define S3C24XX_VA_GPIO ((S3C2410_PA_GPIO - S3C24XX_PA_UART) + S3C24XX_VA_UART) 91#define S3C24XX_VA_GPIO ((S3C2410_PA_GPIO - S3C24XX_PA_UART) + S3C24XX_VA_UART)
126#define S3C24XX_SZ_GPIO SZ_1M 92#define S3C24XX_SZ_GPIO SZ_1M
127 93
128/* RTC */ 94/* RTC */
129#define S3C2400_PA_RTC (0x15700040)
130#define S3C2410_PA_RTC (0x57000000) 95#define S3C2410_PA_RTC (0x57000000)
131#define S3C24XX_SZ_RTC SZ_1M 96#define S3C24XX_SZ_RTC SZ_1M
132 97
133/* ADC */ 98/* ADC */
134#define S3C2400_PA_ADC (0x15800000)
135#define S3C2410_PA_ADC (0x58000000) 99#define S3C2410_PA_ADC (0x58000000)
136#define S3C24XX_SZ_ADC SZ_1M 100#define S3C24XX_SZ_ADC SZ_1M
137 101
138/* SPI */ 102/* SPI */
139#define S3C2400_PA_SPI (0x15900000)
140#define S3C2410_PA_SPI (0x59000000) 103#define S3C2410_PA_SPI (0x59000000)
141#define S3C24XX_SZ_SPI SZ_1M 104#define S3C24XX_SZ_SPI SZ_1M
142 105
@@ -177,37 +140,8 @@
177 140
178#define S3C2410_SDRAM_PA (S3C2410_CS6) 141#define S3C2410_SDRAM_PA (S3C2410_CS6)
179 142
180#define S3C2400_CS0 (0x00000000)
181#define S3C2400_CS1 (0x02000000)
182#define S3C2400_CS2 (0x04000000)
183#define S3C2400_CS3 (0x06000000)
184#define S3C2400_CS4 (0x08000000)
185#define S3C2400_CS5 (0x0A000000)
186#define S3C2400_CS6 (0x0C000000)
187#define S3C2400_CS7 (0x0E000000)
188
189#define S3C2400_SDRAM_PA (S3C2400_CS6)
190
191/* Use a single interface for common resources between S3C24XX cpus */ 143/* Use a single interface for common resources between S3C24XX cpus */
192 144
193#ifdef CONFIG_CPU_S3C2400
194#define S3C24XX_PA_IRQ S3C2400_PA_IRQ
195#define S3C24XX_PA_MEMCTRL S3C2400_PA_MEMCTRL
196#define S3C24XX_PA_USBHOST S3C2400_PA_USBHOST
197#define S3C24XX_PA_DMA S3C2400_PA_DMA
198#define S3C24XX_PA_CLKPWR S3C2400_PA_CLKPWR
199#define S3C24XX_PA_LCD S3C2400_PA_LCD
200#define S3C24XX_PA_UART S3C2400_PA_UART
201#define S3C24XX_PA_TIMER S3C2400_PA_TIMER
202#define S3C24XX_PA_USBDEV S3C2400_PA_USBDEV
203#define S3C24XX_PA_WATCHDOG S3C2400_PA_WATCHDOG
204#define S3C24XX_PA_IIC S3C2400_PA_IIC
205#define S3C24XX_PA_IIS S3C2400_PA_IIS
206#define S3C24XX_PA_GPIO S3C2400_PA_GPIO
207#define S3C24XX_PA_RTC S3C2400_PA_RTC
208#define S3C24XX_PA_ADC S3C2400_PA_ADC
209#define S3C24XX_PA_SPI S3C2400_PA_SPI
210#else
211#define S3C24XX_PA_IRQ S3C2410_PA_IRQ 145#define S3C24XX_PA_IRQ S3C2410_PA_IRQ
212#define S3C24XX_PA_MEMCTRL S3C2410_PA_MEMCTRL 146#define S3C24XX_PA_MEMCTRL S3C2410_PA_MEMCTRL
213#define S3C24XX_PA_USBHOST S3C2410_PA_USBHOST 147#define S3C24XX_PA_USBHOST S3C2410_PA_USBHOST
@@ -224,7 +158,6 @@
224#define S3C24XX_PA_RTC S3C2410_PA_RTC 158#define S3C24XX_PA_RTC S3C2410_PA_RTC
225#define S3C24XX_PA_ADC S3C2410_PA_ADC 159#define S3C24XX_PA_ADC S3C2410_PA_ADC
226#define S3C24XX_PA_SPI S3C2410_PA_SPI 160#define S3C24XX_PA_SPI S3C2410_PA_SPI
227#endif
228 161
229/* deal with the registers that move under the 2412/2413 */ 162/* deal with the registers that move under the 2412/2413 */
230 163
diff --git a/include/asm-arm/arch-s3c2410/memory.h b/include/asm-arm/arch-s3c2410/memory.h
index 4be6a74c4303..533e2436e707 100644
--- a/include/asm-arm/arch-s3c2410/memory.h
+++ b/include/asm-arm/arch-s3c2410/memory.h
@@ -11,20 +11,7 @@
11#ifndef __ASM_ARCH_MEMORY_H 11#ifndef __ASM_ARCH_MEMORY_H
12#define __ASM_ARCH_MEMORY_H 12#define __ASM_ARCH_MEMORY_H
13 13
14/*
15 * DRAM starts at 0x30000000 for S3C2410/S3C2440
16 * and at 0x0C000000 for S3C2400
17 */
18#ifdef CONFIG_CPU_S3C2400
19#define PHYS_OFFSET UL(0x0C000000)
20#else
21#define PHYS_OFFSET UL(0x30000000) 14#define PHYS_OFFSET UL(0x30000000)
22#endif
23
24/*
25 * These are exactly the same on the S3C2410 as the
26 * physical memory view.
27*/
28 15
29#define __virt_to_bus(x) __virt_to_phys(x) 16#define __virt_to_bus(x) __virt_to_phys(x)
30#define __bus_to_virt(x) __phys_to_virt(x) 17#define __bus_to_virt(x) __phys_to_virt(x)
diff --git a/include/asm-arm/arch-s3c2410/regs-lcd.h b/include/asm-arm/arch-s3c2410/regs-lcd.h
index b7faeb04c0ff..76fe5f693426 100644
--- a/include/asm-arm/arch-s3c2410/regs-lcd.h
+++ b/include/asm-arm/arch-s3c2410/regs-lcd.h
@@ -12,7 +12,7 @@
12#ifndef ___ASM_ARCH_REGS_LCD_H 12#ifndef ___ASM_ARCH_REGS_LCD_H
13#define ___ASM_ARCH_REGS_LCD_H "$Id: lcd.h,v 1.3 2003/06/26 13:25:06 ben Exp $" 13#define ___ASM_ARCH_REGS_LCD_H "$Id: lcd.h,v 1.3 2003/06/26 13:25:06 ben Exp $"
14 14
15#define S3C2410_LCDREG(x) ((x) + S3C24XX_VA_LCD) 15#define S3C2410_LCDREG(x) (x)
16 16
17/* LCD control registers */ 17/* LCD control registers */
18#define S3C2410_LCDCON1 S3C2410_LCDREG(0x00) 18#define S3C2410_LCDCON1 S3C2410_LCDREG(0x00)
diff --git a/include/asm-arm/arch-s3c2410/system.h b/include/asm-arm/arch-s3c2410/system.h
index 1c74ef17da33..63891786dfa0 100644
--- a/include/asm-arm/arch-s3c2410/system.h
+++ b/include/asm-arm/arch-s3c2410/system.h
@@ -17,7 +17,7 @@
17#include <asm/arch/idle.h> 17#include <asm/arch/idle.h>
18#include <asm/arch/reset.h> 18#include <asm/arch/reset.h>
19 19
20#include <asm/arch/regs-watchdog.h> 20#include <asm/plat-s3c/regs-watchdog.h>
21#include <asm/arch/regs-clock.h> 21#include <asm/arch/regs-clock.h>
22 22
23void (*s3c24xx_idle)(void); 23void (*s3c24xx_idle)(void);
diff --git a/include/asm-arm/arch-s3c2410/uncompress.h b/include/asm-arm/arch-s3c2410/uncompress.h
index dcb2cef38f50..48a5731ee988 100644
--- a/include/asm-arm/arch-s3c2410/uncompress.h
+++ b/include/asm-arm/arch-s3c2410/uncompress.h
@@ -1,6 +1,7 @@
1/* linux/include/asm-arm/arch-s3c2410/uncompress.h 1/* linux/include/asm-arm/arch-s3c2410/uncompress.h
2 * 2 *
3 * Copyright (c) 2003 Simtec Electronics 3 * Copyright (c) 2003, 2007 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
4 * Ben Dooks <ben@simtec.co.uk> 5 * Ben Dooks <ben@simtec.co.uk>
5 * 6 *
6 * S3C2410 - uncompress code 7 * S3C2410 - uncompress code
@@ -13,153 +14,39 @@
13#ifndef __ASM_ARCH_UNCOMPRESS_H 14#ifndef __ASM_ARCH_UNCOMPRESS_H
14#define __ASM_ARCH_UNCOMPRESS_H 15#define __ASM_ARCH_UNCOMPRESS_H
15 16
16typedef unsigned int upf_t; /* cannot include linux/serial_core.h */ 17#include <asm/arch/regs-gpio.h>
17
18/* defines for UART registers */
19#include "asm/arch/regs-serial.h"
20#include "asm/arch/regs-gpio.h"
21#include "asm/arch/regs-watchdog.h"
22
23#include <asm/arch/map.h> 18#include <asm/arch/map.h>
24 19
25/* working in physical space... */ 20/* working in physical space... */
26#undef S3C2410_GPIOREG 21#undef S3C2410_GPIOREG
27#undef S3C2410_WDOGREG
28
29#define S3C2410_GPIOREG(x) ((S3C24XX_PA_GPIO + (x))) 22#define S3C2410_GPIOREG(x) ((S3C24XX_PA_GPIO + (x)))
30#define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
31 23
32/* how many bytes we allow into the FIFO at a time in FIFO mode */ 24#include <asm/plat-s3c/uncompress.h>
33#define FIFO_MAX (14)
34 25
35#define uart_base S3C24XX_PA_UART + (0x4000*CONFIG_S3C2410_LOWLEVEL_UART_PORT) 26static inline int is_arm926(void)
36
37static __inline__ void
38uart_wr(unsigned int reg, unsigned int val)
39{ 27{
40 volatile unsigned int *ptr; 28 unsigned int cpuid;
41
42 ptr = (volatile unsigned int *)(reg + uart_base);
43 *ptr = val;
44}
45 29
46static __inline__ unsigned int 30 asm volatile ("mrc p15, 0, %0, c1, c0, 0" : "=r" (cpuid));
47uart_rd(unsigned int reg)
48{
49 volatile unsigned int *ptr;
50 31
51 ptr = (volatile unsigned int *)(reg + uart_base); 32 return ((cpuid & 0xff0) == 0x260);
52 return *ptr;
53} 33}
54 34
55 35static void arch_detect_cpu(void)
56/* we can deal with the case the UARTs are being run
57 * in FIFO mode, so that we don't hold up our execution
58 * waiting for tx to happen...
59*/
60
61static void putc(int ch)
62{ 36{
63 int cpuid = S3C2410_GSTATUS1_2410; 37 unsigned int cpuid;
64 38
65#ifndef CONFIG_CPU_S3C2400
66 cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1); 39 cpuid = *((volatile unsigned int *)S3C2410_GSTATUS1);
67 cpuid &= S3C2410_GSTATUS1_IDMASK; 40 cpuid &= S3C2410_GSTATUS1_IDMASK;
68#endif
69
70 if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
71 int level;
72
73 while (1) {
74 level = uart_rd(S3C2410_UFSTAT);
75
76 if (cpuid == S3C2410_GSTATUS1_2440 ||
77 cpuid == S3C2410_GSTATUS1_2442) {
78 level &= S3C2440_UFSTAT_TXMASK;
79 level >>= S3C2440_UFSTAT_TXSHIFT;
80 } else {
81 level &= S3C2410_UFSTAT_TXMASK;
82 level >>= S3C2410_UFSTAT_TXSHIFT;
83 }
84
85 if (level < FIFO_MAX)
86 break;
87 }
88 41
42 if (is_arm926() || cpuid == S3C2410_GSTATUS1_2440 ||
43 cpuid == S3C2410_GSTATUS1_2442) {
44 fifo_mask = S3C2440_UFSTAT_TXMASK;
45 fifo_max = 63 << S3C2440_UFSTAT_TXSHIFT;
89 } else { 46 } else {
90 /* not using fifos */ 47 fifo_mask = S3C2410_UFSTAT_TXMASK;
91 48 fifo_max = 15 << S3C2410_UFSTAT_TXSHIFT;
92 while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
93 barrier();
94 } 49 }
95
96 /* write byte to transmission register */
97 uart_wr(S3C2410_UTXH, ch);
98} 50}
99 51
100static inline void flush(void)
101{
102}
103
104#define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
105
106/* CONFIG_S3C2410_BOOT_WATCHDOG
107 *
108 * Simple boot-time watchdog setup, to reboot the system if there is
109 * any problem with the boot process
110*/
111
112#ifdef CONFIG_S3C2410_BOOT_WATCHDOG
113
114#define WDOG_COUNT (0xff00)
115
116static inline void arch_decomp_wdog(void)
117{
118 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
119}
120
121static void arch_decomp_wdog_start(void)
122{
123 __raw_writel(WDOG_COUNT, S3C2410_WTDAT);
124 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
125 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON);
126}
127
128#else
129#define arch_decomp_wdog_start()
130#define arch_decomp_wdog()
131#endif
132
133#ifdef CONFIG_S3C2410_BOOT_ERROR_RESET
134
135static void arch_decomp_error(const char *x)
136{
137 putstr("\n\n");
138 putstr(x);
139 putstr("\n\n -- System resetting\n");
140
141 __raw_writel(0x4000, S3C2410_WTDAT);
142 __raw_writel(0x4000, S3C2410_WTCNT);
143 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
144
145 while(1);
146}
147
148#define arch_error arch_decomp_error
149#endif
150
151static void error(char *err);
152
153static void
154arch_decomp_setup(void)
155{
156 /* we may need to setup the uart(s) here if we are not running
157 * on an BAST... the BAST will have left the uarts configured
158 * after calling linux.
159 */
160
161 arch_decomp_wdog_start();
162}
163
164
165#endif /* __ASM_ARCH_UNCOMPRESS_H */ 52#endif /* __ASM_ARCH_UNCOMPRESS_H */
diff --git a/include/asm-arm/arch-sa1100/jornada720.h b/include/asm-arm/arch-sa1100/jornada720.h
new file mode 100644
index 000000000000..45d2bb59f9d0
--- /dev/null
+++ b/include/asm-arm/arch-sa1100/jornada720.h
@@ -0,0 +1,27 @@
1/*
2 * include/asm-arm/arch-sa1100/jornada720.h
3 *
4 * This file contains SSP/MCU communication definitions for HP Jornada 710/720/728
5 *
6 * Copyright (C) 2007 Kristoffer Ericson <Kristoffer.Ericson@gmail.com>
7 * Copyright (C) 2000 John Ankcorn <jca@lcs.mit.edu>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 */
14
15 /* HP Jornada 7xx microprocessor commands */
16#define GETBATTERYDATA 0xc0
17#define GETSCANKEYCODE 0x90
18#define GETTOUCHSAMPLES 0xa0
19#define GETCONTRAST 0xD0
20#define SETCONTRAST 0xD1
21#define GETBRIGHTNESS 0xD2
22#define SETBRIGHTNESS 0xD3
23#define CONTRASTOFF 0xD8
24#define BRIGHTNESSOFF 0xD9
25#define PWMOFF 0xDF
26#define TXDUMMY 0x11
27#define ERRORCODE 0x00
diff --git a/include/asm-arm/elf.h b/include/asm-arm/elf.h
index d7a777f05088..ec1c685562ce 100644
--- a/include/asm-arm/elf.h
+++ b/include/asm-arm/elf.h
@@ -1,13 +1,14 @@
1#ifndef __ASMARM_ELF_H 1#ifndef __ASMARM_ELF_H
2#define __ASMARM_ELF_H 2#define __ASMARM_ELF_H
3 3
4#include <asm/hwcap.h>
5
4#ifndef __ASSEMBLY__ 6#ifndef __ASSEMBLY__
5/* 7/*
6 * ELF register definitions.. 8 * ELF register definitions..
7 */ 9 */
8#include <asm/ptrace.h> 10#include <asm/ptrace.h>
9#include <asm/user.h> 11#include <asm/user.h>
10#include <asm/hwcap.h>
11 12
12typedef unsigned long elf_greg_t; 13typedef unsigned long elf_greg_t;
13typedef unsigned long elf_freg_t[3]; 14typedef unsigned long elf_freg_t[3];
diff --git a/include/asm-arm/floppy.h b/include/asm-arm/floppy.h
index 54b5ae44ed94..d595c15166a4 100644
--- a/include/asm-arm/floppy.h
+++ b/include/asm-arm/floppy.h
@@ -30,15 +30,21 @@
30#define fd_disable_irq() disable_irq(IRQ_FLOPPYDISK) 30#define fd_disable_irq() disable_irq(IRQ_FLOPPYDISK)
31#define fd_enable_irq() enable_irq(IRQ_FLOPPYDISK) 31#define fd_enable_irq() enable_irq(IRQ_FLOPPYDISK)
32 32
33static inline int fd_dma_setup(void *data, unsigned int length,
34 unsigned int mode, unsigned long addr)
35{
36 set_dma_mode(DMA_FLOPPY, mode);
37 __set_dma_addr(DMA_FLOPPY, data);
38 set_dma_count(DMA_FLOPPY, length);
39 virtual_dma_port = addr;
40 enable_dma(DMA_FLOPPY);
41 return 0;
42}
43#define fd_dma_setup fd_dma_setup
44
33#define fd_request_dma() request_dma(DMA_FLOPPY,"floppy") 45#define fd_request_dma() request_dma(DMA_FLOPPY,"floppy")
34#define fd_free_dma() free_dma(DMA_FLOPPY) 46#define fd_free_dma() free_dma(DMA_FLOPPY)
35#define fd_disable_dma() disable_dma(DMA_FLOPPY) 47#define fd_disable_dma() disable_dma(DMA_FLOPPY)
36#define fd_enable_dma() enable_dma(DMA_FLOPPY)
37#define fd_clear_dma_ff() clear_dma_ff(DMA_FLOPPY)
38#define fd_set_dma_mode(mode) set_dma_mode(DMA_FLOPPY, (mode))
39#define fd_set_dma_addr(addr) set_dma_addr(DMA_FLOPPY, virt_to_bus((addr)))
40#define fd_set_dma_count(len) set_dma_count(DMA_FLOPPY, (len))
41#define fd_cacheflush(addr,sz)
42 48
43/* need to clean up dma.h */ 49/* need to clean up dma.h */
44#define DMA_FLOPPYDISK DMA_FLOPPY 50#define DMA_FLOPPYDISK DMA_FLOPPY
diff --git a/include/asm-arm/hardware/iop3xx.h b/include/asm-arm/hardware/iop3xx.h
index 81ca5d3e2bff..fb90b421f31c 100644
--- a/include/asm-arm/hardware/iop3xx.h
+++ b/include/asm-arm/hardware/iop3xx.h
@@ -194,6 +194,13 @@ extern int init_atu;
194#define IOP_TMR_PRIVILEGED 0x08 194#define IOP_TMR_PRIVILEGED 0x08
195#define IOP_TMR_RATIO_1_1 0x00 195#define IOP_TMR_RATIO_1_1 0x00
196 196
197/* Watchdog timer definitions */
198#define IOP_WDTCR_EN_ARM 0x1e1e1e1e
199#define IOP_WDTCR_EN 0xe1e1e1e1
200/* iop3xx does not support stopping the watchdog, so we just re-arm */
201#define IOP_WDTCR_DIS_ARM (IOP_WDTCR_EN_ARM)
202#define IOP_WDTCR_DIS (IOP_WDTCR_EN)
203
197/* Application accelerator unit */ 204/* Application accelerator unit */
198#define IOP3XX_AAU_PHYS_BASE (IOP3XX_PERIPHERAL_PHYS_BASE + 0x800) 205#define IOP3XX_AAU_PHYS_BASE (IOP3XX_PERIPHERAL_PHYS_BASE + 0x800)
199#define IOP3XX_AAU_UPPER_PA (IOP3XX_AAU_PHYS_BASE + 0xa7) 206#define IOP3XX_AAU_UPPER_PA (IOP3XX_AAU_PHYS_BASE + 0xa7)
@@ -274,6 +281,32 @@ static inline void write_tisr(u32 val)
274 asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (val)); 281 asm volatile("mcr p6, 0, %0, c6, c1, 0" : : "r" (val));
275} 282}
276 283
284static inline u32 read_wdtcr(void)
285{
286 u32 val;
287 asm volatile("mrc p6, 0, %0, c7, c1, 0":"=r" (val));
288 return val;
289}
290static inline void write_wdtcr(u32 val)
291{
292 asm volatile("mcr p6, 0, %0, c7, c1, 0"::"r" (val));
293}
294
295extern unsigned long get_iop_tick_rate(void);
296
297/* only iop13xx has these registers, we define these to present a
298 * common register interface for the iop_wdt driver.
299 */
300#define IOP_RCSR_WDT (0)
301static inline u32 read_rcsr(void)
302{
303 return 0;
304}
305static inline void write_wdtsr(u32 val)
306{
307 do { } while (0);
308}
309
277extern struct platform_device iop3xx_dma_0_channel; 310extern struct platform_device iop3xx_dma_0_channel;
278extern struct platform_device iop3xx_dma_1_channel; 311extern struct platform_device iop3xx_dma_1_channel;
279extern struct platform_device iop3xx_aau_channel; 312extern struct platform_device iop3xx_aau_channel;
diff --git a/include/asm-arm/pgtable-nommu.h b/include/asm-arm/pgtable-nommu.h
index 0c8be19fd66b..b186bc820e30 100644
--- a/include/asm-arm/pgtable-nommu.h
+++ b/include/asm-arm/pgtable-nommu.h
@@ -102,7 +102,8 @@ extern int is_in_rom(unsigned long);
102#define v4_tlb_fns (0) 102#define v4_tlb_fns (0)
103#define v4wb_tlb_fns (0) 103#define v4wb_tlb_fns (0)
104#define v4wbi_tlb_fns (0) 104#define v4wbi_tlb_fns (0)
105#define v6_tlb_fns (0) 105#define v6wbi_tlb_fns (0)
106#define v7wbi_tlb_fns (0)
106 107
107#define v3_user_fns (0) 108#define v3_user_fns (0)
108#define v4_user_fns (0) 109#define v4_user_fns (0)
diff --git a/include/asm-arm/plat-s3c/debug-macro.S b/include/asm-arm/plat-s3c/debug-macro.S
new file mode 100644
index 000000000000..84c40b847da8
--- /dev/null
+++ b/include/asm-arm/plat-s3c/debug-macro.S
@@ -0,0 +1,75 @@
1/* linux/include/asm-arm/plat-s3c/debug-macro.S
2 *
3 * Copyright 2005, 2007 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12#include <asm/plat-s3c/regs-serial.h>
13
14/* The S3C2440 implementations are used by default as they are the
15 * most widely re-used */
16
17 .macro fifo_level_s3c2440 rd, rx
18 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
19 and \rd, \rd, #S3C2440_UFSTAT_TXMASK
20 .endm
21
22#ifndef fifo_level
23#define fifo_level fifo_level_s3c2410
24#endif
25
26 .macro fifo_full_s3c2440 rd, rx
27 ldr \rd, [ \rx, # S3C2410_UFSTAT ]
28 tst \rd, #S3C2440_UFSTAT_TXFULL
29 .endm
30
31#ifndef fifo_full
32#define fifo_full fifo_full_s3c2440
33#endif
34
35 .macro senduart,rd,rx
36 strb \rd, [\rx, # S3C2410_UTXH ]
37 .endm
38
39 .macro busyuart, rd, rx
40 ldr \rd, [ \rx, # S3C2410_UFCON ]
41 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled?
42 beq 1001f @
43 @ FIFO enabled...
441003:
45 fifo_full \rd, \rx
46 bne 1003b
47 b 1002f
48
491001:
50 @ busy waiting for non fifo
51 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
52 tst \rd, #S3C2410_UTRSTAT_TXFE
53 beq 1001b
54
551002: @ exit busyuart
56 .endm
57
58 .macro waituart,rd,rx
59 ldr \rd, [ \rx, # S3C2410_UFCON ]
60 tst \rd, #S3C2410_UFCON_FIFOMODE @ fifo enabled?
61 beq 1001f @
62 @ FIFO enabled...
631003:
64 fifo_level \rd, \rx
65 teq \rd, #0
66 bne 1003b
67 b 1002f
681001:
69 @ idle waiting for non fifo
70 ldr \rd, [ \rx, # S3C2410_UTRSTAT ]
71 tst \rd, #S3C2410_UTRSTAT_TXFE
72 beq 1001b
73
741002: @ exit busyuart
75 .endm
diff --git a/include/asm-arm/arch-s3c2410/iic.h b/include/asm-arm/plat-s3c/iic.h
index 71211c8b5384..71211c8b5384 100644
--- a/include/asm-arm/arch-s3c2410/iic.h
+++ b/include/asm-arm/plat-s3c/iic.h
diff --git a/include/asm-arm/plat-s3c/map.h b/include/asm-arm/plat-s3c/map.h
new file mode 100644
index 000000000000..95a82b0e84a1
--- /dev/null
+++ b/include/asm-arm/plat-s3c/map.h
@@ -0,0 +1,40 @@
1/* linux/include/asm-arm/plat-s3c/map.h
2 *
3 * Copyright 2003, 2007 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C - Memory map definitions (virtual addresses)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#ifndef __ASM_PLAT_MAP_H
15#define __ASM_PLAT_MAP_H __FILE__
16
17/* Fit all our registers in at 0xF4000000 upwards, trying to use as
18 * little of the VA space as possible so vmalloc and friends have a
19 * better chance of getting memory.
20 *
21 * we try to ensure stuff like the IRQ registers are available for
22 * an single MOVS instruction (ie, only 8 bits of set data)
23 */
24
25#define S3C_ADDR_BASE (0xF4000000)
26
27#ifndef __ASSEMBLY__
28#define S3C_ADDR(x) ((void __iomem __force *)S3C_ADDR_BASE + (x))
29#else
30#define S3C_ADDR(x) (S3C_ADDR_BASE + (x))
31#endif
32
33#define S3C_VA_IRQ S3C_ADDR(0x000000000) /* irq controller(s) */
34#define S3C_VA_SYS S3C_ADDR(0x001000000) /* system control */
35#define S3C_VA_MEM S3C_ADDR(0x002000000) /* system control */
36#define S3C_VA_TIMER S3C_ADDR(0x003000000) /* timer block */
37#define S3C_VA_WATCHDOG S3C_ADDR(0x004000000) /* watchdog */
38#define S3C_VA_UART S3C_ADDR(0x010000000) /* UART */
39
40#endif /* __ASM_PLAT_MAP_H */
diff --git a/include/asm-arm/arch-s3c2410/nand.h b/include/asm-arm/plat-s3c/nand.h
index 8816f7f9cee1..8816f7f9cee1 100644
--- a/include/asm-arm/arch-s3c2410/nand.h
+++ b/include/asm-arm/plat-s3c/nand.h
diff --git a/include/asm-arm/arch-s3c2410/regs-ac97.h b/include/asm-arm/plat-s3c/regs-ac97.h
index b004dee6bcaf..b004dee6bcaf 100644
--- a/include/asm-arm/arch-s3c2410/regs-ac97.h
+++ b/include/asm-arm/plat-s3c/regs-ac97.h
diff --git a/include/asm-arm/arch-s3c2410/regs-adc.h b/include/asm-arm/plat-s3c/regs-adc.h
index c7f231963e76..c7f231963e76 100644
--- a/include/asm-arm/arch-s3c2410/regs-adc.h
+++ b/include/asm-arm/plat-s3c/regs-adc.h
diff --git a/include/asm-arm/arch-s3c2410/regs-iic.h b/include/asm-arm/plat-s3c/regs-iic.h
index 2ae29522f253..2ae29522f253 100644
--- a/include/asm-arm/arch-s3c2410/regs-iic.h
+++ b/include/asm-arm/plat-s3c/regs-iic.h
diff --git a/include/asm-arm/arch-s3c2410/regs-nand.h b/include/asm-arm/plat-s3c/regs-nand.h
index b824d371ae0b..b824d371ae0b 100644
--- a/include/asm-arm/arch-s3c2410/regs-nand.h
+++ b/include/asm-arm/plat-s3c/regs-nand.h
diff --git a/include/asm-arm/arch-s3c2410/regs-rtc.h b/include/asm-arm/plat-s3c/regs-rtc.h
index 93b03c49710a..93b03c49710a 100644
--- a/include/asm-arm/arch-s3c2410/regs-rtc.h
+++ b/include/asm-arm/plat-s3c/regs-rtc.h
diff --git a/include/asm-arm/arch-s3c2410/regs-serial.h b/include/asm-arm/plat-s3c/regs-serial.h
index 8946702a87f5..923e114db663 100644
--- a/include/asm-arm/arch-s3c2410/regs-serial.h
+++ b/include/asm-arm/plat-s3c/regs-serial.h
@@ -32,10 +32,10 @@
32#ifndef __ASM_ARM_REGS_SERIAL_H 32#ifndef __ASM_ARM_REGS_SERIAL_H
33#define __ASM_ARM_REGS_SERIAL_H 33#define __ASM_ARM_REGS_SERIAL_H
34 34
35#define S3C24XX_VA_UART0 (S3C24XX_VA_UART) 35#define S3C24XX_VA_UART0 (S3C_VA_UART)
36#define S3C24XX_VA_UART1 (S3C24XX_VA_UART + 0x4000 ) 36#define S3C24XX_VA_UART1 (S3C_VA_UART + 0x4000 )
37#define S3C24XX_VA_UART2 (S3C24XX_VA_UART + 0x8000 ) 37#define S3C24XX_VA_UART2 (S3C_VA_UART + 0x8000 )
38#define S3C24XX_VA_UART3 (S3C24XX_VA_UART + 0xC000 ) 38#define S3C24XX_VA_UART3 (S3C_VA_UART + 0xC000 )
39 39
40#define S3C2410_PA_UART0 (S3C24XX_PA_UART) 40#define S3C2410_PA_UART0 (S3C24XX_PA_UART)
41#define S3C2410_PA_UART1 (S3C24XX_PA_UART + 0x4000 ) 41#define S3C2410_PA_UART1 (S3C24XX_PA_UART + 0x4000 )
diff --git a/include/asm-arm/arch-s3c2410/regs-timer.h b/include/asm-arm/plat-s3c/regs-timer.h
index 6f8fe432fe3a..8b0d594397b1 100644
--- a/include/asm-arm/arch-s3c2410/regs-timer.h
+++ b/include/asm-arm/plat-s3c/regs-timer.h
@@ -14,12 +14,12 @@
14#ifndef __ASM_ARCH_REGS_TIMER_H 14#ifndef __ASM_ARCH_REGS_TIMER_H
15#define __ASM_ARCH_REGS_TIMER_H "$Id: timer.h,v 1.4 2003/05/06 19:30:50 ben Exp $" 15#define __ASM_ARCH_REGS_TIMER_H "$Id: timer.h,v 1.4 2003/05/06 19:30:50 ben Exp $"
16 16
17#define S3C2410_TIMERREG(x) (S3C24XX_VA_TIMER + (x)) 17#define S3C_TIMERREG(x) (S3C_VA_TIMER + (x))
18#define S3C2410_TIMERREG2(tmr,reg) S3C2410_TIMERREG((reg)+0x0c+((tmr)*0x0c)) 18#define S3C_TIMERREG2(tmr,reg) S3C_TIMERREG((reg)+0x0c+((tmr)*0x0c))
19 19
20#define S3C2410_TCFG0 S3C2410_TIMERREG(0x00) 20#define S3C2410_TCFG0 S3C_TIMERREG(0x00)
21#define S3C2410_TCFG1 S3C2410_TIMERREG(0x04) 21#define S3C2410_TCFG1 S3C_TIMERREG(0x04)
22#define S3C2410_TCON S3C2410_TIMERREG(0x08) 22#define S3C2410_TCON S3C_TIMERREG(0x08)
23 23
24#define S3C2410_TCFG_PRESCALER0_MASK (255<<0) 24#define S3C2410_TCFG_PRESCALER0_MASK (255<<0)
25#define S3C2410_TCFG_PRESCALER1_MASK (255<<8) 25#define S3C2410_TCFG_PRESCALER1_MASK (255<<8)
@@ -71,9 +71,9 @@
71 71
72/* WARNING - timer 4 has no buffer reg, and it's observation is at +4 */ 72/* WARNING - timer 4 has no buffer reg, and it's observation is at +4 */
73 73
74#define S3C2410_TCNTB(tmr) S3C2410_TIMERREG2(tmr, 0x00) 74#define S3C2410_TCNTB(tmr) S3C_TIMERREG2(tmr, 0x00)
75#define S3C2410_TCMPB(tmr) S3C2410_TIMERREG2(tmr, 0x04) 75#define S3C2410_TCMPB(tmr) S3C_TIMERREG2(tmr, 0x04)
76#define S3C2410_TCNTO(tmr) S3C2410_TIMERREG2(tmr, (((tmr) == 4) ? 0x04 : 0x08)) 76#define S3C2410_TCNTO(tmr) S3C_TIMERREG2(tmr, (((tmr) == 4) ? 0x04 : 0x08))
77 77
78#define S3C2410_TCON_T4RELOAD (1<<22) 78#define S3C2410_TCON_T4RELOAD (1<<22)
79#define S3C2410_TCON_T4MANUALUPD (1<<21) 79#define S3C2410_TCON_T4MANUALUPD (1<<21)
diff --git a/include/asm-arm/arch-s3c2410/regs-watchdog.h b/include/asm-arm/plat-s3c/regs-watchdog.h
index a9c5d491bdb6..56c4193b7a46 100644
--- a/include/asm-arm/arch-s3c2410/regs-watchdog.h
+++ b/include/asm-arm/plat-s3c/regs-watchdog.h
@@ -14,11 +14,11 @@
14#ifndef __ASM_ARCH_REGS_WATCHDOG_H 14#ifndef __ASM_ARCH_REGS_WATCHDOG_H
15#define __ASM_ARCH_REGS_WATCHDOG_H "$Id: watchdog.h,v 1.2 2003/04/29 13:31:09 ben Exp $" 15#define __ASM_ARCH_REGS_WATCHDOG_H "$Id: watchdog.h,v 1.2 2003/04/29 13:31:09 ben Exp $"
16 16
17#define S3C2410_WDOGREG(x) ((x) + S3C24XX_VA_WATCHDOG) 17#define S3C_WDOGREG(x) ((x) + S3C_VA_WATCHDOG)
18 18
19#define S3C2410_WTCON S3C2410_WDOGREG(0x00) 19#define S3C2410_WTCON S3C_WDOGREG(0x00)
20#define S3C2410_WTDAT S3C2410_WDOGREG(0x04) 20#define S3C2410_WTDAT S3C_WDOGREG(0x04)
21#define S3C2410_WTCNT S3C2410_WDOGREG(0x08) 21#define S3C2410_WTCNT S3C_WDOGREG(0x08)
22 22
23/* the watchdog can either generate a reset pulse, or an 23/* the watchdog can either generate a reset pulse, or an
24 * interrupt. 24 * interrupt.
diff --git a/include/asm-arm/plat-s3c/uncompress.h b/include/asm-arm/plat-s3c/uncompress.h
new file mode 100644
index 000000000000..b5e6208175d1
--- /dev/null
+++ b/include/asm-arm/plat-s3c/uncompress.h
@@ -0,0 +1,155 @@
1/* linux/include/asm-arm/plat-s3c/uncompress.h
2 *
3 * Copyright 2003, 2007 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C - uncompress code
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14#ifndef __ASM_PLAT_UNCOMPRESS_H
15#define __ASM_PLAT_UNCOMPRESS_H
16
17typedef unsigned int upf_t; /* cannot include linux/serial_core.h */
18
19/* uart setup */
20
21static unsigned int fifo_mask;
22static unsigned int fifo_max;
23
24/* forward declerations */
25
26static void arch_detect_cpu(void);
27
28/* defines for UART registers */
29
30#include "asm/plat-s3c/regs-serial.h"
31#include "asm/plat-s3c/regs-watchdog.h"
32
33/* working in physical space... */
34#undef S3C2410_WDOGREG
35#define S3C2410_WDOGREG(x) ((S3C24XX_PA_WATCHDOG + (x)))
36
37/* how many bytes we allow into the FIFO at a time in FIFO mode */
38#define FIFO_MAX (14)
39
40#define uart_base S3C24XX_PA_UART + (0x4000*CONFIG_S3C_LOWLEVEL_UART_PORT)
41
42static __inline__ void
43uart_wr(unsigned int reg, unsigned int val)
44{
45 volatile unsigned int *ptr;
46
47 ptr = (volatile unsigned int *)(reg + uart_base);
48 *ptr = val;
49}
50
51static __inline__ unsigned int
52uart_rd(unsigned int reg)
53{
54 volatile unsigned int *ptr;
55
56 ptr = (volatile unsigned int *)(reg + uart_base);
57 return *ptr;
58}
59
60/* we can deal with the case the UARTs are being run
61 * in FIFO mode, so that we don't hold up our execution
62 * waiting for tx to happen...
63*/
64
65static void putc(int ch)
66{
67 if (uart_rd(S3C2410_UFCON) & S3C2410_UFCON_FIFOMODE) {
68 int level;
69
70 while (1) {
71 level = uart_rd(S3C2410_UFSTAT);
72 level &= fifo_mask;
73
74 if (level < fifo_max)
75 break;
76 }
77
78 } else {
79 /* not using fifos */
80
81 while ((uart_rd(S3C2410_UTRSTAT) & S3C2410_UTRSTAT_TXE) != S3C2410_UTRSTAT_TXE)
82 barrier();
83 }
84
85 /* write byte to transmission register */
86 uart_wr(S3C2410_UTXH, ch);
87}
88
89static inline void flush(void)
90{
91}
92
93#define __raw_writel(d,ad) do { *((volatile unsigned int *)(ad)) = (d); } while(0)
94
95/* CONFIG_S3C_BOOT_WATCHDOG
96 *
97 * Simple boot-time watchdog setup, to reboot the system if there is
98 * any problem with the boot process
99*/
100
101#ifdef CONFIG_S3C_BOOT_WATCHDOG
102
103#define WDOG_COUNT (0xff00)
104
105static inline void arch_decomp_wdog(void)
106{
107 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
108}
109
110static void arch_decomp_wdog_start(void)
111{
112 __raw_writel(WDOG_COUNT, S3C2410_WTDAT);
113 __raw_writel(WDOG_COUNT, S3C2410_WTCNT);
114 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x80), S3C2410_WTCON);
115}
116
117#else
118#define arch_decomp_wdog_start()
119#define arch_decomp_wdog()
120#endif
121
122#ifdef CONFIG_S3C_BOOT_ERROR_RESET
123
124static void arch_decomp_error(const char *x)
125{
126 putstr("\n\n");
127 putstr(x);
128 putstr("\n\n -- System resetting\n");
129
130 __raw_writel(0x4000, S3C2410_WTDAT);
131 __raw_writel(0x4000, S3C2410_WTCNT);
132 __raw_writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV128 | S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x40), S3C2410_WTCON);
133
134 while(1);
135}
136
137#define arch_error arch_decomp_error
138#endif
139
140static void error(char *err);
141
142static void
143arch_decomp_setup(void)
144{
145 /* we may need to setup the uart(s) here if we are not running
146 * on an BAST... the BAST will have left the uarts configured
147 * after calling linux.
148 */
149
150 arch_detect_cpu();
151 arch_decomp_wdog_start();
152}
153
154
155#endif /* __ASM_PLAT_UNCOMPRESS_H */
diff --git a/include/asm-arm/arch-s3c2410/regs-iis.h b/include/asm-arm/plat-s3c24xx/regs-iis.h
index eaf77916a602..eaf77916a602 100644
--- a/include/asm-arm/arch-s3c2410/regs-iis.h
+++ b/include/asm-arm/plat-s3c24xx/regs-iis.h
diff --git a/include/asm-arm/arch-s3c2410/regs-spi.h b/include/asm-arm/plat-s3c24xx/regs-spi.h
index 4a499a138256..4a499a138256 100644
--- a/include/asm-arm/arch-s3c2410/regs-spi.h
+++ b/include/asm-arm/plat-s3c24xx/regs-spi.h
diff --git a/include/asm-arm/arch-s3c2410/regs-udc.h b/include/asm-arm/plat-s3c24xx/regs-udc.h
index e1e9805d2d9a..e1e9805d2d9a 100644
--- a/include/asm-arm/arch-s3c2410/regs-udc.h
+++ b/include/asm-arm/plat-s3c24xx/regs-udc.h
diff --git a/include/asm-arm/arch-s3c2410/udc.h b/include/asm-arm/plat-s3c24xx/udc.h
index b8aa6cb69b58..b8aa6cb69b58 100644
--- a/include/asm-arm/arch-s3c2410/udc.h
+++ b/include/asm-arm/plat-s3c24xx/udc.h
diff --git a/include/asm-arm/thread_info.h b/include/asm-arm/thread_info.h
index eae85b09db2e..69c65d56a6ac 100644
--- a/include/asm-arm/thread_info.h
+++ b/include/asm-arm/thread_info.h
@@ -24,7 +24,6 @@
24struct task_struct; 24struct task_struct;
25struct exec_domain; 25struct exec_domain;
26 26
27#include <asm/ptrace.h>
28#include <asm/types.h> 27#include <asm/types.h>
29#include <asm/domain.h> 28#include <asm/domain.h>
30 29
diff --git a/include/asm-arm/unistd.h b/include/asm-arm/unistd.h
index bfdbebebdc1b..d327b25c986c 100644
--- a/include/asm-arm/unistd.h
+++ b/include/asm-arm/unistd.h
@@ -441,7 +441,6 @@
441/* 441/*
442 * Unimplemented (or alternatively implemented) syscalls 442 * Unimplemented (or alternatively implemented) syscalls
443 */ 443 */
444#define __IGNORE_sync_file_range 1
445#define __IGNORE_fadvise64_64 1 444#define __IGNORE_fadvise64_64 1
446 445
447#endif /* __KERNEL__ */ 446#endif /* __KERNEL__ */
diff --git a/include/asm-arm/vfp.h b/include/asm-arm/vfp.h
index 14c5e0946c47..bd6be9d7f772 100644
--- a/include/asm-arm/vfp.h
+++ b/include/asm-arm/vfp.h
@@ -26,8 +26,8 @@
26#define FPSID_REV_MASK (0xF << FPSID_REV_BIT) 26#define FPSID_REV_MASK (0xF << FPSID_REV_BIT)
27 27
28/* FPEXC bits */ 28/* FPEXC bits */
29#define FPEXC_EXCEPTION (1<<31) 29#define FPEXC_EX (1 << 31)
30#define FPEXC_ENABLE (1<<30) 30#define FPEXC_EN (1 << 30)
31 31
32/* FPSCR bits */ 32/* FPSCR bits */
33#define FPSCR_DEFAULT_NAN (1<<25) 33#define FPSCR_DEFAULT_NAN (1<<25)
diff --git a/include/asm-arm26/irq.h b/include/asm-arm26/irq.h
index 9aaac87efba9..52971b49ed3b 100644
--- a/include/asm-arm26/irq.h
+++ b/include/asm-arm26/irq.h
@@ -24,11 +24,6 @@
24 24
25struct irqaction; 25struct irqaction;
26 26
27#define disable_irq_nosync(i) disable_irq(i)
28
29extern void disable_irq(unsigned int);
30extern void enable_irq(unsigned int);
31
32#define __IRQT_FALEDGE (1 << 0) 27#define __IRQT_FALEDGE (1 << 0)
33#define __IRQT_RISEDGE (1 << 1) 28#define __IRQT_RISEDGE (1 << 1)
34#define __IRQT_LOWLVL (1 << 2) 29#define __IRQT_LOWLVL (1 << 2)
diff --git a/include/asm-h8300/irq.h b/include/asm-h8300/irq.h
index 41be646c3514..56eec28cc2c4 100644
--- a/include/asm-h8300/irq.h
+++ b/include/asm-h8300/irq.h
@@ -59,7 +59,4 @@ static __inline__ int irq_canonicalize(int irq)
59 return irq; 59 return irq;
60} 60}
61 61
62extern void enable_irq(unsigned int);
63extern void disable_irq(unsigned int);
64
65#endif /* _H8300_IRQ_H_ */ 62#endif /* _H8300_IRQ_H_ */
diff --git a/include/asm-i386/alternative.h b/include/asm-i386/alternative.h
index eb7da5402bfa..bda6c810c0f4 100644
--- a/include/asm-i386/alternative.h
+++ b/include/asm-i386/alternative.h
@@ -149,4 +149,6 @@ apply_paravirt(struct paravirt_patch_site *start,
149#define __parainstructions_end NULL 149#define __parainstructions_end NULL
150#endif 150#endif
151 151
152extern void text_poke(void *addr, unsigned char *opcode, int len);
153
152#endif /* _I386_ALTERNATIVE_H */ 154#endif /* _I386_ALTERNATIVE_H */
diff --git a/include/asm-i386/cmpxchg.h b/include/asm-i386/cmpxchg.h
index 64dcdf46117b..f86ede28f6dc 100644
--- a/include/asm-i386/cmpxchg.h
+++ b/include/asm-i386/cmpxchg.h
@@ -34,7 +34,7 @@ static inline void __set_64bit (unsigned long long * ptr,
34 "\n1:\t" 34 "\n1:\t"
35 "movl (%0), %%eax\n\t" 35 "movl (%0), %%eax\n\t"
36 "movl 4(%0), %%edx\n\t" 36 "movl 4(%0), %%edx\n\t"
37 "lock cmpxchg8b (%0)\n\t" 37 LOCK_PREFIX "cmpxchg8b (%0)\n\t"
38 "jnz 1b" 38 "jnz 1b"
39 : /* no outputs */ 39 : /* no outputs */
40 : "D"(ptr), 40 : "D"(ptr),
diff --git a/include/asm-i386/e820.h b/include/asm-i386/e820.h
index c03290ccecb2..43114c824608 100644
--- a/include/asm-i386/e820.h
+++ b/include/asm-i386/e820.h
@@ -47,6 +47,14 @@ extern void e820_register_memory(void);
47extern void limit_regions(unsigned long long size); 47extern void limit_regions(unsigned long long size);
48extern void print_memory_map(char *who); 48extern void print_memory_map(char *who);
49 49
50#if defined(CONFIG_PM) && defined(CONFIG_SOFTWARE_SUSPEND)
51extern void e820_mark_nosave_regions(void);
52#else
53static inline void e820_mark_nosave_regions(void)
54{
55}
56#endif
57
50#endif/*!__ASSEMBLY__*/ 58#endif/*!__ASSEMBLY__*/
51 59
52#endif/*__E820_HEADER*/ 60#endif/*__E820_HEADER*/
diff --git a/include/asm-i386/geode.h b/include/asm-i386/geode.h
new file mode 100644
index 000000000000..6da4bbbea3dc
--- /dev/null
+++ b/include/asm-i386/geode.h
@@ -0,0 +1,159 @@
1/*
2 * AMD Geode definitions
3 * Copyright (C) 2006, Advanced Micro Devices, Inc.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 2 of the GNU General Public License
7 * as published by the Free Software Foundation.
8 */
9
10#ifndef _ASM_GEODE_H_
11#define _ASM_GEODE_H_
12
13#include <asm/processor.h>
14#include <linux/io.h>
15
16/* Generic southbridge functions */
17
18#define GEODE_DEV_PMS 0
19#define GEODE_DEV_ACPI 1
20#define GEODE_DEV_GPIO 2
21#define GEODE_DEV_MFGPT 3
22
23extern int geode_get_dev_base(unsigned int dev);
24
25/* Useful macros */
26#define geode_pms_base() geode_get_dev_base(GEODE_DEV_PMS)
27#define geode_acpi_base() geode_get_dev_base(GEODE_DEV_ACPI)
28#define geode_gpio_base() geode_get_dev_base(GEODE_DEV_GPIO)
29#define geode_mfgpt_base() geode_get_dev_base(GEODE_DEV_MFGPT)
30
31/* MSRS */
32
33#define GX_GLCP_SYS_RSTPLL 0x4C000014
34
35#define MSR_LBAR_SMB 0x5140000B
36#define MSR_LBAR_GPIO 0x5140000C
37#define MSR_LBAR_MFGPT 0x5140000D
38#define MSR_LBAR_ACPI 0x5140000E
39#define MSR_LBAR_PMS 0x5140000F
40
41#define MSR_PIC_YSEL_LOW 0x51400020
42#define MSR_PIC_YSEL_HIGH 0x51400021
43#define MSR_PIC_ZSEL_LOW 0x51400022
44#define MSR_PIC_ZSEL_HIGH 0x51400023
45
46#define MFGPT_IRQ_MSR 0x51400028
47#define MFGPT_NR_MSR 0x51400029
48
49/* Resource Sizes */
50
51#define LBAR_GPIO_SIZE 0xFF
52#define LBAR_MFGPT_SIZE 0x40
53#define LBAR_ACPI_SIZE 0x40
54#define LBAR_PMS_SIZE 0x80
55
56/* ACPI registers (PMS block) */
57
58/*
59 * PM1_EN is only valid when VSA is enabled for 16 bit reads.
60 * When VSA is not enabled, *always* read both PM1_STS and PM1_EN
61 * with a 32 bit read at offset 0x0
62 */
63
64#define PM1_STS 0x00
65#define PM1_EN 0x02
66#define PM1_CNT 0x08
67#define PM2_CNT 0x0C
68#define PM_TMR 0x10
69#define PM_GPE0_STS 0x18
70#define PM_GPE0_EN 0x1C
71
72/* PMC registers (PMS block) */
73
74#define PM_SSD 0x00
75#define PM_SCXA 0x04
76#define PM_SCYA 0x08
77#define PM_OUT_SLPCTL 0x0C
78#define PM_SCLK 0x10
79#define PM_SED 0x1
80#define PM_SCXD 0x18
81#define PM_SCYD 0x1C
82#define PM_IN_SLPCTL 0x20
83#define PM_WKD 0x30
84#define PM_WKXD 0x34
85#define PM_RD 0x38
86#define PM_WKXA 0x3C
87#define PM_FSD 0x40
88#define PM_TSD 0x44
89#define PM_PSD 0x48
90#define PM_NWKD 0x4C
91#define PM_AWKD 0x50
92#define PM_SSC 0x54
93
94/* GPIO */
95
96#define GPIO_OUTPUT_VAL 0x00
97#define GPIO_OUTPUT_ENABLE 0x04
98#define GPIO_OUTPUT_OPEN_DRAIN 0x08
99#define GPIO_OUTPUT_INVERT 0x0C
100#define GPIO_OUTPUT_AUX1 0x10
101#define GPIO_OUTPUT_AUX2 0x14
102#define GPIO_PULL_UP 0x18
103#define GPIO_PULL_DOWN 0x1C
104#define GPIO_INPUT_ENABLE 0x20
105#define GPIO_INPUT_INVERT 0x24
106#define GPIO_INPUT_FILTER 0x28
107#define GPIO_INPUT_EVENT_COUNT 0x2C
108#define GPIO_READ_BACK 0x30
109#define GPIO_INPUT_AUX1 0x34
110#define GPIO_EVENTS_ENABLE 0x38
111#define GPIO_LOCK_ENABLE 0x3C
112#define GPIO_POSITIVE_EDGE_EN 0x40
113#define GPIO_NEGATIVE_EDGE_EN 0x44
114#define GPIO_POSITIVE_EDGE_STS 0x48
115#define GPIO_NEGATIVE_EDGE_STS 0x4C
116
117#define GPIO_MAP_X 0xE0
118#define GPIO_MAP_Y 0xE4
119#define GPIO_MAP_Z 0xE8
120#define GPIO_MAP_W 0xEC
121
122extern void geode_gpio_set(unsigned int, unsigned int);
123extern void geode_gpio_clear(unsigned int, unsigned int);
124extern int geode_gpio_isset(unsigned int, unsigned int);
125extern void geode_gpio_setup_event(unsigned int, int, int);
126extern void geode_gpio_set_irq(unsigned int, unsigned int);
127
128static inline void geode_gpio_event_irq(unsigned int gpio, int pair)
129{
130 geode_gpio_setup_event(gpio, pair, 0);
131}
132
133static inline void geode_gpio_event_pme(unsigned int gpio, int pair)
134{
135 geode_gpio_setup_event(gpio, pair, 1);
136}
137
138/* Specific geode tests */
139
140static inline int is_geode_gx(void)
141{
142 return ((boot_cpu_data.x86_vendor == X86_VENDOR_NSC) &&
143 (boot_cpu_data.x86 == 5) &&
144 (boot_cpu_data.x86_model == 5));
145}
146
147static inline int is_geode_lx(void)
148{
149 return ((boot_cpu_data.x86_vendor == X86_VENDOR_AMD) &&
150 (boot_cpu_data.x86 == 5) &&
151 (boot_cpu_data.x86_model == 10));
152}
153
154static inline int is_geode(void)
155{
156 return (is_geode_gx() || is_geode_lx());
157}
158
159#endif
diff --git a/include/asm-i386/hpet.h b/include/asm-i386/hpet.h
index dddeedf504b7..c82dc7ed96b3 100644
--- a/include/asm-i386/hpet.h
+++ b/include/asm-i386/hpet.h
@@ -4,112 +4,82 @@
4 4
5#ifdef CONFIG_HPET_TIMER 5#ifdef CONFIG_HPET_TIMER
6 6
7#include <linux/errno.h>
8#include <linux/module.h>
9#include <linux/sched.h>
10#include <linux/kernel.h>
11#include <linux/param.h>
12#include <linux/string.h>
13#include <linux/mm.h>
14#include <linux/interrupt.h>
15#include <linux/time.h>
16#include <linux/delay.h>
17#include <linux/init.h>
18#include <linux/smp.h>
19
20#include <asm/io.h>
21#include <asm/smp.h>
22#include <asm/irq.h>
23#include <asm/msr.h>
24#include <asm/delay.h>
25#include <asm/mpspec.h>
26#include <asm/uaccess.h>
27#include <asm/processor.h>
28
29#include <linux/timex.h>
30
31/* 7/*
32 * Documentation on HPET can be found at: 8 * Documentation on HPET can be found at:
33 * http://www.intel.com/ial/home/sp/pcmmspec.htm 9 * http://www.intel.com/ial/home/sp/pcmmspec.htm
34 * ftp://download.intel.com/ial/home/sp/mmts098.pdf 10 * ftp://download.intel.com/ial/home/sp/mmts098.pdf
35 */ 11 */
36 12
37#define HPET_MMAP_SIZE 1024 13#define HPET_MMAP_SIZE 1024
38 14
39#define HPET_ID 0x000 15#define HPET_ID 0x000
40#define HPET_PERIOD 0x004 16#define HPET_PERIOD 0x004
41#define HPET_CFG 0x010 17#define HPET_CFG 0x010
42#define HPET_STATUS 0x020 18#define HPET_STATUS 0x020
43#define HPET_COUNTER 0x0f0 19#define HPET_COUNTER 0x0f0
44#define HPET_T0_CFG 0x100 20#define HPET_T0_CFG 0x100
45#define HPET_T0_CMP 0x108 21#define HPET_T0_CMP 0x108
46#define HPET_T0_ROUTE 0x110 22#define HPET_T0_ROUTE 0x110
47#define HPET_T1_CFG 0x120 23#define HPET_T1_CFG 0x120
48#define HPET_T1_CMP 0x128 24#define HPET_T1_CMP 0x128
49#define HPET_T1_ROUTE 0x130 25#define HPET_T1_ROUTE 0x130
50#define HPET_T2_CFG 0x140 26#define HPET_T2_CFG 0x140
51#define HPET_T2_CMP 0x148 27#define HPET_T2_CMP 0x148
52#define HPET_T2_ROUTE 0x150 28#define HPET_T2_ROUTE 0x150
53 29
54#define HPET_ID_LEGSUP 0x00008000 30#define HPET_ID_REV 0x000000ff
55#define HPET_ID_NUMBER 0x00001f00 31#define HPET_ID_NUMBER 0x00001f00
56#define HPET_ID_REV 0x000000ff 32#define HPET_ID_64BIT 0x00002000
33#define HPET_ID_LEGSUP 0x00008000
34#define HPET_ID_VENDOR 0xffff0000
57#define HPET_ID_NUMBER_SHIFT 8 35#define HPET_ID_NUMBER_SHIFT 8
36#define HPET_ID_VENDOR_SHIFT 16
58 37
59#define HPET_CFG_ENABLE 0x001 38#define HPET_ID_VENDOR_8086 0x8086
60#define HPET_CFG_LEGACY 0x002 39
40#define HPET_CFG_ENABLE 0x001
41#define HPET_CFG_LEGACY 0x002
61#define HPET_LEGACY_8254 2 42#define HPET_LEGACY_8254 2
62#define HPET_LEGACY_RTC 8 43#define HPET_LEGACY_RTC 8
63 44
64#define HPET_TN_ENABLE 0x004 45#define HPET_TN_LEVEL 0x0002
65#define HPET_TN_PERIODIC 0x008 46#define HPET_TN_ENABLE 0x0004
66#define HPET_TN_PERIODIC_CAP 0x010 47#define HPET_TN_PERIODIC 0x0008
67#define HPET_TN_SETVAL 0x040 48#define HPET_TN_PERIODIC_CAP 0x0010
68#define HPET_TN_32BIT 0x100 49#define HPET_TN_64BIT_CAP 0x0020
69 50#define HPET_TN_SETVAL 0x0040
70/* Use our own asm for 64 bit multiply/divide */ 51#define HPET_TN_32BIT 0x0100
71#define ASM_MUL64_REG(eax_out,edx_out,reg_in,eax_in) \ 52#define HPET_TN_ROUTE 0x3e00
72 __asm__ __volatile__("mull %2" \ 53#define HPET_TN_FSB 0x4000
73 :"=a" (eax_out), "=d" (edx_out) \ 54#define HPET_TN_FSB_CAP 0x8000
74 :"r" (reg_in), "0" (eax_in)) 55#define HPET_TN_ROUTE_SHIFT 9
75 56
76#define ASM_DIV64_REG(eax_out,edx_out,reg_in,eax_in,edx_in) \
77 __asm__ __volatile__("divl %2" \
78 :"=a" (eax_out), "=d" (edx_out) \
79 :"r" (reg_in), "0" (eax_in), "1" (edx_in))
80
81#define KERNEL_TICK_USEC (1000000UL/HZ) /* tick value in microsec */
82/* Max HPET Period is 10^8 femto sec as in HPET spec */ 57/* Max HPET Period is 10^8 femto sec as in HPET spec */
83#define HPET_MAX_PERIOD (100000000UL) 58#define HPET_MAX_PERIOD 100000000UL
84/* 59/*
85 * Min HPET period is 10^5 femto sec just for safety. If it is less than this, 60 * Min HPET period is 10^5 femto sec just for safety. If it is less than this,
86 * then 32 bit HPET counter wrapsaround in less than 0.5 sec. 61 * then 32 bit HPET counter wrapsaround in less than 0.5 sec.
87 */ 62 */
88#define HPET_MIN_PERIOD (100000UL) 63#define HPET_MIN_PERIOD 100000UL
89#define HPET_TICK_RATE (HZ * 100000UL)
90 64
91extern unsigned long hpet_address; /* hpet memory map physical address */ 65/* hpet memory map physical address */
66extern unsigned long hpet_address;
92extern int is_hpet_enabled(void); 67extern int is_hpet_enabled(void);
93
94#ifdef CONFIG_X86_64
95extern unsigned long hpet_tick; /* hpet clks count per tick */
96extern int hpet_use_timer;
97extern int hpet_rtc_timer_init(void);
98extern int hpet_enable(void); 68extern int hpet_enable(void);
99extern int is_hpet_capable(void);
100extern int hpet_readl(unsigned long a);
101#else
102extern int hpet_enable(void);
103#endif
104 69
105#ifdef CONFIG_HPET_EMULATE_RTC 70#ifdef CONFIG_HPET_EMULATE_RTC
71
72#include <linux/interrupt.h>
73
106extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask); 74extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
107extern int hpet_set_rtc_irq_bit(unsigned long bit_mask); 75extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
108extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec); 76extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min,
77 unsigned char sec);
109extern int hpet_set_periodic_freq(unsigned long freq); 78extern int hpet_set_periodic_freq(unsigned long freq);
110extern int hpet_rtc_dropped_irq(void); 79extern int hpet_rtc_dropped_irq(void);
111extern int hpet_rtc_timer_init(void); 80extern int hpet_rtc_timer_init(void);
112extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id); 81extern irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id);
82
113#endif /* CONFIG_HPET_EMULATE_RTC */ 83#endif /* CONFIG_HPET_EMULATE_RTC */
114 84
115#else 85#else
diff --git a/include/asm-i386/i8253.h b/include/asm-i386/i8253.h
index 6cb0dd4dcdde..7577d058d86e 100644
--- a/include/asm-i386/i8253.h
+++ b/include/asm-i386/i8253.h
@@ -3,19 +3,15 @@
3 3
4#include <linux/clockchips.h> 4#include <linux/clockchips.h>
5 5
6/* i8253A PIT registers */
7#define PIT_MODE 0x43
8#define PIT_CH0 0x40
9#define PIT_CH2 0x42
10
6extern spinlock_t i8253_lock; 11extern spinlock_t i8253_lock;
7 12
8extern struct clock_event_device *global_clock_event; 13extern struct clock_event_device *global_clock_event;
9 14
10/** 15extern void setup_pit_timer(void);
11 * pit_interrupt_hook - hook into timer tick
12 * @regs: standard registers from interrupt
13 *
14 * Call the global clock event handler.
15 **/
16static inline void pit_interrupt_hook(void)
17{
18 global_clock_event->event_handler(global_clock_event);
19}
20 16
21#endif /* __ASM_I8253_H__ */ 17#endif /* __ASM_I8253_H__ */
diff --git a/include/asm-i386/mach-default/do_timer.h b/include/asm-i386/mach-default/do_timer.h
index 56e5689863ae..23ecda0b28a0 100644
--- a/include/asm-i386/mach-default/do_timer.h
+++ b/include/asm-i386/mach-default/do_timer.h
@@ -12,5 +12,5 @@
12 12
13static inline void do_timer_interrupt_hook(void) 13static inline void do_timer_interrupt_hook(void)
14{ 14{
15 pit_interrupt_hook(); 15 global_clock_event->event_handler(global_clock_event);
16} 16}
diff --git a/include/asm-i386/mach-default/io_ports.h b/include/asm-i386/mach-default/io_ports.h
index a96d9f6604ee..48540ba97166 100644
--- a/include/asm-i386/mach-default/io_ports.h
+++ b/include/asm-i386/mach-default/io_ports.h
@@ -7,11 +7,6 @@
7#ifndef _MACH_IO_PORTS_H 7#ifndef _MACH_IO_PORTS_H
8#define _MACH_IO_PORTS_H 8#define _MACH_IO_PORTS_H
9 9
10/* i8253A PIT registers */
11#define PIT_MODE 0x43
12#define PIT_CH0 0x40
13#define PIT_CH2 0x42
14
15/* i8259A PIC registers */ 10/* i8259A PIC registers */
16#define PIC_MASTER_CMD 0x20 11#define PIC_MASTER_CMD 0x20
17#define PIC_MASTER_IMR 0x21 12#define PIC_MASTER_IMR 0x21
diff --git a/include/asm-i386/mach-default/mach_reboot.h b/include/asm-i386/mach-default/mach_reboot.h
index a955e57ad016..e23fd9fbebb3 100644
--- a/include/asm-i386/mach-default/mach_reboot.h
+++ b/include/asm-i386/mach-default/mach_reboot.h
@@ -19,14 +19,37 @@ static inline void kb_wait(void)
19static inline void mach_reboot(void) 19static inline void mach_reboot(void)
20{ 20{
21 int i; 21 int i;
22
23 /* old method, works on most machines */
22 for (i = 0; i < 10; i++) { 24 for (i = 0; i < 10; i++) {
23 kb_wait(); 25 kb_wait();
24 udelay(50); 26 udelay(50);
27 outb(0xfe, 0x64); /* pulse reset low */
28 udelay(50);
29 }
30
31 /* New method: sets the "System flag" which, when set, indicates
32 * successful completion of the keyboard controller self-test (Basic
33 * Assurance Test, BAT). This is needed for some machines with no
34 * keyboard plugged in. This read-modify-write sequence sets only the
35 * system flag
36 */
37 for (i = 0; i < 10; i++) {
38 int cmd;
39
40 outb(0x20, 0x64); /* read Controller Command Byte */
41 udelay(50);
42 kb_wait();
43 udelay(50);
44 cmd = inb(0x60);
45 udelay(50);
46 kb_wait();
47 udelay(50);
25 outb(0x60, 0x64); /* write Controller Command Byte */ 48 outb(0x60, 0x64); /* write Controller Command Byte */
26 udelay(50); 49 udelay(50);
27 kb_wait(); 50 kb_wait();
28 udelay(50); 51 udelay(50);
29 outb(0x14, 0x60); /* set "System flag" */ 52 outb(cmd | 0x04, 0x60); /* set "System flag" */
30 udelay(50); 53 udelay(50);
31 kb_wait(); 54 kb_wait();
32 udelay(50); 55 udelay(50);
diff --git a/include/asm-i386/mach-voyager/do_timer.h b/include/asm-i386/mach-voyager/do_timer.h
index 60f9dcc15d54..bc2b58926308 100644
--- a/include/asm-i386/mach-voyager/do_timer.h
+++ b/include/asm-i386/mach-voyager/do_timer.h
@@ -12,7 +12,7 @@
12 **/ 12 **/
13static inline void do_timer_interrupt_hook(void) 13static inline void do_timer_interrupt_hook(void)
14{ 14{
15 pit_interrupt_hook(); 15 global_clock_event->event_handler(global_clock_event);
16 voyager_timer_interrupt(); 16 voyager_timer_interrupt();
17} 17}
18 18
diff --git a/include/asm-i386/mc146818rtc.h b/include/asm-i386/mc146818rtc.h
index 99a890047023..1613b42eaf58 100644
--- a/include/asm-i386/mc146818rtc.h
+++ b/include/asm-i386/mc146818rtc.h
@@ -6,6 +6,7 @@
6 6
7#include <asm/io.h> 7#include <asm/io.h>
8#include <asm/system.h> 8#include <asm/system.h>
9#include <asm/processor.h>
9#include <linux/mc146818rtc.h> 10#include <linux/mc146818rtc.h>
10 11
11#ifndef RTC_PORT 12#ifndef RTC_PORT
@@ -43,8 +44,10 @@ static inline void lock_cmos(unsigned char reg)
43 unsigned long new; 44 unsigned long new;
44 new = ((smp_processor_id()+1) << 8) | reg; 45 new = ((smp_processor_id()+1) << 8) | reg;
45 for (;;) { 46 for (;;) {
46 if (cmos_lock) 47 if (cmos_lock) {
48 cpu_relax();
47 continue; 49 continue;
50 }
48 if (__cmpxchg(&cmos_lock, 0, new, sizeof(cmos_lock)) == 0) 51 if (__cmpxchg(&cmos_lock, 0, new, sizeof(cmos_lock)) == 0)
49 return; 52 return;
50 } 53 }
diff --git a/include/asm-i386/mce.h b/include/asm-i386/mce.h
index b0a02ee34ffd..d56d89742e8f 100644
--- a/include/asm-i386/mce.h
+++ b/include/asm-i386/mce.h
@@ -5,3 +5,7 @@ extern void mcheck_init(struct cpuinfo_x86 *c);
5#endif 5#endif
6 6
7extern int mce_disabled; 7extern int mce_disabled;
8
9extern void stop_mce(void);
10extern void restart_mce(void);
11
diff --git a/include/asm-i386/nmi.h b/include/asm-i386/nmi.h
index fb1e133efd9f..ff30c98f87b0 100644
--- a/include/asm-i386/nmi.h
+++ b/include/asm-i386/nmi.h
@@ -57,5 +57,7 @@ unsigned lapic_adjust_nmi_hz(unsigned hz);
57int lapic_watchdog_ok(void); 57int lapic_watchdog_ok(void);
58void disable_lapic_nmi_watchdog(void); 58void disable_lapic_nmi_watchdog(void);
59void enable_lapic_nmi_watchdog(void); 59void enable_lapic_nmi_watchdog(void);
60void stop_nmi(void);
61void restart_nmi(void);
60 62
61#endif /* ASM_NMI_H */ 63#endif /* ASM_NMI_H */
diff --git a/include/asm-i386/page.h b/include/asm-i386/page.h
index 99cf5d3692a9..80ecc66b6d86 100644
--- a/include/asm-i386/page.h
+++ b/include/asm-i386/page.h
@@ -44,7 +44,6 @@
44extern int nx_enabled; 44extern int nx_enabled;
45 45
46#ifdef CONFIG_X86_PAE 46#ifdef CONFIG_X86_PAE
47extern unsigned long long __supported_pte_mask;
48typedef struct { unsigned long pte_low, pte_high; } pte_t; 47typedef struct { unsigned long pte_low, pte_high; } pte_t;
49typedef struct { unsigned long long pmd; } pmd_t; 48typedef struct { unsigned long long pmd; } pmd_t;
50typedef struct { unsigned long long pgd; } pgd_t; 49typedef struct { unsigned long long pgd; } pgd_t;
diff --git a/include/asm-i386/pci.h b/include/asm-i386/pci.h
index 392d3fe5d45e..d790343e9982 100644
--- a/include/asm-i386/pci.h
+++ b/include/asm-i386/pci.h
@@ -3,6 +3,11 @@
3 3
4 4
5#ifdef __KERNEL__ 5#ifdef __KERNEL__
6
7struct pci_sysdata {
8 int node; /* NUMA node */
9};
10
6#include <linux/mm.h> /* for struct page */ 11#include <linux/mm.h> /* for struct page */
7 12
8/* Can be used to override the logic in pci_scan_bus for skipping 13/* Can be used to override the logic in pci_scan_bus for skipping
diff --git a/include/asm-i386/processor-cyrix.h b/include/asm-i386/processor-cyrix.h
new file mode 100644
index 000000000000..97568ada1f97
--- /dev/null
+++ b/include/asm-i386/processor-cyrix.h
@@ -0,0 +1,30 @@
1/*
2 * NSC/Cyrix CPU indexed register access. Must be inlined instead of
3 * macros to ensure correct access ordering
4 * Access order is always 0x22 (=offset), 0x23 (=value)
5 *
6 * When using the old macros a line like
7 * setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
8 * gets expanded to:
9 * do {
10 * outb((CX86_CCR2), 0x22);
11 * outb((({
12 * outb((CX86_CCR2), 0x22);
13 * inb(0x23);
14 * }) | 0x88), 0x23);
15 * } while (0);
16 *
17 * which in fact violates the access order (= 0x22, 0x22, 0x23, 0x23).
18 */
19
20static inline u8 getCx86(u8 reg)
21{
22 outb(reg, 0x22);
23 return inb(0x23);
24}
25
26static inline void setCx86(u8 reg, u8 data)
27{
28 outb(reg, 0x22);
29 outb(data, 0x23);
30}
diff --git a/include/asm-i386/processor.h b/include/asm-i386/processor.h
index 422cffef00c9..3845fe72383e 100644
--- a/include/asm-i386/processor.h
+++ b/include/asm-i386/processor.h
@@ -88,7 +88,6 @@ struct cpuinfo_x86 {
88#define X86_VENDOR_UMC 3 88#define X86_VENDOR_UMC 3
89#define X86_VENDOR_NEXGEN 4 89#define X86_VENDOR_NEXGEN 4
90#define X86_VENDOR_CENTAUR 5 90#define X86_VENDOR_CENTAUR 5
91#define X86_VENDOR_RISE 6
92#define X86_VENDOR_TRANSMETA 7 91#define X86_VENDOR_TRANSMETA 7
93#define X86_VENDOR_NSC 8 92#define X86_VENDOR_NSC 8
94#define X86_VENDOR_NUM 9 93#define X86_VENDOR_NUM 9
@@ -169,17 +168,6 @@ static inline void clear_in_cr4 (unsigned long mask)
169 write_cr4(cr4); 168 write_cr4(cr4);
170} 169}
171 170
172/*
173 * NSC/Cyrix CPU indexed register access macros
174 */
175
176#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
177
178#define setCx86(reg, data) do { \
179 outb((reg), 0x22); \
180 outb((data), 0x23); \
181} while (0)
182
183/* Stop speculative execution */ 171/* Stop speculative execution */
184static inline void sync_core(void) 172static inline void sync_core(void)
185{ 173{
diff --git a/include/asm-i386/resume-trace.h b/include/asm-i386/resume-trace.h
new file mode 100644
index 000000000000..ec9cfd656230
--- /dev/null
+++ b/include/asm-i386/resume-trace.h
@@ -0,0 +1,13 @@
1#define TRACE_RESUME(user) do { \
2 if (pm_trace_enabled) { \
3 void *tracedata; \
4 asm volatile("movl $1f,%0\n" \
5 ".section .tracedata,\"a\"\n" \
6 "1:\t.word %c1\n" \
7 "\t.long %c2\n" \
8 ".previous" \
9 :"=r" (tracedata) \
10 : "i" (__LINE__), "i" (__FILE__)); \
11 generate_resume_trace(tracedata, user); \
12 } \
13} while (0)
diff --git a/include/asm-i386/string.h b/include/asm-i386/string.h
index b9277361954b..a9b64453bdf5 100644
--- a/include/asm-i386/string.h
+++ b/include/asm-i386/string.h
@@ -2,203 +2,35 @@
2#define _I386_STRING_H_ 2#define _I386_STRING_H_
3 3
4#ifdef __KERNEL__ 4#ifdef __KERNEL__
5/*
6 * On a 486 or Pentium, we are better off not using the
7 * byte string operations. But on a 386 or a PPro the
8 * byte string ops are faster than doing it by hand
9 * (MUCH faster on a Pentium).
10 */
11
12/*
13 * This string-include defines all string functions as inline
14 * functions. Use gcc. It also assumes ds=es=data space, this should be
15 * normal. Most of the string-functions are rather heavily hand-optimized,
16 * see especially strsep,strstr,str[c]spn. They should work, but are not
17 * very easy to understand. Everything is done entirely within the register
18 * set, making the functions fast and clean. String instructions have been
19 * used through-out, making for "slightly" unclear code :-)
20 *
21 * NO Copyright (C) 1991, 1992 Linus Torvalds,
22 * consider these trivial functions to be PD.
23 */
24 5
25/* AK: in fact I bet it would be better to move this stuff all out of line. 6/* Let gcc decide wether to inline or use the out of line functions */
26 */
27 7
28#define __HAVE_ARCH_STRCPY 8#define __HAVE_ARCH_STRCPY
29static inline char * strcpy(char * dest,const char *src) 9extern char *strcpy(char *dest, const char *src);
30{
31int d0, d1, d2;
32__asm__ __volatile__(
33 "1:\tlodsb\n\t"
34 "stosb\n\t"
35 "testb %%al,%%al\n\t"
36 "jne 1b"
37 : "=&S" (d0), "=&D" (d1), "=&a" (d2)
38 :"0" (src),"1" (dest) : "memory");
39return dest;
40}
41 10
42#define __HAVE_ARCH_STRNCPY 11#define __HAVE_ARCH_STRNCPY
43static inline char * strncpy(char * dest,const char *src,size_t count) 12extern char *strncpy(char *dest, const char *src, size_t count);
44{
45int d0, d1, d2, d3;
46__asm__ __volatile__(
47 "1:\tdecl %2\n\t"
48 "js 2f\n\t"
49 "lodsb\n\t"
50 "stosb\n\t"
51 "testb %%al,%%al\n\t"
52 "jne 1b\n\t"
53 "rep\n\t"
54 "stosb\n"
55 "2:"
56 : "=&S" (d0), "=&D" (d1), "=&c" (d2), "=&a" (d3)
57 :"0" (src),"1" (dest),"2" (count) : "memory");
58return dest;
59}
60 13
61#define __HAVE_ARCH_STRCAT 14#define __HAVE_ARCH_STRCAT
62static inline char * strcat(char * dest,const char * src) 15extern char *strcat(char *dest, const char *src);
63{
64int d0, d1, d2, d3;
65__asm__ __volatile__(
66 "repne\n\t"
67 "scasb\n\t"
68 "decl %1\n"
69 "1:\tlodsb\n\t"
70 "stosb\n\t"
71 "testb %%al,%%al\n\t"
72 "jne 1b"
73 : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
74 : "0" (src), "1" (dest), "2" (0), "3" (0xffffffffu):"memory");
75return dest;
76}
77 16
78#define __HAVE_ARCH_STRNCAT 17#define __HAVE_ARCH_STRNCAT
79static inline char * strncat(char * dest,const char * src,size_t count) 18extern char *strncat(char *dest, const char *src, size_t count);
80{
81int d0, d1, d2, d3;
82__asm__ __volatile__(
83 "repne\n\t"
84 "scasb\n\t"
85 "decl %1\n\t"
86 "movl %8,%3\n"
87 "1:\tdecl %3\n\t"
88 "js 2f\n\t"
89 "lodsb\n\t"
90 "stosb\n\t"
91 "testb %%al,%%al\n\t"
92 "jne 1b\n"
93 "2:\txorl %2,%2\n\t"
94 "stosb"
95 : "=&S" (d0), "=&D" (d1), "=&a" (d2), "=&c" (d3)
96 : "0" (src),"1" (dest),"2" (0),"3" (0xffffffffu), "g" (count)
97 : "memory");
98return dest;
99}
100 19
101#define __HAVE_ARCH_STRCMP 20#define __HAVE_ARCH_STRCMP
102static inline int strcmp(const char * cs,const char * ct) 21extern int strcmp(const char *cs, const char *ct);
103{
104int d0, d1;
105register int __res;
106__asm__ __volatile__(
107 "1:\tlodsb\n\t"
108 "scasb\n\t"
109 "jne 2f\n\t"
110 "testb %%al,%%al\n\t"
111 "jne 1b\n\t"
112 "xorl %%eax,%%eax\n\t"
113 "jmp 3f\n"
114 "2:\tsbbl %%eax,%%eax\n\t"
115 "orb $1,%%al\n"
116 "3:"
117 :"=a" (__res), "=&S" (d0), "=&D" (d1)
118 :"1" (cs),"2" (ct)
119 :"memory");
120return __res;
121}
122 22
123#define __HAVE_ARCH_STRNCMP 23#define __HAVE_ARCH_STRNCMP
124static inline int strncmp(const char * cs,const char * ct,size_t count) 24extern int strncmp(const char *cs, const char *ct, size_t count);
125{
126register int __res;
127int d0, d1, d2;
128__asm__ __volatile__(
129 "1:\tdecl %3\n\t"
130 "js 2f\n\t"
131 "lodsb\n\t"
132 "scasb\n\t"
133 "jne 3f\n\t"
134 "testb %%al,%%al\n\t"
135 "jne 1b\n"
136 "2:\txorl %%eax,%%eax\n\t"
137 "jmp 4f\n"
138 "3:\tsbbl %%eax,%%eax\n\t"
139 "orb $1,%%al\n"
140 "4:"
141 :"=a" (__res), "=&S" (d0), "=&D" (d1), "=&c" (d2)
142 :"1" (cs),"2" (ct),"3" (count)
143 :"memory");
144return __res;
145}
146 25
147#define __HAVE_ARCH_STRCHR 26#define __HAVE_ARCH_STRCHR
148static inline char * strchr(const char * s, int c) 27extern char *strchr(const char *s, int c);
149{
150int d0;
151register char * __res;
152__asm__ __volatile__(
153 "movb %%al,%%ah\n"
154 "1:\tlodsb\n\t"
155 "cmpb %%ah,%%al\n\t"
156 "je 2f\n\t"
157 "testb %%al,%%al\n\t"
158 "jne 1b\n\t"
159 "movl $1,%1\n"
160 "2:\tmovl %1,%0\n\t"
161 "decl %0"
162 :"=a" (__res), "=&S" (d0)
163 :"1" (s),"0" (c)
164 :"memory");
165return __res;
166}
167 28
168#define __HAVE_ARCH_STRRCHR 29#define __HAVE_ARCH_STRRCHR
169static inline char * strrchr(const char * s, int c) 30extern char *strrchr(const char *s, int c);
170{
171int d0, d1;
172register char * __res;
173__asm__ __volatile__(
174 "movb %%al,%%ah\n"
175 "1:\tlodsb\n\t"
176 "cmpb %%ah,%%al\n\t"
177 "jne 2f\n\t"
178 "leal -1(%%esi),%0\n"
179 "2:\ttestb %%al,%%al\n\t"
180 "jne 1b"
181 :"=g" (__res), "=&S" (d0), "=&a" (d1)
182 :"0" (0),"1" (s),"2" (c)
183 :"memory");
184return __res;
185}
186 31
187#define __HAVE_ARCH_STRLEN 32#define __HAVE_ARCH_STRLEN
188static inline size_t strlen(const char * s) 33extern size_t strlen(const char *s);
189{
190int d0;
191register int __res;
192__asm__ __volatile__(
193 "repne\n\t"
194 "scasb\n\t"
195 "notl %0\n\t"
196 "decl %0"
197 :"=c" (__res), "=&D" (d0)
198 :"1" (s),"a" (0), "0" (0xffffffffu)
199 :"memory");
200return __res;
201}
202 34
203static __always_inline void * __memcpy(void * to, const void * from, size_t n) 35static __always_inline void * __memcpy(void * to, const void * from, size_t n)
204{ 36{
@@ -207,9 +39,7 @@ __asm__ __volatile__(
207 "rep ; movsl\n\t" 39 "rep ; movsl\n\t"
208 "movl %4,%%ecx\n\t" 40 "movl %4,%%ecx\n\t"
209 "andl $3,%%ecx\n\t" 41 "andl $3,%%ecx\n\t"
210#if 1 /* want to pay 2 byte penalty for a chance to skip microcoded rep? */
211 "jz 1f\n\t" 42 "jz 1f\n\t"
212#endif
213 "rep ; movsb\n\t" 43 "rep ; movsb\n\t"
214 "1:" 44 "1:"
215 : "=&c" (d0), "=&D" (d1), "=&S" (d2) 45 : "=&c" (d0), "=&D" (d1), "=&S" (d2)
@@ -328,23 +158,7 @@ void *memmove(void * dest,const void * src, size_t n);
328#define memcmp __builtin_memcmp 158#define memcmp __builtin_memcmp
329 159
330#define __HAVE_ARCH_MEMCHR 160#define __HAVE_ARCH_MEMCHR
331static inline void * memchr(const void * cs,int c,size_t count) 161extern void *memchr(const void * cs,int c,size_t count);
332{
333int d0;
334register void * __res;
335if (!count)
336 return NULL;
337__asm__ __volatile__(
338 "repne\n\t"
339 "scasb\n\t"
340 "je 1f\n\t"
341 "movl $1,%0\n"
342 "1:\tdecl %0"
343 :"=D" (__res), "=&c" (d0)
344 :"a" (c),"0" (cs),"1" (count)
345 :"memory");
346return __res;
347}
348 162
349static inline void * __memset_generic(void * s, char c,size_t count) 163static inline void * __memset_generic(void * s, char c,size_t count)
350{ 164{
@@ -386,29 +200,10 @@ return (s);
386 200
387/* Added by Gertjan van Wingerde to make minix and sysv module work */ 201/* Added by Gertjan van Wingerde to make minix and sysv module work */
388#define __HAVE_ARCH_STRNLEN 202#define __HAVE_ARCH_STRNLEN
389static inline size_t strnlen(const char * s, size_t count) 203extern size_t strnlen(const char * s, size_t count);
390{
391int d0;
392register int __res;
393__asm__ __volatile__(
394 "movl %2,%0\n\t"
395 "jmp 2f\n"
396 "1:\tcmpb $0,(%0)\n\t"
397 "je 3f\n\t"
398 "incl %0\n"
399 "2:\tdecl %1\n\t"
400 "cmpl $-1,%1\n\t"
401 "jne 1b\n"
402 "3:\tsubl %2,%0"
403 :"=a" (__res), "=&d" (d0)
404 :"c" (s),"1" (count)
405 :"memory");
406return __res;
407}
408/* end of additional stuff */ 204/* end of additional stuff */
409 205
410#define __HAVE_ARCH_STRSTR 206#define __HAVE_ARCH_STRSTR
411
412extern char *strstr(const char *cs, const char *ct); 207extern char *strstr(const char *cs, const char *ct);
413 208
414/* 209/*
@@ -474,19 +269,7 @@ __asm__ __volatile__( \
474 * find the first occurrence of byte 'c', or 1 past the area if none 269 * find the first occurrence of byte 'c', or 1 past the area if none
475 */ 270 */
476#define __HAVE_ARCH_MEMSCAN 271#define __HAVE_ARCH_MEMSCAN
477static inline void * memscan(void * addr, int c, size_t size) 272extern void *memscan(void * addr, int c, size_t size);
478{
479 if (!size)
480 return addr;
481 __asm__("repnz; scasb\n\t"
482 "jnz 1f\n\t"
483 "dec %%edi\n"
484 "1:"
485 : "=D" (addr), "=c" (size)
486 : "0" (addr), "1" (size), "a" (c)
487 : "memory");
488 return addr;
489}
490 273
491#endif /* __KERNEL__ */ 274#endif /* __KERNEL__ */
492 275
diff --git a/include/asm-i386/timer.h b/include/asm-i386/timer.h
index 51a713e33a9e..0db7e994fb8b 100644
--- a/include/asm-i386/timer.h
+++ b/include/asm-i386/timer.h
@@ -5,13 +5,11 @@
5 5
6#define TICK_SIZE (tick_nsec / 1000) 6#define TICK_SIZE (tick_nsec / 1000)
7 7
8void setup_pit_timer(void);
9unsigned long long native_sched_clock(void); 8unsigned long long native_sched_clock(void);
10unsigned long native_calculate_cpu_khz(void); 9unsigned long native_calculate_cpu_khz(void);
11 10
12extern int timer_ack; 11extern int timer_ack;
13extern int no_timer_check; 12extern int no_timer_check;
14extern int no_sync_cmos_clock;
15extern int recalibrate_cpu_khz(void); 13extern int recalibrate_cpu_khz(void);
16 14
17#ifndef CONFIG_PARAVIRT 15#ifndef CONFIG_PARAVIRT
diff --git a/include/asm-i386/tlbflush.h b/include/asm-i386/tlbflush.h
index fc525c5cd5a9..a50fa6741486 100644
--- a/include/asm-i386/tlbflush.h
+++ b/include/asm-i386/tlbflush.h
@@ -160,7 +160,11 @@ DECLARE_PER_CPU(struct tlb_state, cpu_tlbstate);
160 native_flush_tlb_others(&mask, mm, va) 160 native_flush_tlb_others(&mask, mm, va)
161#endif 161#endif
162 162
163#define flush_tlb_kernel_range(start, end) flush_tlb_all() 163static inline void flush_tlb_kernel_range(unsigned long start,
164 unsigned long end)
165{
166 flush_tlb_all();
167}
164 168
165static inline void flush_tlb_pgtables(struct mm_struct *mm, 169static inline void flush_tlb_pgtables(struct mm_struct *mm,
166 unsigned long start, unsigned long end) 170 unsigned long start, unsigned long end)
diff --git a/include/asm-i386/topology.h b/include/asm-i386/topology.h
index 7fc512d90ea8..19b2dafd0c81 100644
--- a/include/asm-i386/topology.h
+++ b/include/asm-i386/topology.h
@@ -67,7 +67,7 @@ static inline int node_to_first_cpu(int node)
67 return first_cpu(mask); 67 return first_cpu(mask);
68} 68}
69 69
70#define pcibus_to_node(bus) ((long) (bus)->sysdata) 70#define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node
71#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus)) 71#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus))
72 72
73/* sched_domains SD_NODE_INIT for NUMAQ machines */ 73/* sched_domains SD_NODE_INIT for NUMAQ machines */
diff --git a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h
index e2aa5e0d0cc7..d2a4f7be9c2c 100644
--- a/include/asm-i386/uaccess.h
+++ b/include/asm-i386/uaccess.h
@@ -581,7 +581,7 @@ long __must_check __strncpy_from_user(char *dst,
581 * If there is a limit on the length of a valid string, you may wish to 581 * If there is a limit on the length of a valid string, you may wish to
582 * consider using strnlen_user() instead. 582 * consider using strnlen_user() instead.
583 */ 583 */
584#define strlen_user(str) strnlen_user(str, ~0UL >> 1) 584#define strlen_user(str) strnlen_user(str, LONG_MAX)
585 585
586long strnlen_user(const char __user *str, long n); 586long strnlen_user(const char __user *str, long n);
587unsigned long __must_check clear_user(void __user *mem, unsigned long len); 587unsigned long __must_check clear_user(void __user *mem, unsigned long len);
diff --git a/include/asm-ia64/irq.h b/include/asm-ia64/irq.h
index 35b360b82e43..a66d26827cbb 100644
--- a/include/asm-ia64/irq.h
+++ b/include/asm-ia64/irq.h
@@ -33,9 +33,6 @@ irq_canonicalize (int irq)
33 return ((irq == 2) ? 9 : irq); 33 return ((irq == 2) ? 9 : irq);
34} 34}
35 35
36extern void disable_irq (unsigned int);
37extern void disable_irq_nosync (unsigned int);
38extern void enable_irq (unsigned int);
39extern void set_irq_affinity_info (unsigned int irq, int dest, int redir); 36extern void set_irq_affinity_info (unsigned int irq, int dest, int redir);
40bool is_affinity_mask_valid(cpumask_t cpumask); 37bool is_affinity_mask_valid(cpumask_t cpumask);
41 38
diff --git a/include/asm-m68k/irq.h b/include/asm-m68k/irq.h
index 4901cb105e2f..eb29a5260591 100644
--- a/include/asm-m68k/irq.h
+++ b/include/asm-m68k/irq.h
@@ -59,9 +59,6 @@
59#define IRQ_USER 8 59#define IRQ_USER 8
60 60
61extern unsigned int irq_canonicalize(unsigned int irq); 61extern unsigned int irq_canonicalize(unsigned int irq);
62extern void enable_irq(unsigned int);
63extern void disable_irq(unsigned int);
64#define disable_irq_nosync disable_irq
65 62
66struct pt_regs; 63struct pt_regs;
67 64
diff --git a/include/asm-powerpc/mpic.h b/include/asm-powerpc/mpic.h
index 2ffb06abe881..262db6b8da73 100644
--- a/include/asm-powerpc/mpic.h
+++ b/include/asm-powerpc/mpic.h
@@ -296,6 +296,9 @@ struct mpic
296 unsigned int dcr_base; 296 unsigned int dcr_base;
297#endif 297#endif
298 298
299 /* Protected sources */
300 unsigned long *protected;
301
299#ifdef CONFIG_MPIC_WEIRD 302#ifdef CONFIG_MPIC_WEIRD
300 /* Pointer to HW info array */ 303 /* Pointer to HW info array */
301 u32 *hw_set; 304 u32 *hw_set;
diff --git a/include/asm-powerpc/prom.h b/include/asm-powerpc/prom.h
index 6e391c9894ce..672083787a1d 100644
--- a/include/asm-powerpc/prom.h
+++ b/include/asm-powerpc/prom.h
@@ -139,7 +139,7 @@ extern unsigned long __init of_get_flat_dt_root(void);
139 139
140/* For updating the device tree at runtime */ 140/* For updating the device tree at runtime */
141extern void of_attach_node(struct device_node *); 141extern void of_attach_node(struct device_node *);
142extern void of_detach_node(const struct device_node *); 142extern void of_detach_node(struct device_node *);
143 143
144/* Other Prototypes */ 144/* Other Prototypes */
145extern void finish_device_tree(void); 145extern void finish_device_tree(void);
diff --git a/include/asm-ppc/system.h b/include/asm-ppc/system.h
index f1311a8f310f..cc45780421ca 100644
--- a/include/asm-ppc/system.h
+++ b/include/asm-ppc/system.h
@@ -54,6 +54,7 @@ extern void show_regs(struct pt_regs * regs);
54extern void flush_instruction_cache(void); 54extern void flush_instruction_cache(void);
55extern void hard_reset_now(void); 55extern void hard_reset_now(void);
56extern void poweroff_now(void); 56extern void poweroff_now(void);
57extern int set_dabr(unsigned long dabr);
57#ifdef CONFIG_6xx 58#ifdef CONFIG_6xx
58extern long _get_L2CR(void); 59extern long _get_L2CR(void);
59extern long _get_L3CR(void); 60extern long _get_L3CR(void);
diff --git a/include/asm-sh64/irq.h b/include/asm-sh64/irq.h
index 1ca49e29288a..5c9e6a873aeb 100644
--- a/include/asm-sh64/irq.h
+++ b/include/asm-sh64/irq.h
@@ -114,10 +114,6 @@
114#define IRL0_PRIORITY 13 114#define IRL0_PRIORITY 13
115#define TOP_PRIORITY 15 115#define TOP_PRIORITY 15
116 116
117extern void disable_irq(unsigned int);
118extern void disable_irq_nosync(unsigned int);
119extern void enable_irq(unsigned int);
120
121extern int intc_evt_to_irq[(0xE20/0x20)+1]; 117extern int intc_evt_to_irq[(0xE20/0x20)+1];
122int intc_irq_describe(char* p, int irq); 118int intc_irq_describe(char* p, int irq);
123 119
diff --git a/include/asm-sparc/irq.h b/include/asm-sparc/irq.h
index ff520ea97473..61fb99643afd 100644
--- a/include/asm-sparc/irq.h
+++ b/include/asm-sparc/irq.h
@@ -7,178 +7,12 @@
7#ifndef _SPARC_IRQ_H 7#ifndef _SPARC_IRQ_H
8#define _SPARC_IRQ_H 8#define _SPARC_IRQ_H
9 9
10#include <linux/linkage.h>
11#include <linux/threads.h> /* For NR_CPUS */
12#include <linux/interrupt.h> 10#include <linux/interrupt.h>
13 11
14#include <asm/system.h> /* For SUN4M_NCPUS */
15#include <asm/btfixup.h>
16
17#define __irq_ino(irq) irq
18#define __irq_pil(irq) irq
19
20#define NR_IRQS 16 12#define NR_IRQS 16
21 13
22#define irq_canonicalize(irq) (irq) 14#define irq_canonicalize(irq) (irq)
23 15
24/* Dave Redman (djhr@tadpole.co.uk)
25 * changed these to function pointers.. it saves cycles and will allow
26 * the irq dependencies to be split into different files at a later date
27 * sun4c_irq.c, sun4m_irq.c etc so we could reduce the kernel size.
28 * Jakub Jelinek (jj@sunsite.mff.cuni.cz)
29 * Changed these to btfixup entities... It saves cycles :)
30 */
31BTFIXUPDEF_CALL(void, disable_irq, unsigned int)
32BTFIXUPDEF_CALL(void, enable_irq, unsigned int)
33BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int)
34BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int)
35BTFIXUPDEF_CALL(void, clear_clock_irq, void)
36BTFIXUPDEF_CALL(void, clear_profile_irq, int)
37BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int)
38
39static inline void disable_irq_nosync(unsigned int irq)
40{
41 BTFIXUP_CALL(disable_irq)(irq);
42}
43
44static inline void disable_irq(unsigned int irq)
45{
46 BTFIXUP_CALL(disable_irq)(irq);
47}
48
49static inline void enable_irq(unsigned int irq)
50{
51 BTFIXUP_CALL(enable_irq)(irq);
52}
53
54static inline void disable_pil_irq(unsigned int irq)
55{
56 BTFIXUP_CALL(disable_pil_irq)(irq);
57}
58
59static inline void enable_pil_irq(unsigned int irq)
60{
61 BTFIXUP_CALL(enable_pil_irq)(irq);
62}
63
64static inline void clear_clock_irq(void)
65{
66 BTFIXUP_CALL(clear_clock_irq)();
67}
68
69static inline void clear_profile_irq(int irq)
70{
71 BTFIXUP_CALL(clear_profile_irq)(irq);
72}
73
74static inline void load_profile_irq(int cpu, int limit)
75{
76 BTFIXUP_CALL(load_profile_irq)(cpu, limit);
77}
78
79extern void (*sparc_init_timers)(irq_handler_t lvl10_irq);
80extern void claim_ticker14(irq_handler_t irq_handler,
81 int irq,
82 unsigned int timeout);
83
84#ifdef CONFIG_SMP
85BTFIXUPDEF_CALL(void, set_cpu_int, int, int)
86BTFIXUPDEF_CALL(void, clear_cpu_int, int, int)
87BTFIXUPDEF_CALL(void, set_irq_udt, int)
88
89#define set_cpu_int(cpu,level) BTFIXUP_CALL(set_cpu_int)(cpu,level)
90#define clear_cpu_int(cpu,level) BTFIXUP_CALL(clear_cpu_int)(cpu,level)
91#define set_irq_udt(cpu) BTFIXUP_CALL(set_irq_udt)(cpu)
92#endif
93
94extern int request_fast_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, __const__ char *devname); 16extern int request_fast_irq(unsigned int irq, irq_handler_t handler, unsigned long flags, __const__ char *devname);
95 17
96/* On the sun4m, just like the timers, we have both per-cpu and master
97 * interrupt registers.
98 */
99
100/* These registers are used for sending/receiving irqs from/to
101 * different cpu's.
102 */
103struct sun4m_intreg_percpu {
104 unsigned int tbt; /* Interrupts still pending for this cpu. */
105
106 /* These next two registers are WRITE-ONLY and are only
107 * "on bit" sensitive, "off bits" written have NO affect.
108 */
109 unsigned int clear; /* Clear this cpus irqs here. */
110 unsigned int set; /* Set this cpus irqs here. */
111 unsigned char space[PAGE_SIZE - 12];
112};
113
114/*
115 * djhr
116 * Actually the clear and set fields in this struct are misleading..
117 * according to the SLAVIO manual (and the same applies for the SEC)
118 * the clear field clears bits in the mask which will ENABLE that IRQ
119 * the set field sets bits in the mask to DISABLE the IRQ.
120 *
121 * Also the undirected_xx address in the SLAVIO is defined as
122 * RESERVED and write only..
123 *
124 * DAVEM_NOTE: The SLAVIO only specifies behavior on uniprocessor
125 * sun4m machines, for MP the layout makes more sense.
126 */
127struct sun4m_intregs {
128 struct sun4m_intreg_percpu cpu_intregs[SUN4M_NCPUS];
129 unsigned int tbt; /* IRQ's that are still pending. */
130 unsigned int irqs; /* Master IRQ bits. */
131
132 /* Again, like the above, two these registers are WRITE-ONLY. */
133 unsigned int clear; /* Clear master IRQ's by setting bits here. */
134 unsigned int set; /* Set master IRQ's by setting bits here. */
135
136 /* This register is both READ and WRITE. */
137 unsigned int undirected_target; /* Which cpu gets undirected irqs. */
138};
139
140extern struct sun4m_intregs *sun4m_interrupts;
141
142/*
143 * Bit field defines for the interrupt registers on various
144 * Sparc machines.
145 */
146
147/* The sun4c interrupt register. */
148#define SUN4C_INT_ENABLE 0x01 /* Allow interrupts. */
149#define SUN4C_INT_E14 0x80 /* Enable level 14 IRQ. */
150#define SUN4C_INT_E10 0x20 /* Enable level 10 IRQ. */
151#define SUN4C_INT_E8 0x10 /* Enable level 8 IRQ. */
152#define SUN4C_INT_E6 0x08 /* Enable level 6 IRQ. */
153#define SUN4C_INT_E4 0x04 /* Enable level 4 IRQ. */
154#define SUN4C_INT_E1 0x02 /* Enable level 1 IRQ. */
155
156/* Dave Redman (djhr@tadpole.co.uk)
157 * The sun4m interrupt registers.
158 */
159#define SUN4M_INT_ENABLE 0x80000000
160#define SUN4M_INT_E14 0x00000080
161#define SUN4M_INT_E10 0x00080000
162
163#define SUN4M_HARD_INT(x) (0x000000001 << (x))
164#define SUN4M_SOFT_INT(x) (0x000010000 << (x))
165
166#define SUN4M_INT_MASKALL 0x80000000 /* mask all interrupts */
167#define SUN4M_INT_MODULE_ERR 0x40000000 /* module error */
168#define SUN4M_INT_M2S_WRITE 0x20000000 /* write buffer error */
169#define SUN4M_INT_ECC 0x10000000 /* ecc memory error */
170#define SUN4M_INT_FLOPPY 0x00400000 /* floppy disk */
171#define SUN4M_INT_MODULE 0x00200000 /* module interrupt */
172#define SUN4M_INT_VIDEO 0x00100000 /* onboard video */
173#define SUN4M_INT_REALTIME 0x00080000 /* system timer */
174#define SUN4M_INT_SCSI 0x00040000 /* onboard scsi */
175#define SUN4M_INT_AUDIO 0x00020000 /* audio/isdn */
176#define SUN4M_INT_ETHERNET 0x00010000 /* onboard ethernet */
177#define SUN4M_INT_SERIAL 0x00008000 /* serial ports */
178#define SUN4M_INT_KBDMS 0x00004000 /* keyboard/mouse */
179#define SUN4M_INT_SBUSBITS 0x00003F80 /* sbus int bits */
180
181#define SUN4M_INT_SBUS(x) (1 << (x+7))
182#define SUN4M_INT_VME(x) (1 << (x))
183
184#endif 18#endif
diff --git a/include/asm-sparc/pgtable.h b/include/asm-sparc/pgtable.h
index a55f4c3488b0..2cc235b74d94 100644
--- a/include/asm-sparc/pgtable.h
+++ b/include/asm-sparc/pgtable.h
@@ -46,7 +46,6 @@ BTFIXUPDEF_SIMM13(user_ptrs_per_pgd)
46#define pgd_ERROR(e) __builtin_trap() 46#define pgd_ERROR(e) __builtin_trap()
47 47
48BTFIXUPDEF_INT(page_none) 48BTFIXUPDEF_INT(page_none)
49BTFIXUPDEF_INT(page_shared)
50BTFIXUPDEF_INT(page_copy) 49BTFIXUPDEF_INT(page_copy)
51BTFIXUPDEF_INT(page_readonly) 50BTFIXUPDEF_INT(page_readonly)
52BTFIXUPDEF_INT(page_kernel) 51BTFIXUPDEF_INT(page_kernel)
@@ -66,7 +65,7 @@ BTFIXUPDEF_INT(page_kernel)
66#define PTE_SIZE (PTRS_PER_PTE*4) 65#define PTE_SIZE (PTRS_PER_PTE*4)
67 66
68#define PAGE_NONE __pgprot(BTFIXUP_INT(page_none)) 67#define PAGE_NONE __pgprot(BTFIXUP_INT(page_none))
69#define PAGE_SHARED __pgprot(BTFIXUP_INT(page_shared)) 68extern pgprot_t PAGE_SHARED;
70#define PAGE_COPY __pgprot(BTFIXUP_INT(page_copy)) 69#define PAGE_COPY __pgprot(BTFIXUP_INT(page_copy))
71#define PAGE_READONLY __pgprot(BTFIXUP_INT(page_readonly)) 70#define PAGE_READONLY __pgprot(BTFIXUP_INT(page_readonly))
72 71
diff --git a/include/asm-v850/irq.h b/include/asm-v850/irq.h
index 88687c181f01..7d0d4cd1ce54 100644
--- a/include/asm-v850/irq.h
+++ b/include/asm-v850/irq.h
@@ -50,16 +50,6 @@ init_irq_handlers (int base_irq, int num, int interval,
50 interrupt. */ 50 interrupt. */
51extern unsigned int handle_irq (int irq, struct pt_regs *regs); 51extern unsigned int handle_irq (int irq, struct pt_regs *regs);
52 52
53
54/* Enable interrupt handling on an irq. */
55extern void enable_irq(unsigned int irq);
56
57/* Disable an irq and wait for completion. */
58extern void disable_irq (unsigned int irq);
59
60/* Disable an irq without waiting. */
61extern void disable_irq_nosync (unsigned int irq);
62
63#endif /* !__ASSEMBLY__ */ 53#endif /* !__ASSEMBLY__ */
64 54
65#endif /* __V850_IRQ_H__ */ 55#endif /* __V850_IRQ_H__ */
diff --git a/include/asm-x86_64/acpi.h b/include/asm-x86_64/acpi.h
index a29f05087a31..1da8f49c0fe2 100644
--- a/include/asm-x86_64/acpi.h
+++ b/include/asm-x86_64/acpi.h
@@ -29,6 +29,7 @@
29#ifdef __KERNEL__ 29#ifdef __KERNEL__
30 30
31#include <acpi/pdc_intel.h> 31#include <acpi/pdc_intel.h>
32#include <asm/numa.h>
32 33
33#define COMPILER_DEPENDENT_INT64 long long 34#define COMPILER_DEPENDENT_INT64 long long
34#define COMPILER_DEPENDENT_UINT64 unsigned long long 35#define COMPILER_DEPENDENT_UINT64 unsigned long long
@@ -141,6 +142,16 @@ extern int acpi_pci_disabled;
141extern int acpi_skip_timer_override; 142extern int acpi_skip_timer_override;
142extern int acpi_use_timer_override; 143extern int acpi_use_timer_override;
143 144
145#ifdef CONFIG_ACPI_NUMA
146extern void __init acpi_fake_nodes(const struct bootnode *fake_nodes,
147 int num_nodes);
148#else
149static inline void acpi_fake_nodes(const struct bootnode *fake_nodes,
150 int num_nodes)
151{
152}
153#endif
154
144#endif /*__KERNEL__*/ 155#endif /*__KERNEL__*/
145 156
146#endif /*_ASM_ACPI_H*/ 157#endif /*_ASM_ACPI_H*/
diff --git a/include/asm-x86_64/alternative.h b/include/asm-x86_64/alternative.h
index eea7aecfac78..ab161e810151 100644
--- a/include/asm-x86_64/alternative.h
+++ b/include/asm-x86_64/alternative.h
@@ -154,4 +154,6 @@ apply_paravirt(struct paravirt_patch *start, struct paravirt_patch *end)
154#define __parainstructions_end NULL 154#define __parainstructions_end NULL
155#endif 155#endif
156 156
157extern void text_poke(void *addr, unsigned char *opcode, int len);
158
157#endif /* _X86_64_ALTERNATIVE_H */ 159#endif /* _X86_64_ALTERNATIVE_H */
diff --git a/include/asm-x86_64/apic.h b/include/asm-x86_64/apic.h
index 45e9fca1febc..85125ef3c414 100644
--- a/include/asm-x86_64/apic.h
+++ b/include/asm-x86_64/apic.h
@@ -83,8 +83,10 @@ extern void disable_APIC_timer(void);
83extern void enable_APIC_timer(void); 83extern void enable_APIC_timer(void);
84extern void setup_apic_routing(void); 84extern void setup_apic_routing(void);
85 85
86extern void setup_APIC_extened_lvt(unsigned char lvt_off, unsigned char vector, 86extern void setup_APIC_extended_lvt(unsigned char lvt_off, unsigned char vector,
87 unsigned char msg_type, unsigned char mask); 87 unsigned char msg_type, unsigned char mask);
88
89extern int apic_is_clustered_box(void);
88 90
89#define K8_APIC_EXT_LVT_BASE 0x500 91#define K8_APIC_EXT_LVT_BASE 0x500
90#define K8_APIC_EXT_INT_MSG_FIX 0x0 92#define K8_APIC_EXT_INT_MSG_FIX 0x0
diff --git a/include/asm-x86_64/auxvec.h b/include/asm-x86_64/auxvec.h
index 2403c4cfced2..1d5ab0d03950 100644
--- a/include/asm-x86_64/auxvec.h
+++ b/include/asm-x86_64/auxvec.h
@@ -1,4 +1,6 @@
1#ifndef __ASM_X86_64_AUXVEC_H 1#ifndef __ASM_X86_64_AUXVEC_H
2#define __ASM_X86_64_AUXVEC_H 2#define __ASM_X86_64_AUXVEC_H
3 3
4#define AT_SYSINFO_EHDR 33
5
4#endif 6#endif
diff --git a/include/asm-x86_64/calgary.h b/include/asm-x86_64/calgary.h
index 4d5747a0923c..67f60406e2d8 100644
--- a/include/asm-x86_64/calgary.h
+++ b/include/asm-x86_64/calgary.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * Derived from include/asm-powerpc/iommu.h 2 * Derived from include/asm-powerpc/iommu.h
3 * 3 *
4 * Copyright (C) IBM Corporation, 2006 4 * Copyright IBM Corporation, 2006-2007
5 * 5 *
6 * Author: Jon Mason <jdmason@us.ibm.com> 6 * Author: Jon Mason <jdmason@us.ibm.com>
7 * Author: Muli Ben-Yehuda <muli@il.ibm.com> 7 * Author: Muli Ben-Yehuda <muli@il.ibm.com>
@@ -31,6 +31,7 @@
31#include <asm/types.h> 31#include <asm/types.h>
32 32
33struct iommu_table { 33struct iommu_table {
34 struct cal_chipset_ops *chip_ops; /* chipset specific funcs */
34 unsigned long it_base; /* mapped address of tce table */ 35 unsigned long it_base; /* mapped address of tce table */
35 unsigned long it_hint; /* Hint for next alloc */ 36 unsigned long it_hint; /* Hint for next alloc */
36 unsigned long *it_map; /* A simple allocation bitmap for now */ 37 unsigned long *it_map; /* A simple allocation bitmap for now */
@@ -42,6 +43,12 @@ struct iommu_table {
42 unsigned char it_busno; /* Bus number this table belongs to */ 43 unsigned char it_busno; /* Bus number this table belongs to */
43}; 44};
44 45
46struct cal_chipset_ops {
47 void (*handle_quirks)(struct iommu_table *tbl, struct pci_dev *dev);
48 void (*tce_cache_blast)(struct iommu_table *tbl);
49 void (*dump_error_regs)(struct iommu_table *tbl);
50};
51
45#define TCE_TABLE_SIZE_UNSPECIFIED ~0 52#define TCE_TABLE_SIZE_UNSPECIFIED ~0
46#define TCE_TABLE_SIZE_64K 0 53#define TCE_TABLE_SIZE_64K 0
47#define TCE_TABLE_SIZE_128K 1 54#define TCE_TABLE_SIZE_128K 1
diff --git a/include/asm-x86_64/cmpxchg.h b/include/asm-x86_64/cmpxchg.h
index 09a6b6b6b74d..5e182062e6ec 100644
--- a/include/asm-x86_64/cmpxchg.h
+++ b/include/asm-x86_64/cmpxchg.h
@@ -128,7 +128,7 @@ static inline unsigned long __cmpxchg_local(volatile void *ptr,
128 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ 128 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\
129 (unsigned long)(n),sizeof(*(ptr)))) 129 (unsigned long)(n),sizeof(*(ptr))))
130#define cmpxchg_local(ptr,o,n)\ 130#define cmpxchg_local(ptr,o,n)\
131 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ 131 ((__typeof__(*(ptr)))__cmpxchg_local((ptr),(unsigned long)(o),\
132 (unsigned long)(n),sizeof(*(ptr)))) 132 (unsigned long)(n),sizeof(*(ptr))))
133 133
134#endif 134#endif
diff --git a/include/asm-x86_64/dmi.h b/include/asm-x86_64/dmi.h
index 93b2b15d4325..d02e32e3c3f0 100644
--- a/include/asm-x86_64/dmi.h
+++ b/include/asm-x86_64/dmi.h
@@ -3,15 +3,12 @@
3 3
4#include <asm/io.h> 4#include <asm/io.h>
5 5
6extern void *dmi_ioremap(unsigned long addr, unsigned long size);
7extern void dmi_iounmap(void *addr, unsigned long size);
8
9#define DMI_MAX_DATA 2048 6#define DMI_MAX_DATA 2048
10 7
11extern int dmi_alloc_index; 8extern int dmi_alloc_index;
12extern char dmi_alloc_data[DMI_MAX_DATA]; 9extern char dmi_alloc_data[DMI_MAX_DATA];
13 10
14/* This is so early that there is no good way to allocate dynamic memory. 11/* This is so early that there is no good way to allocate dynamic memory.
15 Allocate data in an BSS array. */ 12 Allocate data in an BSS array. */
16static inline void *dmi_alloc(unsigned len) 13static inline void *dmi_alloc(unsigned len)
17{ 14{
diff --git a/include/asm-x86_64/elf.h b/include/asm-x86_64/elf.h
index 6d24ea7c4d9d..b4fbe47f6ccd 100644
--- a/include/asm-x86_64/elf.h
+++ b/include/asm-x86_64/elf.h
@@ -162,6 +162,19 @@ extern int dump_task_fpu (struct task_struct *, elf_fpregset_t *);
162/* 1GB for 64bit, 8MB for 32bit */ 162/* 1GB for 64bit, 8MB for 32bit */
163#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff) 163#define STACK_RND_MASK (test_thread_flag(TIF_IA32) ? 0x7ff : 0x3fffff)
164 164
165
166#define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
167struct linux_binprm;
168extern int arch_setup_additional_pages(struct linux_binprm *bprm,
169 int executable_stack);
170
171extern int vdso_enabled;
172
173#define ARCH_DLINFO \
174do if (vdso_enabled) { \
175 NEW_AUX_ENT(AT_SYSINFO_EHDR,(unsigned long)current->mm->context.vdso);\
176} while (0)
177
165#endif 178#endif
166 179
167#endif 180#endif
diff --git a/include/asm-x86_64/fixmap.h b/include/asm-x86_64/fixmap.h
index 2acb9b7f6418..cdfbe4a6ae6f 100644
--- a/include/asm-x86_64/fixmap.h
+++ b/include/asm-x86_64/fixmap.h
@@ -22,9 +22,9 @@
22 * compile time, but to set the physical address only 22 * compile time, but to set the physical address only
23 * in the boot process. 23 * in the boot process.
24 * 24 *
25 * these 'compile-time allocated' memory buffers are 25 * These 'compile-time allocated' memory buffers are
26 * fixed-size 4k pages. (or larger if used with an increment 26 * fixed-size 4k pages (or larger if used with an increment
27 * highger than 1) use fixmap_set(idx,phys) to associate 27 * higher than 1). Use set_fixmap(idx,phys) to associate
28 * physical memory with fixmap indices. 28 * physical memory with fixmap indices.
29 * 29 *
30 * TLB entries of such buffers will not be flushed across 30 * TLB entries of such buffers will not be flushed across
diff --git a/include/asm-x86_64/hpet.h b/include/asm-x86_64/hpet.h
index 59a66f084611..79bb950f82c5 100644
--- a/include/asm-x86_64/hpet.h
+++ b/include/asm-x86_64/hpet.h
@@ -1,78 +1,18 @@
1#ifndef _ASM_X8664_HPET_H 1#ifndef _ASM_X8664_HPET_H
2#define _ASM_X8664_HPET_H 1 2#define _ASM_X8664_HPET_H 1
3 3
4/* 4#include <asm-i386/hpet.h>
5 * Documentation on HPET can be found at:
6 * http://www.intel.com/ial/home/sp/pcmmspec.htm
7 * ftp://download.intel.com/ial/home/sp/mmts098.pdf
8 */
9
10#define HPET_MMAP_SIZE 1024
11
12#define HPET_ID 0x000
13#define HPET_PERIOD 0x004
14#define HPET_CFG 0x010
15#define HPET_STATUS 0x020
16#define HPET_COUNTER 0x0f0
17#define HPET_Tn_OFFSET 0x20
18#define HPET_Tn_CFG(n) (0x100 + (n) * HPET_Tn_OFFSET)
19#define HPET_Tn_ROUTE(n) (0x104 + (n) * HPET_Tn_OFFSET)
20#define HPET_Tn_CMP(n) (0x108 + (n) * HPET_Tn_OFFSET)
21#define HPET_T0_CFG HPET_Tn_CFG(0)
22#define HPET_T0_CMP HPET_Tn_CMP(0)
23#define HPET_T1_CFG HPET_Tn_CFG(1)
24#define HPET_T1_CMP HPET_Tn_CMP(1)
25
26#define HPET_ID_VENDOR 0xffff0000
27#define HPET_ID_LEGSUP 0x00008000
28#define HPET_ID_64BIT 0x00002000
29#define HPET_ID_NUMBER 0x00001f00
30#define HPET_ID_REV 0x000000ff
31#define HPET_ID_NUMBER_SHIFT 8
32
33#define HPET_ID_VENDOR_SHIFT 16
34#define HPET_ID_VENDOR_8086 0x8086
35
36#define HPET_CFG_ENABLE 0x001
37#define HPET_CFG_LEGACY 0x002
38#define HPET_LEGACY_8254 2
39#define HPET_LEGACY_RTC 8
40
41#define HPET_TN_LEVEL 0x0002
42#define HPET_TN_ENABLE 0x0004
43#define HPET_TN_PERIODIC 0x0008
44#define HPET_TN_PERIODIC_CAP 0x0010
45#define HPET_TN_64BIT_CAP 0x0020
46#define HPET_TN_SETVAL 0x0040
47#define HPET_TN_32BIT 0x0100
48#define HPET_TN_ROUTE 0x3e00
49#define HPET_TN_FSB 0x4000
50#define HPET_TN_FSB_CAP 0x8000
51
52#define HPET_TN_ROUTE_SHIFT 9
53 5
54#define HPET_TICK_RATE (HZ * 100000UL) 6#define HPET_TICK_RATE (HZ * 100000UL)
55 7
56extern int is_hpet_enabled(void);
57extern int hpet_rtc_timer_init(void); 8extern int hpet_rtc_timer_init(void);
58extern int apic_is_clustered_box(void);
59extern int hpet_arch_init(void); 9extern int hpet_arch_init(void);
60extern int hpet_timer_stop_set_go(unsigned long tick); 10extern int hpet_timer_stop_set_go(unsigned long tick);
61extern int hpet_reenable(void); 11extern int hpet_reenable(void);
62extern unsigned int hpet_calibrate_tsc(void); 12extern unsigned int hpet_calibrate_tsc(void);
63 13
64extern int hpet_use_timer; 14extern int hpet_use_timer;
65extern unsigned long hpet_address;
66extern unsigned long hpet_period; 15extern unsigned long hpet_period;
67extern unsigned long hpet_tick; 16extern unsigned long hpet_tick;
68 17
69#ifdef CONFIG_HPET_EMULATE_RTC
70extern int hpet_mask_rtc_irq_bit(unsigned long bit_mask);
71extern int hpet_set_rtc_irq_bit(unsigned long bit_mask);
72extern int hpet_set_alarm_time(unsigned char hrs, unsigned char min, unsigned char sec);
73extern int hpet_set_periodic_freq(unsigned long freq);
74extern int hpet_rtc_dropped_irq(void);
75extern int hpet_rtc_timer_init(void);
76#endif /* CONFIG_HPET_EMULATE_RTC */
77
78#endif 18#endif
diff --git a/include/asm-x86_64/hw_irq.h b/include/asm-x86_64/hw_irq.h
index 6153ae5df2e8..09dfc18a6dd0 100644
--- a/include/asm-x86_64/hw_irq.h
+++ b/include/asm-x86_64/hw_irq.h
@@ -95,6 +95,26 @@
95 95
96 96
97#ifndef __ASSEMBLY__ 97#ifndef __ASSEMBLY__
98
99/* Interrupt handlers registered during init_IRQ */
100void apic_timer_interrupt(void);
101void spurious_interrupt(void);
102void error_interrupt(void);
103void reschedule_interrupt(void);
104void call_function_interrupt(void);
105void irq_move_cleanup_interrupt(void);
106void invalidate_interrupt0(void);
107void invalidate_interrupt1(void);
108void invalidate_interrupt2(void);
109void invalidate_interrupt3(void);
110void invalidate_interrupt4(void);
111void invalidate_interrupt5(void);
112void invalidate_interrupt6(void);
113void invalidate_interrupt7(void);
114void thermal_interrupt(void);
115void threshold_interrupt(void);
116void i8254_timer_resume(void);
117
98typedef int vector_irq_t[NR_VECTORS]; 118typedef int vector_irq_t[NR_VECTORS];
99DECLARE_PER_CPU(vector_irq_t, vector_irq); 119DECLARE_PER_CPU(vector_irq_t, vector_irq);
100extern void __setup_vector_irq(int cpu); 120extern void __setup_vector_irq(int cpu);
diff --git a/include/asm-x86_64/hypertransport.h b/include/asm-x86_64/hypertransport.h
index c16c6ff4bdd7..5cbf9fa5e0b5 100644
--- a/include/asm-x86_64/hypertransport.h
+++ b/include/asm-x86_64/hypertransport.h
@@ -1,42 +1 @@
1#ifndef ASM_HYPERTRANSPORT_H #include <asm-i386/hypertransport.h>
2#define ASM_HYPERTRANSPORT_H
3
4/*
5 * Constants for x86 Hypertransport Interrupts.
6 */
7
8#define HT_IRQ_LOW_BASE 0xf8000000
9
10#define HT_IRQ_LOW_VECTOR_SHIFT 16
11#define HT_IRQ_LOW_VECTOR_MASK 0x00ff0000
12#define HT_IRQ_LOW_VECTOR(v) (((v) << HT_IRQ_LOW_VECTOR_SHIFT) & HT_IRQ_LOW_VECTOR_MASK)
13
14#define HT_IRQ_LOW_DEST_ID_SHIFT 8
15#define HT_IRQ_LOW_DEST_ID_MASK 0x0000ff00
16#define HT_IRQ_LOW_DEST_ID(v) (((v) << HT_IRQ_LOW_DEST_ID_SHIFT) & HT_IRQ_LOW_DEST_ID_MASK)
17
18#define HT_IRQ_LOW_DM_PHYSICAL 0x0000000
19#define HT_IRQ_LOW_DM_LOGICAL 0x0000040
20
21#define HT_IRQ_LOW_RQEOI_EDGE 0x0000000
22#define HT_IRQ_LOW_RQEOI_LEVEL 0x0000020
23
24
25#define HT_IRQ_LOW_MT_FIXED 0x0000000
26#define HT_IRQ_LOW_MT_ARBITRATED 0x0000004
27#define HT_IRQ_LOW_MT_SMI 0x0000008
28#define HT_IRQ_LOW_MT_NMI 0x000000c
29#define HT_IRQ_LOW_MT_INIT 0x0000010
30#define HT_IRQ_LOW_MT_STARTUP 0x0000014
31#define HT_IRQ_LOW_MT_EXTINT 0x0000018
32#define HT_IRQ_LOW_MT_LINT1 0x000008c
33#define HT_IRQ_LOW_MT_LINT0 0x0000098
34
35#define HT_IRQ_LOW_IRQ_MASKED 0x0000001
36
37
38#define HT_IRQ_HIGH_DEST_ID_SHIFT 0
39#define HT_IRQ_HIGH_DEST_ID_MASK 0x00ffffff
40#define HT_IRQ_HIGH_DEST_ID(v) ((((v) >> 8) << HT_IRQ_HIGH_DEST_ID_SHIFT) & HT_IRQ_HIGH_DEST_ID_MASK)
41
42#endif /* ASM_HYPERTRANSPORT_H */
diff --git a/include/asm-x86_64/i8253.h b/include/asm-x86_64/i8253.h
new file mode 100644
index 000000000000..015d8df07690
--- /dev/null
+++ b/include/asm-x86_64/i8253.h
@@ -0,0 +1,6 @@
1#ifndef __ASM_I8253_H__
2#define __ASM_I8253_H__
3
4extern spinlock_t i8253_lock;
5
6#endif /* __ASM_I8253_H__ */
diff --git a/include/asm-x86_64/iommu.h b/include/asm-x86_64/iommu.h
new file mode 100644
index 000000000000..5af471f228ee
--- /dev/null
+++ b/include/asm-x86_64/iommu.h
@@ -0,0 +1,29 @@
1#ifndef _ASM_X8664_IOMMU_H
2#define _ASM_X8664_IOMMU_H 1
3
4extern void pci_iommu_shutdown(void);
5extern void no_iommu_init(void);
6extern int force_iommu, no_iommu;
7extern int iommu_detected;
8#ifdef CONFIG_IOMMU
9extern void gart_iommu_init(void);
10extern void gart_iommu_shutdown(void);
11extern void __init gart_parse_options(char *);
12extern void iommu_hole_init(void);
13extern int fallback_aper_order;
14extern int fallback_aper_force;
15extern int iommu_aperture;
16extern int iommu_aperture_allowed;
17extern int iommu_aperture_disabled;
18extern int fix_aperture;
19#else
20#define iommu_aperture 0
21#define iommu_aperture_allowed 0
22
23static inline void gart_iommu_shutdown(void)
24{
25}
26
27#endif
28
29#endif
diff --git a/include/asm-x86_64/mce.h b/include/asm-x86_64/mce.h
index 177e92b4019b..7bc030a1996d 100644
--- a/include/asm-x86_64/mce.h
+++ b/include/asm-x86_64/mce.h
@@ -105,6 +105,11 @@ extern atomic_t mce_entry;
105 105
106extern void do_machine_check(struct pt_regs *, long); 106extern void do_machine_check(struct pt_regs *, long);
107 107
108extern int mce_notify_user(void);
109
110extern void stop_mce(void);
111extern void restart_mce(void);
112
108#endif 113#endif
109 114
110#endif 115#endif
diff --git a/include/asm-x86_64/mmu.h b/include/asm-x86_64/mmu.h
index 5dc6ed79859a..d2cd4a9d984d 100644
--- a/include/asm-x86_64/mmu.h
+++ b/include/asm-x86_64/mmu.h
@@ -15,6 +15,7 @@ typedef struct {
15 rwlock_t ldtlock; 15 rwlock_t ldtlock;
16 int size; 16 int size;
17 struct semaphore sem; 17 struct semaphore sem;
18 void *vdso;
18} mm_context_t; 19} mm_context_t;
19 20
20#endif 21#endif
diff --git a/include/asm-x86_64/msidef.h b/include/asm-x86_64/msidef.h
index 5b8acddb70fb..083ad5827e48 100644
--- a/include/asm-x86_64/msidef.h
+++ b/include/asm-x86_64/msidef.h
@@ -1,47 +1 @@
1#ifndef ASM_MSIDEF_H #include <asm-i386/msidef.h>
2#define ASM_MSIDEF_H
3
4/*
5 * Constants for Intel APIC based MSI messages.
6 */
7
8/*
9 * Shifts for MSI data
10 */
11
12#define MSI_DATA_VECTOR_SHIFT 0
13#define MSI_DATA_VECTOR_MASK 0x000000ff
14#define MSI_DATA_VECTOR(v) (((v) << MSI_DATA_VECTOR_SHIFT) & MSI_DATA_VECTOR_MASK)
15
16#define MSI_DATA_DELIVERY_MODE_SHIFT 8
17#define MSI_DATA_DELIVERY_FIXED (0 << MSI_DATA_DELIVERY_MODE_SHIFT)
18#define MSI_DATA_DELIVERY_LOWPRI (1 << MSI_DATA_DELIVERY_MODE_SHIFT)
19
20#define MSI_DATA_LEVEL_SHIFT 14
21#define MSI_DATA_LEVEL_DEASSERT (0 << MSI_DATA_LEVEL_SHIFT)
22#define MSI_DATA_LEVEL_ASSERT (1 << MSI_DATA_LEVEL_SHIFT)
23
24#define MSI_DATA_TRIGGER_SHIFT 15
25#define MSI_DATA_TRIGGER_EDGE (0 << MSI_DATA_TRIGGER_SHIFT)
26#define MSI_DATA_TRIGGER_LEVEL (1 << MSI_DATA_TRIGGER_SHIFT)
27
28/*
29 * Shift/mask fields for msi address
30 */
31
32#define MSI_ADDR_BASE_HI 0
33#define MSI_ADDR_BASE_LO 0xfee00000
34
35#define MSI_ADDR_DEST_MODE_SHIFT 2
36#define MSI_ADDR_DEST_MODE_PHYSICAL (0 << MSI_ADDR_DEST_MODE_SHIFT)
37#define MSI_ADDR_DEST_MODE_LOGICAL (1 << MSI_ADDR_DEST_MODE_SHIFT)
38
39#define MSI_ADDR_REDIRECTION_SHIFT 3
40#define MSI_ADDR_REDIRECTION_CPU (0 << MSI_ADDR_REDIRECTION_SHIFT) /* dedicated cpu */
41#define MSI_ADDR_REDIRECTION_LOWPRI (1 << MSI_ADDR_REDIRECTION_SHIFT) /* lowest priority */
42
43#define MSI_ADDR_DEST_ID_SHIFT 12
44#define MSI_ADDR_DEST_ID_MASK 0x00ffff0
45#define MSI_ADDR_DEST_ID(dest) (((dest) << MSI_ADDR_DEST_ID_SHIFT) & MSI_ADDR_DEST_ID_MASK)
46
47#endif /* ASM_MSIDEF_H */
diff --git a/include/asm-x86_64/nmi.h b/include/asm-x86_64/nmi.h
index d0a7f53b1497..5fb3c0de5ccc 100644
--- a/include/asm-x86_64/nmi.h
+++ b/include/asm-x86_64/nmi.h
@@ -88,5 +88,7 @@ unsigned lapic_adjust_nmi_hz(unsigned hz);
88int lapic_watchdog_ok(void); 88int lapic_watchdog_ok(void);
89void disable_lapic_nmi_watchdog(void); 89void disable_lapic_nmi_watchdog(void);
90void enable_lapic_nmi_watchdog(void); 90void enable_lapic_nmi_watchdog(void);
91void stop_nmi(void);
92void restart_nmi(void);
91 93
92#endif /* ASM_NMI_H */ 94#endif /* ASM_NMI_H */
diff --git a/include/asm-x86_64/pci.h b/include/asm-x86_64/pci.h
index bda94fd5176f..88926eb44f5c 100644
--- a/include/asm-x86_64/pci.h
+++ b/include/asm-x86_64/pci.h
@@ -5,6 +5,25 @@
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7 7
8struct pci_sysdata {
9 int node; /* NUMA node */
10 void* iommu; /* IOMMU private data */
11};
12
13#ifdef CONFIG_CALGARY_IOMMU
14static inline void* pci_iommu(struct pci_bus *bus)
15{
16 struct pci_sysdata *sd = bus->sysdata;
17 return sd->iommu;
18}
19
20static inline void set_pci_iommu(struct pci_bus *bus, void *val)
21{
22 struct pci_sysdata *sd = bus->sysdata;
23 sd->iommu = val;
24}
25#endif /* CONFIG_CALGARY_IOMMU */
26
8#include <linux/mm.h> /* for struct page */ 27#include <linux/mm.h> /* for struct page */
9 28
10/* Can be used to override the logic in pci_scan_bus for skipping 29/* Can be used to override the logic in pci_scan_bus for skipping
diff --git a/include/asm-x86_64/pgalloc.h b/include/asm-x86_64/pgalloc.h
index 8bb564687860..b467be6d367f 100644
--- a/include/asm-x86_64/pgalloc.h
+++ b/include/asm-x86_64/pgalloc.h
@@ -4,6 +4,10 @@
4#include <asm/pda.h> 4#include <asm/pda.h>
5#include <linux/threads.h> 5#include <linux/threads.h>
6#include <linux/mm.h> 6#include <linux/mm.h>
7#include <linux/quicklist.h>
8
9#define QUICK_PGD 0 /* We preserve special mappings over free */
10#define QUICK_PT 1 /* Other page table pages that are zero on free */
7 11
8#define pmd_populate_kernel(mm, pmd, pte) \ 12#define pmd_populate_kernel(mm, pmd, pte) \
9 set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte))) 13 set_pmd(pmd, __pmd(_PAGE_TABLE | __pa(pte)))
@@ -20,23 +24,23 @@ static inline void pmd_populate(struct mm_struct *mm, pmd_t *pmd, struct page *p
20static inline void pmd_free(pmd_t *pmd) 24static inline void pmd_free(pmd_t *pmd)
21{ 25{
22 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1)); 26 BUG_ON((unsigned long)pmd & (PAGE_SIZE-1));
23 free_page((unsigned long)pmd); 27 quicklist_free(QUICK_PT, NULL, pmd);
24} 28}
25 29
26static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr) 30static inline pmd_t *pmd_alloc_one (struct mm_struct *mm, unsigned long addr)
27{ 31{
28 return (pmd_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); 32 return (pmd_t *)quicklist_alloc(QUICK_PT, GFP_KERNEL|__GFP_REPEAT, NULL);
29} 33}
30 34
31static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr) 35static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
32{ 36{
33 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); 37 return (pud_t *)quicklist_alloc(QUICK_PT, GFP_KERNEL|__GFP_REPEAT, NULL);
34} 38}
35 39
36static inline void pud_free (pud_t *pud) 40static inline void pud_free (pud_t *pud)
37{ 41{
38 BUG_ON((unsigned long)pud & (PAGE_SIZE-1)); 42 BUG_ON((unsigned long)pud & (PAGE_SIZE-1));
39 free_page((unsigned long)pud); 43 quicklist_free(QUICK_PT, NULL, pud);
40} 44}
41 45
42static inline void pgd_list_add(pgd_t *pgd) 46static inline void pgd_list_add(pgd_t *pgd)
@@ -57,41 +61,57 @@ static inline void pgd_list_del(pgd_t *pgd)
57 spin_unlock(&pgd_lock); 61 spin_unlock(&pgd_lock);
58} 62}
59 63
60static inline pgd_t *pgd_alloc(struct mm_struct *mm) 64static inline void pgd_ctor(void *x)
61{ 65{
62 unsigned boundary; 66 unsigned boundary;
63 pgd_t *pgd = (pgd_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT); 67 pgd_t *pgd = x;
64 if (!pgd) 68 struct page *page = virt_to_page(pgd);
65 return NULL; 69
66 pgd_list_add(pgd);
67 /* 70 /*
68 * Copy kernel pointers in from init. 71 * Copy kernel pointers in from init.
69 * Could keep a freelist or slab cache of those because the kernel
70 * part never changes.
71 */ 72 */
72 boundary = pgd_index(__PAGE_OFFSET); 73 boundary = pgd_index(__PAGE_OFFSET);
73 memset(pgd, 0, boundary * sizeof(pgd_t));
74 memcpy(pgd + boundary, 74 memcpy(pgd + boundary,
75 init_level4_pgt + boundary, 75 init_level4_pgt + boundary,
76 (PTRS_PER_PGD - boundary) * sizeof(pgd_t)); 76 (PTRS_PER_PGD - boundary) * sizeof(pgd_t));
77
78 spin_lock(&pgd_lock);
79 list_add(&page->lru, &pgd_list);
80 spin_unlock(&pgd_lock);
81}
82
83static inline void pgd_dtor(void *x)
84{
85 pgd_t *pgd = x;
86 struct page *page = virt_to_page(pgd);
87
88 spin_lock(&pgd_lock);
89 list_del(&page->lru);
90 spin_unlock(&pgd_lock);
91}
92
93static inline pgd_t *pgd_alloc(struct mm_struct *mm)
94{
95 pgd_t *pgd = (pgd_t *)quicklist_alloc(QUICK_PGD,
96 GFP_KERNEL|__GFP_REPEAT, pgd_ctor);
77 return pgd; 97 return pgd;
78} 98}
79 99
80static inline void pgd_free(pgd_t *pgd) 100static inline void pgd_free(pgd_t *pgd)
81{ 101{
82 BUG_ON((unsigned long)pgd & (PAGE_SIZE-1)); 102 BUG_ON((unsigned long)pgd & (PAGE_SIZE-1));
83 pgd_list_del(pgd); 103 quicklist_free(QUICK_PGD, pgd_dtor, pgd);
84 free_page((unsigned long)pgd);
85} 104}
86 105
87static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) 106static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address)
88{ 107{
89 return (pte_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); 108 return (pte_t *)quicklist_alloc(QUICK_PT, GFP_KERNEL|__GFP_REPEAT, NULL);
90} 109}
91 110
92static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address) 111static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long address)
93{ 112{
94 void *p = (void *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT); 113 void *p = (void *)quicklist_alloc(QUICK_PT, GFP_KERNEL|__GFP_REPEAT, NULL);
114
95 if (!p) 115 if (!p)
96 return NULL; 116 return NULL;
97 return virt_to_page(p); 117 return virt_to_page(p);
@@ -103,17 +123,22 @@ static inline struct page *pte_alloc_one(struct mm_struct *mm, unsigned long add
103static inline void pte_free_kernel(pte_t *pte) 123static inline void pte_free_kernel(pte_t *pte)
104{ 124{
105 BUG_ON((unsigned long)pte & (PAGE_SIZE-1)); 125 BUG_ON((unsigned long)pte & (PAGE_SIZE-1));
106 free_page((unsigned long)pte); 126 quicklist_free(QUICK_PT, NULL, pte);
107} 127}
108 128
109static inline void pte_free(struct page *pte) 129static inline void pte_free(struct page *pte)
110{ 130{
111 __free_page(pte); 131 quicklist_free_page(QUICK_PT, NULL, pte);
112} 132}
113 133
114#define __pte_free_tlb(tlb,pte) tlb_remove_page((tlb),(pte)) 134#define __pte_free_tlb(tlb,pte) quicklist_free_page(QUICK_PT, NULL,(pte))
115 135
116#define __pmd_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x)) 136#define __pmd_free_tlb(tlb,x) quicklist_free(QUICK_PT, NULL, (x))
117#define __pud_free_tlb(tlb,x) tlb_remove_page((tlb),virt_to_page(x)) 137#define __pud_free_tlb(tlb,x) quicklist_free(QUICK_PT, NULL, (x))
118 138
139static inline void check_pgt_cache(void)
140{
141 quicklist_trim(QUICK_PGD, pgd_dtor, 25, 16);
142 quicklist_trim(QUICK_PT, NULL, 25, 16);
143}
119#endif /* _X86_64_PGALLOC_H */ 144#endif /* _X86_64_PGALLOC_H */
diff --git a/include/asm-x86_64/pgtable.h b/include/asm-x86_64/pgtable.h
index 3ba53099297d..c9d8764c89d1 100644
--- a/include/asm-x86_64/pgtable.h
+++ b/include/asm-x86_64/pgtable.h
@@ -403,13 +403,14 @@ extern struct list_head pgd_list;
403 403
404extern int kern_addr_valid(unsigned long addr); 404extern int kern_addr_valid(unsigned long addr);
405 405
406pte_t *lookup_address(unsigned long addr);
407
406#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \ 408#define io_remap_pfn_range(vma, vaddr, pfn, size, prot) \
407 remap_pfn_range(vma, vaddr, pfn, size, prot) 409 remap_pfn_range(vma, vaddr, pfn, size, prot)
408 410
409#define HAVE_ARCH_UNMAPPED_AREA 411#define HAVE_ARCH_UNMAPPED_AREA
410 412
411#define pgtable_cache_init() do { } while (0) 413#define pgtable_cache_init() do { } while (0)
412#define check_pgt_cache() do { } while (0)
413 414
414#define PAGE_AGP PAGE_KERNEL_NOCACHE 415#define PAGE_AGP PAGE_KERNEL_NOCACHE
415#define HAVE_PAGE_AGP 1 416#define HAVE_PAGE_AGP 1
diff --git a/include/asm-x86_64/processor.h b/include/asm-x86_64/processor.h
index efc87a5aff7f..19525175b91c 100644
--- a/include/asm-x86_64/processor.h
+++ b/include/asm-x86_64/processor.h
@@ -83,7 +83,6 @@ struct cpuinfo_x86 {
83#define X86_VENDOR_UMC 3 83#define X86_VENDOR_UMC 3
84#define X86_VENDOR_NEXGEN 4 84#define X86_VENDOR_NEXGEN 4
85#define X86_VENDOR_CENTAUR 5 85#define X86_VENDOR_CENTAUR 5
86#define X86_VENDOR_RISE 6
87#define X86_VENDOR_TRANSMETA 7 86#define X86_VENDOR_TRANSMETA 7
88#define X86_VENDOR_NUM 8 87#define X86_VENDOR_NUM 8
89#define X86_VENDOR_UNKNOWN 0xff 88#define X86_VENDOR_UNKNOWN 0xff
@@ -390,17 +389,6 @@ static inline void prefetchw(void *x)
390 389
391#define cpu_relax() rep_nop() 390#define cpu_relax() rep_nop()
392 391
393/*
394 * NSC/Cyrix CPU indexed register access macros
395 */
396
397#define getCx86(reg) ({ outb((reg), 0x22); inb(0x23); })
398
399#define setCx86(reg, data) do { \
400 outb((reg), 0x22); \
401 outb((data), 0x23); \
402} while (0)
403
404static inline void serialize_cpu(void) 392static inline void serialize_cpu(void)
405{ 393{
406 __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx"); 394 __asm__ __volatile__ ("cpuid" : : : "ax", "bx", "cx", "dx");
diff --git a/include/asm-x86_64/proto.h b/include/asm-x86_64/proto.h
index 85255db1e82d..31f20ad65876 100644
--- a/include/asm-x86_64/proto.h
+++ b/include/asm-x86_64/proto.h
@@ -75,8 +75,6 @@ extern void setup_node_bootmem(int nodeid, unsigned long start, unsigned long en
75extern void early_quirks(void); 75extern void early_quirks(void);
76extern void check_efer(void); 76extern void check_efer(void);
77 77
78extern int unhandled_signal(struct task_struct *tsk, int sig);
79
80extern void select_idle_routine(const struct cpuinfo_x86 *c); 78extern void select_idle_routine(const struct cpuinfo_x86 *c);
81 79
82extern unsigned long table_start, table_end; 80extern unsigned long table_start, table_end;
@@ -85,24 +83,6 @@ extern int exception_trace;
85extern unsigned cpu_khz; 83extern unsigned cpu_khz;
86extern unsigned tsc_khz; 84extern unsigned tsc_khz;
87 85
88extern void no_iommu_init(void);
89extern int force_iommu, no_iommu;
90extern int iommu_detected;
91#ifdef CONFIG_IOMMU
92extern void gart_iommu_init(void);
93extern void __init gart_parse_options(char *);
94extern void iommu_hole_init(void);
95extern int fallback_aper_order;
96extern int fallback_aper_force;
97extern int iommu_aperture;
98extern int iommu_aperture_allowed;
99extern int iommu_aperture_disabled;
100extern int fix_aperture;
101#else
102#define iommu_aperture 0
103#define iommu_aperture_allowed 0
104#endif
105
106extern int reboot_force; 86extern int reboot_force;
107extern int notsc_setup(char *); 87extern int notsc_setup(char *);
108 88
diff --git a/include/asm-x86_64/ptrace.h b/include/asm-x86_64/ptrace.h
index 5ea84dbb1e9c..7f166ccb0606 100644
--- a/include/asm-x86_64/ptrace.h
+++ b/include/asm-x86_64/ptrace.h
@@ -1,6 +1,7 @@
1#ifndef _X86_64_PTRACE_H 1#ifndef _X86_64_PTRACE_H
2#define _X86_64_PTRACE_H 2#define _X86_64_PTRACE_H
3 3
4#include <linux/compiler.h> /* For __user */
4#include <asm/ptrace-abi.h> 5#include <asm/ptrace-abi.h>
5 6
6#ifndef __ASSEMBLY__ 7#ifndef __ASSEMBLY__
diff --git a/include/asm-x86_64/resume-trace.h b/include/asm-x86_64/resume-trace.h
new file mode 100644
index 000000000000..34bf998fdf62
--- /dev/null
+++ b/include/asm-x86_64/resume-trace.h
@@ -0,0 +1,13 @@
1#define TRACE_RESUME(user) do { \
2 if (pm_trace_enabled) { \
3 void *tracedata; \
4 asm volatile("movq $1f,%0\n" \
5 ".section .tracedata,\"a\"\n" \
6 "1:\t.word %c1\n" \
7 "\t.quad %c2\n" \
8 ".previous" \
9 :"=r" (tracedata) \
10 : "i" (__LINE__), "i" (__FILE__)); \
11 generate_resume_trace(tracedata, user); \
12 } \
13} while (0)
diff --git a/include/asm-x86_64/string.h b/include/asm-x86_64/string.h
index 9505d9f4bead..e583da7918fb 100644
--- a/include/asm-x86_64/string.h
+++ b/include/asm-x86_64/string.h
@@ -29,6 +29,9 @@ return (to);
29 function. */ 29 function. */
30 30
31#define __HAVE_ARCH_MEMCPY 1 31#define __HAVE_ARCH_MEMCPY 1
32#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4
33extern void *memcpy(void *to, const void *from, size_t len);
34#else
32extern void *__memcpy(void *to, const void *from, size_t len); 35extern void *__memcpy(void *to, const void *from, size_t len);
33#define memcpy(dst,src,len) \ 36#define memcpy(dst,src,len) \
34 ({ size_t __len = (len); \ 37 ({ size_t __len = (len); \
@@ -38,7 +41,7 @@ extern void *__memcpy(void *to, const void *from, size_t len);
38 else \ 41 else \
39 __ret = __builtin_memcpy((dst),(src),__len); \ 42 __ret = __builtin_memcpy((dst),(src),__len); \
40 __ret; }) 43 __ret; })
41 44#endif
42 45
43#define __HAVE_ARCH_MEMSET 46#define __HAVE_ARCH_MEMSET
44void *memset(void *s, int c, size_t n); 47void *memset(void *s, int c, size_t n);
diff --git a/include/asm-x86_64/system.h b/include/asm-x86_64/system.h
index e4f246d62c46..02175aa1d16a 100644
--- a/include/asm-x86_64/system.h
+++ b/include/asm-x86_64/system.h
@@ -75,19 +75,31 @@ static inline unsigned long read_cr0(void)
75 unsigned long cr0; 75 unsigned long cr0;
76 asm volatile("movq %%cr0,%0" : "=r" (cr0)); 76 asm volatile("movq %%cr0,%0" : "=r" (cr0));
77 return cr0; 77 return cr0;
78} 78}
79 79
80static inline void write_cr0(unsigned long val) 80static inline void write_cr0(unsigned long val)
81{ 81{
82 asm volatile("movq %0,%%cr0" :: "r" (val)); 82 asm volatile("movq %0,%%cr0" :: "r" (val));
83} 83}
84
85static inline unsigned long read_cr2(void)
86{
87 unsigned long cr2;
88 asm("movq %%cr2,%0" : "=r" (cr2));
89 return cr2;
90}
91
92static inline void write_cr2(unsigned long val)
93{
94 asm volatile("movq %0,%%cr2" :: "r" (val));
95}
84 96
85static inline unsigned long read_cr3(void) 97static inline unsigned long read_cr3(void)
86{ 98{
87 unsigned long cr3; 99 unsigned long cr3;
88 asm("movq %%cr3,%0" : "=r" (cr3)); 100 asm("movq %%cr3,%0" : "=r" (cr3));
89 return cr3; 101 return cr3;
90} 102}
91 103
92static inline void write_cr3(unsigned long val) 104static inline void write_cr3(unsigned long val)
93{ 105{
@@ -99,17 +111,29 @@ static inline unsigned long read_cr4(void)
99 unsigned long cr4; 111 unsigned long cr4;
100 asm("movq %%cr4,%0" : "=r" (cr4)); 112 asm("movq %%cr4,%0" : "=r" (cr4));
101 return cr4; 113 return cr4;
102} 114}
103 115
104static inline void write_cr4(unsigned long val) 116static inline void write_cr4(unsigned long val)
105{ 117{
106 asm volatile("movq %0,%%cr4" :: "r" (val) : "memory"); 118 asm volatile("movq %0,%%cr4" :: "r" (val) : "memory");
107} 119}
120
121static inline unsigned long read_cr8(void)
122{
123 unsigned long cr8;
124 asm("movq %%cr8,%0" : "=r" (cr8));
125 return cr8;
126}
127
128static inline void write_cr8(unsigned long val)
129{
130 asm volatile("movq %0,%%cr8" :: "r" (val) : "memory");
131}
108 132
109#define stts() write_cr0(8 | read_cr0()) 133#define stts() write_cr0(8 | read_cr0())
110 134
111#define wbinvd() \ 135#define wbinvd() \
112 __asm__ __volatile__ ("wbinvd": : :"memory"); 136 __asm__ __volatile__ ("wbinvd": : :"memory")
113 137
114#endif /* __KERNEL__ */ 138#endif /* __KERNEL__ */
115 139
diff --git a/include/asm-x86_64/thread_info.h b/include/asm-x86_64/thread_info.h
index 10bb5a8ed688..33c72ef15a0c 100644
--- a/include/asm-x86_64/thread_info.h
+++ b/include/asm-x86_64/thread_info.h
@@ -115,6 +115,7 @@ static inline struct thread_info *stack_thread_info(void)
115#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */ 115#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
116#define TIF_SECCOMP 8 /* secure computing */ 116#define TIF_SECCOMP 8 /* secure computing */
117#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */ 117#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
118#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */
118/* 16 free */ 119/* 16 free */
119#define TIF_IA32 17 /* 32bit process */ 120#define TIF_IA32 17 /* 32bit process */
120#define TIF_FORK 18 /* ret_from_fork */ 121#define TIF_FORK 18 /* ret_from_fork */
@@ -133,6 +134,7 @@ static inline struct thread_info *stack_thread_info(void)
133#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 134#define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
134#define _TIF_SECCOMP (1<<TIF_SECCOMP) 135#define _TIF_SECCOMP (1<<TIF_SECCOMP)
135#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK) 136#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
137#define _TIF_MCE_NOTIFY (1<<TIF_MCE_NOTIFY)
136#define _TIF_IA32 (1<<TIF_IA32) 138#define _TIF_IA32 (1<<TIF_IA32)
137#define _TIF_FORK (1<<TIF_FORK) 139#define _TIF_FORK (1<<TIF_FORK)
138#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING) 140#define _TIF_ABI_PENDING (1<<TIF_ABI_PENDING)
diff --git a/include/asm-x86_64/timex.h b/include/asm-x86_64/timex.h
index f6527e1b6c1c..6ed21f44d308 100644
--- a/include/asm-x86_64/timex.h
+++ b/include/asm-x86_64/timex.h
@@ -9,7 +9,6 @@
9#include <asm/8253pit.h> 9#include <asm/8253pit.h>
10#include <asm/msr.h> 10#include <asm/msr.h>
11#include <asm/vsyscall.h> 11#include <asm/vsyscall.h>
12#include <asm/hpet.h>
13#include <asm/system.h> 12#include <asm/system.h>
14#include <asm/processor.h> 13#include <asm/processor.h>
15#include <asm/tsc.h> 14#include <asm/tsc.h>
diff --git a/include/asm-x86_64/tlbflush.h b/include/asm-x86_64/tlbflush.h
index 8516225a8389..888eb4abdd07 100644
--- a/include/asm-x86_64/tlbflush.h
+++ b/include/asm-x86_64/tlbflush.h
@@ -92,7 +92,11 @@ static inline void flush_tlb_range(struct vm_area_struct * vma, unsigned long st
92 92
93#endif 93#endif
94 94
95#define flush_tlb_kernel_range(start, end) flush_tlb_all() 95static inline void flush_tlb_kernel_range(unsigned long start,
96 unsigned long end)
97{
98 flush_tlb_all();
99}
96 100
97static inline void flush_tlb_pgtables(struct mm_struct *mm, 101static inline void flush_tlb_pgtables(struct mm_struct *mm,
98 unsigned long start, unsigned long end) 102 unsigned long start, unsigned long end)
diff --git a/include/asm-x86_64/topology.h b/include/asm-x86_64/topology.h
index 4fd6fb23953e..36e52fba7960 100644
--- a/include/asm-x86_64/topology.h
+++ b/include/asm-x86_64/topology.h
@@ -22,7 +22,7 @@ extern int __node_distance(int, int);
22#define parent_node(node) (node) 22#define parent_node(node) (node)
23#define node_to_first_cpu(node) (first_cpu(node_to_cpumask[node])) 23#define node_to_first_cpu(node) (first_cpu(node_to_cpumask[node]))
24#define node_to_cpumask(node) (node_to_cpumask[node]) 24#define node_to_cpumask(node) (node_to_cpumask[node])
25#define pcibus_to_node(bus) ((long)(bus->sysdata)) 25#define pcibus_to_node(bus) ((struct pci_sysdata *)((bus)->sysdata))->node
26#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus)); 26#define pcibus_to_cpumask(bus) node_to_cpumask(pcibus_to_node(bus));
27 27
28#define numa_node_id() read_pda(nodenumber) 28#define numa_node_id() read_pda(nodenumber)
diff --git a/include/asm-x86_64/vgtod.h b/include/asm-x86_64/vgtod.h
new file mode 100644
index 000000000000..3301f0929342
--- /dev/null
+++ b/include/asm-x86_64/vgtod.h
@@ -0,0 +1,29 @@
1#ifndef _ASM_VGTOD_H
2#define _ASM_VGTOD_H 1
3
4#include <asm/vsyscall.h>
5#include <linux/clocksource.h>
6
7struct vsyscall_gtod_data {
8 seqlock_t lock;
9
10 /* open coded 'struct timespec' */
11 time_t wall_time_sec;
12 u32 wall_time_nsec;
13
14 int sysctl_enabled;
15 struct timezone sys_tz;
16 struct { /* extract of a clocksource struct */
17 cycle_t (*vread)(void);
18 cycle_t cycle_last;
19 cycle_t mask;
20 u32 mult;
21 u32 shift;
22 } clock;
23 struct timespec wall_to_monotonic;
24};
25extern struct vsyscall_gtod_data __vsyscall_gtod_data
26__section_vsyscall_gtod_data;
27extern struct vsyscall_gtod_data vsyscall_gtod_data;
28
29#endif
diff --git a/include/asm-x86_64/vsyscall.h b/include/asm-x86_64/vsyscall.h
index 82b4afe65c91..3b8ceb4af2cf 100644
--- a/include/asm-x86_64/vsyscall.h
+++ b/include/asm-x86_64/vsyscall.h
@@ -22,6 +22,8 @@ enum vsyscall_num {
22/* Definitions for CONFIG_GENERIC_TIME definitions */ 22/* Definitions for CONFIG_GENERIC_TIME definitions */
23#define __section_vsyscall_gtod_data __attribute__ \ 23#define __section_vsyscall_gtod_data __attribute__ \
24 ((unused, __section__ (".vsyscall_gtod_data"),aligned(16))) 24 ((unused, __section__ (".vsyscall_gtod_data"),aligned(16)))
25#define __section_vsyscall_clock __attribute__ \
26 ((unused, __section__ (".vsyscall_clock"),aligned(16)))
25#define __vsyscall_fn __attribute__ ((unused,__section__(".vsyscall_fn"))) 27#define __vsyscall_fn __attribute__ ((unused,__section__(".vsyscall_fn")))
26 28
27#define VGETCPU_RDTSCP 1 29#define VGETCPU_RDTSCP 1
@@ -36,7 +38,6 @@ extern volatile unsigned long __jiffies;
36/* kernel space (writeable) */ 38/* kernel space (writeable) */
37extern int vgetcpu_mode; 39extern int vgetcpu_mode;
38extern struct timezone sys_tz; 40extern struct timezone sys_tz;
39extern struct vsyscall_gtod_data_t vsyscall_gtod_data;
40 41
41#endif /* __KERNEL__ */ 42#endif /* __KERNEL__ */
42 43
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index dc234c508a6f..d5680cd7746a 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -88,10 +88,8 @@ int acpi_table_parse (char *id, acpi_table_handler handler);
88int __init acpi_table_parse_entries(char *id, unsigned long table_size, 88int __init acpi_table_parse_entries(char *id, unsigned long table_size,
89 int entry_id, acpi_table_entry_handler handler, unsigned int max_entries); 89 int entry_id, acpi_table_entry_handler handler, unsigned int max_entries);
90int acpi_table_parse_madt (enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries); 90int acpi_table_parse_madt (enum acpi_madt_type id, acpi_table_entry_handler handler, unsigned int max_entries);
91int acpi_table_parse_srat (enum acpi_srat_type id, acpi_table_entry_handler handler, unsigned int max_entries);
92int acpi_parse_mcfg (struct acpi_table_header *header); 91int acpi_parse_mcfg (struct acpi_table_header *header);
93void acpi_table_print_madt_entry (struct acpi_subtable_header *madt); 92void acpi_table_print_madt_entry (struct acpi_subtable_header *madt);
94void acpi_table_print_srat_entry (struct acpi_subtable_header *srat);
95 93
96/* the following four functions are architecture-dependent */ 94/* the following four functions are architecture-dependent */
97#ifdef CONFIG_HAVE_ARCH_PARSE_SRAT 95#ifdef CONFIG_HAVE_ARCH_PARSE_SRAT
@@ -233,6 +231,9 @@ extern int acpi_paddr_to_node(u64 start_addr, u64 size);
233 231
234extern int pnpacpi_disabled; 232extern int pnpacpi_disabled;
235 233
234#define PXM_INVAL (-1)
235#define NID_INVAL (-1)
236
236#else /* CONFIG_ACPI */ 237#else /* CONFIG_ACPI */
237 238
238static inline int acpi_boot_init(void) 239static inline int acpi_boot_init(void)
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 8ca7ca0b47f0..4bbd8601b8f0 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -161,7 +161,7 @@
161 * are currently used in an audit field constant understood by the kernel. 161 * are currently used in an audit field constant understood by the kernel.
162 * If you are adding a new #define AUDIT_<whatever>, please ensure that 162 * If you are adding a new #define AUDIT_<whatever>, please ensure that
163 * AUDIT_UNUSED_BITS is updated if need be. */ 163 * AUDIT_UNUSED_BITS is updated if need be. */
164#define AUDIT_UNUSED_BITS 0x0FFFFC00 164#define AUDIT_UNUSED_BITS 0x07FFFC00
165 165
166 166
167/* Rule fields */ 167/* Rule fields */
@@ -213,25 +213,29 @@
213#define AUDIT_NEGATE 0x80000000 213#define AUDIT_NEGATE 0x80000000
214 214
215/* These are the supported operators. 215/* These are the supported operators.
216 * 4 2 1 216 * 4 2 1 8
217 * = > < 217 * = > < ?
218 * ------- 218 * ----------
219 * 0 0 0 0 nonsense 219 * 0 0 0 0 00 nonsense
220 * 0 0 1 1 < 220 * 0 0 0 1 08 & bit mask
221 * 0 1 0 2 > 221 * 0 0 1 0 10 <
222 * 0 1 1 3 != 222 * 0 1 0 0 20 >
223 * 1 0 0 4 = 223 * 0 1 1 0 30 !=
224 * 1 0 1 5 <= 224 * 1 0 0 0 40 =
225 * 1 1 0 6 >= 225 * 1 0 0 1 48 &= bit test
226 * 1 1 1 7 all operators 226 * 1 0 1 0 50 <=
227 * 1 1 0 0 60 >=
228 * 1 1 1 1 78 all operators
227 */ 229 */
230#define AUDIT_BIT_MASK 0x08000000
228#define AUDIT_LESS_THAN 0x10000000 231#define AUDIT_LESS_THAN 0x10000000
229#define AUDIT_GREATER_THAN 0x20000000 232#define AUDIT_GREATER_THAN 0x20000000
230#define AUDIT_NOT_EQUAL 0x30000000 233#define AUDIT_NOT_EQUAL 0x30000000
231#define AUDIT_EQUAL 0x40000000 234#define AUDIT_EQUAL 0x40000000
235#define AUDIT_BIT_TEST (AUDIT_BIT_MASK|AUDIT_EQUAL)
232#define AUDIT_LESS_THAN_OR_EQUAL (AUDIT_LESS_THAN|AUDIT_EQUAL) 236#define AUDIT_LESS_THAN_OR_EQUAL (AUDIT_LESS_THAN|AUDIT_EQUAL)
233#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL) 237#define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL)
234#define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL) 238#define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL|AUDIT_BIT_MASK)
235 239
236/* Status symbols */ 240/* Status symbols */
237 /* Mask values */ 241 /* Mask values */
@@ -407,7 +411,6 @@ extern int audit_bprm(struct linux_binprm *bprm);
407extern int audit_socketcall(int nargs, unsigned long *args); 411extern int audit_socketcall(int nargs, unsigned long *args);
408extern int audit_sockaddr(int len, void *addr); 412extern int audit_sockaddr(int len, void *addr);
409extern int __audit_fd_pair(int fd1, int fd2); 413extern int __audit_fd_pair(int fd1, int fd2);
410extern int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt);
411extern int audit_set_macxattr(const char *name); 414extern int audit_set_macxattr(const char *name);
412extern int __audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr); 415extern int __audit_mq_open(int oflag, mode_t mode, struct mq_attr __user *u_attr);
413extern int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout); 416extern int __audit_mq_timedsend(mqd_t mqdes, size_t msg_len, unsigned int msg_prio, const struct timespec __user *u_abs_timeout);
@@ -487,7 +490,6 @@ extern int audit_signals;
487#define audit_socketcall(n,a) ({ 0; }) 490#define audit_socketcall(n,a) ({ 0; })
488#define audit_fd_pair(n,a) ({ 0; }) 491#define audit_fd_pair(n,a) ({ 0; })
489#define audit_sockaddr(len, addr) ({ 0; }) 492#define audit_sockaddr(len, addr) ({ 0; })
490#define audit_avc_path(dentry, mnt) ({ 0; })
491#define audit_set_macxattr(n) do { ; } while (0) 493#define audit_set_macxattr(n) do { ; } while (0)
492#define audit_mq_open(o,m,a) ({ 0; }) 494#define audit_mq_open(o,m,a) ({ 0; })
493#define audit_mq_timedsend(d,l,p,t) ({ 0; }) 495#define audit_mq_timedsend(d,l,p,t) ({ 0; })
diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index 1023ba0d6e55..c897c7b03858 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -69,8 +69,8 @@ struct backlight_device {
69 69
70 /* The framebuffer notifier block */ 70 /* The framebuffer notifier block */
71 struct notifier_block fb_notif; 71 struct notifier_block fb_notif;
72 /* The class device structure */ 72
73 struct class_device class_dev; 73 struct device dev;
74}; 74};
75 75
76static inline void backlight_update_status(struct backlight_device *bd) 76static inline void backlight_update_status(struct backlight_device *bd)
@@ -85,6 +85,11 @@ extern struct backlight_device *backlight_device_register(const char *name,
85 struct device *dev, void *devdata, struct backlight_ops *ops); 85 struct device *dev, void *devdata, struct backlight_ops *ops);
86extern void backlight_device_unregister(struct backlight_device *bd); 86extern void backlight_device_unregister(struct backlight_device *bd);
87 87
88#define to_backlight_device(obj) container_of(obj, struct backlight_device, class_dev) 88#define to_backlight_device(obj) container_of(obj, struct backlight_device, dev)
89
90static inline void * bl_get_data(struct backlight_device *bl_dev)
91{
92 return dev_get_drvdata(&bl_dev->dev);
93}
89 94
90#endif 95#endif
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index f78965fc6426..695e34964cb7 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -698,11 +698,6 @@ extern int blk_execute_rq(request_queue_t *, struct gendisk *,
698 struct request *, int); 698 struct request *, int);
699extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *, 699extern void blk_execute_rq_nowait(request_queue_t *, struct gendisk *,
700 struct request *, int, rq_end_io_fn *); 700 struct request *, int, rq_end_io_fn *);
701extern int blk_fill_sghdr_rq(request_queue_t *, struct request *,
702 struct sg_io_hdr *, int);
703extern int blk_unmap_sghdr_rq(struct request *, struct sg_io_hdr *);
704extern int blk_complete_sghdr_rq(struct request *, struct sg_io_hdr *,
705 struct bio *);
706extern int blk_verify_command(unsigned char *, int); 701extern int blk_verify_command(unsigned char *, int);
707 702
708static inline request_queue_t *bdev_get_queue(struct block_device *bdev) 703static inline request_queue_t *bdev_get_queue(struct block_device *bdev)
diff --git a/include/linux/bsg.h b/include/linux/bsg.h
index 8547b10c388b..f415f89e0ac8 100644
--- a/include/linux/bsg.h
+++ b/include/linux/bsg.h
@@ -57,10 +57,10 @@ struct bsg_class_device {
57 struct request_queue *queue; 57 struct request_queue *queue;
58}; 58};
59 59
60extern int bsg_register_queue(struct request_queue *, const char *); 60extern int bsg_register_queue(struct request_queue *, struct device *, const char *);
61extern void bsg_unregister_queue(struct request_queue *); 61extern void bsg_unregister_queue(struct request_queue *);
62#else 62#else
63#define bsg_register_queue(disk, name) (0) 63#define bsg_register_queue(disk, dev, name) (0)
64#define bsg_unregister_queue(disk) do { } while (0) 64#define bsg_unregister_queue(disk) do { } while (0)
65#endif 65#endif
66 66
diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 8486e78f7335..e0bd46eb2414 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -23,6 +23,7 @@ enum clock_event_mode {
23 CLOCK_EVT_MODE_SHUTDOWN, 23 CLOCK_EVT_MODE_SHUTDOWN,
24 CLOCK_EVT_MODE_PERIODIC, 24 CLOCK_EVT_MODE_PERIODIC,
25 CLOCK_EVT_MODE_ONESHOT, 25 CLOCK_EVT_MODE_ONESHOT,
26 CLOCK_EVT_MODE_RESUME,
26}; 27};
27 28
28/* Clock event notification values */ 29/* Clock event notification values */
@@ -119,10 +120,6 @@ extern void clockevents_register_device(struct clock_event_device *dev);
119 120
120extern void clockevents_exchange_device(struct clock_event_device *old, 121extern void clockevents_exchange_device(struct clock_event_device *old,
121 struct clock_event_device *new); 122 struct clock_event_device *new);
122extern
123struct clock_event_device *clockevents_request_device(unsigned int features,
124 cpumask_t cpumask);
125extern void clockevents_release_device(struct clock_event_device *dev);
126extern void clockevents_set_mode(struct clock_event_device *dev, 123extern void clockevents_set_mode(struct clock_event_device *dev,
127 enum clock_event_mode mode); 124 enum clock_event_mode mode);
128extern int clockevents_register_notifier(struct notifier_block *nb); 125extern int clockevents_register_notifier(struct notifier_block *nb);
diff --git a/include/linux/coda_linux.h b/include/linux/coda_linux.h
index c4079b403e9e..1c47a34aa794 100644
--- a/include/linux/coda_linux.h
+++ b/include/linux/coda_linux.h
@@ -36,7 +36,6 @@ extern const struct file_operations coda_ioctl_operations;
36 36
37/* operations shared over more than one file */ 37/* operations shared over more than one file */
38int coda_open(struct inode *i, struct file *f); 38int coda_open(struct inode *i, struct file *f);
39int coda_flush(struct file *f, fl_owner_t id);
40int coda_release(struct inode *i, struct file *f); 39int coda_release(struct inode *i, struct file *f);
41int coda_permission(struct inode *inode, int mask, struct nameidata *nd); 40int coda_permission(struct inode *inode, int mask, struct nameidata *nd);
42int coda_revalidate_inode(struct dentry *); 41int coda_revalidate_inode(struct dentry *);
diff --git a/include/linux/coda_psdev.h b/include/linux/coda_psdev.h
index aa8f454b3b77..07ae8f846055 100644
--- a/include/linux/coda_psdev.h
+++ b/include/linux/coda_psdev.h
@@ -33,9 +33,6 @@ int venus_setattr(struct super_block *, struct CodaFid *, struct coda_vattr *);
33int venus_lookup(struct super_block *sb, struct CodaFid *fid, 33int venus_lookup(struct super_block *sb, struct CodaFid *fid,
34 const char *name, int length, int *type, 34 const char *name, int length, int *type,
35 struct CodaFid *resfid); 35 struct CodaFid *resfid);
36int venus_store(struct super_block *sb, struct CodaFid *fid, int flags,
37 vuid_t uid);
38int venus_release(struct super_block *sb, struct CodaFid *fid, int flags);
39int venus_close(struct super_block *sb, struct CodaFid *fid, int flags, 36int venus_close(struct super_block *sb, struct CodaFid *fid, int flags,
40 vuid_t uid); 37 vuid_t uid);
41int venus_open(struct super_block *sb, struct CodaFid *fid, int flags, 38int venus_open(struct super_block *sb, struct CodaFid *fid, int flags,
diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
index a03e9398a6c2..14f7494280f0 100644
--- a/include/linux/compiler-gcc4.h
+++ b/include/linux/compiler-gcc4.h
@@ -23,3 +23,21 @@
23 * code 23 * code
24 */ 24 */
25#define uninitialized_var(x) x = x 25#define uninitialized_var(x) x = x
26
27#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 3)
28/* Mark functions as cold. gcc will assume any path leading to a call
29 to them will be unlikely. This means a lot of manual unlikely()s
30 are unnecessary now for any paths leading to the usual suspects
31 like BUG(), printk(), panic() etc. [but let's keep them for now for
32 older compilers]
33
34 Early snapshots of gcc 4.3 don't support this and we can't detect this
35 in the preprocessor, but we can live with this because they're unreleased.
36 Maketime probing would be overkill here.
37
38 gcc also has a __attribute__((__hot__)) to move hot functions into
39 a special section, but I don't see any sense in this right now in
40 the kernel context */
41#define __cold __attribute__((__cold__))
42
43#endif
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 8287a72bb6a9..12a1291855e2 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -174,4 +174,13 @@ extern void __chk_io_ptr(const void __iomem *);
174# define __attribute_const__ /* unimplemented */ 174# define __attribute_const__ /* unimplemented */
175#endif 175#endif
176 176
177/*
178 * Tell gcc if a function is cold. The compiler will assume any path
179 * directly leading to the call is unlikely.
180 */
181
182#ifndef __cold
183#define __cold
184#endif
185
177#endif /* __LINUX_COMPILER_H */ 186#endif /* __LINUX_COMPILER_H */
diff --git a/include/linux/init.h b/include/linux/init.h
index 5b5285316339..f0d0e3295a9b 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -40,10 +40,10 @@
40 40
41/* These are for everybody (although not all archs will actually 41/* These are for everybody (although not all archs will actually
42 discard it in modules) */ 42 discard it in modules) */
43#define __init __attribute__ ((__section__ (".init.text"))) 43#define __init __attribute__ ((__section__ (".init.text"))) __cold
44#define __initdata __attribute__ ((__section__ (".init.data"))) 44#define __initdata __attribute__ ((__section__ (".init.data")))
45#define __exitdata __attribute__ ((__section__(".exit.data"))) 45#define __exitdata __attribute__ ((__section__(".exit.data")))
46#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) 46#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) __cold
47 47
48/* modpost check for section mismatches during the kernel build. 48/* modpost check for section mismatches during the kernel build.
49 * A section mismatch happens when there are references from a 49 * A section mismatch happens when there are references from a
@@ -59,9 +59,9 @@
59#define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) 59#define __initdata_refok __attribute__ ((__section__ (".data.init.refok")))
60 60
61#ifdef MODULE 61#ifdef MODULE
62#define __exit __attribute__ ((__section__(".exit.text"))) 62#define __exit __attribute__ ((__section__(".exit.text"))) __cold
63#else 63#else
64#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) 64#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold
65#endif 65#endif
66 66
67/* For assembly routines */ 67/* For assembly routines */
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 5323f6275854..0a3c2ebf2008 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -120,11 +120,11 @@ extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
120# define local_irq_enable_in_hardirq() local_irq_enable() 120# define local_irq_enable_in_hardirq() local_irq_enable()
121#endif 121#endif
122 122
123#ifdef CONFIG_GENERIC_HARDIRQS
124extern void disable_irq_nosync(unsigned int irq); 123extern void disable_irq_nosync(unsigned int irq);
125extern void disable_irq(unsigned int irq); 124extern void disable_irq(unsigned int irq);
126extern void enable_irq(unsigned int irq); 125extern void enable_irq(unsigned int irq);
127 126
127#ifdef CONFIG_GENERIC_HARDIRQS
128/* 128/*
129 * Special lockdep variants of irq disabling/enabling. 129 * Special lockdep variants of irq disabling/enabling.
130 * These should be used for locking constructs that 130 * These should be used for locking constructs that
diff --git a/include/linux/irda.h b/include/linux/irda.h
index 8e3735714c1c..28f88ecba344 100644
--- a/include/linux/irda.h
+++ b/include/linux/irda.h
@@ -77,6 +77,7 @@ typedef enum {
77 IRDA_ACT200L_DONGLE = 10, 77 IRDA_ACT200L_DONGLE = 10,
78 IRDA_MA600_DONGLE = 11, 78 IRDA_MA600_DONGLE = 11,
79 IRDA_TOIM3232_DONGLE = 12, 79 IRDA_TOIM3232_DONGLE = 12,
80 IRDA_EP7211_DONGLE = 13,
80} IRDA_DONGLE; 81} IRDA_DONGLE;
81 82
82/* Protocol types to be used for SOCK_DGRAM */ 83/* Protocol types to be used for SOCK_DGRAM */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 1eb9cde550c4..4300bb462d29 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -106,7 +106,7 @@ extern int cond_resched(void);
106extern struct atomic_notifier_head panic_notifier_list; 106extern struct atomic_notifier_head panic_notifier_list;
107extern long (*panic_blink)(long time); 107extern long (*panic_blink)(long time);
108NORET_TYPE void panic(const char * fmt, ...) 108NORET_TYPE void panic(const char * fmt, ...)
109 __attribute__ ((NORET_AND format (printf, 1, 2))); 109 __attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
110extern void oops_enter(void); 110extern void oops_enter(void);
111extern void oops_exit(void); 111extern void oops_exit(void);
112extern int oops_may_print(void); 112extern int oops_may_print(void);
@@ -155,14 +155,14 @@ extern void dump_thread(struct pt_regs *regs, struct user *dump);
155asmlinkage int vprintk(const char *fmt, va_list args) 155asmlinkage int vprintk(const char *fmt, va_list args)
156 __attribute__ ((format (printf, 1, 0))); 156 __attribute__ ((format (printf, 1, 0)));
157asmlinkage int printk(const char * fmt, ...) 157asmlinkage int printk(const char * fmt, ...)
158 __attribute__ ((format (printf, 1, 2))); 158 __attribute__ ((format (printf, 1, 2))) __cold;
159#else 159#else
160static inline int vprintk(const char *s, va_list args) 160static inline int vprintk(const char *s, va_list args)
161 __attribute__ ((format (printf, 1, 0))); 161 __attribute__ ((format (printf, 1, 0)));
162static inline int vprintk(const char *s, va_list args) { return 0; } 162static inline int vprintk(const char *s, va_list args) { return 0; }
163static inline int printk(const char *s, ...) 163static inline int printk(const char *s, ...)
164 __attribute__ ((format (printf, 1, 2))); 164 __attribute__ ((format (printf, 1, 2)));
165static inline int printk(const char *s, ...) { return 0; } 165static inline int __cold printk(const char *s, ...) { return 0; }
166#endif 166#endif
167 167
168unsigned long int_sqrt(unsigned long); 168unsigned long int_sqrt(unsigned long);
@@ -212,7 +212,7 @@ extern enum system_states {
212#define TAINT_USER (1<<6) 212#define TAINT_USER (1<<6)
213#define TAINT_DIE (1<<7) 213#define TAINT_DIE (1<<7)
214 214
215extern void dump_stack(void); 215extern void dump_stack(void) __cold;
216 216
217enum { 217enum {
218 DUMP_PREFIX_NONE, 218 DUMP_PREFIX_NONE,
diff --git a/include/linux/lcd.h b/include/linux/lcd.h
index 598793c0745b..1d379787f2e7 100644
--- a/include/linux/lcd.h
+++ b/include/linux/lcd.h
@@ -62,8 +62,8 @@ struct lcd_device {
62 struct mutex update_lock; 62 struct mutex update_lock;
63 /* The framebuffer notifier block */ 63 /* The framebuffer notifier block */
64 struct notifier_block fb_notif; 64 struct notifier_block fb_notif;
65 /* The class device structure */ 65
66 struct class_device class_dev; 66 struct device dev;
67}; 67};
68 68
69static inline void lcd_set_power(struct lcd_device *ld, int power) 69static inline void lcd_set_power(struct lcd_device *ld, int power)
@@ -75,9 +75,15 @@ static inline void lcd_set_power(struct lcd_device *ld, int power)
75} 75}
76 76
77extern struct lcd_device *lcd_device_register(const char *name, 77extern struct lcd_device *lcd_device_register(const char *name,
78 void *devdata, struct lcd_ops *ops); 78 struct device *parent, void *devdata, struct lcd_ops *ops);
79extern void lcd_device_unregister(struct lcd_device *ld); 79extern void lcd_device_unregister(struct lcd_device *ld);
80 80
81#define to_lcd_device(obj) container_of(obj, struct lcd_device, class_dev) 81#define to_lcd_device(obj) container_of(obj, struct lcd_device, dev)
82
83static inline void * lcd_get_data(struct lcd_device *ld_dev)
84{
85 return dev_get_drvdata(&ld_dev->dev);
86}
87
82 88
83#endif 89#endif
diff --git a/include/linux/leds.h b/include/linux/leds.h
index 494bed7c2fc1..421175092ee2 100644
--- a/include/linux/leds.h
+++ b/include/linux/leds.h
@@ -15,7 +15,6 @@
15#include <linux/list.h> 15#include <linux/list.h>
16 16
17struct device; 17struct device;
18struct class_device;
19/* 18/*
20 * LED Core 19 * LED Core
21 */ 20 */
@@ -37,7 +36,7 @@ struct led_classdev {
37 void (*brightness_set)(struct led_classdev *led_cdev, 36 void (*brightness_set)(struct led_classdev *led_cdev,
38 enum led_brightness brightness); 37 enum led_brightness brightness);
39 38
40 struct class_device *class_dev; 39 struct device *dev;
41 struct list_head node; /* LED Device list */ 40 struct list_head node; /* LED Device list */
42 char *default_trigger; /* Trigger to use */ 41 char *default_trigger; /* Trigger to use */
43 42
@@ -109,4 +108,18 @@ extern void ledtrig_ide_activity(void);
109#define ledtrig_ide_activity() do {} while(0) 108#define ledtrig_ide_activity() do {} while(0)
110#endif 109#endif
111 110
111/* For the leds-gpio driver */
112struct gpio_led {
113 const char *name;
114 char *default_trigger;
115 unsigned gpio;
116 u8 active_low;
117};
118
119struct gpio_led_platform_data {
120 int num_leds;
121 struct gpio_led *leds;
122};
123
124
112#endif /* __LINUX_LEDS_H_INCLUDED */ 125#endif /* __LINUX_LEDS_H_INCLUDED */
diff --git a/include/linux/libata.h b/include/linux/libata.h
index be5a43928c84..9aa6c10f7bb1 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -412,6 +412,7 @@ struct ata_queued_cmd {
412 ata_qc_cb_t complete_fn; 412 ata_qc_cb_t complete_fn;
413 413
414 void *private_data; 414 void *private_data;
415 void *lldd_task;
415}; 416};
416 417
417struct ata_port_stats { 418struct ata_port_stats {
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9820ca1e45e2..4a616d73cc25 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -575,7 +575,7 @@ struct net_device
575 575
576 /* The TX queue control structures */ 576 /* The TX queue control structures */
577 unsigned int egress_subqueue_count; 577 unsigned int egress_subqueue_count;
578 struct net_device_subqueue egress_subqueue[0]; 578 struct net_device_subqueue egress_subqueue[1];
579}; 579};
580#define to_net_dev(d) container_of(d, struct net_device, dev) 580#define to_net_dev(d) container_of(d, struct net_device, dev)
581 581
diff --git a/include/linux/of_platform.h b/include/linux/of_platform.h
index 5fd44e63fb26..448f70b30a0c 100644
--- a/include/linux/of_platform.h
+++ b/include/linux/of_platform.h
@@ -31,8 +31,8 @@ extern struct bus_type of_platform_bus_type;
31 */ 31 */
32struct of_platform_driver 32struct of_platform_driver
33{ 33{
34 char *name; 34 const char *name;
35 struct of_device_id *match_table; 35 const struct of_device_id *match_table;
36 struct module *owner; 36 struct module *owner;
37 37
38 int (*probe)(struct of_device* dev, 38 int (*probe)(struct of_device* dev,
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index b15c6498fe67..cbabb9c675c9 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -2019,6 +2019,8 @@
2019 2019
2020#define PCI_VENDOR_ID_ARIMA 0x161f 2020#define PCI_VENDOR_ID_ARIMA 0x161f
2021 2021
2022#define PCI_VENDOR_ID_BROCADE 0x1657
2023
2022#define PCI_VENDOR_ID_SIBYTE 0x166d 2024#define PCI_VENDOR_ID_SIBYTE 0x166d
2023#define PCI_DEVICE_ID_BCM1250_PCI 0x0001 2025#define PCI_DEVICE_ID_BCM1250_PCI 0x0001
2024#define PCI_DEVICE_ID_BCM1250_HT 0x0002 2026#define PCI_DEVICE_ID_BCM1250_HT 0x0002
@@ -2040,6 +2042,8 @@
2040#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea 2042#define PCI_DEVICE_ID_ALTIMA_AC9100 0x03ea
2041#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb 2043#define PCI_DEVICE_ID_ALTIMA_AC1003 0x03eb
2042 2044
2045#define PCI_VENDOR_ID_LENOVO 0x17aa
2046
2043#define PCI_VENDOR_ID_ARECA 0x17d3 2047#define PCI_VENDOR_ID_ARECA 0x17d3
2044#define PCI_DEVICE_ID_ARECA_1110 0x1110 2048#define PCI_DEVICE_ID_ARECA_1110 0x1110
2045#define PCI_DEVICE_ID_ARECA_1120 0x1120 2049#define PCI_DEVICE_ID_ARECA_1120 0x1120
diff --git a/include/linux/resume-trace.h b/include/linux/resume-trace.h
index 81e9299ca148..f3f4f28c6960 100644
--- a/include/linux/resume-trace.h
+++ b/include/linux/resume-trace.h
@@ -2,6 +2,7 @@
2#define RESUME_TRACE_H 2#define RESUME_TRACE_H
3 3
4#ifdef CONFIG_PM_TRACE 4#ifdef CONFIG_PM_TRACE
5#include <asm/resume-trace.h>
5 6
6extern int pm_trace_enabled; 7extern int pm_trace_enabled;
7 8
@@ -9,20 +10,10 @@ struct device;
9extern void set_trace_device(struct device *); 10extern void set_trace_device(struct device *);
10extern void generate_resume_trace(void *tracedata, unsigned int user); 11extern void generate_resume_trace(void *tracedata, unsigned int user);
11 12
12#define TRACE_DEVICE(dev) set_trace_device(dev) 13#define TRACE_DEVICE(dev) do { \
13#define TRACE_RESUME(user) do { \ 14 if (pm_trace_enabled) \
14 if (pm_trace_enabled) { \ 15 set_trace_device(dev); \
15 void *tracedata; \ 16 } while(0)
16 asm volatile("movl $1f,%0\n" \
17 ".section .tracedata,\"a\"\n" \
18 "1:\t.word %c1\n" \
19 "\t.long %c2\n" \
20 ".previous" \
21 :"=r" (tracedata) \
22 : "i" (__LINE__), "i" (__FILE__)); \
23 generate_resume_trace(tracedata, user); \
24 } \
25} while (0)
26 17
27#else 18#else
28 19
diff --git a/include/linux/signal.h b/include/linux/signal.h
index ea91abe740da..0ae338866240 100644
--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -237,12 +237,15 @@ extern int group_send_sig_info(int sig, struct siginfo *info, struct task_struct
237extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *); 237extern int __group_send_sig_info(int, struct siginfo *, struct task_struct *);
238extern long do_sigpending(void __user *, unsigned long); 238extern long do_sigpending(void __user *, unsigned long);
239extern int sigprocmask(int, sigset_t *, sigset_t *); 239extern int sigprocmask(int, sigset_t *, sigset_t *);
240extern int show_unhandled_signals;
240 241
241struct pt_regs; 242struct pt_regs;
242extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie); 243extern int get_signal_to_deliver(siginfo_t *info, struct k_sigaction *return_ka, struct pt_regs *regs, void *cookie);
243 244
244extern struct kmem_cache *sighand_cachep; 245extern struct kmem_cache *sighand_cachep;
245 246
247int unhandled_signal(struct task_struct *tsk, int sig);
248
246/* 249/*
247 * In POSIX a signal is sent either to a specific thread (Linux task) 250 * In POSIX a signal is sent either to a specific thread (Linux task)
248 * or to the process as a whole (Linux thread group). How the signal 251 * or to the process as a whole (Linux thread group). How the signal
diff --git a/include/linux/time.h b/include/linux/time.h
index ec3b0ced0afe..e6aea5146e5d 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -4,6 +4,7 @@
4#include <linux/types.h> 4#include <linux/types.h>
5 5
6#ifdef __KERNEL__ 6#ifdef __KERNEL__
7# include <linux/cache.h>
7# include <linux/seqlock.h> 8# include <linux/seqlock.h>
8#endif 9#endif
9 10
@@ -94,6 +95,8 @@ extern struct timespec wall_to_monotonic;
94extern seqlock_t xtime_lock __attribute__((weak)); 95extern seqlock_t xtime_lock __attribute__((weak));
95 96
96extern unsigned long read_persistent_clock(void); 97extern unsigned long read_persistent_clock(void);
98extern int update_persistent_clock(struct timespec now);
99extern int no_sync_cmos_clock __read_mostly;
97void timekeeping_init(void); 100void timekeeping_init(void);
98 101
99static inline unsigned long get_seconds(void) 102static inline unsigned long get_seconds(void)
diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
index c2b10cae5da5..89338b468d0d 100644
--- a/include/linux/vmalloc.h
+++ b/include/linux/vmalloc.h
@@ -58,6 +58,13 @@ void vmalloc_sync_all(void);
58/* 58/*
59 * Lowlevel-APIs (not for driver use!) 59 * Lowlevel-APIs (not for driver use!)
60 */ 60 */
61
62static inline size_t get_vm_area_size(const struct vm_struct *area)
63{
64 /* return actual size without guard page */
65 return area->size - PAGE_SIZE;
66}
67
61extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags); 68extern struct vm_struct *get_vm_area(unsigned long size, unsigned long flags);
62extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags, 69extern struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
63 unsigned long start, unsigned long end); 70 unsigned long start, unsigned long end);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index 2e6bdc4e7a0a..df36461fe881 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -30,6 +30,7 @@
30#include <linux/timer.h> 30#include <linux/timer.h>
31#include <linux/pci.h> 31#include <linux/pci.h>
32#include <scsi/sas.h> 32#include <scsi/sas.h>
33#include <linux/libata.h>
33#include <linux/list.h> 34#include <linux/list.h>
34#include <asm/semaphore.h> 35#include <asm/semaphore.h>
35#include <scsi/scsi_device.h> 36#include <scsi/scsi_device.h>
@@ -165,6 +166,13 @@ struct sata_device {
165 166
166 u8 port_no; /* port number, if this is a PM (Port) */ 167 u8 port_no; /* port number, if this is a PM (Port) */
167 struct list_head children; /* PM Ports if this is a PM */ 168 struct list_head children; /* PM Ports if this is a PM */
169
170 struct ata_port *ap;
171 struct ata_host ata_host;
172 struct ata_taskfile tf;
173 u32 sstatus;
174 u32 serror;
175 u32 scontrol;
168}; 176};
169 177
170/* ---------- Domain device ---------- */ 178/* ---------- Domain device ---------- */
@@ -624,6 +632,7 @@ int sas_set_phy_speed(struct sas_phy *phy,
624 struct sas_phy_linkrates *rates); 632 struct sas_phy_linkrates *rates);
625int sas_phy_enable(struct sas_phy *phy, int enabled); 633int sas_phy_enable(struct sas_phy *phy, int enabled);
626int sas_phy_reset(struct sas_phy *phy, int hard_reset); 634int sas_phy_reset(struct sas_phy *phy, int hard_reset);
635int sas_queue_up(struct sas_task *task);
627extern int sas_queuecommand(struct scsi_cmnd *, 636extern int sas_queuecommand(struct scsi_cmnd *,
628 void (*scsi_done)(struct scsi_cmnd *)); 637 void (*scsi_done)(struct scsi_cmnd *));
629extern int sas_target_alloc(struct scsi_target *); 638extern int sas_target_alloc(struct scsi_target *);
@@ -661,4 +670,10 @@ int __sas_task_abort(struct sas_task *);
661int sas_eh_device_reset_handler(struct scsi_cmnd *cmd); 670int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
662int sas_eh_bus_reset_handler(struct scsi_cmnd *cmd); 671int sas_eh_bus_reset_handler(struct scsi_cmnd *cmd);
663 672
673extern void sas_target_destroy(struct scsi_target *);
674extern int sas_slave_alloc(struct scsi_device *);
675extern int sas_ioctl(struct scsi_device *sdev, int cmd, void __user *arg);
676
677extern int sas_smp_handler(struct Scsi_Host *shost, struct sas_rphy *rphy,
678 struct request *req);
664#endif /* _SASLIB_H_ */ 679#endif /* _SASLIB_H_ */
diff --git a/include/scsi/sas_ata.h b/include/scsi/sas_ata.h
new file mode 100644
index 000000000000..dd5edc915417
--- /dev/null
+++ b/include/scsi/sas_ata.h
@@ -0,0 +1,60 @@
1/*
2 * Support for SATA devices on Serial Attached SCSI (SAS) controllers
3 *
4 * Copyright (C) 2006 IBM Corporation
5 *
6 * Written by: Darrick J. Wong <djwong@us.ibm.com>, IBM Corporation
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of the
11 * License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21 * USA
22 *
23 */
24
25#ifndef _SAS_ATA_H_
26#define _SAS_ATA_H_
27
28#include <linux/libata.h>
29#include <scsi/libsas.h>
30
31#ifdef CONFIG_SCSI_SAS_ATA
32
33static inline int dev_is_sata(struct domain_device *dev)
34{
35 return (dev->rphy->identify.target_port_protocols & SAS_PROTOCOL_SATA);
36}
37
38int sas_ata_init_host_and_port(struct domain_device *found_dev,
39 struct scsi_target *starget);
40
41void sas_ata_task_abort(struct sas_task *task);
42
43#else
44
45
46static inline int dev_is_sata(struct domain_device *dev)
47{
48 return 0;
49}
50int sas_ata_init_host_and_port(struct domain_device *found_dev,
51 struct scsi_target *starget)
52{
53 return 0;
54}
55void sas_ata_task_abort(struct sas_task *task)
56{
57}
58#endif
59
60#endif /* _SAS_ATA_H_ */
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index ba07cf7c04ba..3b8a6a85c2f8 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -341,7 +341,7 @@ struct scsi_host_template {
341 /* 341 /*
342 * Name of proc directory 342 * Name of proc directory
343 */ 343 */
344 char *proc_name; 344 const char *proc_name;
345 345
346 /* 346 /*
347 * Used to store the procfs directory if a driver implements the 347 * Used to store the procfs directory if a driver implements the
diff --git a/include/scsi/scsi_transport_sas.h b/include/scsi/scsi_transport_sas.h
index 9aedc19820b0..abdfd2e27dd7 100644
--- a/include/scsi/scsi_transport_sas.h
+++ b/include/scsi/scsi_transport_sas.h
@@ -7,7 +7,7 @@
7 7
8struct scsi_transport_template; 8struct scsi_transport_template;
9struct sas_rphy; 9struct sas_rphy;
10 10struct request;
11 11
12enum sas_device_type { 12enum sas_device_type {
13 SAS_PHY_UNUSED, 13 SAS_PHY_UNUSED,
@@ -23,6 +23,12 @@ enum sas_protocol {
23 SAS_PROTOCOL_SSP = 0x08, 23 SAS_PROTOCOL_SSP = 0x08,
24}; 24};
25 25
26static inline int sas_protocol_ata(enum sas_protocol proto)
27{
28 return ((proto & SAS_PROTOCOL_SATA) ||
29 (proto & SAS_PROTOCOL_STP))? 1 : 0;
30}
31
26enum sas_linkrate { 32enum sas_linkrate {
27 /* These Values are defined in the SAS standard */ 33 /* These Values are defined in the SAS standard */
28 SAS_LINK_RATE_UNKNOWN = 0, 34 SAS_LINK_RATE_UNKNOWN = 0,
@@ -85,10 +91,12 @@ struct sas_phy {
85#define phy_to_shost(phy) \ 91#define phy_to_shost(phy) \
86 dev_to_shost((phy)->dev.parent) 92 dev_to_shost((phy)->dev.parent)
87 93
94struct request_queue;
88struct sas_rphy { 95struct sas_rphy {
89 struct device dev; 96 struct device dev;
90 struct sas_identify identify; 97 struct sas_identify identify;
91 struct list_head list; 98 struct list_head list;
99 struct request_queue *q;
92 u32 scsi_target_id; 100 u32 scsi_target_id;
93}; 101};
94 102
@@ -166,6 +174,7 @@ struct sas_function_template {
166 int (*phy_reset)(struct sas_phy *, int); 174 int (*phy_reset)(struct sas_phy *, int);
167 int (*phy_enable)(struct sas_phy *, int); 175 int (*phy_enable)(struct sas_phy *, int);
168 int (*set_phy_speed)(struct sas_phy *, struct sas_phy_linkrates *); 176 int (*set_phy_speed)(struct sas_phy *, struct sas_phy_linkrates *);
177 int (*smp_handler)(struct Scsi_Host *, struct sas_rphy *, struct request *);
169}; 178};
170 179
171 180
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 1bf093dcffe0..359645cff5b2 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -304,7 +304,7 @@ int __init audit_register_class(int class, unsigned *list)
304 304
305int audit_match_class(int class, unsigned syscall) 305int audit_match_class(int class, unsigned syscall)
306{ 306{
307 if (unlikely(syscall >= AUDIT_BITMASK_SIZE * sizeof(__u32))) 307 if (unlikely(syscall >= AUDIT_BITMASK_SIZE * 32))
308 return 0; 308 return 0;
309 if (unlikely(class >= AUDIT_SYSCALL_CLASSES || !classes[class])) 309 if (unlikely(class >= AUDIT_SYSCALL_CLASSES || !classes[class]))
310 return 0; 310 return 0;
@@ -456,6 +456,13 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule)
456 case AUDIT_DEVMINOR: 456 case AUDIT_DEVMINOR:
457 case AUDIT_EXIT: 457 case AUDIT_EXIT:
458 case AUDIT_SUCCESS: 458 case AUDIT_SUCCESS:
459 /* bit ops are only useful on syscall args */
460 if (f->op == AUDIT_BIT_MASK ||
461 f->op == AUDIT_BIT_TEST) {
462 err = -EINVAL;
463 goto exit_free;
464 }
465 break;
459 case AUDIT_ARG0: 466 case AUDIT_ARG0:
460 case AUDIT_ARG1: 467 case AUDIT_ARG1:
461 case AUDIT_ARG2: 468 case AUDIT_ARG2:
@@ -1566,6 +1573,10 @@ int audit_comparator(const u32 left, const u32 op, const u32 right)
1566 return (left > right); 1573 return (left > right);
1567 case AUDIT_GREATER_THAN_OR_EQUAL: 1574 case AUDIT_GREATER_THAN_OR_EQUAL:
1568 return (left >= right); 1575 return (left >= right);
1576 case AUDIT_BIT_MASK:
1577 return (left & right);
1578 case AUDIT_BIT_TEST:
1579 return ((left & right) == right);
1569 } 1580 }
1570 BUG(); 1581 BUG();
1571 return 0; 1582 return 0;
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index 145cbb79c4b9..bde1124d5908 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -173,12 +173,6 @@ struct audit_aux_data_fd_pair {
173 int fd[2]; 173 int fd[2];
174}; 174};
175 175
176struct audit_aux_data_path {
177 struct audit_aux_data d;
178 struct dentry *dentry;
179 struct vfsmount *mnt;
180};
181
182struct audit_aux_data_pids { 176struct audit_aux_data_pids {
183 struct audit_aux_data d; 177 struct audit_aux_data d;
184 pid_t target_pid[AUDIT_AUX_PIDS]; 178 pid_t target_pid[AUDIT_AUX_PIDS];
@@ -654,12 +648,6 @@ static inline void audit_free_aux(struct audit_context *context)
654 struct audit_aux_data *aux; 648 struct audit_aux_data *aux;
655 649
656 while ((aux = context->aux)) { 650 while ((aux = context->aux)) {
657 if (aux->type == AUDIT_AVC_PATH) {
658 struct audit_aux_data_path *axi = (void *)aux;
659 dput(axi->dentry);
660 mntput(axi->mnt);
661 }
662
663 context->aux = aux->next; 651 context->aux = aux->next;
664 kfree(aux); 652 kfree(aux);
665 } 653 }
@@ -995,7 +983,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
995 case AUDIT_IPC: { 983 case AUDIT_IPC: {
996 struct audit_aux_data_ipcctl *axi = (void *)aux; 984 struct audit_aux_data_ipcctl *axi = (void *)aux;
997 audit_log_format(ab, 985 audit_log_format(ab,
998 "ouid=%u ogid=%u mode=%x", 986 "ouid=%u ogid=%u mode=%#o",
999 axi->uid, axi->gid, axi->mode); 987 axi->uid, axi->gid, axi->mode);
1000 if (axi->osid != 0) { 988 if (axi->osid != 0) {
1001 char *ctx = NULL; 989 char *ctx = NULL;
@@ -1014,7 +1002,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
1014 case AUDIT_IPC_SET_PERM: { 1002 case AUDIT_IPC_SET_PERM: {
1015 struct audit_aux_data_ipcctl *axi = (void *)aux; 1003 struct audit_aux_data_ipcctl *axi = (void *)aux;
1016 audit_log_format(ab, 1004 audit_log_format(ab,
1017 "qbytes=%lx ouid=%u ogid=%u mode=%x", 1005 "qbytes=%lx ouid=%u ogid=%u mode=%#o",
1018 axi->qbytes, axi->uid, axi->gid, axi->mode); 1006 axi->qbytes, axi->uid, axi->gid, axi->mode);
1019 break; } 1007 break; }
1020 1008
@@ -1038,11 +1026,6 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts
1038 audit_log_hex(ab, axs->a, axs->len); 1026 audit_log_hex(ab, axs->a, axs->len);
1039 break; } 1027 break; }
1040 1028
1041 case AUDIT_AVC_PATH: {
1042 struct audit_aux_data_path *axi = (void *)aux;
1043 audit_log_d_path(ab, "path=", axi->dentry, axi->mnt);
1044 break; }
1045
1046 case AUDIT_FD_PAIR: { 1029 case AUDIT_FD_PAIR: {
1047 struct audit_aux_data_fd_pair *axs = (void *)aux; 1030 struct audit_aux_data_fd_pair *axs = (void *)aux;
1048 audit_log_format(ab, "fd0=%d fd1=%d", axs->fd[0], axs->fd[1]); 1031 audit_log_format(ab, "fd0=%d fd1=%d", axs->fd[0], axs->fd[1]);
@@ -1991,36 +1974,6 @@ void __audit_ptrace(struct task_struct *t)
1991} 1974}
1992 1975
1993/** 1976/**
1994 * audit_avc_path - record the granting or denial of permissions
1995 * @dentry: dentry to record
1996 * @mnt: mnt to record
1997 *
1998 * Returns 0 for success or NULL context or < 0 on error.
1999 *
2000 * Called from security/selinux/avc.c::avc_audit()
2001 */
2002int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt)
2003{
2004 struct audit_aux_data_path *ax;
2005 struct audit_context *context = current->audit_context;
2006
2007 if (likely(!context))
2008 return 0;
2009
2010 ax = kmalloc(sizeof(*ax), GFP_ATOMIC);
2011 if (!ax)
2012 return -ENOMEM;
2013
2014 ax->dentry = dget(dentry);
2015 ax->mnt = mntget(mnt);
2016
2017 ax->d.type = AUDIT_AVC_PATH;
2018 ax->d.next = context->aux;
2019 context->aux = (void *)ax;
2020 return 0;
2021}
2022
2023/**
2024 * audit_signal_info - record signal info for shutting down audit subsystem 1977 * audit_signal_info - record signal info for shutting down audit subsystem
2025 * @sig: signal value 1978 * @sig: signal value
2026 * @t: task being signaled 1979 * @t: task being signaled
diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
index 72d034258ba1..eb1ddebd2c04 100644
--- a/kernel/hrtimer.c
+++ b/kernel/hrtimer.c
@@ -558,7 +558,8 @@ static inline int hrtimer_enqueue_reprogram(struct hrtimer *timer,
558 */ 558 */
559static int hrtimer_switch_to_hres(void) 559static int hrtimer_switch_to_hres(void)
560{ 560{
561 struct hrtimer_cpu_base *base = &__get_cpu_var(hrtimer_bases); 561 int cpu = smp_processor_id();
562 struct hrtimer_cpu_base *base = &per_cpu(hrtimer_bases, cpu);
562 unsigned long flags; 563 unsigned long flags;
563 564
564 if (base->hres_active) 565 if (base->hres_active)
@@ -568,6 +569,8 @@ static int hrtimer_switch_to_hres(void)
568 569
569 if (tick_init_highres()) { 570 if (tick_init_highres()) {
570 local_irq_restore(flags); 571 local_irq_restore(flags);
572 printk(KERN_WARNING "Could not switch to high resolution "
573 "mode on CPU %d\n", cpu);
571 return 0; 574 return 0;
572 } 575 }
573 base->hres_active = 1; 576 base->hres_active = 1;
@@ -683,6 +686,7 @@ static void enqueue_hrtimer(struct hrtimer *timer,
683 struct rb_node **link = &base->active.rb_node; 686 struct rb_node **link = &base->active.rb_node;
684 struct rb_node *parent = NULL; 687 struct rb_node *parent = NULL;
685 struct hrtimer *entry; 688 struct hrtimer *entry;
689 int leftmost = 1;
686 690
687 /* 691 /*
688 * Find the right place in the rbtree: 692 * Find the right place in the rbtree:
@@ -694,18 +698,19 @@ static void enqueue_hrtimer(struct hrtimer *timer,
694 * We dont care about collisions. Nodes with 698 * We dont care about collisions. Nodes with
695 * the same expiry time stay together. 699 * the same expiry time stay together.
696 */ 700 */
697 if (timer->expires.tv64 < entry->expires.tv64) 701 if (timer->expires.tv64 < entry->expires.tv64) {
698 link = &(*link)->rb_left; 702 link = &(*link)->rb_left;
699 else 703 } else {
700 link = &(*link)->rb_right; 704 link = &(*link)->rb_right;
705 leftmost = 0;
706 }
701 } 707 }
702 708
703 /* 709 /*
704 * Insert the timer to the rbtree and check whether it 710 * Insert the timer to the rbtree and check whether it
705 * replaces the first pending timer 711 * replaces the first pending timer
706 */ 712 */
707 if (!base->first || timer->expires.tv64 < 713 if (leftmost) {
708 rb_entry(base->first, struct hrtimer, node)->expires.tv64) {
709 /* 714 /*
710 * Reprogram the clock event device. When the timer is already 715 * Reprogram the clock event device. When the timer is already
711 * expired hrtimer_enqueue_reprogram has either called the 716 * expired hrtimer_enqueue_reprogram has either called the
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index b4f1674fca79..50b81b98046a 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -19,7 +19,15 @@ static struct proc_dir_entry *root_irq_dir;
19static int irq_affinity_read_proc(char *page, char **start, off_t off, 19static int irq_affinity_read_proc(char *page, char **start, off_t off,
20 int count, int *eof, void *data) 20 int count, int *eof, void *data)
21{ 21{
22 int len = cpumask_scnprintf(page, count, irq_desc[(long)data].affinity); 22 struct irq_desc *desc = irq_desc + (long)data;
23 cpumask_t *mask = &desc->affinity;
24 int len;
25
26#ifdef CONFIG_GENERIC_PENDING_IRQ
27 if (desc->status & IRQ_MOVE_PENDING)
28 mask = &desc->pending_mask;
29#endif
30 len = cpumask_scnprintf(page, count, *mask);
23 31
24 if (count - len < 2) 32 if (count - len < 2)
25 return -EINVAL; 33 return -EINVAL;
diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
index 7358609e4735..c1a106d87d90 100644
--- a/kernel/power/Kconfig
+++ b/kernel/power/Kconfig
@@ -57,7 +57,7 @@ config DISABLE_CONSOLE_SUSPEND
57 57
58config PM_TRACE 58config PM_TRACE
59 bool "Suspend/resume event tracing" 59 bool "Suspend/resume event tracing"
60 depends on PM_DEBUG && X86_32 && EXPERIMENTAL 60 depends on PM_DEBUG && X86 && EXPERIMENTAL
61 default n 61 default n
62 ---help--- 62 ---help---
63 This enables some cheesy code to save the last PM event point in the 63 This enables some cheesy code to save the last PM event point in the
diff --git a/kernel/signal.c b/kernel/signal.c
index 39d122753bac..ef8156a6aad5 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -255,6 +255,16 @@ flush_signal_handlers(struct task_struct *t, int force_default)
255 } 255 }
256} 256}
257 257
258int unhandled_signal(struct task_struct *tsk, int sig)
259{
260 if (is_init(tsk))
261 return 1;
262 if (tsk->ptrace & PT_PTRACED)
263 return 0;
264 return (tsk->sighand->action[sig-1].sa.sa_handler == SIG_IGN) ||
265 (tsk->sighand->action[sig-1].sa.sa_handler == SIG_DFL);
266}
267
258 268
259/* Notify the system that a driver wants to block all signals for this 269/* Notify the system that a driver wants to block all signals for this
260 * process, and wants to be notified if any signals at all were to be 270 * process, and wants to be notified if any signals at all were to be
diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 222299844ad1..ddebf3f2affe 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1203,6 +1203,16 @@ static ctl_table fs_table[] = {
1203}; 1203};
1204 1204
1205static ctl_table debug_table[] = { 1205static ctl_table debug_table[] = {
1206#ifdef CONFIG_X86
1207 {
1208 .ctl_name = CTL_UNNUMBERED,
1209 .procname = "exception-trace",
1210 .data = &show_unhandled_signals,
1211 .maxlen = sizeof(int),
1212 .mode = 0644,
1213 .proc_handler = proc_dointvec
1214 },
1215#endif
1206 { .ctl_name = 0 } 1216 { .ctl_name = 0 }
1207}; 1217};
1208 1218
diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index b5e352597cbb..cd91237dbfe3 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -10,6 +10,7 @@
10 10
11#include <linux/mm.h> 11#include <linux/mm.h>
12#include <linux/time.h> 12#include <linux/time.h>
13#include <linux/timer.h>
13#include <linux/timex.h> 14#include <linux/timex.h>
14#include <linux/jiffies.h> 15#include <linux/jiffies.h>
15#include <linux/hrtimer.h> 16#include <linux/hrtimer.h>
@@ -175,12 +176,64 @@ u64 current_tick_length(void)
175 return tick_length; 176 return tick_length;
176} 177}
177 178
179#ifdef CONFIG_GENERIC_CMOS_UPDATE
178 180
179void __attribute__ ((weak)) notify_arch_cmos_timer(void) 181/* Disable the cmos update - used by virtualization and embedded */
182int no_sync_cmos_clock __read_mostly;
183
184static void sync_cmos_clock(unsigned long dummy);
185
186static DEFINE_TIMER(sync_cmos_timer, sync_cmos_clock, 0, 0);
187
188static void sync_cmos_clock(unsigned long dummy)
189{
190 struct timespec now, next;
191 int fail = 1;
192
193 /*
194 * If we have an externally synchronized Linux clock, then update
195 * CMOS clock accordingly every ~11 minutes. Set_rtc_mmss() has to be
196 * called as close as possible to 500 ms before the new second starts.
197 * This code is run on a timer. If the clock is set, that timer
198 * may not expire at the correct time. Thus, we adjust...
199 */
200 if (!ntp_synced())
201 /*
202 * Not synced, exit, do not restart a timer (if one is
203 * running, let it run out).
204 */
205 return;
206
207 getnstimeofday(&now);
208 if (abs(xtime.tv_nsec - (NSEC_PER_SEC / 2)) <= tick_nsec / 2)
209 fail = update_persistent_clock(now);
210
211 next.tv_nsec = (NSEC_PER_SEC / 2) - now.tv_nsec;
212 if (next.tv_nsec <= 0)
213 next.tv_nsec += NSEC_PER_SEC;
214
215 if (!fail)
216 next.tv_sec = 659;
217 else
218 next.tv_sec = 0;
219
220 if (next.tv_nsec >= NSEC_PER_SEC) {
221 next.tv_sec++;
222 next.tv_nsec -= NSEC_PER_SEC;
223 }
224 mod_timer(&sync_cmos_timer, jiffies + timespec_to_jiffies(&next));
225}
226
227static void notify_cmos_timer(void)
180{ 228{
181 return; 229 if (no_sync_cmos_clock)
230 mod_timer(&sync_cmos_timer, jiffies + 1);
182} 231}
183 232
233#else
234static inline void notify_cmos_timer(void) { }
235#endif
236
184/* adjtimex mainly allows reading (and writing, if superuser) of 237/* adjtimex mainly allows reading (and writing, if superuser) of
185 * kernel time-keeping variables. used by xntpd. 238 * kernel time-keeping variables. used by xntpd.
186 */ 239 */
@@ -345,6 +398,6 @@ leave: if ((time_status & (STA_UNSYNC|STA_CLOCKERR)) != 0)
345 txc->stbcnt = 0; 398 txc->stbcnt = 0;
346 write_sequnlock_irq(&xtime_lock); 399 write_sequnlock_irq(&xtime_lock);
347 do_gettimeofday(&txc->time); 400 do_gettimeofday(&txc->time);
348 notify_arch_cmos_timer(); 401 notify_cmos_timer();
349 return(result); 402 return(result);
350} 403}
diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
index 8001d37071f5..db8e0f3d409b 100644
--- a/kernel/time/tick-broadcast.c
+++ b/kernel/time/tick-broadcast.c
@@ -31,6 +31,12 @@ struct tick_device tick_broadcast_device;
31static cpumask_t tick_broadcast_mask; 31static cpumask_t tick_broadcast_mask;
32static DEFINE_SPINLOCK(tick_broadcast_lock); 32static DEFINE_SPINLOCK(tick_broadcast_lock);
33 33
34#ifdef CONFIG_TICK_ONESHOT
35static void tick_broadcast_clear_oneshot(int cpu);
36#else
37static inline void tick_broadcast_clear_oneshot(int cpu) { }
38#endif
39
34/* 40/*
35 * Debugging: see timer_list.c 41 * Debugging: see timer_list.c
36 */ 42 */
@@ -49,7 +55,7 @@ cpumask_t *tick_get_broadcast_mask(void)
49 */ 55 */
50static void tick_broadcast_start_periodic(struct clock_event_device *bc) 56static void tick_broadcast_start_periodic(struct clock_event_device *bc)
51{ 57{
52 if (bc && bc->mode == CLOCK_EVT_MODE_SHUTDOWN) 58 if (bc)
53 tick_setup_periodic(bc, 1); 59 tick_setup_periodic(bc, 1);
54} 60}
55 61
@@ -99,8 +105,19 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
99 cpu_set(cpu, tick_broadcast_mask); 105 cpu_set(cpu, tick_broadcast_mask);
100 tick_broadcast_start_periodic(tick_broadcast_device.evtdev); 106 tick_broadcast_start_periodic(tick_broadcast_device.evtdev);
101 ret = 1; 107 ret = 1;
102 } 108 } else {
109 /*
110 * When the new device is not affected by the stop
111 * feature and the cpu is marked in the broadcast mask
112 * then clear the broadcast bit.
113 */
114 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
115 int cpu = smp_processor_id();
103 116
117 cpu_clear(cpu, tick_broadcast_mask);
118 tick_broadcast_clear_oneshot(cpu);
119 }
120 }
104 spin_unlock_irqrestore(&tick_broadcast_lock, flags); 121 spin_unlock_irqrestore(&tick_broadcast_lock, flags);
105 return ret; 122 return ret;
106} 123}
@@ -299,7 +316,7 @@ void tick_suspend_broadcast(void)
299 spin_lock_irqsave(&tick_broadcast_lock, flags); 316 spin_lock_irqsave(&tick_broadcast_lock, flags);
300 317
301 bc = tick_broadcast_device.evtdev; 318 bc = tick_broadcast_device.evtdev;
302 if (bc && tick_broadcast_device.mode == TICKDEV_MODE_PERIODIC) 319 if (bc)
303 clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN); 320 clockevents_set_mode(bc, CLOCK_EVT_MODE_SHUTDOWN);
304 321
305 spin_unlock_irqrestore(&tick_broadcast_lock, flags); 322 spin_unlock_irqrestore(&tick_broadcast_lock, flags);
@@ -316,6 +333,8 @@ int tick_resume_broadcast(void)
316 bc = tick_broadcast_device.evtdev; 333 bc = tick_broadcast_device.evtdev;
317 334
318 if (bc) { 335 if (bc) {
336 clockevents_set_mode(bc, CLOCK_EVT_MODE_RESUME);
337
319 switch (tick_broadcast_device.mode) { 338 switch (tick_broadcast_device.mode) {
320 case TICKDEV_MODE_PERIODIC: 339 case TICKDEV_MODE_PERIODIC:
321 if(!cpus_empty(tick_broadcast_mask)) 340 if(!cpus_empty(tick_broadcast_mask))
@@ -485,6 +504,16 @@ out:
485 spin_unlock_irqrestore(&tick_broadcast_lock, flags); 504 spin_unlock_irqrestore(&tick_broadcast_lock, flags);
486} 505}
487 506
507/*
508 * Reset the one shot broadcast for a cpu
509 *
510 * Called with tick_broadcast_lock held
511 */
512static void tick_broadcast_clear_oneshot(int cpu)
513{
514 cpu_clear(cpu, tick_broadcast_oneshot_mask);
515}
516
488/** 517/**
489 * tick_broadcast_setup_highres - setup the broadcast device for highres 518 * tick_broadcast_setup_highres - setup the broadcast device for highres
490 */ 519 */
diff --git a/kernel/time/tick-common.c b/kernel/time/tick-common.c
index a96ec9ab3454..77a21abc8716 100644
--- a/kernel/time/tick-common.c
+++ b/kernel/time/tick-common.c
@@ -318,12 +318,17 @@ static void tick_resume(void)
318{ 318{
319 struct tick_device *td = &__get_cpu_var(tick_cpu_device); 319 struct tick_device *td = &__get_cpu_var(tick_cpu_device);
320 unsigned long flags; 320 unsigned long flags;
321 int broadcast = tick_resume_broadcast();
321 322
322 spin_lock_irqsave(&tick_device_lock, flags); 323 spin_lock_irqsave(&tick_device_lock, flags);
323 if (td->mode == TICKDEV_MODE_PERIODIC) 324 clockevents_set_mode(td->evtdev, CLOCK_EVT_MODE_RESUME);
324 tick_setup_periodic(td->evtdev, 0); 325
325 else 326 if (!broadcast) {
326 tick_resume_oneshot(); 327 if (td->mode == TICKDEV_MODE_PERIODIC)
328 tick_setup_periodic(td->evtdev, 0);
329 else
330 tick_resume_oneshot();
331 }
327 spin_unlock_irqrestore(&tick_device_lock, flags); 332 spin_unlock_irqrestore(&tick_device_lock, flags);
328} 333}
329 334
@@ -360,8 +365,7 @@ static int tick_notify(struct notifier_block *nb, unsigned long reason,
360 break; 365 break;
361 366
362 case CLOCK_EVT_NOTIFY_RESUME: 367 case CLOCK_EVT_NOTIFY_RESUME:
363 if (!tick_resume_broadcast()) 368 tick_resume();
364 tick_resume();
365 break; 369 break;
366 370
367 default: 371 default:
diff --git a/kernel/time/tick-oneshot.c b/kernel/time/tick-oneshot.c
index f6997ab0c3c9..0258d3115d54 100644
--- a/kernel/time/tick-oneshot.c
+++ b/kernel/time/tick-oneshot.c
@@ -73,8 +73,21 @@ int tick_switch_to_oneshot(void (*handler)(struct clock_event_device *))
73 struct clock_event_device *dev = td->evtdev; 73 struct clock_event_device *dev = td->evtdev;
74 74
75 if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT) || 75 if (!dev || !(dev->features & CLOCK_EVT_FEAT_ONESHOT) ||
76 !tick_device_is_functional(dev)) 76 !tick_device_is_functional(dev)) {
77
78 printk(KERN_INFO "Clockevents: "
79 "could not switch to one-shot mode:");
80 if (!dev) {
81 printk(" no tick device\n");
82 } else {
83 if (!tick_device_is_functional(dev))
84 printk(" %s is not functional.\n", dev->name);
85 else
86 printk(" %s does not support one-shot mode.\n",
87 dev->name);
88 }
77 return -EINVAL; 89 return -EINVAL;
90 }
78 91
79 td->mode = TICKDEV_MODE_ONESHOT; 92 td->mode = TICKDEV_MODE_ONESHOT;
80 dev->event_handler = handler; 93 dev->event_handler = handler;
diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c
index 52db9e3c526e..b416995b9757 100644
--- a/kernel/time/tick-sched.c
+++ b/kernel/time/tick-sched.c
@@ -546,6 +546,7 @@ void tick_setup_sched_timer(void)
546{ 546{
547 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched); 547 struct tick_sched *ts = &__get_cpu_var(tick_cpu_sched);
548 ktime_t now = ktime_get(); 548 ktime_t now = ktime_get();
549 u64 offset;
549 550
550 /* 551 /*
551 * Emulate tick processing via per-CPU hrtimers: 552 * Emulate tick processing via per-CPU hrtimers:
@@ -554,8 +555,12 @@ void tick_setup_sched_timer(void)
554 ts->sched_timer.function = tick_sched_timer; 555 ts->sched_timer.function = tick_sched_timer;
555 ts->sched_timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ; 556 ts->sched_timer.cb_mode = HRTIMER_CB_IRQSAFE_NO_SOFTIRQ;
556 557
557 /* Get the next period */ 558 /* Get the next period (per cpu) */
558 ts->sched_timer.expires = tick_init_jiffy_update(); 559 ts->sched_timer.expires = tick_init_jiffy_update();
560 offset = ktime_to_ns(tick_period) >> 1;
561 do_div(offset, NR_CPUS);
562 offset *= smp_processor_id();
563 ts->sched_timer.expires = ktime_add_ns(ts->sched_timer.expires, offset);
559 564
560 for (;;) { 565 for (;;) {
561 hrtimer_forward(&ts->sched_timer, now, tick_period); 566 hrtimer_forward(&ts->sched_timer, now, tick_period);
diff --git a/lib/swiotlb.c b/lib/swiotlb.c
index 10c13ad0d82d..a7381d55663a 100644
--- a/lib/swiotlb.c
+++ b/lib/swiotlb.c
@@ -357,7 +357,8 @@ map_single(struct device *hwdev, char *buffer, size_t size, int dir)
357 * This is needed when we sync the memory. Then we sync the buffer if 357 * This is needed when we sync the memory. Then we sync the buffer if
358 * needed. 358 * needed.
359 */ 359 */
360 io_tlb_orig_addr[index] = buffer; 360 for (i = 0; i < nslots; i++)
361 io_tlb_orig_addr[index+i] = buffer + (i << IO_TLB_SHIFT);
361 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) 362 if (dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL)
362 memcpy(dma_addr, buffer, size); 363 memcpy(dma_addr, buffer, size);
363 364
@@ -418,6 +419,8 @@ sync_single(struct device *hwdev, char *dma_addr, size_t size,
418 int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT; 419 int index = (dma_addr - io_tlb_start) >> IO_TLB_SHIFT;
419 char *buffer = io_tlb_orig_addr[index]; 420 char *buffer = io_tlb_orig_addr[index];
420 421
422 buffer += ((unsigned long)dma_addr & ((1 << IO_TLB_SHIFT) - 1));
423
421 switch (target) { 424 switch (target) {
422 case SYNC_FOR_CPU: 425 case SYNC_FOR_CPU:
423 if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL)) 426 if (likely(dir == DMA_FROM_DEVICE || dir == DMA_BIDIRECTIONAL))
diff --git a/mm/memory.c b/mm/memory.c
index 8aace3db3a54..ca8cac11bd2c 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2659,8 +2659,6 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
2659 return handle_pte_fault(mm, vma, address, pte, pmd, write_access); 2659 return handle_pte_fault(mm, vma, address, pte, pmd, write_access);
2660} 2660}
2661 2661
2662EXPORT_SYMBOL_GPL(handle_mm_fault);
2663
2664#ifndef __PAGETABLE_PUD_FOLDED 2662#ifndef __PAGETABLE_PUD_FOLDED
2665/* 2663/*
2666 * Allocate page upper directory. 2664 * Allocate page upper directory.
diff --git a/mm/nommu.c b/mm/nommu.c
index 1b105d28949f..9eef6a398555 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -54,12 +54,6 @@ DECLARE_RWSEM(nommu_vma_sem);
54struct vm_operations_struct generic_file_vm_ops = { 54struct vm_operations_struct generic_file_vm_ops = {
55}; 55};
56 56
57EXPORT_SYMBOL(vfree);
58EXPORT_SYMBOL(vmalloc_to_page);
59EXPORT_SYMBOL(vmalloc_32);
60EXPORT_SYMBOL(vmap);
61EXPORT_SYMBOL(vunmap);
62
63/* 57/*
64 * Handle all mappings that got truncated by a "truncate()" 58 * Handle all mappings that got truncated by a "truncate()"
65 * system call. 59 * system call.
@@ -168,7 +162,6 @@ int get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
168finish_or_fault: 162finish_or_fault:
169 return i ? : -EFAULT; 163 return i ? : -EFAULT;
170} 164}
171
172EXPORT_SYMBOL(get_user_pages); 165EXPORT_SYMBOL(get_user_pages);
173 166
174DEFINE_RWLOCK(vmlist_lock); 167DEFINE_RWLOCK(vmlist_lock);
@@ -178,6 +171,7 @@ void vfree(void *addr)
178{ 171{
179 kfree(addr); 172 kfree(addr);
180} 173}
174EXPORT_SYMBOL(vfree);
181 175
182void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot) 176void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
183{ 177{
@@ -186,17 +180,19 @@ void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot)
186 */ 180 */
187 return kmalloc(size, (gfp_mask | __GFP_COMP) & ~__GFP_HIGHMEM); 181 return kmalloc(size, (gfp_mask | __GFP_COMP) & ~__GFP_HIGHMEM);
188} 182}
183EXPORT_SYMBOL(__vmalloc);
189 184
190struct page * vmalloc_to_page(void *addr) 185struct page * vmalloc_to_page(void *addr)
191{ 186{
192 return virt_to_page(addr); 187 return virt_to_page(addr);
193} 188}
189EXPORT_SYMBOL(vmalloc_to_page);
194 190
195unsigned long vmalloc_to_pfn(void *addr) 191unsigned long vmalloc_to_pfn(void *addr)
196{ 192{
197 return page_to_pfn(virt_to_page(addr)); 193 return page_to_pfn(virt_to_page(addr));
198} 194}
199 195EXPORT_SYMBOL(vmalloc_to_pfn);
200 196
201long vread(char *buf, char *addr, unsigned long count) 197long vread(char *buf, char *addr, unsigned long count)
202{ 198{
@@ -237,9 +233,8 @@ void *vmalloc_node(unsigned long size, int node)
237} 233}
238EXPORT_SYMBOL(vmalloc_node); 234EXPORT_SYMBOL(vmalloc_node);
239 235
240/* 236/**
241 * vmalloc_32 - allocate virtually continguos memory (32bit addressable) 237 * vmalloc_32 - allocate virtually contiguous memory (32bit addressable)
242 *
243 * @size: allocation size 238 * @size: allocation size
244 * 239 *
245 * Allocate enough 32bit PA addressable pages to cover @size from the 240 * Allocate enough 32bit PA addressable pages to cover @size from the
@@ -249,17 +244,33 @@ void *vmalloc_32(unsigned long size)
249{ 244{
250 return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL); 245 return __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
251} 246}
247EXPORT_SYMBOL(vmalloc_32);
248
249/**
250 * vmalloc_32_user - allocate zeroed virtually contiguous 32bit memory
251 * @size: allocation size
252 *
253 * The resulting memory area is 32bit addressable and zeroed so it can be
254 * mapped to userspace without leaking data.
255 */
256void *vmalloc_32_user(unsigned long size)
257{
258 return __vmalloc(size, GFP_KERNEL | __GFP_ZERO, PAGE_KERNEL);
259}
260EXPORT_SYMBOL(vmalloc_32_user);
252 261
253void *vmap(struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot) 262void *vmap(struct page **pages, unsigned int count, unsigned long flags, pgprot_t prot)
254{ 263{
255 BUG(); 264 BUG();
256 return NULL; 265 return NULL;
257} 266}
267EXPORT_SYMBOL(vmap);
258 268
259void vunmap(void *addr) 269void vunmap(void *addr)
260{ 270{
261 BUG(); 271 BUG();
262} 272}
273EXPORT_SYMBOL(vunmap);
263 274
264/* 275/*
265 * Implement a stub for vmalloc_sync_all() if the architecture chose not to 276 * Implement a stub for vmalloc_sync_all() if the architecture chose not to
@@ -269,6 +280,13 @@ void __attribute__((weak)) vmalloc_sync_all(void)
269{ 280{
270} 281}
271 282
283int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
284 struct page *page)
285{
286 return -EINVAL;
287}
288EXPORT_SYMBOL(vm_insert_page);
289
272/* 290/*
273 * sys_brk() for the most part doesn't need the global kernel 291 * sys_brk() for the most part doesn't need the global kernel
274 * lock, except when an application is doing something nasty 292 * lock, except when an application is doing something nasty
@@ -994,6 +1012,7 @@ unsigned long do_mmap_pgoff(struct file *file,
994 show_free_areas(); 1012 show_free_areas();
995 return -ENOMEM; 1013 return -ENOMEM;
996} 1014}
1015EXPORT_SYMBOL(do_mmap_pgoff);
997 1016
998/* 1017/*
999 * handle mapping disposal for uClinux 1018 * handle mapping disposal for uClinux
@@ -1074,6 +1093,7 @@ int do_munmap(struct mm_struct *mm, unsigned long addr, size_t len)
1074 1093
1075 return 0; 1094 return 0;
1076} 1095}
1096EXPORT_SYMBOL(do_munmap);
1077 1097
1078asmlinkage long sys_munmap(unsigned long addr, size_t len) 1098asmlinkage long sys_munmap(unsigned long addr, size_t len)
1079{ 1099{
@@ -1164,6 +1184,7 @@ unsigned long do_mremap(unsigned long addr,
1164 1184
1165 return vma->vm_start; 1185 return vma->vm_start;
1166} 1186}
1187EXPORT_SYMBOL(do_mremap);
1167 1188
1168asmlinkage unsigned long sys_mremap(unsigned long addr, 1189asmlinkage unsigned long sys_mremap(unsigned long addr,
1169 unsigned long old_len, unsigned long new_len, 1190 unsigned long old_len, unsigned long new_len,
@@ -1231,7 +1252,6 @@ unsigned long get_unmapped_area(struct file *file, unsigned long addr,
1231 1252
1232 return get_area(file, addr, len, pgoff, flags); 1253 return get_area(file, addr, len, pgoff, flags);
1233} 1254}
1234
1235EXPORT_SYMBOL(get_unmapped_area); 1255EXPORT_SYMBOL(get_unmapped_area);
1236 1256
1237/* 1257/*
@@ -1346,6 +1366,7 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
1346 BUG(); 1366 BUG();
1347 return 0; 1367 return 0;
1348} 1368}
1369EXPORT_SYMBOL(filemap_fault);
1349 1370
1350/* 1371/*
1351 * Access another process' address space. 1372 * Access another process' address space.
diff --git a/mm/slob.c b/mm/slob.c
index d50920ecc02b..ec33fcdc852e 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -293,6 +293,7 @@ static void *slob_page_alloc(struct slob_page *sp, size_t size, int align)
293static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) 293static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
294{ 294{
295 struct slob_page *sp; 295 struct slob_page *sp;
296 struct list_head *prev;
296 slob_t *b = NULL; 297 slob_t *b = NULL;
297 unsigned long flags; 298 unsigned long flags;
298 299
@@ -307,12 +308,22 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
307 if (node != -1 && page_to_nid(&sp->page) != node) 308 if (node != -1 && page_to_nid(&sp->page) != node)
308 continue; 309 continue;
309#endif 310#endif
311 /* Enough room on this page? */
312 if (sp->units < SLOB_UNITS(size))
313 continue;
310 314
311 if (sp->units >= SLOB_UNITS(size)) { 315 /* Attempt to alloc */
312 b = slob_page_alloc(sp, size, align); 316 prev = sp->list.prev;
313 if (b) 317 b = slob_page_alloc(sp, size, align);
314 break; 318 if (!b)
315 } 319 continue;
320
321 /* Improve fragment distribution and reduce our average
322 * search time by starting our next search here. (see
323 * Knuth vol 1, sec 2.5, pg 449) */
324 if (free_slob_pages.next != prev->next)
325 list_move_tail(&free_slob_pages, prev->next);
326 break;
316 } 327 }
317 spin_unlock_irqrestore(&slob_lock, flags); 328 spin_unlock_irqrestore(&slob_lock, flags);
318 329
diff --git a/mm/sparse.c b/mm/sparse.c
index e03b39f3540f..3047bf06c1f3 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -209,7 +209,7 @@ static int __meminit sparse_init_one_section(struct mem_section *ms,
209 return 1; 209 return 1;
210} 210}
211 211
212__attribute__((weak)) 212__attribute__((weak)) __init
213void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size) 213void *alloc_bootmem_high_node(pg_data_t *pgdat, unsigned long size)
214{ 214{
215 return NULL; 215 return NULL;
diff --git a/net/core/dev.c b/net/core/dev.c
index 38212c3f9971..ee4035571c21 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3624,7 +3624,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
3624 3624
3625 /* ensure 32-byte alignment of both the device and private area */ 3625 /* ensure 32-byte alignment of both the device and private area */
3626 alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST + 3626 alloc_size = (sizeof(*dev) + NETDEV_ALIGN_CONST +
3627 (sizeof(struct net_device_subqueue) * queue_count)) & 3627 (sizeof(struct net_device_subqueue) * (queue_count - 1))) &
3628 ~NETDEV_ALIGN_CONST; 3628 ~NETDEV_ALIGN_CONST;
3629 alloc_size += sizeof_priv + NETDEV_ALIGN_CONST; 3629 alloc_size += sizeof_priv + NETDEV_ALIGN_CONST;
3630 3630
@@ -3642,7 +3642,7 @@ struct net_device *alloc_netdev_mq(int sizeof_priv, const char *name,
3642 dev->priv = ((char *)dev + 3642 dev->priv = ((char *)dev +
3643 ((sizeof(struct net_device) + 3643 ((sizeof(struct net_device) +
3644 (sizeof(struct net_device_subqueue) * 3644 (sizeof(struct net_device_subqueue) *
3645 queue_count) + NETDEV_ALIGN_CONST) 3645 (queue_count - 1)) + NETDEV_ALIGN_CONST)
3646 & ~NETDEV_ALIGN_CONST)); 3646 & ~NETDEV_ALIGN_CONST));
3647 } 3647 }
3648 3648
diff --git a/net/core/sock.c b/net/core/sock.c
index bd209c4477a9..cfed7d42c485 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -182,7 +182,8 @@ static const char *af_family_clock_key_strings[AF_MAX+1] = {
182 "clock-21" , "clock-AF_SNA" , "clock-AF_IRDA" , 182 "clock-21" , "clock-AF_SNA" , "clock-AF_IRDA" ,
183 "clock-AF_PPPOX" , "clock-AF_WANPIPE" , "clock-AF_LLC" , 183 "clock-AF_PPPOX" , "clock-AF_WANPIPE" , "clock-AF_LLC" ,
184 "clock-27" , "clock-28" , "clock-29" , 184 "clock-27" , "clock-28" , "clock-29" ,
185 "clock-AF_TIPC" , "clock-AF_BLUETOOTH", "clock-AF_MAX" 185 "clock-AF_TIPC" , "clock-AF_BLUETOOTH", "clock-AF_IUCV" ,
186 "clock-AF_RXRPC" , "clock-AF_MAX"
186}; 187};
187#endif 188#endif
188 189
diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
index 6cbce96a54ce..771031dfbd0f 100644
--- a/net/ipv4/inetpeer.c
+++ b/net/ipv4/inetpeer.c
@@ -158,7 +158,7 @@ static void unlink_from_unused(struct inet_peer *p)
158#define lookup(_daddr,_stack) \ 158#define lookup(_daddr,_stack) \
159({ \ 159({ \
160 struct inet_peer *u, **v; \ 160 struct inet_peer *u, **v; \
161 if (_stack) { \ 161 if (_stack != NULL) { \
162 stackptr = _stack; \ 162 stackptr = _stack; \
163 *stackptr++ = &peer_root; \ 163 *stackptr++ = &peer_root; \
164 } \ 164 } \
@@ -169,7 +169,7 @@ static void unlink_from_unused(struct inet_peer *p)
169 v = &u->avl_left; \ 169 v = &u->avl_left; \
170 else \ 170 else \
171 v = &u->avl_right; \ 171 v = &u->avl_right; \
172 if (_stack) \ 172 if (_stack != NULL) \
173 *stackptr++ = v; \ 173 *stackptr++ = v; \
174 u = *v; \ 174 u = *v; \
175 } \ 175 } \
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 281aee42d3f0..df30976f6dfd 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -962,8 +962,8 @@ ip4ip6_tnl_xmit(struct sk_buff *skb, struct net_device *dev)
962 dsfield = ipv4_get_dsfield(iph); 962 dsfield = ipv4_get_dsfield(iph);
963 963
964 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS)) 964 if ((t->parms.flags & IP6_TNL_F_USE_ORIG_TCLASS))
965 fl.fl6_flowlabel |= ntohl(((__u32)iph->tos << IPV6_TCLASS_SHIFT) 965 fl.fl6_flowlabel |= htonl((__u32)iph->tos << IPV6_TCLASS_SHIFT)
966 & IPV6_TCLASS_MASK); 966 & IPV6_TCLASS_MASK;
967 967
968 err = ip6_tnl_xmit2(skb, dev, dsfield, &fl, encap_limit, &mtu); 968 err = ip6_tnl_xmit2(skb, dev, dsfield, &fl, encap_limit, &mtu);
969 if (err != 0) { 969 if (err != 0) {
diff --git a/net/irda/irnetlink.c b/net/irda/irnetlink.c
index db716580e1ae..694ea4d92fa8 100644
--- a/net/irda/irnetlink.c
+++ b/net/irda/irnetlink.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * IrDA netlink layer, for stack configuration. 2 * IrDA netlink layer, for stack configuration.
3 * 3 *
4 * Copyright (c) 2007 Samuel Ortiz <samuel@sortiz> 4 * Copyright (c) 2007 Samuel Ortiz <samuel@sortiz.org>
5 * 5 *
6 * Partly based on the 802.11 nelink implementation 6 * Partly based on the 802.11 nelink implementation
7 * (see net/wireless/nl80211.c) which is: 7 * (see net/wireless/nl80211.c) which is:
diff --git a/security/selinux/avc.c b/security/selinux/avc.c
index ecd067384531..0e69adf63bdb 100644
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -570,10 +570,12 @@ void avc_audit(u32 ssid, u32 tsid,
570 case AVC_AUDIT_DATA_FS: 570 case AVC_AUDIT_DATA_FS:
571 if (a->u.fs.dentry) { 571 if (a->u.fs.dentry) {
572 struct dentry *dentry = a->u.fs.dentry; 572 struct dentry *dentry = a->u.fs.dentry;
573 if (a->u.fs.mnt) 573 if (a->u.fs.mnt) {
574 audit_avc_path(dentry, a->u.fs.mnt); 574 audit_log_d_path(ab, "path=", dentry, a->u.fs.mnt);
575 audit_log_format(ab, " name="); 575 } else {
576 audit_log_untrustedstring(ab, dentry->d_name.name); 576 audit_log_format(ab, " name=");
577 audit_log_untrustedstring(ab, dentry->d_name.name);
578 }
577 inode = dentry->d_inode; 579 inode = dentry->d_inode;
578 } else if (a->u.fs.inode) { 580 } else if (a->u.fs.inode) {
579 struct dentry *dentry; 581 struct dentry *dentry;
@@ -624,9 +626,8 @@ void avc_audit(u32 ssid, u32 tsid,
624 case AF_UNIX: 626 case AF_UNIX:
625 u = unix_sk(sk); 627 u = unix_sk(sk);
626 if (u->dentry) { 628 if (u->dentry) {
627 audit_avc_path(u->dentry, u->mnt); 629 audit_log_d_path(ab, "path=",
628 audit_log_format(ab, " name="); 630 u->dentry, u->mnt);
629 audit_log_untrustedstring(ab, u->dentry->d_name.name);
630 break; 631 break;
631 } 632 }
632 if (!u->addr) 633 if (!u->addr)